From 858942279a49e796a8d6286bf4fa7848306eef19 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Fri, 8 May 2015 21:21:22 -0400 Subject: [PATCH] upgrade packages --- .../async-20141001.151/async-autoloads.el | 80 - .../elpa/async-20141001.151/async-bytecomp.el | 107 - emacs.d/elpa/async-20141001.151/async-pkg.el | 4 - emacs.d/elpa/async-20141001.151/async.el | 291 - .../async-20150412.2207/async-autoloads.el | 81 + .../async-20150412.2207/async-bytecomp.el | 149 + emacs.d/elpa/async-20150412.2207/async-pkg.el | 4 + emacs.d/elpa/async-20150412.2207/async.el | 292 + .../dired-async.el | 0 .../smtpmail-async.el | 0 .../auto-complete-autoloads.el | 64 - .../auto-complete-config.el | 521 - .../auto-complete-pkg.el | 5 - .../auto-complete.el | 2101 --- .../auto-complete-20140824.1658/dict/c++-mode | 84 - .../auto-complete-20140824.1658/dict/c-mode | 44 - .../auto-complete-20140824.1658/dict/css-mode | 874 -- .../auto-complete-autoloads.el | 64 + .../auto-complete-config.el | 543 + .../auto-complete-pkg.el | 6 + .../auto-complete.el | 2162 +++ .../dict/ada-mode | 0 .../auto-complete-20150408.1132/dict/c++-mode | 99 + .../auto-complete-20150408.1132/dict/c-mode | 55 + .../dict/caml-mode | 0 .../dict/clojure-mode | 0 .../dict/clojurescript-mode | 0 .../dict/coq-mode | 0 .../auto-complete-20150408.1132/dict/css-mode | 874 ++ .../dict/erlang-mode | 0 .../dict/go-mode | 0 .../dict/haskell-mode | 0 .../dict/java-mode | 0 .../dict/js-mode} | 0 .../dict/lua-mode | 0 .../dict/octave-mode | 46 + .../dict/php-mode | 0 .../dict/python-mode | 0 .../dict/qml-mode | 0 .../dict/ruby-mode | 0 .../dict/scala-mode | 1347 ++ .../dict/scheme-mode | 0 .../dict/sclang-mode | 0 .../dict/sh-mode | 0 .../dict/tcl-mode | 0 .../dict/ts-mode | 0 .../dict/tuareg-mode | 0 .../dict/verilog-mode | 0 .../auto-complete-etags-autoloads.el | 16 - .../auto-complete-etags-pkg.el | 1 - .../auto-complete-etags.el | 69 - .../bison-mode-autoloads.el | 28 - .../bison-mode-20141119.43/bison-mode-pkg.el | 1 - .../elpa/bison-mode-20141119.43/bison-mode.el | 908 -- .../centered-cursor-mode-autoloads.el | 23 - .../centered-cursor-mode-pkg.el | 1 - .../centered-cursor-mode.el | 423 - .../centered-cursor-mode-autoloads.el | 23 + .../centered-cursor-mode-pkg.el | 1 + .../centered-cursor-mode.el | 430 + .../company-autoloads.el | 293 - .../company-20141014.1517/company-bbdb.el | 52 - .../company-20141014.1517/company-capf.el | 148 - .../company-20141014.1517/company-clang.el | 327 - .../company-20141014.1517/company-cmake.el | 129 - .../company-20141014.1517/company-dabbrev.el | 163 - .../company-20141014.1517/company-etags.el | 94 - .../company-20141014.1517/company-files.el | 104 - .../company-20141014.1517/company-gtags.el | 115 - .../company-20141014.1517/company-ispell.el | 69 - .../elpa/company-20141014.1517/company-pkg.el | 8 - .../company-20141014.1517/company-pysmell.el | 69 - .../company-20141014.1517/company-ropemacs.el | 72 - .../company-20141014.1517/company-semantic.el | 146 - .../company-20141014.1517/company-template.el | 197 - .../company-20141014.1517/company-xcode.el | 123 - emacs.d/elpa/company-20141014.1517/company.el | 2674 ---- .../company-abbrev.el | 0 .../company-autoloads.el | 281 + .../company-20150503.1854/company-bbdb.el | 61 + .../company-20150503.1854/company-capf.el | 153 + .../company-20150503.1854/company-clang.el | 331 + .../company-20150503.1854/company-cmake.el | 198 + .../company-css.el | 0 .../company-dabbrev-code.el | 0 .../company-20150503.1854/company-dabbrev.el | 170 + .../company-eclim.el | 0 .../company-elisp.el | 0 .../company-20150503.1854/company-etags.el | 94 + .../company-20150503.1854/company-files.el | 111 + .../company-20150503.1854/company-gtags.el | 116 + .../company-20150503.1854/company-ispell.el | 76 + .../company-keywords.el | 0 .../company-nxml.el | 0 .../company-oddmuse.el | 0 .../elpa/company-20150503.1854/company-pkg.el | 8 + .../company-20150503.1854/company-semantic.el | 156 + .../company-20150503.1854/company-template.el | 214 + .../company-tempo.el | 0 .../company-20150503.1854/company-xcode.el | 123 + .../company-yasnippet.el | 0 emacs.d/elpa/company-20150503.1854/company.el | 2841 ++++ .../concurrent-autoloads.el | 15 - .../concurrent-pkg.el | 1 - .../concurrent-20140609.1940/concurrent.el | 509 - .../concurrent-autoloads.el | 15 + .../concurrent-pkg.el | 1 + .../concurrent-20150309.2052/concurrent.el | 507 + .../elpa/dash-20141008.712/dash-autoloads.el | 15 - emacs.d/elpa/dash-20141008.712/dash-pkg.el | 1 - emacs.d/elpa/dash-20141008.712/dash.el | 2180 --- .../elpa/dash-20150503.1343/dash-autoloads.el | 15 + emacs.d/elpa/dash-20150503.1343/dash-pkg.el | 1 + emacs.d/elpa/dash-20150503.1343/dash.el | 2374 +++ .../deferred-autoloads.el | 15 - .../deferred-20140816.2205/deferred-pkg.el | 1 - .../elpa/deferred-20140816.2205/deferred.el | 963 -- .../deferred-autoloads.el | 15 + .../deferred-20150309.2052/deferred-pkg.el | 1 + .../elpa/deferred-20150309.2052/deferred.el | 964 ++ .../elixir-mode-autoloads.el | 76 - .../elixir-mode-pkg.el | 5 - .../elixir-mode-20150103.439/elixir-mode.el | 608 - .../elixir-deprecated.el | 0 .../elixir-mode-autoloads.el | 76 + .../elixir-mode-pkg.el | 5 + .../elixir-mode-20150317.1454/elixir-mode.el | 619 + .../elixir-smie.el | 0 emacs.d/elpa/elpy-1.7.1/LICENSE | 674 - emacs.d/elpa/elpy-1.7.1/README.rst | 65 - emacs.d/elpa/elpy-1.7.1/elpy-autoloads.el | 54 - emacs.d/elpa/elpy-1.7.1/elpy-pkg.el | 8 - emacs.d/elpa/elpy-1.7.1/elpy.el | 3501 ----- emacs.d/elpa/elpy-1.7.1/elpy/__init__.py | 41 - emacs.d/elpa/elpy-1.7.1/elpy/__main__.py | 26 - emacs.d/elpa/elpy-1.7.1/elpy/impmagic.py | 82 - emacs.d/elpa/elpy-1.7.1/elpy/jedibackend.py | 320 - emacs.d/elpa/elpy-1.7.1/elpy/ropebackend.py | 322 - emacs.d/elpa/elpy-1.7.1/elpy/server.py | 275 - emacs.d/elpa/elpy-20150502.740/NEWS.rst | 375 + .../elpa/elpy-20150502.740/elpy-autoloads.el | 51 + emacs.d/elpa/elpy-20150502.740/elpy-pkg.el | 9 + .../elpy-refactor.el | 0 emacs.d/elpa/elpy-20150502.740/elpy.el | 3449 +++++ .../elpa/elpy-20150502.740/elpy/__init__.py | 41 + .../elpa/elpy-20150502.740/elpy/__main__.py | 25 + .../elpy/compat.py | 0 .../elpa/elpy-20150502.740/elpy/impmagic.py | 95 + .../elpy-20150502.740/elpy/jedibackend.py | 323 + .../elpy/pydocutils.py | 0 .../elpy/refactor.py | 0 .../elpy-20150502.740/elpy/ropebackend.py | 326 + .../elpy/rpc.py | 0 emacs.d/elpa/elpy-20150502.740/elpy/server.py | 275 + .../elpy-20150502.740/elpy/tests/__init__.py | 8 + .../elpy-20150502.740/elpy/tests/compat.py | 18 + .../elpy-20150502.740/elpy/tests/support.py | 743 + .../elpy/tests/test_impmagic.py | 72 + .../elpy/tests/test_jedibackend.py | 265 + .../elpy/tests/test_pydocutils.py | 88 + .../elpy/tests/test_refactor.py | 542 + .../elpy/tests/test_ropebackend.py | 193 + .../elpy-20150502.740/elpy/tests/test_rpc.py | 209 + .../elpy/tests/test_server.py | 413 + .../elpy/tests/test_support.py | 19 + .../snippets/python-mode/.yas-setup.el | 0 .../snippets/python-mode/__abs__ | 0 .../snippets/python-mode/__add__ | 0 .../snippets/python-mode/__and__ | 0 .../snippets/python-mode/__bool__ | 0 .../snippets/python-mode/__call__ | 0 .../snippets/python-mode/__cmp__ | 0 .../snippets/python-mode/__coerce__ | 0 .../snippets/python-mode/__complex__ | 0 .../snippets/python-mode/__contains__ | 0 .../snippets/python-mode/__del__ | 0 .../snippets/python-mode/__delattr__ | 0 .../snippets/python-mode/__delete__ | 0 .../snippets/python-mode/__delitem__ | 0 .../snippets/python-mode/__div__ | 0 .../snippets/python-mode/__divmod__ | 0 .../snippets/python-mode/__enter__ | 0 .../snippets/python-mode/__eq__ | 0 .../snippets/python-mode/__exit__ | 0 .../snippets/python-mode/__float__ | 0 .../snippets/python-mode/__floordiv__ | 0 .../snippets/python-mode/__ge__ | 0 .../snippets/python-mode/__get__ | 0 .../snippets/python-mode/__getattr__ | 0 .../snippets/python-mode/__getattribute__ | 0 .../snippets/python-mode/__getitem__ | 0 .../snippets/python-mode/__gt__ | 0 .../snippets/python-mode/__hash__ | 0 .../snippets/python-mode/__hex__ | 0 .../snippets/python-mode/__iadd__ | 0 .../snippets/python-mode/__iand__ | 0 .../snippets/python-mode/__idiv__ | 0 .../snippets/python-mode/__ifloordiv__ | 0 .../snippets/python-mode/__ilshift__ | 0 .../snippets/python-mode/__imod__ | 0 .../snippets/python-mode/__imul__ | 0 .../snippets/python-mode/__index__ | 0 .../snippets/python-mode/__init__ | 0 .../snippets/python-mode/__instancecheck__ | 0 .../snippets/python-mode/__int__ | 0 .../snippets/python-mode/__invert__ | 0 .../snippets/python-mode/__ior__ | 0 .../snippets/python-mode/__ipow__ | 0 .../snippets/python-mode/__irshift__ | 0 .../snippets/python-mode/__isub__ | 0 .../snippets/python-mode/__iter__ | 0 .../snippets/python-mode/__itruediv__ | 0 .../snippets/python-mode/__ixor__ | 0 .../snippets/python-mode/__le__ | 0 .../snippets/python-mode/__len__ | 0 .../snippets/python-mode/__long__ | 0 .../snippets/python-mode/__lshift__ | 0 .../snippets/python-mode/__lt__ | 0 .../snippets/python-mode/__mod__ | 0 .../snippets/python-mode/__mul__ | 0 .../snippets/python-mode/__ne__ | 0 .../snippets/python-mode/__neg__ | 0 .../snippets/python-mode/__new__ | 0 .../snippets/python-mode/__nonzero__ | 0 .../snippets/python-mode/__oct__ | 0 .../snippets/python-mode/__or__ | 0 .../snippets/python-mode/__pos__ | 0 .../snippets/python-mode/__pow__ | 0 .../snippets/python-mode/__radd__ | 0 .../snippets/python-mode/__rand__ | 0 .../snippets/python-mode/__rdivmod__ | 0 .../snippets/python-mode/__repr__ | 0 .../snippets/python-mode/__reversed__ | 0 .../snippets/python-mode/__rfloordiv__ | 0 .../snippets/python-mode/__rlshift__ | 0 .../snippets/python-mode/__rmod__ | 0 .../snippets/python-mode/__rmul__ | 0 .../snippets/python-mode/__ror__ | 0 .../snippets/python-mode/__rpow__ | 0 .../snippets/python-mode/__rrshift__ | 0 .../snippets/python-mode/__rshift__ | 0 .../snippets/python-mode/__rsub__ | 0 .../snippets/python-mode/__rtruediv__ | 0 .../snippets/python-mode/__rxor__ | 0 .../snippets/python-mode/__set__ | 0 .../snippets/python-mode/__setattr__ | 0 .../snippets/python-mode/__setitem__ | 0 .../snippets/python-mode/__slots__ | 0 .../snippets/python-mode/__str__ | 0 .../snippets/python-mode/__sub__ | 0 .../snippets/python-mode/__subclasscheck__ | 0 .../snippets/python-mode/__truediv__ | 0 .../snippets/python-mode/__unicode__ | 0 .../snippets/python-mode/__xor__ | 0 .../snippets/python-mode/ase | 0 .../snippets/python-mode/asne | 0 .../snippets/python-mode/asr | 0 .../snippets/python-mode/class | 0 .../snippets/python-mode/defs | 0 .../snippets/python-mode/enc | 0 .../snippets/python-mode/env | 0 .../snippets/python-mode/from | 0 .../snippets/python-mode/pdb | 0 .../snippets/python-mode/py3 | 0 .../snippets/python-mode/super | 0 .../elpa/epl-20140823.609/epl-autoloads.el | 15 - emacs.d/elpa/epl-20140823.609/epl-pkg.el | 1 - emacs.d/elpa/epl-20140823.609/epl.el | 651 - .../elpa/epl-20150326.1212/epl-autoloads.el | 15 + emacs.d/elpa/epl-20150326.1212/epl-pkg.el | 1 + emacs.d/elpa/epl-20150326.1212/epl.el | 695 + .../erlang-20141104.17/erlang-autoloads.el | 144 - emacs.d/elpa/erlang-20141104.17/erlang-pkg.el | 4 - emacs.d/elpa/erlang-20141104.17/erlang.el | 5753 ------- .../erlang-20150319.456/erlang-autoloads.el | 144 + .../erlang-eunit.el | 0 .../erlang-flymake.el | 0 .../elpa/erlang-20150319.456/erlang-pkg.el | 4 + .../erlang-skels-old.el | 0 .../erlang-skels.el | 0 .../erlang-start.el | 0 emacs.d/elpa/erlang-20150319.456/erlang.el | 5796 +++++++ .../erlang_appwiz.el | 0 .../find-file-in-project-autoloads.el | 40 - .../find-file-in-project-pkg.el | 1 - .../find-file-in-project.el | 184 - .../find-file-in-project-autoloads.el | 54 + .../find-file-in-project-pkg.el | 1 + .../find-file-in-project.el | 337 + emacs.d/elpa/flymake-cursor-1.0.2/Changes | 11 - emacs.d/elpa/flymake-cursor-1.0.2/LICENSE.txt | 674 - emacs.d/elpa/flymake-cursor-1.0.2/README.mkdn | 46 - .../flymake-cursor-autoloads.el | 34 - .../flymake-cursor-pkg.el | 3 - .../flymake-cursor-1.0.2/flymake-cursor.el | 227 - .../flymake-cursor-autoloads.el | 37 + .../flymake-cursor-pkg.el | 1 + .../flymake-cursor.el | 168 + .../flymake-elixir-autoloads.el | 22 - .../flymake-elixir-0.5/flymake-elixir-pkg.el | 1 - .../elpa/flymake-elixir-0.5/flymake-elixir.el | 71 - .../flymake-elixir-autoloads.el | 22 + .../flymake-elixir-pkg.el | 1 + .../flymake-elixir.el | 72 + .../flymake-php-autoloads.el | 22 - .../flymake-php-pkg.el | 1 - .../flymake-php-20121104.1102/flymake-php.el | 40 - .../git-commit-mode-autoloads.el | 30 + .../git-commit-mode-pkg.el | 1 + .../git-commit-mode.el | 668 + .../git-gutter-autoloads.el | 99 - .../git-gutter-pkg.el | 1 - .../git-gutter-20141007.2327/git-gutter.el | 876 -- .../git-gutter-autoloads.el | 109 + .../git-gutter-20150501.756/git-gutter-pkg.el | 1 + .../git-gutter-20150501.756/git-gutter.el | 1030 ++ .../git-rebase-mode-autoloads.el | 29 + .../git-rebase-mode-pkg.el | 1 + .../git-rebase-mode.el | 393 + .../go-mode-autoloads.el | 95 - .../elpa/go-mode-20140905.2210/go-mode-pkg.el | 1 - emacs.d/elpa/go-mode-20140905.2210/go-mode.el | 1505 -- .../go-mode-20150503.258/go-mode-autoloads.el | 102 + .../elpa/go-mode-20150503.258/go-mode-pkg.el | 5 + emacs.d/elpa/go-mode-20150503.258/go-mode.el | 1564 ++ emacs.d/elpa/helm-20141016.2217/emacs-helm.sh | 95 - .../elpa/helm-20141016.2217/helm-adaptive.el | 243 - .../elpa/helm-20141016.2217/helm-aliases.el | 897 -- emacs.d/elpa/helm-20141016.2217/helm-apt.el | 292 - .../elpa/helm-20141016.2217/helm-autoloads.el | 1302 -- emacs.d/elpa/helm-20141016.2217/helm-bbdb.el | 185 - .../elpa/helm-20141016.2217/helm-bookmark.el | 788 - .../elpa/helm-20141016.2217/helm-buffers.el | 794 - emacs.d/elpa/helm-20141016.2217/helm-color.el | 163 - .../elpa/helm-20141016.2217/helm-command.el | 200 - .../elpa/helm-20141016.2217/helm-config.el | 231 - .../elpa/helm-20141016.2217/helm-dabbrev.el | 321 - .../helm-20141016.2217/helm-elisp-package.el | 170 - emacs.d/elpa/helm-20141016.2217/helm-elisp.el | 777 - .../elpa/helm-20141016.2217/helm-elscreen.el | 79 - emacs.d/elpa/helm-20141016.2217/helm-emms.el | 186 - .../elpa/helm-20141016.2217/helm-eshell.el | 236 - emacs.d/elpa/helm-20141016.2217/helm-eval.el | 177 - .../elpa/helm-20141016.2217/helm-external.el | 215 - emacs.d/elpa/helm-20141016.2217/helm-files.el | 2922 ---- .../elpa/helm-20141016.2217/helm-firefox.el | 124 - emacs.d/elpa/helm-20141016.2217/helm-font.el | 177 - .../elpa/helm-20141016.2217/helm-gentoo.el | 258 - emacs.d/elpa/helm-20141016.2217/helm-grep.el | 1197 -- emacs.d/elpa/helm-20141016.2217/helm-help.el | 1479 -- emacs.d/elpa/helm-20141016.2217/helm-imenu.el | 170 - emacs.d/elpa/helm-20141016.2217/helm-info.el | 144 - .../elpa/helm-20141016.2217/helm-locate.el | 325 - emacs.d/elpa/helm-20141016.2217/helm-man.el | 102 - .../helm-20141016.2217/helm-match-plugin.el | 436 - emacs.d/elpa/helm-20141016.2217/helm-misc.el | 402 - emacs.d/elpa/helm-20141016.2217/helm-mode.el | 1053 -- emacs.d/elpa/helm-20141016.2217/helm-net.el | 607 - emacs.d/elpa/helm-20141016.2217/helm-org.el | 185 - emacs.d/elpa/helm-20141016.2217/helm-pkg.el | 7 - .../elpa/helm-20141016.2217/helm-plugin.el | 344 - .../elpa/helm-20141016.2217/helm-regexp.el | 623 - emacs.d/elpa/helm-20141016.2217/helm-ring.el | 378 - .../elpa/helm-20141016.2217/helm-semantic.el | 161 - .../elpa/helm-20141016.2217/helm-source.el | 929 -- emacs.d/elpa/helm-20141016.2217/helm-sys.el | 301 - emacs.d/elpa/helm-20141016.2217/helm-tags.el | 339 - emacs.d/elpa/helm-20141016.2217/helm-utils.el | 960 -- emacs.d/elpa/helm-20141016.2217/helm-w3m.el | 149 - .../elpa/helm-20141016.2217/helm-yaoddmuse.el | 171 - emacs.d/elpa/helm-20141016.2217/helm.el | 4673 ------ emacs.d/elpa/helm-20150507.2215/emacs-helm.sh | 96 + .../elpa/helm-20150507.2215/helm-adaptive.el | 243 + .../elpa/helm-20150507.2215/helm-aliases.el | 778 + emacs.d/elpa/helm-20150507.2215/helm-apt.el | 292 + .../elpa/helm-20150507.2215/helm-autoloads.el | 1224 ++ .../elpa/helm-20150507.2215/helm-bookmark.el | 793 + .../elpa/helm-20150507.2215/helm-buffers.el | 854 ++ emacs.d/elpa/helm-20150507.2215/helm-color.el | 163 + .../elpa/helm-20150507.2215/helm-command.el | 254 + .../elpa/helm-20150507.2215/helm-config.el | 216 + .../elpa/helm-20150507.2215/helm-dabbrev.el | 354 + .../helm-20150507.2215/helm-elisp-package.el | 315 + emacs.d/elpa/helm-20150507.2215/helm-elisp.el | 832 ++ .../elpa/helm-20150507.2215/helm-elscreen.el | 79 + .../elpa/helm-20150507.2215/helm-eshell.el | 246 + emacs.d/elpa/helm-20150507.2215/helm-eval.el | 193 + .../elpa/helm-20150507.2215/helm-external.el | 216 + emacs.d/elpa/helm-20150507.2215/helm-files.el | 3254 ++++ emacs.d/elpa/helm-20150507.2215/helm-font.el | 187 + emacs.d/elpa/helm-20150507.2215/helm-grep.el | 1229 ++ emacs.d/elpa/helm-20150507.2215/helm-help.el | 1716 +++ emacs.d/elpa/helm-20150507.2215/helm-imenu.el | 183 + emacs.d/elpa/helm-20150507.2215/helm-info.el | 183 + .../elpa/helm-20150507.2215/helm-locate.el | 345 + emacs.d/elpa/helm-20150507.2215/helm-man.el | 102 + .../helm-20150507.2215/helm-match-plugin.el | 331 + emacs.d/elpa/helm-20150507.2215/helm-misc.el | 330 + emacs.d/elpa/helm-20150507.2215/helm-mode.el | 1132 ++ emacs.d/elpa/helm-20150507.2215/helm-net.el | 607 + emacs.d/elpa/helm-20150507.2215/helm-org.el | 148 + emacs.d/elpa/helm-20150507.2215/helm-pkg.el | 8 + .../elpa/helm-20150507.2215/helm-plugin.el | 137 + .../elpa/helm-20150507.2215/helm-regexp.el | 643 + emacs.d/elpa/helm-20150507.2215/helm-ring.el | 413 + .../elpa/helm-20150507.2215/helm-semantic.el | 209 + .../elpa/helm-20150507.2215/helm-source.el | 1153 ++ emacs.d/elpa/helm-20150507.2215/helm-sys.el | 299 + emacs.d/elpa/helm-20150507.2215/helm-tags.el | 318 + emacs.d/elpa/helm-20150507.2215/helm-utils.el | 871 ++ emacs.d/elpa/helm-20150507.2215/helm.el | 5220 +++++++ .../helm-projectile-autoloads.el | 27 - .../helm-projectile-pkg.el | 1 - .../helm-projectile.el | 455 - .../helm-projectile-autoloads.el | 70 + .../helm-projectile-pkg.el | 1 + .../helm-projectile.el | 842 ++ .../highlight-indentation-autoloads.el | 36 - .../highlight-indentation-pkg.el | 1 - .../highlight-indentation.el | 156 - .../highlight-indentation-autoloads.el | 35 + .../highlight-indentation-pkg.el | 1 + .../highlight-indentation.el | 244 + .../idomenu-autoloads.el | 21 - .../elpa/idomenu-20111122.1048/idomenu-pkg.el | 1 - emacs.d/elpa/idomenu-20111122.1048/idomenu.el | 83 - .../idomenu-autoloads.el | 21 + .../elpa/idomenu-20141123.1320/idomenu-pkg.el | 1 + emacs.d/elpa/idomenu-20141123.1320/idomenu.el | 83 + emacs.d/elpa/jedi-20140321.1323/Makefile | 201 - .../elpa/jedi-20140321.1323/jedi-autoloads.el | 125 - emacs.d/elpa/jedi-20140321.1323/jedi-pkg.el | 7 - emacs.d/elpa/jedi-20140321.1323/jedi.el | 1352 -- .../elpa/jedi-20140321.1323/jediepcserver.py | 314 - emacs.d/elpa/jedi-20140321.1323/setup.py | 25 - .../elpa/jedi-20150413.2208/jedi-autoloads.el | 42 + emacs.d/elpa/jedi-20150413.2208/jedi-pkg.el | 1 + emacs.d/elpa/jedi-20150413.2208/jedi.el | 112 + emacs.d/elpa/jedi-core-20150507.438/Makefile | 201 + .../jedi-core-autoloads.el | 107 + .../jedi-core-20150507.438/jedi-core-pkg.el | 8 + .../elpa/jedi-core-20150507.438/jedi-core.el | 1282 ++ .../jedi-core-20150507.438/jediepcserver.py | 321 + emacs.d/elpa/jedi-core-20150507.438/setup.py | 25 + .../js2-mode-autoloads.el | 50 - .../js2-mode-20150423.1929/js2-mode-pkg.el | 8 - .../elpa/js2-mode-20150423.1929/js2-mode.el | 12427 --------------- .../js2-imenu-extras.el | 0 .../js2-mode-autoloads.el | 50 + .../js2-mode-20150503.617/js2-mode-pkg.el | 8 + .../elpa/js2-mode-20150503.617/js2-mode.el | 12455 ++++++++++++++++ .../markdown-mode-autoloads.el | 27 - .../markdown-mode-2.0/markdown-mode-pkg.el | 1 - .../elpa/markdown-mode-2.0/markdown-mode.el | 4669 ------ .../markdown-mode-autoloads.el | 30 + .../markdown-mode-pkg.el | 1 + .../markdown-mode.el | 4702 ++++++ .../paredit-autoloads.el | 32 - .../elpa/paredit-20140128.1248/paredit-pkg.el | 1 - emacs.d/elpa/paredit-20140128.1248/paredit.el | 2919 ---- .../paredit-20150217.713/paredit-autoloads.el | 32 + .../elpa/paredit-20150217.713/paredit-pkg.el | 1 + emacs.d/elpa/paredit-20150217.713/paredit.el | 2922 ++++ .../polymode-autoloads.el | 105 - .../polymode-classes.el | 313 - .../polymode-20140614.1301/polymode-common.el | 368 - .../polymode-methods.el | 606 - .../polymode-20140614.1301/polymode-pkg.el | 7 - .../polymode-20140614.1301/polymode-weave.el | 230 - .../elpa/polymode-20140614.1301/polymode.el | 556 - .../poly-R.el | 0 .../poly-base.el | 0 .../poly-markdown.el | 0 .../poly-noweb.el | 0 .../poly-org.el | 0 .../polymode-autoloads.el | 105 + .../polymode-classes.el | 305 + .../polymode-20150508.1633/polymode-common.el | 373 + .../polymode-configuration.el | 0 .../polymode-export.el | 0 .../polymode-methods.el | 606 + .../polymode-20150508.1633/polymode-pkg.el | 7 + .../polymode-tangle.el | 0 .../polymode-20150508.1633/polymode-weave.el | 230 + .../elpa/polymode-20150508.1633/polymode.el | 559 + .../popup-20141002.320/popup-autoloads.el | 15 - emacs.d/elpa/popup-20141002.320/popup-pkg.el | 1 - emacs.d/elpa/popup-20141002.320/popup.el | 1419 -- .../popup-20150315.612/popup-autoloads.el | 15 + emacs.d/elpa/popup-20150315.612/popup-pkg.el | 1 + emacs.d/elpa/popup-20150315.612/popup.el | 1410 ++ .../projectile-autoloads.el | 77 - .../projectile-20141017.242/projectile-pkg.el | 1 - .../projectile-20141017.242/projectile.el | 2599 ---- .../projectile-autoloads.el | 256 + .../projectile-20150428.158/projectile-pkg.el | 1 + .../projectile-20150428.158/projectile.el | 2635 ++++ .../python-environment-autoloads.el | 16 - .../python-environment-pkg.el | 7 - .../python-environment.el | 246 - .../python-environment-autoloads.el | 16 + .../python-environment-pkg.el | 7 + .../python-environment.el | 245 + .../test-python-environment.el | 0 .../pyvenv-20140921.816/pyvenv-autoloads.el | 71 - .../elpa/pyvenv-20140921.816/pyvenv-pkg.el | 1 - emacs.d/elpa/pyvenv-20140921.816/pyvenv.el | 434 - .../pyvenv-20150503.941/pyvenv-autoloads.el | 71 + .../elpa/pyvenv-20150503.941/pyvenv-pkg.el | 1 + emacs.d/elpa/pyvenv-20150503.941/pyvenv.el | 459 + .../rich-minority-autoloads.el | 40 - .../rich-minority-pkg.el | 1 - .../rich-minority.el | 281 - .../rich-minority-autoloads.el | 40 + .../rich-minority-pkg.el | 1 + .../rich-minority.el | 282 + .../smart-mode-line-autoloads.el | 57 - .../smart-mode-line-dark-theme.el | 50 - .../smart-mode-line-light-theme.el | 48 - .../smart-mode-line-pkg.el | 9 - .../smart-mode-line-respectful-theme.el | 48 - .../smart-mode-line.el | 1646 -- .../smart-mode-line-autoloads.el | 58 + .../smart-mode-line-dark-theme.el | 49 + .../smart-mode-line-light-theme.el | 47 + .../smart-mode-line-pkg.el | 8 + .../smart-mode-line-respectful-theme.el | 49 + .../smart-mode-line.el | 1713 +++ .../yaml-mode-0.0.9/yaml-mode-autoloads.el | 27 - emacs.d/elpa/yaml-mode-0.0.9/yaml-mode-pkg.el | 1 - emacs.d/elpa/yaml-mode-0.0.9/yaml-mode.el | 415 - .../yaml-mode-autoloads.el | 27 + .../yaml-mode-20141125.37/yaml-mode-pkg.el | 1 + .../elpa/yaml-mode-20141125.37/yaml-mode.el | 413 + .../yasnippet-autoloads.el | 58 - .../yasnippet-20141017.736/yasnippet-pkg.el | 5 - .../elpa/yasnippet-20141017.736/yasnippet.el | 4616 ------ .../snippets/.nosearch | 0 .../snippets/CONTRIBUTORS.txt | 0 .../snippets/LICENSE | 0 .../snippets/README.md | 0 .../snippets/antlr-mode/project | 0 .../snippets/antlr-mode/property | 0 .../snippets/antlr-mode/target | 0 .../snippets/applescript-mode/.yas-parents | 0 .../snippets/c++-mode/.yas-parents | 0 .../snippets/c++-mode/assert | 0 .../snippets/c++-mode/beginend | 0 .../snippets/c++-mode/boost_require | 0 .../snippets/c++-mode/cerr | 0 .../snippets/c++-mode/cin | 0 .../snippets/c++-mode/class | 0 .../snippets/c++-mode/const_[] | 0 .../snippets/c++-mode/constructor | 0 .../snippets/c++-mode/cout | 0 .../snippets/c++-mode/cpp | 0 .../snippets/c++-mode/cstd | 0 .../snippets/c++-mode/d+= | 0 .../snippets/c++-mode/d_operator | 0 .../snippets/c++-mode/d_operator[] | 0 .../snippets/c++-mode/d_operator[]_const | 0 .../snippets/c++-mode/delete | 0 .../snippets/c++-mode/delete[] | 0 .../snippets/c++-mode/doc | 0 .../snippets/c++-mode/dynamic_casting | 0 .../snippets/c++-mode/enum | 0 .../snippets/c++-mode/fixture | 0 .../snippets/c++-mode/fori | 0 .../snippets/c++-mode/friend | 0 .../snippets/c++-mode/fun_declaration | 0 .../snippets/c++-mode/function | 0 .../snippets/c++-mode/gtest | 0 .../snippets/c++-mode/ignore | 0 .../snippets/c++-mode/inline | 0 .../snippets/c++-mode/io | 0 .../snippets/c++-mode/iterator | 0 .../snippets/c++-mode/map | 0 .../snippets/c++-mode/module | 0 .../snippets/c++-mode/namespace | 0 .../snippets/c++-mode/ns | 0 .../snippets/c++-mode/operator!= | 0 .../snippets/c++-mode/operator+ | 0 .../snippets/c++-mode/operator+= | 0 .../snippets/c++-mode/operator= | 0 .../snippets/c++-mode/operator== | 0 .../snippets/c++-mode/operator[] | 0 .../snippets/c++-mode/operator_istream | 0 .../snippets/c++-mode/operator_ostream | 0 .../snippets/c++-mode/ostream | 0 .../snippets/c++-mode/pack | 0 .../snippets/c++-mode/private | 0 .../snippets/c++-mode/protected | 0 .../snippets/c++-mode/public | 0 .../snippets/c++-mode/sstream | 0 .../snippets/c++-mode/std | 0 .../snippets/c++-mode/std_colon | 0 .../snippets/c++-mode/str | 0 .../snippets/c++-mode/template | 0 .../snippets/c++-mode/test case | 0 .../snippets/c++-mode/test_main | 0 .../snippets/c++-mode/test_suite | 0 .../snippets/c++-mode/this | 0 .../snippets/c++-mode/throw | 0 .../snippets/c++-mode/try | 0 .../snippets/c++-mode/tryw | 0 .../snippets/c++-mode/using | 0 .../snippets/c++-mode/vector | 0 .../snippets/c-mode/.yas-parents | 0 .../snippets/c-mode/assert | 0 .../snippets/c-mode/compile | 0 .../snippets/c-mode/define | 0 .../snippets/c-mode/fopen | 0 .../snippets/c-mode/malloc | 0 .../snippets/c-mode/packed | 0 .../snippets/c-mode/printf | 0 .../snippets/c-mode/stdio | 0 .../snippets/c-mode/stdlib | 0 .../snippets/c-mode/string | 0 .../snippets/c-mode/switch | 0 .../snippets/c-mode/union | 0 .../snippets/c-mode/unistd | 0 .../snippets/cc-mode/do | 0 .../snippets/cc-mode/for | 0 .../snippets/cc-mode/if | 0 .../snippets/cc-mode/ifdef | 0 .../snippets/cc-mode/inc | 0 .../snippets/cc-mode/inc.1 | 0 .../snippets/cc-mode/main | 0 .../snippets/cc-mode/math | 0 .../snippets/cc-mode/once | 0 .../snippets/cc-mode/struct | 0 .../snippets/cc-mode/ternary | 0 .../snippets/cc-mode/typedef | 0 .../snippets/cc-mode/while | 0 .../snippets/chef-mode/action | 0 .../snippets/chef-mode/bash | 0 .../snippets/chef-mode/cookbook_file | 0 .../snippets/chef-mode/cron | 0 .../snippets/chef-mode/cronf | 0 .../snippets/chef-mode/deploy | 0 .../snippets/chef-mode/directory | 0 .../snippets/chef-mode/directoryf | 0 .../snippets/chef-mode/env | 0 .../snippets/chef-mode/execute | 0 .../snippets/chef-mode/executef | 0 .../snippets/chef-mode/file | 0 .../snippets/chef-mode/filef | 0 .../snippets/chef-mode/git | 0 .../snippets/chef-mode/group | 0 .../snippets/chef-mode/http_request | 0 .../snippets/chef-mode/http_requestp | 0 .../snippets/chef-mode/ignore_failure | 0 .../snippets/chef-mode/inc | 0 .../snippets/chef-mode/link | 0 .../snippets/chef-mode/linkf | 0 .../snippets/chef-mode/log | 0 .../snippets/chef-mode/meta | 0 .../snippets/chef-mode/not_if | 0 .../snippets/chef-mode/notifies | 0 .../snippets/chef-mode/only_if | 0 .../snippets/chef-mode/pac | 0 .../snippets/chef-mode/pak | 0 .../snippets/chef-mode/provider | 0 .../snippets/chef-mode/python | 0 .../snippets/chef-mode/remote_file | 0 .../snippets/chef-mode/retries | 0 .../snippets/chef-mode/role | 0 .../snippets/chef-mode/ruby | 0 .../snippets/chef-mode/script | 0 .../snippets/chef-mode/service | 0 .../snippets/chef-mode/servicep | 0 .../snippets/chef-mode/subscribes | 0 .../snippets/chef-mode/supports | 0 .../snippets/chef-mode/template | 0 .../snippets/chef-mode/templatev | 0 .../snippets/chef-mode/user | 0 .../cmake-mode/cmake_minimum_required | 0 .../snippets/cmake-mode/foreach | 0 .../snippets/cmake-mode/function | 0 .../snippets/cmake-mode/if | 0 .../snippets/cmake-mode/ifelse | 0 .../snippets/cmake-mode/include | 0 .../snippets/cmake-mode/macro | 0 .../snippets/cmake-mode/message | 0 .../snippets/cmake-mode/option | 0 .../snippets/cmake-mode/project | 0 .../snippets/cmake-mode/set | 0 .../snippets/conf-unix-mode/.yas-parents | 0 .../snippets/conf-unix-mode/section | 0 .../snippets/cperl-mode/.yas-parents | 0 .../snippets/cpp-omnet-mode/EV | 0 .../snippets/cpp-omnet-mode/emit_signal | 0 .../snippets/cpp-omnet-mode/intuniform | 0 .../snippets/cpp-omnet-mode/math | 0 .../snippets/cpp-omnet-mode/nan | 0 .../snippets/cpp-omnet-mode/omnet | 0 .../snippets/cpp-omnet-mode/parameter_omnetpp | 0 .../snippets/cpp-omnet-mode/scheduleAt | 0 .../snippets/cpp-omnet-mode/uniform | 0 .../snippets/csharp-mode/.yas-parents | 0 .../snippets/csharp-mode/attrib | 0 .../snippets/csharp-mode/attrib.1 | 0 .../snippets/csharp-mode/attrib.2 | 0 .../snippets/csharp-mode/class | 0 .../snippets/csharp-mode/comment | 0 .../snippets/csharp-mode/comment.1 | 0 .../snippets/csharp-mode/comment.2 | 0 .../snippets/csharp-mode/comment.3 | 0 .../snippets/csharp-mode/method | 0 .../snippets/csharp-mode/namespace | 0 .../snippets/csharp-mode/prop | 0 .../snippets/csharp-mode/region | 0 .../snippets/csharp-mode/using | 0 .../snippets/csharp-mode/using.1 | 0 .../snippets/csharp-mode/using.2 | 0 .../snippets/css-mode/bg | 0 .../snippets/css-mode/bg.1 | 0 .../snippets/css-mode/bor | 0 .../snippets/css-mode/cl | 0 .../snippets/css-mode/disp.block | 0 .../snippets/css-mode/disp.inline | 0 .../snippets/css-mode/disp.none | 0 .../snippets/css-mode/ff | 0 .../snippets/css-mode/fs | 0 .../snippets/css-mode/mar.bottom | 0 .../snippets/css-mode/mar.left | 0 .../snippets/css-mode/mar.mar | 0 .../snippets/css-mode/mar.margin | 0 .../snippets/css-mode/mar.right | 0 .../snippets/css-mode/mar.top | 0 .../snippets/css-mode/pad.bottom | 0 .../snippets/css-mode/pad.left | 0 .../snippets/css-mode/pad.pad | 0 .../snippets/css-mode/pad.padding | 0 .../snippets/css-mode/pad.right | 0 .../snippets/css-mode/pad.top | 0 .../snippets/css-mode/v | 0 .../snippets/emacs-lisp-mode/.read_me | 0 .../snippets/emacs-lisp-mode/add-hook | 0 .../snippets/emacs-lisp-mode/and | 0 .../snippets/emacs-lisp-mode/append | 0 .../snippets/emacs-lisp-mode/apply | 0 .../snippets/emacs-lisp-mode/aref | 0 .../snippets/emacs-lisp-mode/aset | 0 .../snippets/emacs-lisp-mode/assq | 0 .../snippets/emacs-lisp-mode/autoload | 0 .../snippets/emacs-lisp-mode/backward-char | 0 .../emacs-lisp-mode/beginning-of-line | 0 .../emacs-lisp-mode/bounds-of-thing-at-point | 0 .../snippets/emacs-lisp-mode/buffer-file-name | 0 .../emacs-lisp-mode/buffer-modified-p | 0 .../snippets/emacs-lisp-mode/buffer-substring | 0 .../buffer-substring-no-properties | 0 .../snippets/emacs-lisp-mode/car | 0 .../snippets/emacs-lisp-mode/cdr | 0 .../snippets/emacs-lisp-mode/concat | 0 .../snippets/emacs-lisp-mode/cond | 0 .../snippets/emacs-lisp-mode/condition-case | 0 .../snippets/emacs-lisp-mode/cons | 0 .../snippets/emacs-lisp-mode/consp | 0 .../snippets/emacs-lisp-mode/copy-directory | 0 .../snippets/emacs-lisp-mode/copy-file | 0 .../snippets/emacs-lisp-mode/current-buffer | 0 .../snippets/emacs-lisp-mode/custom-autoload | 0 .../snippets/emacs-lisp-mode/defalias | 0 .../snippets/emacs-lisp-mode/defcustom | 0 .../snippets/emacs-lisp-mode/define-key | 0 .../snippets/emacs-lisp-mode/defsubst | 0 .../snippets/emacs-lisp-mode/defun | 0 .../snippets/emacs-lisp-mode/defvar | 0 .../snippets/emacs-lisp-mode/delete-char | 0 .../snippets/emacs-lisp-mode/delete-directory | 0 .../snippets/emacs-lisp-mode/delete-file | 0 .../snippets/emacs-lisp-mode/delete-region | 0 .../snippets/emacs-lisp-mode/directory-files | 0 .../emacs-lisp-mode/dired.process_marked | 0 .../snippets/emacs-lisp-mode/dolist | 0 .../snippets/emacs-lisp-mode/end-of-line | 0 .../snippets/emacs-lisp-mode/eq | 0 .../snippets/emacs-lisp-mode/equal | 0 .../snippets/emacs-lisp-mode/error | 0 .../snippets/emacs-lisp-mode/expand-file-name | 0 .../snippets/emacs-lisp-mode/f | 0 .../snippets/emacs-lisp-mode/fboundp | 0 .../emacs-lisp-mode/file-name-directory | 0 .../emacs-lisp-mode/file-name-extension | 0 .../emacs-lisp-mode/file-name-nondirectory | 0 .../emacs-lisp-mode/file-name-sans-extension | 0 .../emacs-lisp-mode/file-relative-name | 0 .../snippets/emacs-lisp-mode/file.process | 0 .../snippets/emacs-lisp-mode/file.read-lines | 0 .../snippets/emacs-lisp-mode/find-file | 0 .../snippets/emacs-lisp-mode/find-replace | 0 .../snippets/emacs-lisp-mode/format | 0 .../snippets/emacs-lisp-mode/forward-char | 0 .../snippets/emacs-lisp-mode/forward-line | 0 .../snippets/emacs-lisp-mode/funcall | 0 .../snippets/emacs-lisp-mode/function | 0 .../snippets/emacs-lisp-mode/get | 0 .../snippets/emacs-lisp-mode/global-set-key | 0 .../snippets/emacs-lisp-mode/goto-char | 0 .../snippets/emacs-lisp-mode/grabstring | 0 .../snippets/emacs-lisp-mode/grabthing | 0 .../snippets/emacs-lisp-mode/hash | 0 .../snippets/emacs-lisp-mode/if | 0 .../snippets/emacs-lisp-mode/insert | 0 .../emacs-lisp-mode/insert-file-contents | 0 .../snippets/emacs-lisp-mode/interactive | 0 .../snippets/emacs-lisp-mode/kbd | 0 .../snippets/emacs-lisp-mode/kill-buffer | 0 .../snippets/emacs-lisp-mode/lambda | 0 .../snippets/emacs-lisp-mode/length | 0 .../snippets/emacs-lisp-mode/let | 0 .../emacs-lisp-mode/line-beginning-position | 0 .../emacs-lisp-mode/line-end-position | 0 .../snippets/emacs-lisp-mode/list | 0 .../snippets/emacs-lisp-mode/looking-at | 0 .../snippets/emacs-lisp-mode/make-directory | 0 .../emacs-lisp-mode/make-local-variable | 0 .../snippets/emacs-lisp-mode/mapc | 0 .../snippets/emacs-lisp-mode/mapcar | 0 .../snippets/emacs-lisp-mode/match-beginning | 0 .../snippets/emacs-lisp-mode/match-end | 0 .../snippets/emacs-lisp-mode/match-string | 0 .../snippets/emacs-lisp-mode/memq | 0 .../snippets/emacs-lisp-mode/message | 0 .../snippets/emacs-lisp-mode/minor_mode | 0 .../snippets/emacs-lisp-mode/not | 0 .../snippets/emacs-lisp-mode/nth | 0 .../snippets/emacs-lisp-mode/null | 0 .../snippets/emacs-lisp-mode/number-to-string | 0 .../snippets/emacs-lisp-mode/or | 0 .../snippets/emacs-lisp-mode/point | 0 .../snippets/emacs-lisp-mode/point-max | 0 .../snippets/emacs-lisp-mode/point-min | 0 .../snippets/emacs-lisp-mode/princ | 0 .../snippets/emacs-lisp-mode/print | 0 .../snippets/emacs-lisp-mode/progn | 0 .../snippets/emacs-lisp-mode/push | 0 .../snippets/emacs-lisp-mode/put | 0 .../emacs-lisp-mode/re-search-backward | 0 .../emacs-lisp-mode/re-search-forward | 0 .../snippets/emacs-lisp-mode/region-active-p | 0 .../snippets/emacs-lisp-mode/region-beginning | 0 .../snippets/emacs-lisp-mode/region-end | 0 .../snippets/emacs-lisp-mode/rename-file | 0 .../snippets/emacs-lisp-mode/repeat | 0 .../snippets/emacs-lisp-mode/replace-regexp | 0 .../emacs-lisp-mode/replace-regexp-in-string | 0 .../snippets/emacs-lisp-mode/require | 0 .../snippets/emacs-lisp-mode/save-buffer | 0 .../snippets/emacs-lisp-mode/save-excursion | 0 .../snippets/emacs-lisp-mode/search-backward | 0 .../emacs-lisp-mode/search-backward-regexp | 0 .../snippets/emacs-lisp-mode/search-forward | 0 .../emacs-lisp-mode/search-forward-regexp | 0 .../snippets/emacs-lisp-mode/set | 0 .../snippets/emacs-lisp-mode/set-buffer | 0 .../snippets/emacs-lisp-mode/set-file-modes | 0 .../snippets/emacs-lisp-mode/set-mark | 0 .../snippets/emacs-lisp-mode/setq | 0 .../emacs-lisp-mode/skip-chars-backward | 0 .../emacs-lisp-mode/skip-chars-forward | 0 .../snippets/emacs-lisp-mode/split-string | 0 .../snippets/emacs-lisp-mode/string | 0 .../snippets/emacs-lisp-mode/string-match | 0 .../snippets/emacs-lisp-mode/string-to-number | 0 .../snippets/emacs-lisp-mode/string= | 0 .../snippets/emacs-lisp-mode/stringp | 0 .../snippets/emacs-lisp-mode/substring | 0 .../snippets/emacs-lisp-mode/thing-at-point | 0 .../snippets/emacs-lisp-mode/traverse_dir | 0 .../snippets/emacs-lisp-mode/unless | 0 .../snippets/emacs-lisp-mode/vector | 0 .../snippets/emacs-lisp-mode/when | 0 .../snippets/emacs-lisp-mode/while | 0 .../snippets/emacs-lisp-mode/widget-get | 0 .../emacs-lisp-mode/with-current-buffer | 0 .../snippets/emacs-lisp-mode/word-or-region | 0 .../snippets/emacs-lisp-mode/word_regexp | 0 .../emacs-lisp-mode/x-dired.process_marked | 0 .../snippets/emacs-lisp-mode/x-file.process | 0 .../emacs-lisp-mode/x-file.read-lines | 0 .../snippets/emacs-lisp-mode/x-find-replace | 0 .../snippets/emacs-lisp-mode/x-grabstring | 0 .../snippets/emacs-lisp-mode/x-grabthing | 0 .../snippets/emacs-lisp-mode/x-traverse_dir | 0 .../snippets/emacs-lisp-mode/x-word-or-region | 0 .../snippets/emacs-lisp-mode/y-or-n-p | 0 .../snippets/emacs-lisp-mode/yes-or-no-p | 0 .../snippets/enh-ruby-mode | 0 .../snippets/ensime-mode | 0 .../snippets/erc-mode/blist | 0 .../snippets/erc-mode/help | 0 .../snippets/erlang-mode/after | 0 .../snippets/erlang-mode/begin | 0 .../snippets/erlang-mode/beh | 0 .../snippets/erlang-mode/case | 0 .../snippets/erlang-mode/compile | 0 .../snippets/erlang-mode/def | 0 .../snippets/erlang-mode/exp | 0 .../snippets/erlang-mode/fun | 0 .../snippets/erlang-mode/if | 0 .../snippets/erlang-mode/ifdef | 0 .../snippets/erlang-mode/ifndef | 0 .../snippets/erlang-mode/imp | 0 .../snippets/erlang-mode/inc | 0 .../snippets/erlang-mode/inc.lib | 0 .../snippets/erlang-mode/loop | 0 .../snippets/erlang-mode/mod | 0 .../snippets/erlang-mode/rcv | 0 .../snippets/erlang-mode/rcv.after | 0 .../snippets/erlang-mode/rec | 0 .../snippets/erlang-mode/try | 0 .../snippets/erlang-mode/undef | 0 .../snippets/f90-mode/au | 0 .../snippets/f90-mode/bd | 0 .../snippets/f90-mode/c | 0 .../snippets/f90-mode/ch | 0 .../snippets/f90-mode/cx | 0 .../snippets/f90-mode/dc | 0 .../snippets/f90-mode/do | 0 .../snippets/f90-mode/dp | 0 .../snippets/f90-mode/eq | 0 .../snippets/f90-mode/forall | 0 .../snippets/f90-mode/function | 0 .../snippets/f90-mode/ib | 0 .../snippets/f90-mode/ic | 0 .../snippets/f90-mode/ich | 0 .../snippets/f90-mode/if | 0 .../snippets/f90-mode/ii | 0 .../snippets/f90-mode/il | 0 .../snippets/f90-mode/in | 0 .../snippets/f90-mode/inc | 0 .../snippets/f90-mode/intr | 0 .../snippets/f90-mode/ir | 0 .../snippets/f90-mode/l | 0 .../snippets/f90-mode/module | 0 .../snippets/f90-mode/pa | 0 .../snippets/f90-mode/pr | 0 .../snippets/f90-mode/program | 0 .../snippets/f90-mode/puref | 0 .../snippets/f90-mode/purefunc | 0 .../snippets/f90-mode/pures | 0 .../snippets/f90-mode/puresub | 0 .../snippets/f90-mode/re | 0 .../snippets/f90-mode/st | 0 .../snippets/f90-mode/su | 0 .../snippets/f90-mode/subroutine | 0 .../snippets/f90-mode/until | 0 .../snippets/f90-mode/where | 0 .../snippets/f90-mode/while | 0 .../snippets/f90-mode/wr | 0 .../snippets/fundamental-mode/.yas-setup.el | 0 .../snippets/git-commit-mode/.yas-parents | 0 .../snippets/git-commit-mode/fixes | 0 .../snippets/git-commit-mode/references | 0 .../snippets/go-mode/const | 0 .../snippets/go-mode/const( | 0 .../snippets/go-mode/dd | 0 .../snippets/go-mode/default | 0 .../snippets/go-mode/else | 0 .../snippets/go-mode/for | 0 .../snippets/go-mode/func | 0 .../snippets/go-mode/if | 0 .../snippets/go-mode/iferr | 0 .../snippets/go-mode/import | 0 .../snippets/go-mode/import( | 0 .../snippets/go-mode/lambda | 0 .../snippets/go-mode/main | 0 .../snippets/go-mode/map | 0 .../snippets/go-mode/printf | 0 .../snippets/go-mode/select | 0 .../snippets/go-mode/switch | 0 .../snippets/go-mode/type | 0 .../snippets/go-mode/var | 0 .../snippets/go-mode/var( | 0 .../snippets/groovy-mode/.yas-parents | 0 .../snippets/groovy-mode/class | 0 .../snippets/groovy-mode/def | 0 .../snippets/groovy-mode/dict | 0 .../snippets/groovy-mode/for | 0 .../snippets/groovy-mode/println | 0 .../snippets/groovy-mode/times | 0 .../snippets/haskell-mode/case | 0 .../snippets/haskell-mode/data | 0 .../snippets/haskell-mode/doc | 0 .../snippets/haskell-mode/function | 0 .../snippets/haskell-mode/import | 0 .../snippets/haskell-mode/instance | 0 .../snippets/haskell-mode/main | 0 .../snippets/haskell-mode/module | 0 .../snippets/haskell-mode/new class | 0 .../snippets/haskell-mode/pragma | 0 .../snippets/haskell-mode/print | 0 .../snippets/html-mode/.yas-parents | 0 .../snippets/html-mode/dd | 0 .../snippets/html-mode/dl | 0 .../snippets/html-mode/doctype | 0 .../snippets/html-mode/doctype.xhml1 | 0 .../snippets/html-mode/doctype.xhtml1_1 | 0 .../snippets/html-mode/doctype.xhtml1_strict | 0 .../html-mode/doctype.xhtml1_transitional | 0 .../snippets/html-mode/dov | 0 .../snippets/html-mode/dt | 0 .../snippets/html-mode/form | 0 .../snippets/html-mode/html | 0 .../snippets/html-mode/html.xmlns | 0 .../snippets/html-mode/link.stylesheet | 0 .../snippets/html-mode/link.stylesheet-ie | 0 .../snippets/html-mode/mailto | 0 .../snippets/html-mode/meta | 0 .../snippets/html-mode/meta.http-equiv | 0 .../snippets/html-mode/script.javascript | 0 .../snippets/html-mode/script.javascript-src | 0 .../snippets/html-mode/textarea | 0 .../snippets/html-mode/th | 0 .../snippets/java-mode/apr_assert | 0 .../snippets/java-mode/cls | 0 .../snippets/java-mode/doc | 0 .../snippets/java-mode/equals | 0 .../snippets/java-mode/file_class | 0 .../snippets/java-mode/for | 0 .../snippets/java-mode/fori | 0 .../snippets/java-mode/if | 0 .../snippets/java-mode/ife | 0 .../snippets/java-mode/import | 0 .../snippets/java-mode/iterator | 0 .../snippets/java-mode/javadoc | 0 .../snippets/java-mode/main | 0 .../snippets/java-mode/main_class | 0 .../snippets/java-mode/method | 0 .../snippets/java-mode/new | 0 .../snippets/java-mode/param | 0 .../snippets/java-mode/printf | 0 .../snippets/java-mode/println | 0 .../snippets/java-mode/return | 0 .../snippets/java-mode/test | 0 .../snippets/java-mode/testClass | 0 .../snippets/java-mode/this | 0 .../snippets/java-mode/toString | 0 .../snippets/java-mode/try | 0 .../snippets/js-mode/al | 0 .../snippets/js-mode/class | 0 .../snippets/js-mode/com | 0 .../snippets/js-mode/def | 0 .../snippets/js-mode/each | 0 .../snippets/js-mode/el | 0 .../snippets/js-mode/ev.add | 0 .../snippets/js-mode/ev.fire | 0 .../snippets/js-mode/f | 0 .../snippets/js-mode/for | 0 .../snippets/js-mode/if | 0 .../snippets/js-mode/init | 0 .../snippets/js-mode/log | 0 .../snippets/js-mode/req.html | 0 .../snippets/js-mode/req.json | 0 .../snippets/js2-mode/.yas-parents | 0 .../snippets/latex-mode/acronym | 0 .../snippets/latex-mode/alertblock | 0 .../snippets/latex-mode/alg | 0 .../snippets/latex-mode/begin | 0 .../snippets/latex-mode/block | 0 .../snippets/latex-mode/capgls | 0 .../snippets/latex-mode/caption | 0 .../snippets/latex-mode/cite | 0 .../snippets/latex-mode/code | 0 .../snippets/latex-mode/columns | 0 .../snippets/latex-mode/emph | 0 .../snippets/latex-mode/figure | 0 .../snippets/latex-mode/frac | 0 .../snippets/latex-mode/frame | 0 .../snippets/latex-mode/gls | 0 .../snippets/latex-mode/glspl | 0 .../snippets/latex-mode/if | 0 .../snippets/latex-mode/includegraphics | 0 .../snippets/latex-mode/item | 0 .../snippets/latex-mode/itemize | 0 .../snippets/latex-mode/label | 0 .../snippets/latex-mode/listing | 0 .../snippets/latex-mode/movie | 0 .../snippets/latex-mode/newcommand | 0 .../snippets/latex-mode/newglossaryentry | 0 .../snippets/latex-mode/note | 0 .../snippets/latex-mode/python | 0 .../snippets/latex-mode/question | 0 .../snippets/latex-mode/section | 0 .../snippets/latex-mode/subf | 0 .../snippets/latex-mode/subfigure | 0 .../snippets/latex-mode/subsec | 0 .../snippets/latex-mode/textbf | 0 .../snippets/latex-mode/usepackage | 0 .../snippets/lisp-interaction-mode/defun | 0 .../snippets/lua-mode/fun | 0 .../snippets/m4-mode/def | 0 .../makefile-automake-mode/noinst_HEADERS | 0 .../snippets/makefile-bsdmake-mode/PHONY | 0 .../snippets/makefile-bsdmake-mode/echo | 0 .../snippets/makefile-bsdmake-mode/gen | 0 .../snippets/makefile-bsdmake-mode/if | 0 .../snippets/makefile-bsdmake-mode/var | 0 .../snippets/makefile-gmake-mode/patsubst | 0 .../snippets/makefile-gmake-mode/phony | 0 .../snippets/makefile-gmake-mode/wildcard | 0 .../snippets/makefile-mode/all | 0 .../snippets/markdown-mode/+ | 0 .../snippets/markdown-mode/- | 0 .../snippets/markdown-mode/_ | 0 .../snippets/markdown-mode/__ | 0 .../snippets/markdown-mode/` | 0 .../snippets/markdown-mode/h1.1 | 0 .../snippets/markdown-mode/h1.2 | 0 .../snippets/markdown-mode/h2.1 | 0 .../snippets/markdown-mode/h2.2 | 0 .../snippets/markdown-mode/h3 | 0 .../snippets/markdown-mode/h4 | 0 .../snippets/markdown-mode/h5 | 0 .../snippets/markdown-mode/h6 | 0 .../snippets/markdown-mode/hr.1 | 0 .../snippets/markdown-mode/hr.2 | 0 .../snippets/markdown-mode/img | 0 .../snippets/markdown-mode/link | 0 .../snippets/markdown-mode/ol | 0 .../snippets/markdown-mode/rimg | 0 .../snippets/markdown-mode/rlb | 0 .../snippets/markdown-mode/rlink | 0 .../snippets/markdown-mode/utf8 | 0 .../snippets/ned-mode/.yas-parents | 0 .../snippets/ned-mode/chan | 0 .../snippets/ned-mode/connections | 0 .../snippets/ned-mode/for | 0 .../snippets/ned-mode/import | 0 .../snippets/ned-mode/network | 0 .../snippets/ned-mode/simple | 0 .../snippets/ned-mode/submodules | 0 .../snippets/nesc-mode/.yas-parents | 0 .../snippets/nesc-mode/TOSSIM | 0 .../snippets/nesc-mode/command | 0 .../snippets/nesc-mode/dbg | 0 .../snippets/nesc-mode/event | 0 .../snippets/nesc-mode/ifdef | 0 .../snippets/nesc-mode/interface | 0 .../snippets/nesc-mode/module | 0 .../snippets/nesc-mode/nx | 0 .../snippets/nesc-mode/provides | 0 .../snippets/nesc-mode/sim | 0 .../snippets/nesc-mode/uint8_t | 0 .../snippets/nesc-mode/uses | 0 .../snippets/nsis-mode/.yas-parents | 0 .../snippets/nsis-mode/define | 0 .../snippets/nsis-mode/function | 0 .../snippets/nsis-mode/if | 0 .../snippets/nsis-mode/include | 0 .../snippets/nsis-mode/insert_macro | 0 .../snippets/nsis-mode/instdir | 0 .../snippets/nsis-mode/macro | 0 .../snippets/nsis-mode/message | 0 .../snippets/nsis-mode/outdir | 0 .../snippets/nsis-mode/outfile | 0 .../snippets/nsis-mode/section | 0 .../snippets/nxml-mode/body | 0 .../snippets/nxml-mode/br | 0 .../snippets/nxml-mode/doctype | 0 .../snippets/nxml-mode/doctype_xhtml1_strict | 0 .../nxml-mode/doctype_xhtml1_transitional | 0 .../snippets/nxml-mode/form | 0 .../snippets/nxml-mode/href | 0 .../snippets/nxml-mode/html | 0 .../snippets/nxml-mode/img | 0 .../snippets/nxml-mode/input | 0 .../snippets/nxml-mode/link | 0 .../snippets/nxml-mode/meta | 0 .../snippets/nxml-mode/name | 0 .../snippets/nxml-mode/quote | 0 .../snippets/nxml-mode/style | 0 .../snippets/nxml-mode/tag | 0 .../snippets/nxml-mode/tag_closing | 0 .../snippets/nxml-mode/tag_newline | 0 .../snippets/octave-mode/for | 0 .../snippets/octave-mode/function | 0 .../snippets/octave-mode/if | 0 .../snippets/org-mode/blog | 0 .../snippets/org-mode/code | 0 .../snippets/org-mode/dot | 0 .../snippets/org-mode/elisp | 0 .../snippets/org-mode/embedded | 0 .../snippets/org-mode/entry | 0 .../snippets/org-mode/figure | 0 .../snippets/org-mode/img | 0 .../snippets/org-mode/latex | 0 .../snippets/org-mode/matrix | 0 .../snippets/org-mode/src | 0 .../snippets/org-mode/srcname | 0 .../snippets/org-mode/verse | 0 .../snippets/perl-mode/.yas-parents | 0 .../snippets/perl-mode/eval | 0 .../snippets/perl-mode/for | 0 .../snippets/perl-mode/fore | 0 .../snippets/perl-mode/if | 0 .../snippets/perl-mode/ife | 0 .../snippets/perl-mode/ifee | 0 .../snippets/perl-mode/sub | 0 .../snippets/perl-mode/unless | 0 .../snippets/perl-mode/while | 0 .../snippets/perl-mode/xfore | 0 .../snippets/perl-mode/xif | 0 .../snippets/perl-mode/xunless | 0 .../snippets/perl-mode/xwhile | 0 .../snippets/prog-mode/.yas-setup.el | 0 .../snippets/prog-mode/fixme | 0 .../snippets/prog-mode/todo | 0 .../snippets/prog-mode/xxx | 0 .../snippets/python-mode/.yas-parents | 0 .../snippets/python-mode/.yas-setup.el | 0 .../snippets/python-mode/__contains__ | 0 .../snippets/python-mode/__enter__ | 0 .../snippets/python-mode/__exit__ | 0 .../snippets/python-mode/__getitem__ | 0 .../snippets/python-mode/__len__ | 0 .../snippets/python-mode/__new__ | 0 .../snippets/python-mode/__setitem__ | 0 .../snippets/python-mode/all | 0 .../snippets/python-mode/arg | 0 .../snippets/python-mode/arg_positional | 0 .../snippets/python-mode/ass | 0 .../snippets/python-mode/assertEqual | 0 .../snippets/python-mode/assertFalse | 0 .../snippets/python-mode/assertIn | 0 .../snippets/python-mode/assertNotEqual | 0 .../snippets/python-mode/assertRaises | 0 .../snippets/python-mode/assertRaises.with | 0 .../snippets/python-mode/assertTrue | 0 .../snippets/python-mode/assetNotIn | 0 .../snippets/python-mode/celery_pdb | 0 .../snippets/python-mode/classmethod | 0 .../snippets/python-mode/cls | 0 .../snippets/python-mode/dec | 0 .../snippets/python-mode/deftest | 0 .../snippets/python-mode/django_test_class | 0 .../snippets/python-mode/doc | 0 .../snippets/python-mode/doctest | 0 .../snippets/python-mode/eq | 0 .../snippets/python-mode/for | 0 .../snippets/python-mode/from | 0 .../snippets/python-mode/function | 0 .../snippets/python-mode/function_docstring | 0 .../snippets/python-mode/if | 0 .../snippets/python-mode/ife | 0 .../snippets/python-mode/ifmain | 0 .../snippets/python-mode/import | 0 .../snippets/python-mode/init | 0 .../snippets/python-mode/init_docstring | 0 .../snippets/python-mode/interact | 0 .../snippets/python-mode/ipdbdebug | 0 .../snippets/python-mode/iter | 0 .../snippets/python-mode/lambda | 0 .../snippets/python-mode/list | 0 .../snippets/python-mode/logger_name | 0 .../snippets/python-mode/logging | 0 .../snippets/python-mode/main | 0 .../snippets/python-mode/metaclass | 0 .../snippets/python-mode/method | 0 .../snippets/python-mode/method_docstring | 0 .../snippets/python-mode/not_impl | 0 .../snippets/python-mode/np | 0 .../snippets/python-mode/parse_args | 0 .../snippets/python-mode/parser | 0 .../snippets/python-mode/pass | 0 .../snippets/python-mode/print | 0 .../snippets/python-mode/prop | 0 .../snippets/python-mode/reg | 0 .../snippets/python-mode/repr | 0 .../snippets/python-mode/return | 0 .../snippets/python-mode/script | 0 .../snippets/python-mode/self | 0 .../snippets/python-mode/self_without_dot | 0 .../snippets/python-mode/selfassign | 0 .../snippets/python-mode/setdef | 0 .../snippets/python-mode/setup | 0 .../snippets/python-mode/size | 0 .../snippets/python-mode/static | 0 .../snippets/python-mode/str | 0 .../snippets/python-mode/super | 0 .../snippets/python-mode/test_class | 0 .../snippets/python-mode/test_file | 0 .../snippets/python-mode/trace | 0 .../snippets/python-mode/try | 0 .../snippets/python-mode/tryelse | 0 .../snippets/python-mode/unicode | 0 .../snippets/python-mode/utf8 | 0 .../snippets/python-mode/while | 0 .../snippets/python-mode/with | 0 .../snippets/python-mode/with_statement | 0 .../snippets/rename_add_contr.py | 0 .../snippets/rst-mode/autoclass | 0 .../snippets/rst-mode/autofunction | 0 .../snippets/rst-mode/automodule | 0 .../snippets/rst-mode/class | 0 .../snippets/rst-mode/code | 0 .../snippets/rst-mode/digraph | 0 .../snippets/rst-mode/function | 0 .../snippets/rst-mode/graph | 0 .../snippets/rst-mode/graphviz | 0 .../snippets/rst-mode/image | 0 .../snippets/rst-mode/inheritance | 0 .../snippets/rst-mode/literal_include | 0 .../snippets/rst-mode/meta | 0 .../snippets/rst-mode/module | 0 .../snippets/rst-mode/parsed_literal | 0 .../snippets/rst-mode/pause | 0 .../snippets/rst-mode/term | 0 .../snippets/rst-mode/url | 0 .../snippets/rst-mode/verbatim | 0 .../snippets/rst-mode/warning | 0 .../snippets/ruby-mode/# | 0 .../snippets/ruby-mode/=b | 0 .../snippets/ruby-mode/Comp | 0 .../snippets/ruby-mode/GLOB | 0 .../snippets/ruby-mode/all | 0 .../snippets/ruby-mode/am | 0 .../snippets/ruby-mode/any | 0 .../snippets/ruby-mode/app | 0 .../snippets/ruby-mode/attribute | 0 .../snippets/ruby-mode/bench | 0 .../snippets/ruby-mode/bm | 0 .../snippets/ruby-mode/case | 0 .../snippets/ruby-mode/cla | 0 .../snippets/ruby-mode/cls | 0 .../snippets/ruby-mode/collect | 0 .../snippets/ruby-mode/dee | 0 .../snippets/ruby-mode/def | 0 .../snippets/ruby-mode/deli | 0 .../snippets/ruby-mode/det | 0 .../snippets/ruby-mode/dow | 0 .../snippets/ruby-mode/ea | 0 .../snippets/ruby-mode/eac | 0 .../snippets/ruby-mode/eai | 0 .../snippets/ruby-mode/eav | 0 .../snippets/ruby-mode/eawi | 0 .../snippets/ruby-mode/for | 0 .../snippets/ruby-mode/forin | 0 .../snippets/ruby-mode/formula | 0 .../snippets/ruby-mode/if | 0 .../snippets/ruby-mode/ife | 0 .../snippets/ruby-mode/init | 0 .../snippets/ruby-mode/inject | 0 .../snippets/ruby-mode/mm | 0 .../snippets/ruby-mode/r | 0 .../snippets/ruby-mode/rb | 0 .../snippets/ruby-mode/reject | 0 .../snippets/ruby-mode/rel | 0 .../snippets/ruby-mode/req | 0 .../snippets/ruby-mode/rw | 0 .../snippets/ruby-mode/select | 0 .../snippets/ruby-mode/str | 0 .../snippets/ruby-mode/test class | 0 .../snippets/ruby-mode/tim | 0 .../snippets/ruby-mode/to_ | 0 .../snippets/ruby-mode/tu | 0 .../snippets/ruby-mode/until | 0 .../snippets/ruby-mode/upt | 0 .../snippets/ruby-mode/w | 0 .../snippets/ruby-mode/when | 0 .../snippets/ruby-mode/while | 0 .../snippets/ruby-mode/y | 0 .../snippets/ruby-mode/zip | 0 .../snippets/scala-mode/act | 0 .../snippets/scala-mode/act.arg | 0 .../snippets/scala-mode/actor | 0 .../snippets/scala-mode/ano | 0 .../snippets/scala-mode/app | 0 .../snippets/scala-mode/arr.new | 0 .../snippets/scala-mode/arr.val-new | 0 .../snippets/scala-mode/asof | 0 .../snippets/scala-mode/ass | 0 .../snippets/scala-mode/ass.true | 0 .../snippets/scala-mode/at.author | 0 .../snippets/scala-mode/at.param | 0 .../snippets/scala-mode/at.return | 0 .../snippets/scala-mode/at.version | 0 .../snippets/scala-mode/bang | 0 .../snippets/scala-mode/case | 0 .../snippets/scala-mode/case.match-all | 0 .../snippets/scala-mode/cast | 0 .../snippets/scala-mode/cc | 0 .../snippets/scala-mode/cl | 0 .../snippets/scala-mode/cl.abs | 0 .../snippets/scala-mode/cl.abs-arg | 0 .../snippets/scala-mode/cl.arg | 0 .../snippets/scala-mode/clof | 0 .../snippets/scala-mode/co | 0 .../snippets/scala-mode/cons | 0 .../snippets/scala-mode/cons.nil | 0 .../snippets/scala-mode/def.arg | 0 .../snippets/scala-mode/def.arg-body | 0 .../snippets/scala-mode/def.arg-ret | 0 .../snippets/scala-mode/def.arg-ret-body | 0 .../snippets/scala-mode/def.body | 0 .../snippets/scala-mode/def.ret | 0 .../snippets/scala-mode/def.ret-body | 0 .../snippets/scala-mode/def.simple | 0 .../snippets/scala-mode/doc.class | 0 .../snippets/scala-mode/doc.def | 0 .../snippets/scala-mode/doc.file | 0 .../snippets/scala-mode/doc.file-scala | 0 .../snippets/scala-mode/doc.file-scala-api | 0 .../snippets/scala-mode/doc.scaladoc | 0 .../snippets/scala-mode/expect | 0 .../snippets/scala-mode/ext | 0 .../snippets/scala-mode/for.extract | 0 .../snippets/scala-mode/for.if | 0 .../snippets/scala-mode/for.loop | 0 .../snippets/scala-mode/for.multi | 0 .../snippets/scala-mode/foreach | 0 .../snippets/scala-mode/hmap.new | 0 .../snippets/scala-mode/hmap.val-new | 0 .../snippets/scala-mode/hset.new | 0 .../snippets/scala-mode/hset.val-new | 0 .../snippets/scala-mode/if | 0 .../snippets/scala-mode/if.else | 0 .../snippets/scala-mode/imp | 0 .../snippets/scala-mode/intercept | 0 .../snippets/scala-mode/isof | 0 .../snippets/scala-mode/ls.new | 0 .../snippets/scala-mode/ls.val-new | 0 .../snippets/scala-mode/main | 0 .../snippets/scala-mode/map | 0 .../snippets/scala-mode/map.new | 0 .../snippets/scala-mode/match | 0 .../snippets/scala-mode/match.can | 0 .../snippets/scala-mode/match.option | 0 .../snippets/scala-mode/mix | 0 .../snippets/scala-mode/ob | 0 .../snippets/scala-mode/pac | 0 .../snippets/scala-mode/pr.newline | 0 .../snippets/scala-mode/pr.simple | 0 .../snippets/scala-mode/pr.string | 0 .../snippets/scala-mode/pr.trace | 0 .../snippets/scala-mode/pri | 0 .../snippets/scala-mode/pri.param | 0 .../snippets/scala-mode/pro | 0 .../snippets/scala-mode/pro.param | 0 .../snippets/scala-mode/suite | 0 .../snippets/scala-mode/test | 0 .../snippets/scala-mode/throw | 0 .../snippets/scala-mode/tr | 0 .../snippets/scala-mode/tr.ext | 0 .../snippets/scala-mode/tr.ext-with | 0 .../snippets/scala-mode/tr.with | 0 .../snippets/scala-mode/try | 0 .../snippets/scala-mode/try.catch-finally | 0 .../snippets/scala-mode/try.finally | 0 .../snippets/scala-mode/tup.arrow | 0 .../snippets/scala-mode/tup.paren | 0 .../snippets/scala-mode/val | 0 .../snippets/scala-mode/val.new | 0 .../snippets/scala-mode/val.ret | 0 .../snippets/scala-mode/var | 0 .../snippets/scala-mode/var.new | 0 .../snippets/scala-mode/var.ret | 0 .../snippets/scala-mode/whi | 0 .../snippets/scala-mode/with | 0 .../snippets/sh-mode/args | 0 .../snippets/sh-mode/bang | 0 .../snippets/sh-mode/for loop | 0 .../snippets/sh-mode/function | 0 .../snippets/sh-mode/if | 0 .../snippets/sh-mode/ife | 0 .../snippets/snippet-mode/cont | 0 .../snippets/snippet-mode/elisp | 0 .../snippets/snippet-mode/field | 0 .../snippets/snippet-mode/group | 0 .../snippets/snippet-mode/mirror | 0 .../snippets/snippet-mode/vars | 0 .../snippets/sql-mode/column | 0 .../snippets/sql-mode/constraint | 0 .../snippets/sql-mode/constraint.1 | 0 .../snippets/sql-mode/create | 0 .../snippets/sql-mode/create.1 | 0 .../snippets/sql-mode/references | 0 .../snippets/text-mode/.yas-parents | 0 .../snippets/tuareg-mode/assert | 0 .../snippets/tuareg-mode/docstring | 0 .../snippets/tuareg-mode/for | 0 .../snippets/tuareg-mode/fun | 0 .../snippets/tuareg-mode/guard | 0 .../snippets/tuareg-mode/ifthen | 0 .../snippets/tuareg-mode/ifthenelse | 0 .../snippets/tuareg-mode/let | 0 .../snippets/tuareg-mode/list_comprehension | 0 .../snippets/tuareg-mode/main | 0 .../snippets/tuareg-mode/match | 0 .../snippets/tuareg-mode/module | 0 .../snippets/tuareg-mode/open | 0 .../snippets/tuareg-mode/printf | 0 .../snippets/tuareg-mode/rec | 0 .../snippets/tuareg-mode/try | 0 .../snippets/tuareg-mode/type | 0 .../snippets/tuareg-mode/type_type | 0 .../snippets/tuareg-mode/val | 0 .../snippets/tuareg-mode/while | 0 .../snippets/typerex-mode | 0 .../snippets/udev-mode/ENV | 0 .../snippets/udev-mode/GOTO | 0 .../snippets/udev-mode/KERNEL | 0 .../snippets/udev-mode/add | 0 .../snippets/udev-mode/env$ | 0 .../snippets/udev-mode/run | 0 .../snippets/yaml-mode/entry | 0 .../snippets/yaml-mode/list | 0 .../snippets/yaml-mode/section | 0 .../yasnippet-autoloads.el | 58 + .../yasnippet-20150415.244/yasnippet-pkg.el | 5 + .../elpa/yasnippet-20150415.244/yasnippet.el | 4582 ++++++ 1514 files changed, 98921 insertions(+), 93987 deletions(-) delete mode 100644 emacs.d/elpa/async-20141001.151/async-autoloads.el delete mode 100644 emacs.d/elpa/async-20141001.151/async-bytecomp.el delete mode 100644 emacs.d/elpa/async-20141001.151/async-pkg.el delete mode 100644 emacs.d/elpa/async-20141001.151/async.el create mode 100644 emacs.d/elpa/async-20150412.2207/async-autoloads.el create mode 100644 emacs.d/elpa/async-20150412.2207/async-bytecomp.el create mode 100644 emacs.d/elpa/async-20150412.2207/async-pkg.el create mode 100644 emacs.d/elpa/async-20150412.2207/async.el rename emacs.d/elpa/{async-20141001.151 => async-20150412.2207}/dired-async.el (100%) rename emacs.d/elpa/{async-20141001.151 => async-20150412.2207}/smtpmail-async.el (100%) delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/auto-complete-autoloads.el delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/auto-complete-config.el delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/auto-complete-pkg.el delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/auto-complete.el delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/dict/c++-mode delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/dict/c-mode delete mode 100644 emacs.d/elpa/auto-complete-20140824.1658/dict/css-mode create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/auto-complete-autoloads.el create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/auto-complete-config.el create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/auto-complete-pkg.el create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/auto-complete.el rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/ada-mode (100%) create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/dict/c++-mode create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/dict/c-mode rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/caml-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/clojure-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/clojurescript-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/coq-mode (100%) create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/dict/css-mode rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/erlang-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/go-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/haskell-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/java-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658/dict/javascript-mode => auto-complete-20150408.1132/dict/js-mode} (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/lua-mode (100%) create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/dict/octave-mode rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/php-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/python-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/qml-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/ruby-mode (100%) create mode 100644 emacs.d/elpa/auto-complete-20150408.1132/dict/scala-mode rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/scheme-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/sclang-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/sh-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/tcl-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/ts-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/tuareg-mode (100%) rename emacs.d/elpa/{auto-complete-20140824.1658 => auto-complete-20150408.1132}/dict/verilog-mode (100%) delete mode 100644 emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-autoloads.el delete mode 100644 emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-pkg.el delete mode 100644 emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags.el delete mode 100644 emacs.d/elpa/bison-mode-20141119.43/bison-mode-autoloads.el delete mode 100644 emacs.d/elpa/bison-mode-20141119.43/bison-mode-pkg.el delete mode 100644 emacs.d/elpa/bison-mode-20141119.43/bison-mode.el delete mode 100644 emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-autoloads.el delete mode 100644 emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-pkg.el delete mode 100644 emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode.el create mode 100644 emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-autoloads.el create mode 100644 emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-pkg.el create mode 100644 emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-autoloads.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-bbdb.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-capf.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-clang.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-cmake.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-dabbrev.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-etags.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-files.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-gtags.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-ispell.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-pkg.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-pysmell.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-ropemacs.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-semantic.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-template.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company-xcode.el delete mode 100644 emacs.d/elpa/company-20141014.1517/company.el rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-abbrev.el (100%) create mode 100644 emacs.d/elpa/company-20150503.1854/company-autoloads.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-bbdb.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-capf.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-clang.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-cmake.el rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-css.el (100%) rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-dabbrev-code.el (100%) create mode 100644 emacs.d/elpa/company-20150503.1854/company-dabbrev.el rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-eclim.el (100%) rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-elisp.el (100%) create mode 100644 emacs.d/elpa/company-20150503.1854/company-etags.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-files.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-gtags.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-ispell.el rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-keywords.el (100%) rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-nxml.el (100%) rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-oddmuse.el (100%) create mode 100644 emacs.d/elpa/company-20150503.1854/company-pkg.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-semantic.el create mode 100644 emacs.d/elpa/company-20150503.1854/company-template.el rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-tempo.el (100%) create mode 100644 emacs.d/elpa/company-20150503.1854/company-xcode.el rename emacs.d/elpa/{company-20141014.1517 => company-20150503.1854}/company-yasnippet.el (100%) create mode 100644 emacs.d/elpa/company-20150503.1854/company.el delete mode 100644 emacs.d/elpa/concurrent-20140609.1940/concurrent-autoloads.el delete mode 100644 emacs.d/elpa/concurrent-20140609.1940/concurrent-pkg.el delete mode 100644 emacs.d/elpa/concurrent-20140609.1940/concurrent.el create mode 100644 emacs.d/elpa/concurrent-20150309.2052/concurrent-autoloads.el create mode 100644 emacs.d/elpa/concurrent-20150309.2052/concurrent-pkg.el create mode 100644 emacs.d/elpa/concurrent-20150309.2052/concurrent.el delete mode 100644 emacs.d/elpa/dash-20141008.712/dash-autoloads.el delete mode 100644 emacs.d/elpa/dash-20141008.712/dash-pkg.el delete mode 100644 emacs.d/elpa/dash-20141008.712/dash.el create mode 100644 emacs.d/elpa/dash-20150503.1343/dash-autoloads.el create mode 100644 emacs.d/elpa/dash-20150503.1343/dash-pkg.el create mode 100644 emacs.d/elpa/dash-20150503.1343/dash.el delete mode 100644 emacs.d/elpa/deferred-20140816.2205/deferred-autoloads.el delete mode 100644 emacs.d/elpa/deferred-20140816.2205/deferred-pkg.el delete mode 100644 emacs.d/elpa/deferred-20140816.2205/deferred.el create mode 100644 emacs.d/elpa/deferred-20150309.2052/deferred-autoloads.el create mode 100644 emacs.d/elpa/deferred-20150309.2052/deferred-pkg.el create mode 100644 emacs.d/elpa/deferred-20150309.2052/deferred.el delete mode 100644 emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-autoloads.el delete mode 100644 emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-pkg.el delete mode 100644 emacs.d/elpa/elixir-mode-20150103.439/elixir-mode.el rename emacs.d/elpa/{elixir-mode-20150103.439 => elixir-mode-20150317.1454}/elixir-deprecated.el (100%) create mode 100644 emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-autoloads.el create mode 100644 emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-pkg.el create mode 100644 emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode.el rename emacs.d/elpa/{elixir-mode-20150103.439 => elixir-mode-20150317.1454}/elixir-smie.el (100%) delete mode 100644 emacs.d/elpa/elpy-1.7.1/LICENSE delete mode 100644 emacs.d/elpa/elpy-1.7.1/README.rst delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy-autoloads.el delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy-pkg.el delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy.el delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy/__init__.py delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy/__main__.py delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy/impmagic.py delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy/jedibackend.py delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy/ropebackend.py delete mode 100644 emacs.d/elpa/elpy-1.7.1/elpy/server.py create mode 100644 emacs.d/elpa/elpy-20150502.740/NEWS.rst create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy-autoloads.el create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy-pkg.el rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/elpy-refactor.el (100%) create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy.el create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/__init__.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/__main__.py rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/elpy/compat.py (100%) create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/impmagic.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/jedibackend.py rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/elpy/pydocutils.py (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/elpy/refactor.py (100%) create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/ropebackend.py rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/elpy/rpc.py (100%) create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/server.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/__init__.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/compat.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/support.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_impmagic.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_jedibackend.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_pydocutils.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_refactor.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_ropebackend.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_rpc.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_server.py create mode 100644 emacs.d/elpa/elpy-20150502.740/elpy/tests/test_support.py rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/.yas-setup.el (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__abs__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__add__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__and__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__bool__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__call__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__cmp__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__coerce__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__complex__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__contains__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__del__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__delattr__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__delete__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__delitem__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__div__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__divmod__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__enter__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__eq__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__exit__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__float__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__floordiv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ge__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__get__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__getattr__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__getattribute__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__getitem__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__gt__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__hash__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__hex__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__iadd__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__iand__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__idiv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ifloordiv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ilshift__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__imod__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__imul__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__index__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__init__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__instancecheck__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__int__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__invert__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ior__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ipow__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__irshift__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__isub__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__iter__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__itruediv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ixor__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__le__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__len__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__long__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__lshift__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__lt__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__mod__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__mul__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ne__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__neg__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__new__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__nonzero__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__oct__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__or__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__pos__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__pow__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__radd__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rand__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rdivmod__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__repr__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__reversed__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rfloordiv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rlshift__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rmod__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rmul__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__ror__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rpow__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rrshift__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rshift__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rsub__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rtruediv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__rxor__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__set__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__setattr__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__setitem__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__slots__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__str__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__sub__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__subclasscheck__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__truediv__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__unicode__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/__xor__ (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/ase (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/asne (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/asr (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/class (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/defs (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/enc (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/env (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/from (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/pdb (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/py3 (100%) rename emacs.d/elpa/{elpy-1.7.1 => elpy-20150502.740}/snippets/python-mode/super (100%) delete mode 100644 emacs.d/elpa/epl-20140823.609/epl-autoloads.el delete mode 100644 emacs.d/elpa/epl-20140823.609/epl-pkg.el delete mode 100644 emacs.d/elpa/epl-20140823.609/epl.el create mode 100644 emacs.d/elpa/epl-20150326.1212/epl-autoloads.el create mode 100644 emacs.d/elpa/epl-20150326.1212/epl-pkg.el create mode 100644 emacs.d/elpa/epl-20150326.1212/epl.el delete mode 100644 emacs.d/elpa/erlang-20141104.17/erlang-autoloads.el delete mode 100644 emacs.d/elpa/erlang-20141104.17/erlang-pkg.el delete mode 100644 emacs.d/elpa/erlang-20141104.17/erlang.el create mode 100644 emacs.d/elpa/erlang-20150319.456/erlang-autoloads.el rename emacs.d/elpa/{erlang-20141104.17 => erlang-20150319.456}/erlang-eunit.el (100%) rename emacs.d/elpa/{erlang-20141104.17 => erlang-20150319.456}/erlang-flymake.el (100%) create mode 100644 emacs.d/elpa/erlang-20150319.456/erlang-pkg.el rename emacs.d/elpa/{erlang-20141104.17 => erlang-20150319.456}/erlang-skels-old.el (100%) rename emacs.d/elpa/{erlang-20141104.17 => erlang-20150319.456}/erlang-skels.el (100%) rename emacs.d/elpa/{erlang-20141104.17 => erlang-20150319.456}/erlang-start.el (100%) create mode 100644 emacs.d/elpa/erlang-20150319.456/erlang.el rename emacs.d/elpa/{erlang-20141104.17 => erlang-20150319.456}/erlang_appwiz.el (100%) delete mode 100644 emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-autoloads.el delete mode 100644 emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-pkg.el delete mode 100644 emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project.el create mode 100644 emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-autoloads.el create mode 100644 emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-pkg.el create mode 100644 emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project.el delete mode 100644 emacs.d/elpa/flymake-cursor-1.0.2/Changes delete mode 100644 emacs.d/elpa/flymake-cursor-1.0.2/LICENSE.txt delete mode 100644 emacs.d/elpa/flymake-cursor-1.0.2/README.mkdn delete mode 100644 emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-autoloads.el delete mode 100644 emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-pkg.el delete mode 100644 emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor.el create mode 100644 emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-autoloads.el create mode 100644 emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-pkg.el create mode 100644 emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor.el delete mode 100644 emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-autoloads.el delete mode 100644 emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-pkg.el delete mode 100644 emacs.d/elpa/flymake-elixir-0.5/flymake-elixir.el create mode 100644 emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-autoloads.el create mode 100644 emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-pkg.el create mode 100644 emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir.el delete mode 100644 emacs.d/elpa/flymake-php-20121104.1102/flymake-php-autoloads.el delete mode 100644 emacs.d/elpa/flymake-php-20121104.1102/flymake-php-pkg.el delete mode 100644 emacs.d/elpa/flymake-php-20121104.1102/flymake-php.el create mode 100644 emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-autoloads.el create mode 100644 emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-pkg.el create mode 100644 emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode.el delete mode 100644 emacs.d/elpa/git-gutter-20141007.2327/git-gutter-autoloads.el delete mode 100644 emacs.d/elpa/git-gutter-20141007.2327/git-gutter-pkg.el delete mode 100644 emacs.d/elpa/git-gutter-20141007.2327/git-gutter.el create mode 100644 emacs.d/elpa/git-gutter-20150501.756/git-gutter-autoloads.el create mode 100644 emacs.d/elpa/git-gutter-20150501.756/git-gutter-pkg.el create mode 100644 emacs.d/elpa/git-gutter-20150501.756/git-gutter.el create mode 100644 emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-autoloads.el create mode 100644 emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-pkg.el create mode 100644 emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode.el delete mode 100644 emacs.d/elpa/go-mode-20140905.2210/go-mode-autoloads.el delete mode 100644 emacs.d/elpa/go-mode-20140905.2210/go-mode-pkg.el delete mode 100644 emacs.d/elpa/go-mode-20140905.2210/go-mode.el create mode 100644 emacs.d/elpa/go-mode-20150503.258/go-mode-autoloads.el create mode 100644 emacs.d/elpa/go-mode-20150503.258/go-mode-pkg.el create mode 100644 emacs.d/elpa/go-mode-20150503.258/go-mode.el delete mode 100755 emacs.d/elpa/helm-20141016.2217/emacs-helm.sh delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-adaptive.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-aliases.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-apt.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-autoloads.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-bbdb.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-bookmark.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-buffers.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-color.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-command.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-config.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-dabbrev.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-elisp-package.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-elisp.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-elscreen.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-emms.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-eshell.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-eval.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-external.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-files.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-firefox.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-font.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-gentoo.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-grep.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-help.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-imenu.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-info.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-locate.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-man.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-match-plugin.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-misc.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-mode.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-net.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-org.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-pkg.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-plugin.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-regexp.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-ring.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-semantic.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-source.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-sys.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-tags.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-utils.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-w3m.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm-yaoddmuse.el delete mode 100644 emacs.d/elpa/helm-20141016.2217/helm.el create mode 100755 emacs.d/elpa/helm-20150507.2215/emacs-helm.sh create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-adaptive.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-aliases.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-apt.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-autoloads.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-bookmark.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-buffers.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-color.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-command.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-config.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-dabbrev.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-elisp-package.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-elisp.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-elscreen.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-eshell.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-eval.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-external.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-files.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-font.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-grep.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-help.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-imenu.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-info.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-locate.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-man.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-match-plugin.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-misc.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-mode.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-net.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-org.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-pkg.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-plugin.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-regexp.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-ring.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-semantic.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-source.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-sys.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-tags.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm-utils.el create mode 100644 emacs.d/elpa/helm-20150507.2215/helm.el delete mode 100644 emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-autoloads.el delete mode 100644 emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-pkg.el delete mode 100644 emacs.d/elpa/helm-projectile-20141017.246/helm-projectile.el create mode 100644 emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-autoloads.el create mode 100644 emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-pkg.el create mode 100644 emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile.el delete mode 100644 emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-autoloads.el delete mode 100644 emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-pkg.el delete mode 100644 emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation.el create mode 100644 emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-autoloads.el create mode 100644 emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-pkg.el create mode 100644 emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation.el delete mode 100644 emacs.d/elpa/idomenu-20111122.1048/idomenu-autoloads.el delete mode 100644 emacs.d/elpa/idomenu-20111122.1048/idomenu-pkg.el delete mode 100644 emacs.d/elpa/idomenu-20111122.1048/idomenu.el create mode 100644 emacs.d/elpa/idomenu-20141123.1320/idomenu-autoloads.el create mode 100644 emacs.d/elpa/idomenu-20141123.1320/idomenu-pkg.el create mode 100644 emacs.d/elpa/idomenu-20141123.1320/idomenu.el delete mode 100644 emacs.d/elpa/jedi-20140321.1323/Makefile delete mode 100644 emacs.d/elpa/jedi-20140321.1323/jedi-autoloads.el delete mode 100644 emacs.d/elpa/jedi-20140321.1323/jedi-pkg.el delete mode 100644 emacs.d/elpa/jedi-20140321.1323/jedi.el delete mode 100755 emacs.d/elpa/jedi-20140321.1323/jediepcserver.py delete mode 100644 emacs.d/elpa/jedi-20140321.1323/setup.py create mode 100644 emacs.d/elpa/jedi-20150413.2208/jedi-autoloads.el create mode 100644 emacs.d/elpa/jedi-20150413.2208/jedi-pkg.el create mode 100644 emacs.d/elpa/jedi-20150413.2208/jedi.el create mode 100644 emacs.d/elpa/jedi-core-20150507.438/Makefile create mode 100644 emacs.d/elpa/jedi-core-20150507.438/jedi-core-autoloads.el create mode 100644 emacs.d/elpa/jedi-core-20150507.438/jedi-core-pkg.el create mode 100644 emacs.d/elpa/jedi-core-20150507.438/jedi-core.el create mode 100755 emacs.d/elpa/jedi-core-20150507.438/jediepcserver.py create mode 100644 emacs.d/elpa/jedi-core-20150507.438/setup.py delete mode 100644 emacs.d/elpa/js2-mode-20150423.1929/js2-mode-autoloads.el delete mode 100644 emacs.d/elpa/js2-mode-20150423.1929/js2-mode-pkg.el delete mode 100644 emacs.d/elpa/js2-mode-20150423.1929/js2-mode.el rename emacs.d/elpa/{js2-mode-20150423.1929 => js2-mode-20150503.617}/js2-imenu-extras.el (100%) create mode 100644 emacs.d/elpa/js2-mode-20150503.617/js2-mode-autoloads.el create mode 100644 emacs.d/elpa/js2-mode-20150503.617/js2-mode-pkg.el create mode 100644 emacs.d/elpa/js2-mode-20150503.617/js2-mode.el delete mode 100644 emacs.d/elpa/markdown-mode-2.0/markdown-mode-autoloads.el delete mode 100644 emacs.d/elpa/markdown-mode-2.0/markdown-mode-pkg.el delete mode 100644 emacs.d/elpa/markdown-mode-2.0/markdown-mode.el create mode 100644 emacs.d/elpa/markdown-mode-20150121.1229/markdown-mode-autoloads.el create mode 100644 emacs.d/elpa/markdown-mode-20150121.1229/markdown-mode-pkg.el create mode 100644 emacs.d/elpa/markdown-mode-20150121.1229/markdown-mode.el delete mode 100644 emacs.d/elpa/paredit-20140128.1248/paredit-autoloads.el delete mode 100644 emacs.d/elpa/paredit-20140128.1248/paredit-pkg.el delete mode 100644 emacs.d/elpa/paredit-20140128.1248/paredit.el create mode 100644 emacs.d/elpa/paredit-20150217.713/paredit-autoloads.el create mode 100644 emacs.d/elpa/paredit-20150217.713/paredit-pkg.el create mode 100644 emacs.d/elpa/paredit-20150217.713/paredit.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode-autoloads.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode-classes.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode-common.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode-methods.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode-pkg.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode-weave.el delete mode 100644 emacs.d/elpa/polymode-20140614.1301/polymode.el rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/poly-R.el (100%) rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/poly-base.el (100%) rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/poly-markdown.el (100%) rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/poly-noweb.el (100%) rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/poly-org.el (100%) create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode-autoloads.el create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode-classes.el create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode-common.el rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/polymode-configuration.el (100%) rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/polymode-export.el (100%) create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode-methods.el create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode-pkg.el rename emacs.d/elpa/{polymode-20140614.1301 => polymode-20150508.1633}/polymode-tangle.el (100%) create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode-weave.el create mode 100644 emacs.d/elpa/polymode-20150508.1633/polymode.el delete mode 100644 emacs.d/elpa/popup-20141002.320/popup-autoloads.el delete mode 100644 emacs.d/elpa/popup-20141002.320/popup-pkg.el delete mode 100644 emacs.d/elpa/popup-20141002.320/popup.el create mode 100644 emacs.d/elpa/popup-20150315.612/popup-autoloads.el create mode 100644 emacs.d/elpa/popup-20150315.612/popup-pkg.el create mode 100644 emacs.d/elpa/popup-20150315.612/popup.el delete mode 100644 emacs.d/elpa/projectile-20141017.242/projectile-autoloads.el delete mode 100644 emacs.d/elpa/projectile-20141017.242/projectile-pkg.el delete mode 100644 emacs.d/elpa/projectile-20141017.242/projectile.el create mode 100644 emacs.d/elpa/projectile-20150428.158/projectile-autoloads.el create mode 100644 emacs.d/elpa/projectile-20150428.158/projectile-pkg.el create mode 100644 emacs.d/elpa/projectile-20150428.158/projectile.el delete mode 100644 emacs.d/elpa/python-environment-20140321.1116/python-environment-autoloads.el delete mode 100644 emacs.d/elpa/python-environment-20140321.1116/python-environment-pkg.el delete mode 100644 emacs.d/elpa/python-environment-20140321.1116/python-environment.el create mode 100644 emacs.d/elpa/python-environment-20150310.153/python-environment-autoloads.el create mode 100644 emacs.d/elpa/python-environment-20150310.153/python-environment-pkg.el create mode 100644 emacs.d/elpa/python-environment-20150310.153/python-environment.el rename emacs.d/elpa/{python-environment-20140321.1116 => python-environment-20150310.153}/test-python-environment.el (100%) delete mode 100644 emacs.d/elpa/pyvenv-20140921.816/pyvenv-autoloads.el delete mode 100644 emacs.d/elpa/pyvenv-20140921.816/pyvenv-pkg.el delete mode 100644 emacs.d/elpa/pyvenv-20140921.816/pyvenv.el create mode 100644 emacs.d/elpa/pyvenv-20150503.941/pyvenv-autoloads.el create mode 100644 emacs.d/elpa/pyvenv-20150503.941/pyvenv-pkg.el create mode 100644 emacs.d/elpa/pyvenv-20150503.941/pyvenv.el delete mode 100644 emacs.d/elpa/rich-minority-20140821.2020/rich-minority-autoloads.el delete mode 100644 emacs.d/elpa/rich-minority-20140821.2020/rich-minority-pkg.el delete mode 100644 emacs.d/elpa/rich-minority-20140821.2020/rich-minority.el create mode 100644 emacs.d/elpa/rich-minority-20150305.516/rich-minority-autoloads.el create mode 100644 emacs.d/elpa/rich-minority-20150305.516/rich-minority-pkg.el create mode 100644 emacs.d/elpa/rich-minority-20150305.516/rich-minority.el delete mode 100644 emacs.d/elpa/smart-mode-line-20140904.1144/smart-mode-line-autoloads.el delete mode 100644 emacs.d/elpa/smart-mode-line-20140904.1144/smart-mode-line-dark-theme.el delete mode 100644 emacs.d/elpa/smart-mode-line-20140904.1144/smart-mode-line-light-theme.el delete mode 100644 emacs.d/elpa/smart-mode-line-20140904.1144/smart-mode-line-pkg.el delete mode 100644 emacs.d/elpa/smart-mode-line-20140904.1144/smart-mode-line-respectful-theme.el delete mode 100755 emacs.d/elpa/smart-mode-line-20140904.1144/smart-mode-line.el create mode 100644 emacs.d/elpa/smart-mode-line-20150426.910/smart-mode-line-autoloads.el create mode 100644 emacs.d/elpa/smart-mode-line-20150426.910/smart-mode-line-dark-theme.el create mode 100644 emacs.d/elpa/smart-mode-line-20150426.910/smart-mode-line-light-theme.el create mode 100644 emacs.d/elpa/smart-mode-line-20150426.910/smart-mode-line-pkg.el create mode 100644 emacs.d/elpa/smart-mode-line-20150426.910/smart-mode-line-respectful-theme.el create mode 100755 emacs.d/elpa/smart-mode-line-20150426.910/smart-mode-line.el delete mode 100644 emacs.d/elpa/yaml-mode-0.0.9/yaml-mode-autoloads.el delete mode 100644 emacs.d/elpa/yaml-mode-0.0.9/yaml-mode-pkg.el delete mode 100644 emacs.d/elpa/yaml-mode-0.0.9/yaml-mode.el create mode 100644 emacs.d/elpa/yaml-mode-20141125.37/yaml-mode-autoloads.el create mode 100644 emacs.d/elpa/yaml-mode-20141125.37/yaml-mode-pkg.el create mode 100644 emacs.d/elpa/yaml-mode-20141125.37/yaml-mode.el delete mode 100644 emacs.d/elpa/yasnippet-20141017.736/yasnippet-autoloads.el delete mode 100644 emacs.d/elpa/yasnippet-20141017.736/yasnippet-pkg.el delete mode 100644 emacs.d/elpa/yasnippet-20141017.736/yasnippet.el rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/.nosearch (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/CONTRIBUTORS.txt (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/LICENSE (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/README.md (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/antlr-mode/project (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/antlr-mode/property (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/antlr-mode/target (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/applescript-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/assert (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/beginend (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/boost_require (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/cerr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/cin (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/const_[] (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/constructor (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/cout (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/cpp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/cstd (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/d+= (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/d_operator (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/d_operator[] (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/d_operator[]_const (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/delete (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/delete[] (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/doc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/dynamic_casting (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/enum (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/fixture (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/fori (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/friend (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/fun_declaration (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/gtest (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/ignore (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/inline (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/io (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/iterator (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/map (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/module (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/namespace (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/ns (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator!= (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator+ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator+= (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator= (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator== (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator[] (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator_istream (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/operator_ostream (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/ostream (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/pack (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/private (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/protected (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/public (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/sstream (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/std (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/std_colon (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/str (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/template (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/test case (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/test_main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/test_suite (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/this (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/throw (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/try (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/tryw (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/using (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c++-mode/vector (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/assert (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/compile (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/define (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/fopen (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/malloc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/packed (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/printf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/stdio (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/stdlib (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/switch (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/union (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/c-mode/unistd (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/do (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/ifdef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/inc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/inc.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/math (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/once (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/struct (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/ternary (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/typedef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cc-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/action (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/bash (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/cookbook_file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/cron (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/cronf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/deploy (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/directory (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/directoryf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/env (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/execute (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/executef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/filef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/git (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/group (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/http_request (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/http_requestp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/ignore_failure (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/inc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/link (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/linkf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/log (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/meta (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/not_if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/notifies (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/only_if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/pac (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/pak (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/provider (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/python (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/remote_file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/retries (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/role (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/ruby (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/script (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/service (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/servicep (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/subscribes (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/supports (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/template (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/templatev (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/chef-mode/user (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/cmake_minimum_required (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/foreach (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/ifelse (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/include (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/macro (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/message (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/option (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/project (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cmake-mode/set (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/conf-unix-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/conf-unix-mode/section (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cperl-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/EV (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/emit_signal (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/intuniform (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/math (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/nan (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/omnet (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/parameter_omnetpp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/scheduleAt (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/cpp-omnet-mode/uniform (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/attrib (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/attrib.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/attrib.2 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/comment (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/comment.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/comment.2 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/comment.3 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/method (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/namespace (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/prop (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/region (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/using (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/using.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/csharp-mode/using.2 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/bg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/bg.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/bor (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/cl (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/disp.block (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/disp.inline (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/disp.none (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/ff (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/fs (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/mar.bottom (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/mar.left (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/mar.mar (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/mar.margin (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/mar.right (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/mar.top (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/pad.bottom (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/pad.left (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/pad.pad (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/pad.padding (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/pad.right (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/pad.top (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/css-mode/v (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/.read_me (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/add-hook (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/and (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/append (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/apply (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/aref (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/aset (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/assq (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/autoload (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/backward-char (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/beginning-of-line (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/bounds-of-thing-at-point (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/buffer-file-name (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/buffer-modified-p (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/buffer-substring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/buffer-substring-no-properties (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/car (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/cdr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/concat (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/cond (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/condition-case (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/cons (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/consp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/copy-directory (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/copy-file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/current-buffer (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/custom-autoload (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/defalias (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/defcustom (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/define-key (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/defsubst (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/defun (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/defvar (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/delete-char (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/delete-directory (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/delete-file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/delete-region (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/directory-files (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/dired.process_marked (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/dolist (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/end-of-line (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/eq (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/equal (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/error (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/expand-file-name (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/f (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/fboundp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file-name-directory (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file-name-extension (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file-name-nondirectory (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file-name-sans-extension (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file-relative-name (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file.process (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/file.read-lines (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/find-file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/find-replace (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/format (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/forward-char (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/forward-line (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/funcall (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/get (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/global-set-key (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/goto-char (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/grabstring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/grabthing (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/hash (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/insert (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/insert-file-contents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/interactive (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/kbd (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/kill-buffer (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/lambda (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/length (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/let (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/line-beginning-position (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/line-end-position (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/list (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/looking-at (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/make-directory (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/make-local-variable (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/mapc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/mapcar (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/match-beginning (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/match-end (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/match-string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/memq (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/message (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/minor_mode (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/not (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/nth (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/null (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/number-to-string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/or (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/point (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/point-max (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/point-min (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/princ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/print (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/progn (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/push (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/put (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/re-search-backward (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/re-search-forward (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/region-active-p (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/region-beginning (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/region-end (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/rename-file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/repeat (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/replace-regexp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/replace-regexp-in-string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/require (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/save-buffer (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/save-excursion (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/search-backward (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/search-backward-regexp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/search-forward (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/search-forward-regexp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/set (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/set-buffer (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/set-file-modes (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/set-mark (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/setq (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/skip-chars-backward (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/skip-chars-forward (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/split-string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/string-match (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/string-to-number (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/string= (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/stringp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/substring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/thing-at-point (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/traverse_dir (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/unless (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/vector (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/when (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/widget-get (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/with-current-buffer (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/word-or-region (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/word_regexp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-dired.process_marked (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-file.process (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-file.read-lines (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-find-replace (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-grabstring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-grabthing (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-traverse_dir (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/x-word-or-region (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/y-or-n-p (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/emacs-lisp-mode/yes-or-no-p (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/enh-ruby-mode (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ensime-mode (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erc-mode/blist (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erc-mode/help (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/after (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/begin (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/beh (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/case (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/compile (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/def (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/exp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/fun (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/ifdef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/ifndef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/imp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/inc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/inc.lib (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/loop (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/mod (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/rcv (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/rcv.after (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/rec (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/try (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/erlang-mode/undef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/au (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/bd (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/c (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/ch (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/cx (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/dc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/do (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/dp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/eq (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/forall (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/ib (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/ic (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/ich (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/ii (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/il (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/in (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/inc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/intr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/ir (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/l (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/module (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/pa (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/pr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/program (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/puref (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/purefunc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/pures (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/puresub (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/re (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/st (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/su (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/subroutine (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/until (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/where (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/f90-mode/wr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/fundamental-mode/.yas-setup.el (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/git-commit-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/git-commit-mode/fixes (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/git-commit-mode/references (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/const (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/const( (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/dd (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/default (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/else (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/func (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/iferr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/import (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/import( (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/lambda (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/map (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/printf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/select (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/switch (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/type (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/var (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/go-mode/var( (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/def (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/dict (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/println (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/groovy-mode/times (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/case (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/data (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/doc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/import (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/instance (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/module (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/new class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/pragma (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/haskell-mode/print (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/dd (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/dl (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/doctype (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/doctype.xhml1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/doctype.xhtml1_1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/doctype.xhtml1_strict (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/doctype.xhtml1_transitional (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/dov (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/dt (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/form (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/html (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/html.xmlns (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/link.stylesheet (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/link.stylesheet-ie (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/mailto (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/meta (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/meta.http-equiv (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/script.javascript (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/script.javascript-src (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/textarea (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/html-mode/th (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/apr_assert (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/cls (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/doc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/equals (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/file_class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/fori (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/ife (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/import (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/iterator (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/javadoc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/main_class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/method (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/param (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/printf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/println (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/return (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/test (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/testClass (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/this (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/toString (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/java-mode/try (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/al (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/com (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/def (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/each (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/el (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/ev.add (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/ev.fire (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/f (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/init (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/log (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/req.html (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js-mode/req.json (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/js2-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/acronym (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/alertblock (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/alg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/begin (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/block (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/capgls (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/caption (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/cite (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/code (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/columns (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/emph (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/figure (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/frac (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/frame (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/gls (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/glspl (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/includegraphics (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/item (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/itemize (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/label (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/listing (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/movie (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/newcommand (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/newglossaryentry (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/note (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/python (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/question (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/section (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/subf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/subfigure (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/subsec (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/textbf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/latex-mode/usepackage (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/lisp-interaction-mode/defun (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/lua-mode/fun (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/m4-mode/def (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-automake-mode/noinst_HEADERS (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-bsdmake-mode/PHONY (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-bsdmake-mode/echo (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-bsdmake-mode/gen (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-bsdmake-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-bsdmake-mode/var (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-gmake-mode/patsubst (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-gmake-mode/phony (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-gmake-mode/wildcard (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/makefile-mode/all (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/+ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/- (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/_ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/` (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h1.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h1.2 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h2.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h2.2 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h3 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h4 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h5 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/h6 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/hr.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/hr.2 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/img (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/link (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/ol (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/rimg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/rlb (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/rlink (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/markdown-mode/utf8 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/chan (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/connections (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/import (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/network (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/simple (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ned-mode/submodules (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/TOSSIM (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/command (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/dbg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/event (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/ifdef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/interface (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/module (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/nx (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/provides (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/sim (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/uint8_t (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nesc-mode/uses (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/define (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/include (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/insert_macro (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/instdir (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/macro (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/message (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/outdir (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/outfile (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nsis-mode/section (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/body (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/br (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/doctype (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/doctype_xhtml1_strict (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/doctype_xhtml1_transitional (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/form (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/href (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/html (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/img (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/input (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/link (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/meta (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/name (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/quote (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/style (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/tag (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/tag_closing (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/nxml-mode/tag_newline (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/octave-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/octave-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/octave-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/blog (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/code (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/dot (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/elisp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/embedded (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/entry (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/figure (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/img (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/latex (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/matrix (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/src (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/srcname (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/org-mode/verse (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/eval (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/fore (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/ife (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/ifee (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/sub (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/unless (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/xfore (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/xif (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/xunless (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/perl-mode/xwhile (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/prog-mode/.yas-setup.el (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/prog-mode/fixme (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/prog-mode/todo (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/prog-mode/xxx (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/.yas-setup.el (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__contains__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__enter__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__exit__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__getitem__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__len__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__new__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/__setitem__ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/all (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/arg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/arg_positional (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/ass (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertEqual (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertFalse (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertIn (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertNotEqual (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertRaises (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertRaises.with (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assertTrue (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/assetNotIn (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/celery_pdb (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/classmethod (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/cls (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/dec (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/deftest (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/django_test_class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/doc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/doctest (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/eq (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/from (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/function_docstring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/ife (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/ifmain (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/import (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/init (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/init_docstring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/interact (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/ipdbdebug (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/iter (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/lambda (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/list (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/logger_name (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/logging (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/metaclass (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/method (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/method_docstring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/not_impl (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/np (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/parse_args (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/parser (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/pass (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/print (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/prop (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/reg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/repr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/return (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/script (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/self (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/self_without_dot (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/selfassign (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/setdef (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/setup (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/size (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/static (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/str (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/super (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/test_class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/test_file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/trace (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/try (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/tryelse (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/unicode (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/utf8 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/with (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/python-mode/with_statement (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rename_add_contr.py (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/autoclass (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/autofunction (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/automodule (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/code (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/digraph (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/graph (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/graphviz (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/image (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/inheritance (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/literal_include (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/meta (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/module (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/parsed_literal (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/pause (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/term (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/url (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/verbatim (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/rst-mode/warning (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/# (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/=b (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/Comp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/GLOB (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/all (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/am (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/any (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/app (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/attribute (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/bench (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/bm (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/case (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/cla (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/cls (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/collect (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/dee (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/def (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/deli (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/det (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/dow (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/ea (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/eac (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/eai (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/eav (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/eawi (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/forin (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/formula (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/ife (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/init (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/inject (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/mm (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/r (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/rb (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/reject (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/rel (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/req (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/rw (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/select (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/str (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/test class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/tim (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/to_ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/tu (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/until (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/upt (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/w (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/when (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/y (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/ruby-mode/zip (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/act (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/act.arg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/actor (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ano (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/app (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/arr.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/arr.val-new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/asof (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ass (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ass.true (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/at.author (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/at.param (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/at.return (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/at.version (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/bang (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/case (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/case.match-all (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cast (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cl (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cl.abs (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cl.abs-arg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cl.arg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/clof (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/co (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cons (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/cons.nil (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.arg (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.arg-body (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.arg-ret (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.arg-ret-body (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.body (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.ret (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.ret-body (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/def.simple (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/doc.class (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/doc.def (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/doc.file (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/doc.file-scala (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/doc.file-scala-api (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/doc.scaladoc (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/expect (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ext (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/for.extract (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/for.if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/for.loop (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/for.multi (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/foreach (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/hmap.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/hmap.val-new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/hset.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/hset.val-new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/if.else (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/imp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/intercept (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/isof (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ls.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ls.val-new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/map (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/map.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/match (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/match.can (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/match.option (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/mix (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/ob (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pac (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pr.newline (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pr.simple (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pr.string (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pr.trace (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pri (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pri.param (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pro (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/pro.param (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/suite (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/test (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/throw (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/tr (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/tr.ext (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/tr.ext-with (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/tr.with (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/try (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/try.catch-finally (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/try.finally (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/tup.arrow (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/tup.paren (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/val (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/val.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/val.ret (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/var (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/var.new (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/var.ret (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/whi (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/scala-mode/with (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sh-mode/args (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sh-mode/bang (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sh-mode/for loop (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sh-mode/function (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sh-mode/if (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sh-mode/ife (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/snippet-mode/cont (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/snippet-mode/elisp (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/snippet-mode/field (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/snippet-mode/group (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/snippet-mode/mirror (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/snippet-mode/vars (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sql-mode/column (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sql-mode/constraint (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sql-mode/constraint.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sql-mode/create (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sql-mode/create.1 (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/sql-mode/references (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/text-mode/.yas-parents (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/assert (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/docstring (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/for (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/fun (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/guard (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/ifthen (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/ifthenelse (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/let (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/list_comprehension (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/main (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/match (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/module (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/open (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/printf (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/rec (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/try (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/type (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/type_type (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/val (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/tuareg-mode/while (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/typerex-mode (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/udev-mode/ENV (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/udev-mode/GOTO (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/udev-mode/KERNEL (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/udev-mode/add (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/udev-mode/env$ (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/udev-mode/run (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/yaml-mode/entry (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/yaml-mode/list (100%) rename emacs.d/elpa/{yasnippet-20141017.736 => yasnippet-20150415.244}/snippets/yaml-mode/section (100%) create mode 100644 emacs.d/elpa/yasnippet-20150415.244/yasnippet-autoloads.el create mode 100644 emacs.d/elpa/yasnippet-20150415.244/yasnippet-pkg.el create mode 100644 emacs.d/elpa/yasnippet-20150415.244/yasnippet.el diff --git a/emacs.d/elpa/async-20141001.151/async-autoloads.el b/emacs.d/elpa/async-20141001.151/async-autoloads.el deleted file mode 100644 index b82cf21..0000000 --- a/emacs.d/elpa/async-20141001.151/async-autoloads.el +++ /dev/null @@ -1,80 +0,0 @@ -;;; async-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "async" "async.el" (21570 22530 0 0)) -;;; Generated autoloads from async.el - -(autoload 'async-start-process "async" "\ -Start the executable PROGRAM asynchronously. See `async-start'. -PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the -process object when done. If FINISH-FUNC is nil, the future -object will return the process object when the program is -finished. - -\(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil) - -(autoload 'async-start "async" "\ -Execute START-FUNC (often a lambda) in a subordinate Emacs process. -When done, the return value is passed to FINISH-FUNC. Example: - - (async-start - ;; What to do in the child process - (lambda () - (message \"This is a test\") - (sleep-for 3) - 222) - - ;; What to do when it finishes - (lambda (result) - (message \"Async process done, result should be 222: %s\" - result))) - -If FINISH-FUNC is nil or missing, a future is returned that can -be inspected using `async-get', blocking until the value is -ready. Example: - - (let ((proc (async-start - ;; What to do in the child process - (lambda () - (message \"This is a test\") - (sleep-for 3) - 222)))) - - (message \"I'm going to do some work here\") ;; .... - - (message \"Waiting on async process, result should be 222: %s\" - (async-get proc))) - -If you don't want to use a callback, and you don't care about any -return value form the child process, pass the `ignore' symbol as -the second argument (if you don't, and never call `async-get', it -will leave *emacs* process buffers hanging around): - - (async-start - (lambda () - (delete-file \"a remote file on a slow link\" nil)) - 'ignore) - -Note: Even when FINISH-FUNC is present, a future is still -returned except that it yields no value (since the value is -passed to FINISH-FUNC). Call `async-get' on such a future always -returns nil. It can still be useful, however, as an argument to -`async-ready' or `async-wait'. - -\(fn START-FUNC &optional FINISH-FUNC)" nil t) - -;;;*** - -;;;### (autoloads nil nil ("async-bytecomp.el" "async-pkg.el" "dired-async.el" -;;;;;; "smtpmail-async.el") (21570 22530 118194 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; async-autoloads.el ends here diff --git a/emacs.d/elpa/async-20141001.151/async-bytecomp.el b/emacs.d/elpa/async-20141001.151/async-bytecomp.el deleted file mode 100644 index d229eb8..0000000 --- a/emacs.d/elpa/async-20141001.151/async-bytecomp.el +++ /dev/null @@ -1,107 +0,0 @@ -;;; async-bytecomp.el --- Async functions to compile elisp files async - -;; Copyright (C) 2014 John Wiegley -;; Copyright (C) 2014 Thierry Volpiatto - -;; Authors: John Wiegley -;; Thierry Volpiatto - -;; Keywords: dired async byte-compile -;; X-URL: https://github.com/jwiegley/dired-async - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2, or (at -;; your option) any later version. - -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: -;; -;; This package provide the `async-byte-recompile-directory' function -;; which allows, as the name says to recompile a directory outside of -;; your running emacs. -;; The benefit is your files will be compiled in a clean environment without -;; the old *.el files loaded. -;; Among other things, this fix a bug in package.el which recompile -;; the new files in the current environment with the old files loaded, creating -;; errors in most packages after upgrades. -;; -;; NB: This package is advicing the function `package--compile'. - -;;; Code: - -(require 'cl-lib) -(require 'async) - -(defvar async-byte-compile-log-file "~/.emacs.d/async-bytecomp.log") - -(defun async-byte-recompile-directory (directory &optional arg force quiet) - (cl-loop with dir = (directory-files directory t "\\.elc\\'") - unless dir return nil - for f in dir - when (file-exists-p f) do (delete-file f)) - ;; Ensure async is reloaded when async.elc is deleted. - ;; This happen when recompiling its own directory. - (load "async") - (let ((call-back - `(lambda (&optional ignore) - (if (file-exists-p async-byte-compile-log-file) - (let ((buf (get-buffer-create byte-compile-log-buffer)) - (n 0)) - (with-current-buffer buf - (goto-char (point-max)) - (let ((inhibit-read-only t)) - (insert-file-contents async-byte-compile-log-file) - (compilation-mode)) - (display-buffer buf) - (delete-file async-byte-compile-log-file) - (unless ,quiet - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^.*:Error:" nil t) - (incf n))) - (if (> n 0) - (message "Failed to compile %d files in directory `%s'" n ,directory) - (message "Directory `%s' compiled asynchronously with warnings" ,directory))))) - (unless ,quiet - (message "Directory `%s' compiled asynchronously with success" ,directory)))))) - (async-start - `(lambda () - (require 'bytecomp) - ,(async-inject-variables "\\`load-path\\'") - (let ((default-directory (file-name-as-directory ,directory)) - error-data) - (add-to-list 'load-path default-directory) - (byte-recompile-directory ,directory ,arg ,force) - (when (get-buffer byte-compile-log-buffer) - (setq error-data (with-current-buffer byte-compile-log-buffer - (buffer-substring-no-properties (point-min) (point-max)))) - (unless (string= error-data "") - (with-temp-file ,async-byte-compile-log-file - (erase-buffer) - (insert error-data)))))) - call-back) - (message "Started compiling asynchronously directory %s..." directory))) - -(defadvice package--compile (around byte-compile-async activate) - ;; FIXME this seems redundant and unneeded, the only thing it - ;; does is loading the autoload file to update load-path but - ;; async-byte-recompile-directory is already doing this. - ;; for the rest (i.e installing info) it is done anyway after - ;; compilation in package-activate (force arg). - (package-activate-1 pkg-desc) - (load "async-bytecomp") - (async-byte-recompile-directory (package-desc-dir pkg-desc) 0 t t)) - -(provide 'async-bytecomp) - -;;; async-bytecomp.el ends here diff --git a/emacs.d/elpa/async-20141001.151/async-pkg.el b/emacs.d/elpa/async-20141001.151/async-pkg.el deleted file mode 100644 index 1b39803..0000000 --- a/emacs.d/elpa/async-20141001.151/async-pkg.el +++ /dev/null @@ -1,4 +0,0 @@ -(define-package "async" "20141001.151" "Asynchronous processing in Emacs" 'nil) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/async-20141001.151/async.el b/emacs.d/elpa/async-20141001.151/async.el deleted file mode 100644 index d44f14a..0000000 --- a/emacs.d/elpa/async-20141001.151/async.el +++ /dev/null @@ -1,291 +0,0 @@ -;;; async --- Asynchronous processing in Emacs - -;; Copyright (C) 2012~2014 John Wiegley - -;; Author: John Wiegley -;; Created: 18 Jun 2012 - -;; Keywords: async -;; X-URL: https://github.com/jwiegley/emacs-async - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License as -;; published by the Free Software Foundation; either version 2, or (at -;; your option) any later version. - -;; This program is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; Adds the ability to call asynchronous functions and process with ease. See -;; the documentation for `async-start' and `async-start-process'. - -;;; Code: - -(defgroup async nil - "Simple asynchronous processing in Emacs" - :group 'emacs) - -(defvar async-debug nil) -(defvar async-send-over-pipe t) -(defvar async-in-child-emacs nil) -(defvar async-callback nil) -(defvar async-callback-for-process nil) -(defvar async-callback-value nil) -(defvar async-callback-value-set nil) -(defvar async-current-process nil) - -(defun async-inject-variables - (include-regexp &optional predicate exclude-regexp) - "Return a `setq' form that replicates part of the calling environment. -It sets the value for every variable matching INCLUDE-REGEXP and -also PREDICATE. It will not perform injection for any variable -matching EXCLUDE-REGEXP (if present). It is intended to be used -as follows: - - (async-start - `(lambda () - (require 'smtpmail) - (with-temp-buffer - (insert ,(buffer-substring-no-properties (point-min) (point-max))) - ;; Pass in the variable environment for smtpmail - ,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\") - (smtpmail-send-it))) - 'ignore)" - `(setq - ,@(let (bindings) - (mapatoms - (lambda (sym) - (if (and (boundp sym) - (or (null include-regexp) - (string-match include-regexp (symbol-name sym))) - (not (string-match - (or exclude-regexp "-syntax-table\\'") - (symbol-name sym)))) - (let ((value (symbol-value sym))) - (when (or (null predicate) - (funcall predicate sym)) - (setq bindings (cons `(quote ,value) bindings) - bindings (cons sym bindings))))))) - bindings))) - -(defalias 'async-inject-environment 'async-inject-variables) - -(defun async-handle-result (func result buf) - (if (null func) - (progn - (set (make-local-variable 'async-callback-value) result) - (set (make-local-variable 'async-callback-value-set) t)) - (unwind-protect - (if (and (listp result) - (eq 'async-signal (nth 0 result))) - (signal (car (nth 1 result)) - (cdr (nth 1 result))) - (funcall func result)) - (unless async-debug - (kill-buffer buf))))) - -(defun async-when-done (proc &optional change) - "Process sentinal used to retrieve the value from the child process." - (when (eq 'exit (process-status proc)) - (with-current-buffer (process-buffer proc) - (let ((async-current-process proc)) - (if (= 0 (process-exit-status proc)) - (if async-callback-for-process - (if async-callback - (prog1 - (funcall async-callback proc) - (unless async-debug - (kill-buffer (current-buffer)))) - (set (make-local-variable 'async-callback-value) proc) - (set (make-local-variable 'async-callback-value-set) t)) - (goto-char (point-max)) - (backward-sexp) - (async-handle-result async-callback (read (current-buffer)) - (current-buffer))) - (set (make-local-variable 'async-callback-value) - (list 'error - (format "Async process '%s' failed with exit code %d" - (process-name proc) (process-exit-status proc)))) - (set (make-local-variable 'async-callback-value-set) t)))))) - -(defun async--receive-sexp (&optional stream) - (let ((sexp (decode-coding-string (base64-decode-string - (read stream)) 'utf-8-unix))) - (if async-debug - (message "Received sexp {{{%s}}}" (pp-to-string sexp))) - (setq sexp (read sexp)) - (if async-debug - (message "Read sexp {{{%s}}}" (pp-to-string sexp))) - (eval sexp))) - -(defun async--insert-sexp (sexp) - (prin1 sexp (current-buffer)) - ;; Just in case the string we're sending might contain EOF - (encode-coding-region (point-min) (point-max) 'utf-8-unix) - (base64-encode-region (point-min) (point-max) t) - (goto-char (point-min)) (insert ?\") - (goto-char (point-max)) (insert ?\" ?\n)) - -(defun async--transmit-sexp (process sexp) - (with-temp-buffer - (if async-debug - (message "Transmitting sexp {{{%s}}}" (pp-to-string sexp))) - (async--insert-sexp sexp) - (process-send-region process (point-min) (point-max)))) - -(defun async-batch-invoke () - "Called from the child Emacs process' command-line." - (setq async-in-child-emacs t - debug-on-error async-debug) - (if debug-on-error - (prin1 (funcall - (async--receive-sexp (unless async-send-over-pipe - command-line-args-left)))) - (condition-case err - (prin1 (funcall - (async--receive-sexp (unless async-send-over-pipe - command-line-args-left)))) - (error - (prin1 (list 'async-signal err)))))) - -(defun async-ready (future) - "Query a FUTURE to see if the ready is ready -- i.e., if no blocking -would result from a call to `async-get' on that FUTURE." - (and (memq (process-status future) '(exit signal)) - (with-current-buffer (process-buffer future) - async-callback-value-set))) - -(defun async-wait (future) - "Wait for FUTURE to become ready." - (while (not (async-ready future)) - (sit-for 0.05))) - -(defun async-get (future) - "Get the value from an asynchronously function when it is ready. -FUTURE is returned by `async-start' or `async-start-process' when -its FINISH-FUNC is nil." - (async-wait future) - (with-current-buffer (process-buffer future) - (async-handle-result #'identity async-callback-value (current-buffer)))) - -(defun async-message-p (value) - "Return true of VALUE is an async.el message packet." - (and (listp value) - (plist-get value :async-message))) - -(defun async-send (&rest args) - "Send the given messages to the asychronous Emacs PROCESS." - (let ((args (append args '(:async-message t)))) - (if async-in-child-emacs - (if async-callback - (funcall async-callback args)) - (async--transmit-sexp (car args) (list 'quote (cdr args)))))) - -(defun async-receive (&rest args) - "Send the given messages to the asychronous Emacs PROCESS." - (async--receive-sexp)) - -;;;###autoload -(defun async-start-process (name program finish-func &rest program-args) - "Start the executable PROGRAM asynchronously. See `async-start'. -PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the -process object when done. If FINISH-FUNC is nil, the future -object will return the process object when the program is -finished." - (let* ((buf (generate-new-buffer (concat "*" name "*"))) - (proc (let ((process-connection-type nil)) - (apply #'start-process name buf program program-args)))) - (with-current-buffer buf - (set (make-local-variable 'async-callback) finish-func) - (set-process-sentinel proc #'async-when-done) - (unless (string= name "emacs") - (set (make-local-variable 'async-callback-for-process) t)) - proc))) - -;;;###autoload -(defmacro async-start (start-func &optional finish-func) - "Execute START-FUNC (often a lambda) in a subordinate Emacs process. -When done, the return value is passed to FINISH-FUNC. Example: - - (async-start - ;; What to do in the child process - (lambda () - (message \"This is a test\") - (sleep-for 3) - 222) - - ;; What to do when it finishes - (lambda (result) - (message \"Async process done, result should be 222: %s\" - result))) - -If FINISH-FUNC is nil or missing, a future is returned that can -be inspected using `async-get', blocking until the value is -ready. Example: - - (let ((proc (async-start - ;; What to do in the child process - (lambda () - (message \"This is a test\") - (sleep-for 3) - 222)))) - - (message \"I'm going to do some work here\") ;; .... - - (message \"Waiting on async process, result should be 222: %s\" - (async-get proc))) - -If you don't want to use a callback, and you don't care about any -return value form the child process, pass the `ignore' symbol as -the second argument (if you don't, and never call `async-get', it -will leave *emacs* process buffers hanging around): - - (async-start - (lambda () - (delete-file \"a remote file on a slow link\" nil)) - 'ignore) - -Note: Even when FINISH-FUNC is present, a future is still -returned except that it yields no value (since the value is -passed to FINISH-FUNC). Call `async-get' on such a future always -returns nil. It can still be useful, however, as an argument to -`async-ready' or `async-wait'." - (require 'find-func) - (let ((procvar (make-symbol "proc"))) - `(let* ((sexp ,start-func) - (,procvar - (async-start-process - "emacs" (file-truename - (expand-file-name invocation-name - invocation-directory)) - ,finish-func - "-Q" "-l" - ;; Using `locate-library' ensure we use the right file - ;; when the .elc have been deleted. - ,(locate-library "async") - "-batch" "-f" "async-batch-invoke" - (if async-send-over-pipe - "" - (with-temp-buffer - (async--insert-sexp (list 'quote sexp)) - (buffer-string)))))) - (if async-send-over-pipe - (async--transmit-sexp ,procvar (list 'quote sexp))) - ,procvar))) - -(defmacro async-sandbox(func) - "Evaluate FUNC in a separate Emacs process, synchronously." - `(async-get (async-start ,func))) - -(provide 'async) - -;;; async.el ends here diff --git a/emacs.d/elpa/async-20150412.2207/async-autoloads.el b/emacs.d/elpa/async-20150412.2207/async-autoloads.el new file mode 100644 index 0000000..443706e --- /dev/null +++ b/emacs.d/elpa/async-20150412.2207/async-autoloads.el @@ -0,0 +1,81 @@ +;;; async-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "async" "async.el" (21837 24217 0 0)) +;;; Generated autoloads from async.el + +(autoload 'async-start-process "async" "\ +Start the executable PROGRAM asynchronously. See `async-start'. +PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the +process object when done. If FINISH-FUNC is nil, the future +object will return the process object when the program is +finished. Set DEFAULT-DIRECTORY to change PROGRAM's current +working directory. + +\(fn NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS)" nil nil) + +(autoload 'async-start "async" "\ +Execute START-FUNC (often a lambda) in a subordinate Emacs process. +When done, the return value is passed to FINISH-FUNC. Example: + + (async-start + ;; What to do in the child process + (lambda () + (message \"This is a test\") + (sleep-for 3) + 222) + + ;; What to do when it finishes + (lambda (result) + (message \"Async process done, result should be 222: %s\" + result))) + +If FINISH-FUNC is nil or missing, a future is returned that can +be inspected using `async-get', blocking until the value is +ready. Example: + + (let ((proc (async-start + ;; What to do in the child process + (lambda () + (message \"This is a test\") + (sleep-for 3) + 222)))) + + (message \"I'm going to do some work here\") ;; .... + + (message \"Waiting on async process, result should be 222: %s\" + (async-get proc))) + +If you don't want to use a callback, and you don't care about any +return value form the child process, pass the `ignore' symbol as +the second argument (if you don't, and never call `async-get', it +will leave *emacs* process buffers hanging around): + + (async-start + (lambda () + (delete-file \"a remote file on a slow link\" nil)) + 'ignore) + +Note: Even when FINISH-FUNC is present, a future is still +returned except that it yields no value (since the value is +passed to FINISH-FUNC). Call `async-get' on such a future always +returns nil. It can still be useful, however, as an argument to +`async-ready' or `async-wait'. + +\(fn START-FUNC &optional FINISH-FUNC)" nil t) + +;;;*** + +;;;### (autoloads nil nil ("async-bytecomp.el" "async-pkg.el" "dired-async.el" +;;;;;; "smtpmail-async.el") (21837 24217 654301 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; async-autoloads.el ends here diff --git a/emacs.d/elpa/async-20150412.2207/async-bytecomp.el b/emacs.d/elpa/async-20150412.2207/async-bytecomp.el new file mode 100644 index 0000000..047e605 --- /dev/null +++ b/emacs.d/elpa/async-20150412.2207/async-bytecomp.el @@ -0,0 +1,149 @@ +;;; async-bytecomp.el --- Async functions to compile elisp files async + +;; Copyright (C) 2014 John Wiegley +;; Copyright (C) 2014 Thierry Volpiatto + +;; Authors: John Wiegley +;; Thierry Volpiatto + +;; Keywords: dired async byte-compile +;; X-URL: https://github.com/jwiegley/dired-async + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: +;; +;; This package provide the `async-byte-recompile-directory' function +;; which allows, as the name says to recompile a directory outside of +;; your running emacs. +;; The benefit is your files will be compiled in a clean environment without +;; the old *.el files loaded. +;; Among other things, this fix a bug in package.el which recompile +;; the new files in the current environment with the old files loaded, creating +;; errors in most packages after upgrades. +;; +;; NB: This package is advicing the function `package--compile'. + +;;; Code: + +(require 'cl-lib) +(require 'async) + +(defcustom async-bytecomp-allowed-packages '(async helm) + "Packages in this list will be compiled asynchronously by `package--compile'. +All the dependencies of these packages will be compiled async too, +so no need to add dependencies to this list. +The value of this variable can also be a list with a single element, +the symbol `all', in this case packages are always compiled asynchronously." + :group 'async + :type '(repeat (choice symbol))) + +(defvar async-byte-compile-log-file "~/.emacs.d/async-bytecomp.log") + +(defun async-byte-recompile-directory (directory &optional quiet) + "Compile all *.el files in DIRECTORY asynchronously. +All *.elc files are systematically deleted before proceeding." + (cl-loop with dir = (directory-files directory t "\\.elc\\'") + unless dir return nil + for f in dir + when (file-exists-p f) do (delete-file f)) + ;; Ensure async is reloaded when async.elc is deleted. + ;; This happen when recompiling its own directory. + (load "async") + (let ((call-back + `(lambda (&optional ignore) + (if (file-exists-p async-byte-compile-log-file) + (let ((buf (get-buffer-create byte-compile-log-buffer)) + (n 0)) + (with-current-buffer buf + (goto-char (point-max)) + (let ((inhibit-read-only t)) + (insert-file-contents async-byte-compile-log-file) + (compilation-mode)) + (display-buffer buf) + (delete-file async-byte-compile-log-file) + (unless ,quiet + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "^.*:Error:" nil t) + (cl-incf n))) + (if (> n 0) + (message "Failed to compile %d files in directory `%s'" n ,directory) + (message "Directory `%s' compiled asynchronously with warnings" ,directory))))) + (unless ,quiet + (message "Directory `%s' compiled asynchronously with success" ,directory)))))) + (async-start + `(lambda () + (require 'bytecomp) + ,(async-inject-variables "\\`\\(load-path\\)\\|byte\\'") + (let ((default-directory (file-name-as-directory ,directory)) + error-data) + (add-to-list 'load-path default-directory) + (byte-recompile-directory ,directory 0 t) + (when (get-buffer byte-compile-log-buffer) + (setq error-data (with-current-buffer byte-compile-log-buffer + (buffer-substring-no-properties (point-min) (point-max)))) + (unless (string= error-data "") + (with-temp-file ,async-byte-compile-log-file + (erase-buffer) + (insert error-data)))))) + call-back) + (message "Started compiling asynchronously directory %s" directory))) + +(defvar package-archive-contents) +(declare-function package-desc-reqs "package.el" (cl-x)) + +(defun async-bytecomp--get-package-deps (pkg &optional only) + (let* ((pkg-desc (cadr (assq pkg package-archive-contents))) + (direct-deps (cl-loop for p in (package-desc-reqs pkg-desc) + for name = (car p) + when (assq name package-archive-contents) + collect name)) + (indirect-deps (unless (eq only 'direct) + (delete-dups + (cl-loop for p in direct-deps append + (async-bytecomp--get-package-deps p)))))) + (cl-case only + (direct direct-deps) + (separate (list direct-deps indirect-deps)) + (indirect indirect-deps) + (t (delete-dups (append direct-deps indirect-deps)))))) + +(defun async-bytecomp-get-allowed-pkgs () + (when (and async-bytecomp-allowed-packages + (listp async-bytecomp-allowed-packages)) + (cl-loop for p in async-bytecomp-allowed-packages + append (async-bytecomp--get-package-deps p) into reqs + finally return + (delete-dups + (append async-bytecomp-allowed-packages reqs))))) + +(defadvice package--compile (around byte-compile-async activate) + (let ((cur-package (package-desc-name pkg-desc))) + (if (or (equal async-bytecomp-allowed-packages '(all)) + (memq cur-package (async-bytecomp-get-allowed-pkgs))) + (progn + (when (eq cur-package 'async) + (fmakunbound 'async-byte-recompile-directory)) + (package-activate-1 pkg-desc) + (load "async-bytecomp") ; emacs-24.3 don't reload new files. + (async-byte-recompile-directory (package-desc-dir pkg-desc) t)) + ad-do-it))) + + +(provide 'async-bytecomp) + +;;; async-bytecomp.el ends here diff --git a/emacs.d/elpa/async-20150412.2207/async-pkg.el b/emacs.d/elpa/async-20150412.2207/async-pkg.el new file mode 100644 index 0000000..7d1eb8b --- /dev/null +++ b/emacs.d/elpa/async-20150412.2207/async-pkg.el @@ -0,0 +1,4 @@ +(define-package "async" "20150412.2207" "Asynchronous processing in Emacs" 'nil) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/async-20150412.2207/async.el b/emacs.d/elpa/async-20150412.2207/async.el new file mode 100644 index 0000000..be9c04e --- /dev/null +++ b/emacs.d/elpa/async-20150412.2207/async.el @@ -0,0 +1,292 @@ +;;; async --- Asynchronous processing in Emacs + +;; Copyright (C) 2012~2014 John Wiegley + +;; Author: John Wiegley +;; Created: 18 Jun 2012 + +;; Keywords: async +;; X-URL: https://github.com/jwiegley/emacs-async + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Adds the ability to call asynchronous functions and process with ease. See +;; the documentation for `async-start' and `async-start-process'. + +;;; Code: + +(defgroup async nil + "Simple asynchronous processing in Emacs" + :group 'emacs) + +(defvar async-debug nil) +(defvar async-send-over-pipe t) +(defvar async-in-child-emacs nil) +(defvar async-callback nil) +(defvar async-callback-for-process nil) +(defvar async-callback-value nil) +(defvar async-callback-value-set nil) +(defvar async-current-process nil) + +(defun async-inject-variables + (include-regexp &optional predicate exclude-regexp) + "Return a `setq' form that replicates part of the calling environment. +It sets the value for every variable matching INCLUDE-REGEXP and +also PREDICATE. It will not perform injection for any variable +matching EXCLUDE-REGEXP (if present). It is intended to be used +as follows: + + (async-start + `(lambda () + (require 'smtpmail) + (with-temp-buffer + (insert ,(buffer-substring-no-properties (point-min) (point-max))) + ;; Pass in the variable environment for smtpmail + ,(async-inject-variables \"\\`\\(smtpmail\\|\\(user-\\)?mail\\)-\") + (smtpmail-send-it))) + 'ignore)" + `(setq + ,@(let (bindings) + (mapatoms + (lambda (sym) + (if (and (boundp sym) + (or (null include-regexp) + (string-match include-regexp (symbol-name sym))) + (not (string-match + (or exclude-regexp "-syntax-table\\'") + (symbol-name sym)))) + (let ((value (symbol-value sym))) + (when (or (null predicate) + (funcall predicate sym)) + (setq bindings (cons `(quote ,value) bindings) + bindings (cons sym bindings))))))) + bindings))) + +(defalias 'async-inject-environment 'async-inject-variables) + +(defun async-handle-result (func result buf) + (if (null func) + (progn + (set (make-local-variable 'async-callback-value) result) + (set (make-local-variable 'async-callback-value-set) t)) + (unwind-protect + (if (and (listp result) + (eq 'async-signal (nth 0 result))) + (signal (car (nth 1 result)) + (cdr (nth 1 result))) + (funcall func result)) + (unless async-debug + (kill-buffer buf))))) + +(defun async-when-done (proc &optional change) + "Process sentinal used to retrieve the value from the child process." + (when (eq 'exit (process-status proc)) + (with-current-buffer (process-buffer proc) + (let ((async-current-process proc)) + (if (= 0 (process-exit-status proc)) + (if async-callback-for-process + (if async-callback + (prog1 + (funcall async-callback proc) + (unless async-debug + (kill-buffer (current-buffer)))) + (set (make-local-variable 'async-callback-value) proc) + (set (make-local-variable 'async-callback-value-set) t)) + (goto-char (point-max)) + (backward-sexp) + (async-handle-result async-callback (read (current-buffer)) + (current-buffer))) + (set (make-local-variable 'async-callback-value) + (list 'error + (format "Async process '%s' failed with exit code %d" + (process-name proc) (process-exit-status proc)))) + (set (make-local-variable 'async-callback-value-set) t)))))) + +(defun async--receive-sexp (&optional stream) + (let ((sexp (decode-coding-string (base64-decode-string + (read stream)) 'utf-8-unix))) + (if async-debug + (message "Received sexp {{{%s}}}" (pp-to-string sexp))) + (setq sexp (read sexp)) + (if async-debug + (message "Read sexp {{{%s}}}" (pp-to-string sexp))) + (eval sexp))) + +(defun async--insert-sexp (sexp) + (prin1 sexp (current-buffer)) + ;; Just in case the string we're sending might contain EOF + (encode-coding-region (point-min) (point-max) 'utf-8-unix) + (base64-encode-region (point-min) (point-max) t) + (goto-char (point-min)) (insert ?\") + (goto-char (point-max)) (insert ?\" ?\n)) + +(defun async--transmit-sexp (process sexp) + (with-temp-buffer + (if async-debug + (message "Transmitting sexp {{{%s}}}" (pp-to-string sexp))) + (async--insert-sexp sexp) + (process-send-region process (point-min) (point-max)))) + +(defun async-batch-invoke () + "Called from the child Emacs process' command-line." + (setq async-in-child-emacs t + debug-on-error async-debug) + (if debug-on-error + (prin1 (funcall + (async--receive-sexp (unless async-send-over-pipe + command-line-args-left)))) + (condition-case err + (prin1 (funcall + (async--receive-sexp (unless async-send-over-pipe + command-line-args-left)))) + (error + (prin1 (list 'async-signal err)))))) + +(defun async-ready (future) + "Query a FUTURE to see if the ready is ready -- i.e., if no blocking +would result from a call to `async-get' on that FUTURE." + (and (memq (process-status future) '(exit signal)) + (with-current-buffer (process-buffer future) + async-callback-value-set))) + +(defun async-wait (future) + "Wait for FUTURE to become ready." + (while (not (async-ready future)) + (sit-for 0.05))) + +(defun async-get (future) + "Get the value from an asynchronously function when it is ready. +FUTURE is returned by `async-start' or `async-start-process' when +its FINISH-FUNC is nil." + (async-wait future) + (with-current-buffer (process-buffer future) + (async-handle-result #'identity async-callback-value (current-buffer)))) + +(defun async-message-p (value) + "Return true of VALUE is an async.el message packet." + (and (listp value) + (plist-get value :async-message))) + +(defun async-send (&rest args) + "Send the given messages to the asychronous Emacs PROCESS." + (let ((args (append args '(:async-message t)))) + (if async-in-child-emacs + (if async-callback + (funcall async-callback args)) + (async--transmit-sexp (car args) (list 'quote (cdr args)))))) + +(defun async-receive (&rest args) + "Send the given messages to the asychronous Emacs PROCESS." + (async--receive-sexp)) + +;;;###autoload +(defun async-start-process (name program finish-func &rest program-args) + "Start the executable PROGRAM asynchronously. See `async-start'. +PROGRAM is passed PROGRAM-ARGS, calling FINISH-FUNC with the +process object when done. If FINISH-FUNC is nil, the future +object will return the process object when the program is +finished. Set DEFAULT-DIRECTORY to change PROGRAM's current +working directory." + (let* ((buf (generate-new-buffer (concat "*" name "*"))) + (proc (let ((process-connection-type nil)) + (apply #'start-process name buf program program-args)))) + (with-current-buffer buf + (set (make-local-variable 'async-callback) finish-func) + (set-process-sentinel proc #'async-when-done) + (unless (string= name "emacs") + (set (make-local-variable 'async-callback-for-process) t)) + proc))) + +;;;###autoload +(defmacro async-start (start-func &optional finish-func) + "Execute START-FUNC (often a lambda) in a subordinate Emacs process. +When done, the return value is passed to FINISH-FUNC. Example: + + (async-start + ;; What to do in the child process + (lambda () + (message \"This is a test\") + (sleep-for 3) + 222) + + ;; What to do when it finishes + (lambda (result) + (message \"Async process done, result should be 222: %s\" + result))) + +If FINISH-FUNC is nil or missing, a future is returned that can +be inspected using `async-get', blocking until the value is +ready. Example: + + (let ((proc (async-start + ;; What to do in the child process + (lambda () + (message \"This is a test\") + (sleep-for 3) + 222)))) + + (message \"I'm going to do some work here\") ;; .... + + (message \"Waiting on async process, result should be 222: %s\" + (async-get proc))) + +If you don't want to use a callback, and you don't care about any +return value form the child process, pass the `ignore' symbol as +the second argument (if you don't, and never call `async-get', it +will leave *emacs* process buffers hanging around): + + (async-start + (lambda () + (delete-file \"a remote file on a slow link\" nil)) + 'ignore) + +Note: Even when FINISH-FUNC is present, a future is still +returned except that it yields no value (since the value is +passed to FINISH-FUNC). Call `async-get' on such a future always +returns nil. It can still be useful, however, as an argument to +`async-ready' or `async-wait'." + (require 'find-func) + (let ((procvar (make-symbol "proc"))) + `(let* ((sexp ,start-func) + (,procvar + (async-start-process + "emacs" (file-truename + (expand-file-name invocation-name + invocation-directory)) + ,finish-func + "-Q" "-l" + ;; Using `locate-library' ensure we use the right file + ;; when the .elc have been deleted. + ,(locate-library "async") + "-batch" "-f" "async-batch-invoke" + (if async-send-over-pipe + "" + (with-temp-buffer + (async--insert-sexp (list 'quote sexp)) + (buffer-string)))))) + (if async-send-over-pipe + (async--transmit-sexp ,procvar (list 'quote sexp))) + ,procvar))) + +(defmacro async-sandbox(func) + "Evaluate FUNC in a separate Emacs process, synchronously." + `(async-get (async-start ,func))) + +(provide 'async) + +;;; async.el ends here diff --git a/emacs.d/elpa/async-20141001.151/dired-async.el b/emacs.d/elpa/async-20150412.2207/dired-async.el similarity index 100% rename from emacs.d/elpa/async-20141001.151/dired-async.el rename to emacs.d/elpa/async-20150412.2207/dired-async.el diff --git a/emacs.d/elpa/async-20141001.151/smtpmail-async.el b/emacs.d/elpa/async-20150412.2207/smtpmail-async.el similarity index 100% rename from emacs.d/elpa/async-20141001.151/smtpmail-async.el rename to emacs.d/elpa/async-20150412.2207/smtpmail-async.el diff --git a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-autoloads.el b/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-autoloads.el deleted file mode 100644 index 6af8f63..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-autoloads.el +++ /dev/null @@ -1,64 +0,0 @@ -;;; auto-complete-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "auto-complete" "auto-complete.el" (21570 24553 -;;;;;; 0 0)) -;;; Generated autoloads from auto-complete.el - -(autoload 'auto-complete "auto-complete" "\ -Start auto-completion at current point. - -\(fn &optional SOURCES)" t nil) - -(autoload 'auto-complete-mode "auto-complete" "\ -AutoComplete mode - -\(fn &optional ARG)" t nil) - -(defvar global-auto-complete-mode nil "\ -Non-nil if Global-Auto-Complete mode is enabled. -See the command `global-auto-complete-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `global-auto-complete-mode'.") - -(custom-autoload 'global-auto-complete-mode "auto-complete" nil) - -(autoload 'global-auto-complete-mode "auto-complete" "\ -Toggle Auto-Complete mode in all buffers. -With prefix ARG, enable Global-Auto-Complete mode if ARG is positive; -otherwise, disable it. If called from Lisp, enable the mode if -ARG is omitted or nil. - -Auto-Complete mode is enabled in all buffers where -`auto-complete-mode-maybe' would do it. -See `auto-complete-mode' for more information on Auto-Complete mode. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "auto-complete-config" "auto-complete-config.el" -;;;;;; (21570 24553 0 0)) -;;; Generated autoloads from auto-complete-config.el - -(autoload 'ac-config-default "auto-complete-config" "\ - - -\(fn)" nil nil) - -;;;*** - -;;;### (autoloads nil nil ("auto-complete-pkg.el") (21570 24553 81515 -;;;;;; 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; auto-complete-autoloads.el ends here diff --git a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-config.el b/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-config.el deleted file mode 100644 index 40e63bc..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-config.el +++ /dev/null @@ -1,521 +0,0 @@ -;;; auto-complete-config.el --- auto-complete additional configuations - -;; Copyright (C) 2009, 2010 Tomohiro Matsuyama - -;; Author: Tomohiro Matsuyama -;; Keywords: convenience -;; Version: 1.4 - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -(require 'auto-complete) - - - -;;;; Additional sources - -;; imenu - -(defvar ac-imenu-index nil) - -(ac-clear-variable-every-10-minutes 'ac-imenu-index) - -(defun ac-imenu-candidates () - (loop with i = 0 - with stack = (progn - (unless (local-variable-p 'ac-imenu-index) - (make-local-variable 'ac-imenu-index)) - (or ac-imenu-index - (setq ac-imenu-index - (ignore-errors - (with-no-warnings - (imenu--make-index-alist)))))) - with result - while (and stack (or (not (integerp ac-limit)) - (< i ac-limit))) - for node = (pop stack) - if (consp node) - do - (let ((car (car node)) - (cdr (cdr node))) - (if (consp cdr) - (mapc (lambda (child) - (push child stack)) - cdr) - (when (and (stringp car) - (string-match (concat "^" (regexp-quote ac-prefix)) car)) - ;; Remove extra characters - (if (string-match "^.*\\(()\\|=\\|<>\\)$" car) - (setq car (substring car 0 (match-beginning 1)))) - (push car result) - (incf i)))) - finally return (nreverse result))) - -(ac-define-source imenu - '((depends imenu) - (candidates . ac-imenu-candidates) - (symbol . "s"))) - -;; gtags - -(defface ac-gtags-candidate-face - '((t (:inherit ac-candidate-face :foreground "navy"))) - "Face for gtags candidate" - :group 'auto-complete) - -(defface ac-gtags-selection-face - '((t (:inherit ac-selection-face :background "navy"))) - "Face for the gtags selected candidate." - :group 'auto-complete) - -(defun ac-gtags-candidate () - (ignore-errors - (split-string (shell-command-to-string (format "global -ciq %s" ac-prefix)) "\n"))) - -(ac-define-source gtags - '((candidates . ac-gtags-candidate) - (candidate-face . ac-gtags-candidate-face) - (selection-face . ac-gtags-selection-face) - (requires . 3) - (symbol . "s"))) - -;; yasnippet - -(defface ac-yasnippet-candidate-face - '((t (:inherit ac-candidate-face - :background "sandybrown" :foreground "black"))) - "Face for yasnippet candidate." - :group 'auto-complete) - -(defface ac-yasnippet-selection-face - '((t (:inherit ac-selection-face :background "coral3"))) - "Face for the yasnippet selected candidate." - :group 'auto-complete) - -(defun ac-yasnippet-table-hash (table) - (cond - ((fboundp 'yas/snippet-table-hash) - (yas/snippet-table-hash table)) - ((fboundp 'yas/table-hash) - (yas/table-hash table)))) - -(defun ac-yasnippet-table-parent (table) - (cond - ((fboundp 'yas/snippet-table-parent) - (yas/snippet-table-parent table)) - ((fboundp 'yas/table-parent) - (yas/table-parent table)))) - -(defun ac-yasnippet-candidate-1 (table) - (with-no-warnings - (let ((hashtab (ac-yasnippet-table-hash table)) - (parent (ac-yasnippet-table-parent table)) - candidates) - (maphash (lambda (key value) - (push key candidates)) - hashtab) - (setq candidates (all-completions ac-prefix (nreverse candidates))) - (if parent - (setq candidates - (append candidates (ac-yasnippet-candidate-1 parent)))) - candidates))) - -(defun ac-yasnippet-candidates () - (with-no-warnings - (cond (;; 0.8 onwards - (fboundp 'yas-active-keys) - (all-completions ac-prefix (yas-active-keys))) - (;; >0.6.0 - (fboundp 'yas/get-snippet-tables) - (apply 'append (mapcar 'ac-yasnippet-candidate-1 - (condition-case nil - (yas/get-snippet-tables major-mode) - (wrong-number-of-arguments - (yas/get-snippet-tables))))) - ) - (t - (let ((table - (if (fboundp 'yas/snippet-table) - ;; <0.6.0 - (yas/snippet-table major-mode) - ;; 0.6.0 - (yas/current-snippet-table)))) - (if table - (ac-yasnippet-candidate-1 table))))))) - -(ac-define-source yasnippet - '((depends yasnippet) - (candidates . ac-yasnippet-candidates) - (action . yas/expand) - (candidate-face . ac-yasnippet-candidate-face) - (selection-face . ac-yasnippet-selection-face) - (symbol . "a"))) - -;; semantic - -(defun ac-semantic-candidates (prefix) - (with-no-warnings - (delete "" ; semantic sometimes returns an empty string - (mapcar (lambda (elem) - (cons (semantic-tag-name elem) - (semantic-tag-clone elem))) - (ignore-errors - (or (semantic-analyze-possible-completions - (semantic-analyze-current-context)) - (senator-find-tag-for-completion prefix))))))) - -(defun ac-semantic-doc (symbol) - (with-no-warnings - (let* ((proto (semantic-format-tag-summarize-with-file symbol nil t)) - (doc (semantic-documentation-for-tag symbol)) - (res proto)) - (when doc - (setq res (concat res "\n\n" doc))) - res))) - -(ac-define-source semantic - '((available . (or (require 'semantic-ia nil t) - (require 'semantic/ia nil t))) - (candidates . (ac-semantic-candidates ac-prefix)) - (document . ac-semantic-doc) - (prefix . cc-member) - (requires . 0) - (symbol . "m"))) - -(ac-define-source semantic-raw - '((available . (or (require 'semantic-ia nil t) - (require 'semantic/ia nil t))) - (candidates . (ac-semantic-candidates ac-prefix)) - (document . ac-semantic-doc) - (symbol . "s"))) - -;; eclim - -(defun ac-eclim-candidates () - (with-no-warnings - (loop for c in (eclim/java-complete) - collect (nth 1 c)))) - -(ac-define-source eclim - '((candidates . ac-eclim-candidates) - (prefix . c-dot) - (requires . 0) - (symbol . "f"))) - -;; css - -;; Copied from company-css.el -(defconst ac-css-property-alist - ;; see http://www.w3.org/TR/CSS21/propidx.html - '(("azimuth" angle "left-side" "far-left" "left" "center-left" "center" - "center-right" "right" "far-right" "right-side" "behind" "leftwards" - "rightwards") - ("background" background-color background-image background-repeat - background-attachment background-position) - ("background-attachment" "scroll" "fixed") - ("background-color" color "transparent") - ("background-image" uri "none") - ("background-position" percentage length "left" "center" "right" percentage - length "top" "center" "bottom" "left" "center" "right" "top" "center" - "bottom") - ("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat") - ("border" border-width border-style border-color) - ("border-bottom" border) - ("border-bottom-color" border-color) - ("border-bottom-style" border-style) - ("border-bottom-width" border-width) - ("border-collapse" "collapse" "separate") - ("border-color" color "transparent") - ("border-left" border) - ("border-left-color" border-color) - ("border-left-style" border-style) - ("border-left-width" border-width) - ("border-right" border) - ("border-right-color" border-color) - ("border-right-style" border-style) - ("border-right-width" border-width) - ("border-spacing" length length) - ("border-style" border-style) - ("border-top" border) - ("border-top-color" border-color) - ("border-top-style" border-style) - ("border-top-width" border-width) - ("border-width" border-width) - ("bottom" length percentage "auto") - ("caption-side" "top" "bottom") - ("clear" "none" "left" "right" "both") - ("clip" shape "auto") - ("color" color) - ("content" "normal" "none" string uri counter "attr()" "open-quote" - "close-quote" "no-open-quote" "no-close-quote") - ("counter-increment" identifier integer "none") - ("counter-reset" identifier integer "none") - ("cue" cue-before cue-after) - ("cue-after" uri "none") - ("cue-before" uri "none") - ("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize" - "ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize" - "w-resize" "text" "wait" "help" "progress") - ("direction" "ltr" "rtl") - ("display" "inline" "block" "list-item" "run-in" "inline-block" "table" - "inline-table" "table-row-group" "table-header-group" "table-footer-group" - "table-row" "table-column-group" "table-column" "table-cell" - "table-caption" "none") - ("elevation" angle "below" "level" "above" "higher" "lower") - ("empty-cells" "show" "hide") - ("float" "left" "right" "none") - ("font" font-style font-variant font-weight font-size "/" line-height - font-family "caption" "icon" "menu" "message-box" "small-caption" - "status-bar") - ("font-family" family-name generic-family) - ("font-size" absolute-size relative-size length percentage) - ("font-style" "normal" "italic" "oblique") - ("font-variant" "normal" "small-caps") - ("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400" - "500" "600" "700" "800" "900") - ("height" length percentage "auto") - ("left" length percentage "auto") - ("letter-spacing" "normal" length) - ("line-height" "normal" number length percentage) - ("list-style" list-style-type list-style-position list-style-image) - ("list-style-image" uri "none") - ("list-style-position" "inside" "outside") - ("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero" - "lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin" - "armenian" "georgian" "lower-alpha" "upper-alpha" "none") - ("margin" margin-width) - ("margin-bottom" margin-width) - ("margin-left" margin-width) - ("margin-right" margin-width) - ("margin-top" margin-width) - ("max-height" length percentage "none") - ("max-width" length percentage "none") - ("min-height" length percentage) - ("min-width" length percentage) - ("orphans" integer) - ("outline" outline-color outline-style outline-width) - ("outline-color" color "invert") - ("outline-style" border-style) - ("outline-width" border-width) - ("overflow" "visible" "hidden" "scroll" "auto") - ("padding" padding-width) - ("padding-bottom" padding-width) - ("padding-left" padding-width) - ("padding-right" padding-width) - ("padding-top" padding-width) - ("page-break-after" "auto" "always" "avoid" "left" "right") - ("page-break-before" "auto" "always" "avoid" "left" "right") - ("page-break-inside" "avoid" "auto") - ("pause" time percentage) - ("pause-after" time percentage) - ("pause-before" time percentage) - ("pitch" frequency "x-low" "low" "medium" "high" "x-high") - ("pitch-range" number) - ("play-during" uri "mix" "repeat" "auto" "none") - ("position" "static" "relative" "absolute" "fixed") - ("quotes" string string "none") - ("richness" number) - ("right" length percentage "auto") - ("speak" "normal" "none" "spell-out") - ("speak-header" "once" "always") - ("speak-numeral" "digits" "continuous") - ("speak-punctuation" "code" "none") - ("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster" - "slower") - ("stress" number) - ("table-layout" "auto" "fixed") - ("text-align" "left" "right" "center" "justify") - ("text-decoration" "none" "underline" "overline" "line-through" "blink") - ("text-indent" length percentage) - ("text-transform" "capitalize" "uppercase" "lowercase" "none") - ("top" length percentage "auto") - ("unicode-bidi" "normal" "embed" "bidi-override") - ("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle" - "bottom" "text-bottom" percentage length) - ("visibility" "visible" "hidden" "collapse") - ("voice-family" specific-voice generic-voice "*" specific-voice - generic-voice) - ("volume" number percentage "silent" "x-soft" "soft" "medium" "loud" - "x-loud") - ("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line") - ("widows" integer) - ("width" length percentage "auto") - ("word-spacing" "normal" length) - ("z-index" "auto" integer)) - "A list of CSS properties and their possible values.") - -(defconst ac-css-value-classes - '((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" - "xx-large") - (border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove" - "ridge" "inset" "outset") - (color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy" - "olive" "orange" "purple" "red" "silver" "teal" "white" "yellow" - "rgb") - (counter "counter") - (family-name "Courier" "Helvetica" "Times") - (generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace") - (generic-voice "male" "female" "child") - (margin-width "auto") ;; length percentage - (relative-size "larger" "smaller") - (shape "rect") - (uri "url")) - "A list of CSS property value classes and their contents.") - -(defconst ac-css-pseudo-classes - '("active" "after" "before" "first" "first-child" "first-letter" "first-line" - "focus" "hover" "lang" "left" "link" "right" "visited") - "Identifiers for CSS pseudo-elements and pseudo-classes.") - -(defvar ac-css-property nil - "Current editing property.") - -(defun ac-css-prefix () - (when (save-excursion (re-search-backward "\\_<\\(.+?\\)\\_>\\s *:[^;]*\\=" nil t)) - (setq ac-css-property (match-string 1)) - (or (ac-prefix-symbol) (point)))) - -(defun ac-css-property-candidates () - (let ((list (assoc-default ac-css-property ac-css-property-alist))) - (if list - (loop with seen - with value - while (setq value (pop list)) - if (symbolp value) - do (unless (memq value seen) - (push value seen) - (setq list - (append list - (or (assoc-default value ac-css-value-classes) - (assoc-default (symbol-name value) ac-css-property-alist))))) - else collect value) - ac-css-pseudo-classes))) - -(ac-define-source css-property - '((candidates . ac-css-property-candidates) - (prefix . ac-css-prefix) - (requires . 0))) - -;; slime -(ac-define-source slime - '((depends slime) - (candidates . (car (slime-simple-completions ac-prefix))) - (symbol . "s") - (cache))) - -;; ghc-mod -(ac-define-source ghc-mod - '((depends ghc) - (candidates . (ghc-select-completion-symbol)) - (symbol . "s") - (cache))) - - - -;;;; Not maintained sources - -;; ropemacs - -(defvar ac-ropemacs-loaded nil) -(defun ac-ropemacs-require () - (with-no-warnings - (unless ac-ropemacs-loaded - (pymacs-load "ropemacs" "rope-") - (if (boundp 'ropemacs-enable-autoimport) - (setq ropemacs-enable-autoimport t)) - (setq ac-ropemacs-loaded t)))) - -(defun ac-ropemacs-setup () - (ac-ropemacs-require) - ;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources)) - (setq ac-omni-completion-sources '(("\\." ac-source-ropemacs)))) - -(defun ac-ropemacs-initialize () - (autoload 'pymacs-apply "pymacs") - (autoload 'pymacs-call "pymacs") - (autoload 'pymacs-eval "pymacs" nil t) - (autoload 'pymacs-exec "pymacs" nil t) - (autoload 'pymacs-load "pymacs" nil t) - (add-hook 'python-mode-hook 'ac-ropemacs-setup) - t) - -(defvar ac-ropemacs-completions-cache nil) -(defvar ac-source-ropemacs - '((init - . (lambda () - (setq ac-ropemacs-completions-cache - (mapcar - (lambda (completion) - (concat ac-prefix completion)) - (ignore-errors - (rope-completions)))))) - (candidates . ac-ropemacs-completions-cache))) - -;; rcodetools - -(defvar ac-source-rcodetools - '((init . (lambda () - (require 'rcodetools) - (condition-case x - (save-excursion - (rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles")) - (error) (setq rct-method-completion-table nil)))) - (candidates . (lambda () - (all-completions - ac-prefix - (mapcar - (lambda (completion) - (replace-regexp-in-string "\t.*$" "" (car completion))) - rct-method-completion-table)))))) - - - -;;;; Default settings - -(defun ac-common-setup () - ;(add-to-list 'ac-sources 'ac-source-filename) - ) - -(defun ac-emacs-lisp-mode-setup () - (setq ac-sources (append '(ac-source-features ac-source-functions ac-source-yasnippet ac-source-variables ac-source-symbols) ac-sources))) - -(defun ac-cc-mode-setup () - (setq ac-sources (append '(ac-source-yasnippet ac-source-gtags) ac-sources))) - -(defun ac-ruby-mode-setup ()) - -(defun ac-css-mode-setup () - (setq ac-sources (append '(ac-source-css-property) ac-sources))) - -;;;###autoload -(defun ac-config-default () - (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) - (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup) - (add-hook 'c-mode-common-hook 'ac-cc-mode-setup) - (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup) - (add-hook 'css-mode-hook 'ac-css-mode-setup) - (add-hook 'auto-complete-mode-hook 'ac-common-setup) - (global-auto-complete-mode t)) - -(provide 'auto-complete-config) -;;; auto-complete-config.el ends here diff --git a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-pkg.el b/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-pkg.el deleted file mode 100644 index 81f0fbf..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete-pkg.el +++ /dev/null @@ -1,5 +0,0 @@ -(define-package "auto-complete" "20140824.1658" "Auto Completion for GNU Emacs" - '((popup "0.5.0"))) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete.el b/emacs.d/elpa/auto-complete-20140824.1658/auto-complete.el deleted file mode 100644 index 3624287..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/auto-complete.el +++ /dev/null @@ -1,2101 +0,0 @@ -;;; auto-complete.el --- Auto Completion for GNU Emacs - -;; Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Tomohiro Matsuyama - -;; Author: Tomohiro Matsuyama -;; URL: http://cx4a.org/software/auto-complete -;; Keywords: completion, convenience -;; Version: 1.4.0 - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; -;; This extension provides a way to complete with popup menu like: -;; -;; def-!- -;; +-----------------+ -;; |defun::::::::::::| -;; |defvar | -;; |defmacro | -;; | ... | -;; +-----------------+ -;; -;; You can complete by typing and selecting menu. -;; -;; Entire documents are located in doc/ directory. -;; Take a look for information. -;; -;; Enjoy! - -;;; Code: - - - -(defconst ac-version "1.4.0") - -(eval-when-compile - (require 'cl)) - -(require 'popup) - -;;;; Global stuff - -(defun ac-error (&optional var) - "Report an error and disable `auto-complete-mode'." - (ignore-errors - (message "auto-complete error: %s" var) - (auto-complete-mode -1) - var)) - - - -;;;; Customization - -(defgroup auto-complete nil - "Auto completion." - :group 'completion - :prefix "ac-") - -(defcustom ac-delay 0.1 - "Delay to completions will be available." - :type 'float - :group 'auto-complete) - -(defcustom ac-auto-show-menu 0.8 - "Non-nil means completion menu will be automatically shown." - :type '(choice (const :tag "Yes" t) - (const :tag "Never" nil) - (float :tag "Timer")) - :group 'auto-complete) - -(defcustom ac-show-menu-immediately-on-auto-complete t - "Non-nil means menu will be showed immediately on `auto-complete'." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-expand-on-auto-complete t - "Non-nil means expand whole common part on first time `auto-complete'." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-disable-faces '(font-lock-comment-face font-lock-string-face font-lock-doc-face) - "Non-nil means disable automatic completion on specified faces." - :type '(repeat symbol) - :group 'auto-complete) - -(defcustom ac-stop-flymake-on-completing t - "Non-nil means disble flymake temporarily on completing." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-flycheck-poll-completion-end-interval 0.5 - "Polling interval to restart automatically flycheck's checking after completion is end." - :type 'float - :group 'auto-complete) - -(defcustom ac-use-fuzzy (and (locate-library "fuzzy") t) - "Non-nil means use fuzzy matching." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-fuzzy-cursor-color "red" - "Cursor color in fuzzy mode." - :type 'string - :group 'auto-complete) - -(defcustom ac-use-comphist t - "Non-nil means use intelligent completion history." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-comphist-threshold 0.7 - "Percentage of ignoring low scored candidates." - :type 'float - :group 'auto-complete) - -(defcustom ac-comphist-file - (expand-file-name (concat (if (boundp 'user-emacs-directory) - user-emacs-directory - "~/.emacs.d/") - "/ac-comphist.dat")) - "Completion history file name." - :type 'string - :group 'auto-complete) - -(defcustom ac-user-dictionary nil - "User defined dictionary" - :type '(repeat string) - :group 'auto-complete) - -(defcustom ac-dictionary-files '("~/.dict") - "Dictionary files." - :type '(repeat string) - :group 'auto-complete) -(defvaralias 'ac-user-dictionary-files 'ac-dictionary-files) - -(defcustom ac-dictionary-directories - (ignore-errors - (when load-file-name - (let ((installed-dir (file-name-directory load-file-name))) - (loop for name in '("ac-dict" "dict") - for dir = (concat installed-dir name) - if (file-directory-p dir) - collect dir)))) - "Dictionary directories." - :type '(repeat string) - :group 'auto-complete) - -(defcustom ac-use-quick-help t - "Non-nil means use quick help." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-quick-help-delay 1.5 - "Delay to show quick help." - :type 'float - :group 'auto-complete) - -(defcustom ac-menu-height 10 - "Max height of candidate menu." - :type 'integer - :group 'auto-complete) -(defvaralias 'ac-candidate-menu-height 'ac-menu-height) - -(defcustom ac-quick-help-height 20 - "Max height of quick help." - :type 'integer - :group 'auto-complete) - -(defcustom ac-quick-help-prefer-pos-tip t - "Prefer native tooltip with pos-tip than overlay popup for displaying quick help." - :type 'boolean - :group 'auto-complete) -(defvaralias 'ac-quick-help-prefer-x 'ac-quick-help-prefer-pos-tip) - -(defcustom ac-candidate-limit nil - "Limit number of candidates. Non-integer means no limit." - :type 'integer - :group 'auto-complete) -(defvaralias 'ac-candidate-max 'ac-candidate-limit) - -(defcustom ac-modes - '(emacs-lisp-mode lisp-mode lisp-interaction-mode - slime-repl-mode - c-mode cc-mode c++-mode go-mode - java-mode malabar-mode clojure-mode clojurescript-mode scala-mode - scheme-mode - ocaml-mode tuareg-mode coq-mode haskell-mode agda-mode agda2-mode - perl-mode cperl-mode python-mode ruby-mode lua-mode tcl-mode - ecmascript-mode javascript-mode js-mode js2-mode php-mode css-mode less-css-mode - makefile-mode sh-mode fortran-mode f90-mode ada-mode - xml-mode sgml-mode - ts-mode - sclang-mode - verilog-mode - qml-mode) - "Major modes `auto-complete-mode' can run on." - :type '(repeat symbol) - :group 'auto-complete) - -(defcustom ac-compatible-packages-regexp - "^ac-" - "Regexp to indicate what packages can work with auto-complete." - :type 'string - :group 'auto-complete) - -(defcustom ac-non-trigger-commands - '(*table--cell-self-insert-command - electric-buffer-list) - "Commands that can't be used as triggers of `auto-complete'." - :type '(repeat symbol) - :group 'auto-complete) - -(defcustom ac-trigger-commands - '(self-insert-command) - "Trigger commands that specify whether `auto-complete' should start or not." - :type '(repeat symbol) - :group 'auto-complete) - -(defcustom ac-trigger-commands-on-completing - '(delete-backward-char - backward-delete-char - backward-delete-char-untabify - ;; autopair - autopair-backspace - ;; paredit - paredit-backward-delete - paredit-backward-delete-word) - "Trigger commands that specify whether `auto-complete' should continue or not." - :type '(repeat symbol) - :group 'auto-complete) - -(defcustom ac-trigger-key nil - "Non-nil means `auto-complete' will start by typing this key. -If you specify this TAB, for example, `auto-complete' will start by typing TAB, -and if there is no completions, an original command will be fallbacked." - :type '(choice (const :tag "None" nil) - (string :tag "Key")) - :group 'auto-complete - :set (lambda (symbol value) - (set-default symbol value) - (when (and value - (fboundp 'ac-set-trigger-key)) - (ac-set-trigger-key value)))) - -(defcustom ac-auto-start 2 - "Non-nil means completion will be started automatically. -Positive integer means if a length of a word you entered is larger than the value, -completion will be started automatically. -If you specify `nil', never be started automatically." - :type '(choice (const :tag "Yes" t) - (const :tag "Never" nil) - (integer :tag "Require")) - :group 'auto-complete) - -(defcustom ac-stop-words nil - "List of string to stop completion." - :type '(repeat string) - :group 'auto-complete) -(defvaralias 'ac-ignores 'ac-stop-words) - -(defcustom ac-use-dictionary-as-stop-words t - "Non-nil means a buffer related dictionary will be thought of as stop words." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-ignore-case 'smart - "Non-nil means auto-complete ignores case. -If this value is `smart', auto-complete ignores case only when -a prefix doen't contain any upper case letters." - :type '(choice (const :tag "Yes" t) - (const :tag "Smart" smart) - (const :tag "No" nil)) - :group 'auto-complete) - -(defcustom ac-dwim t - "Non-nil means `auto-complete' works based on Do What I Mean." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-use-menu-map nil - "Non-nil means a special keymap `ac-menu-map' on completing menu will be used." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-use-overriding-local-map nil - "Non-nil means `overriding-local-map' will be used to hack for overriding key events on auto-completion." - :type 'boolean - :group 'auto-complete) - -(defcustom ac-disable-inline nil - "Non-nil disable inline completion visibility" - :type 'boolean - :group 'auto-complete) - -(defcustom ac-candidate-menu-min 1 - "Number of candidates required to display menu" - :type 'integer - :group 'auto-complete) - -(defcustom ac-max-width nil - "Maximum width for auto-complete menu to have" - :type '(choice (const :tag "No limit" nil) - (const :tag "Character Limit" 25) - (const :tag "Window Ratio Limit" 0.5)) - :group 'auto-complete) - -(defface ac-completion-face - '((t (:foreground "darkgray" :underline t))) - "Face for inline completion" - :group 'auto-complete) - -(defface ac-candidate-face - '((t (:inherit popup-face))) - "Face for candidate." - :group 'auto-complete) - -(defface ac-candidate-mouse-face - '((t (:inherit popup-menu-mouse-face))) - "Mouse face for candidate." - :group 'auto-complete) - -(defface ac-selection-face - '((t (:inherit popup-menu-selection-face))) - "Face for selected candidate." - :group 'auto-complete) - -(defvar auto-complete-mode-hook nil - "Hook for `auto-complete-mode'.") - - - -;;;; Internal variables - -(defvar auto-complete-mode nil - "Dummy variable to suppress compiler warnings.") - -(defvar ac-cursor-color nil - "Old cursor color.") - -(defvar ac-inline nil - "Inline completion instance.") - -(defvar ac-menu nil - "Menu instance.") - -(defvar ac-show-menu nil - "Flag to show menu on timer tick.") - -(defvar ac-last-completion nil - "Cons of prefix marker and selected item of last completion.") - -(defvar ac-quick-help nil - "Quick help instance") - -(defvar ac-completing nil - "Non-nil means `auto-complete-mode' is now working on completion.") - -(defvar ac-buffer nil - "Buffer where auto-complete is started.") - -(defvar ac-point nil - "Start point of prefix.") - -(defvar ac-last-point nil - "Last point of updating pattern.") - -(defvar ac-prefix nil - "Prefix string.") -(defvaralias 'ac-target 'ac-prefix) - -(defvar ac-selected-candidate nil - "Last selected candidate.") - -(defvar ac-common-part nil - "Common part string of meaningful candidates. -If there is no common part, this will be nil.") - -(defvar ac-whole-common-part nil - "Common part string of whole candidates. -If there is no common part, this will be nil.") - -(defvar ac-prefix-overlay nil - "Overlay for prefix string.") - -(defvar ac-timer nil - "Completion idle timer.") - -(defvar ac-show-menu-timer nil - "Show menu idle timer.") - -(defvar ac-quick-help-timer nil - "Quick help idle timer.") - -(defvar ac-triggered nil - "Flag to update.") - -(defvar ac-limit nil - "Limit number of candidates for each sources.") - -(defvar ac-candidates nil - "Current candidates.") - -(defvar ac-candidates-cache nil - "Candidates cache for individual sources.") - -(defvar ac-fuzzy-enable nil - "Non-nil means fuzzy matching is enabled.") - -(defvar ac-dwim-enable nil - "Non-nil means DWIM completion will be allowed.") - -(defvar ac-mode-map (make-sparse-keymap) - "Auto-complete mode map. It is also used for trigger key command. See also `ac-trigger-key'.") - -(defvar ac-completing-map - (let ((map (make-sparse-keymap))) - (define-key map "\t" 'ac-expand) - (define-key map [tab] 'ac-expand) - (define-key map "\r" 'ac-complete) - (define-key map [return] 'ac-complete) - (define-key map (kbd "M-TAB") 'auto-complete) - - (define-key map "\M-n" 'ac-next) - (define-key map "\M-p" 'ac-previous) - (define-key map [down] 'ac-next) - (define-key map [up] 'ac-previous) - - (define-key map [f1] 'ac-help) - (define-key map [M-f1] 'ac-persist-help) - (define-key map (kbd "C-?") 'ac-help) - (define-key map (kbd "C-M-?") 'ac-persist-help) - - (define-key map [C-down] 'ac-quick-help-scroll-down) - (define-key map [C-up] 'ac-quick-help-scroll-up) - (define-key map "\C-\M-n" 'ac-quick-help-scroll-down) - (define-key map "\C-\M-p" 'ac-quick-help-scroll-up) - - (dotimes (i 9) - (let ((symbol (intern (format "ac-complete-select-%d" (1+ i))))) - (fset symbol - `(lambda () - (interactive) - (when (and (ac-menu-live-p) (popup-select ac-menu ,i)) - (ac-complete)))) - (define-key map (read-kbd-macro (format "M-%s" (1+ i))) symbol))) - - map) - "Keymap for completion.") -(defvaralias 'ac-complete-mode-map 'ac-completing-map) - -(defvar ac-menu-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map ac-completing-map) - (define-key map "\C-n" 'ac-next) - (define-key map "\C-p" 'ac-previous) - (define-key map "\C-s" 'ac-isearch) - (define-key map [mouse-1] 'ac-mouse-1) - (define-key map [down-mouse-1] 'ac-ignore) - (define-key map [mouse-4] 'ac-mouse-4) - (define-key map [mouse-5] 'ac-mouse-5) - map) - "Keymap for completion on completing menu.") - -(defvar ac-current-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map ac-completing-map) - map)) - -(defvar ac-match-function 'all-completions - "Default match function.") - -(defvar ac-prefix-definitions - '((symbol . ac-prefix-symbol) - (file . ac-prefix-file) - (valid-file . ac-prefix-valid-file) - (c-dot . ac-prefix-c-dot) - (c-dot-ref . ac-prefix-c-dot-ref) - (cc-member . ac-prefix-cc-member)) - "Prefix definitions for common use.") - -(defvar ac-sources '(ac-source-words-in-same-mode-buffers) - "Sources for completion.") -(make-variable-buffer-local 'ac-sources) - -(defvar ac-compiled-sources nil - "Compiled source of `ac-sources'.") - -(defvar ac-current-sources nil - "Current working sources. This is sublist of `ac-compiled-sources'.") - -(defvar ac-omni-completion-sources nil - "Do not use this anymore.") - -(defvar ac-current-prefix-def nil) - -(defvar ac-ignoring-prefix-def nil) - - - -;;;; Intelligent completion history - -(defvar ac-comphist nil - "Database of completion history.") - -(defsubst ac-comphist-make-tab () - (make-hash-table :test 'equal)) - -(defsubst ac-comphist-tab (db) - (nth 0 db)) - -(defsubst ac-comphist-cache (db) - (nth 1 db)) - -(defun ac-comphist-make (&optional tab) - (list (or tab (ac-comphist-make-tab)) (make-hash-table :test 'equal :weakness t))) - -(defun ac-comphist-get (db string &optional create) - (let* ((tab (ac-comphist-tab db)) - (index (gethash string tab))) - (when (and create (null index)) - (setq index (make-vector (length string) 0)) - (puthash string index tab)) - index)) - -(defun ac-comphist-add (db string prefix) - (setq prefix (min prefix (1- (length string)))) - (when (<= 0 prefix) - (setq string (substring-no-properties string)) - (let ((stat (ac-comphist-get db string t))) - (incf (aref stat prefix)) - (remhash string (ac-comphist-cache db))))) - -(defun ac-comphist-score (db string prefix) - (setq prefix (min prefix (1- (length string)))) - (if (<= 0 prefix) - (let ((cache (gethash string (ac-comphist-cache db)))) - (or (and cache (aref cache prefix)) - (let ((stat (ac-comphist-get db string)) - (score 0.0)) - (when stat - (loop for p from 0 below (length string) - ;; sigmoid function - with a = 5 - with b = (/ 700.0 a) ; bounds for avoiding range error in `exp' - with d = (/ 6.0 a) - for x = (max (- b) (min b (- d (abs (- prefix p))))) - for r = (/ 1.0 (1+ (exp (* (- a) x)))) - do - (incf score (* (aref stat p) r)))) - ;; Weight by distance - (incf score (max 0.0 (- 0.3 (/ (- (length string) prefix) 100.0)))) - (unless cache - (setq cache (make-vector (length string) nil)) - (puthash string cache (ac-comphist-cache db))) - (aset cache prefix score) - score))) - 0.0)) - -(defun ac-comphist-sort (db collection prefix &optional threshold) - (let (result - (n 0) - (total 0) - (cur 0)) - (setq result (mapcar (lambda (a) - (when (and cur threshold) - (if (>= cur (* total threshold)) - (setq cur nil) - (incf n) - (incf cur (cdr a)))) - (car a)) - (sort (mapcar (lambda (string) - (let ((score (ac-comphist-score db string prefix))) - (incf total score) - (cons string score))) - collection) - (lambda (a b) (< (cdr b) (cdr a)))))) - (if threshold - (cons n result) - result))) - -(defun ac-comphist-serialize (db) - (let (alist) - (maphash (lambda (k v) - (push (cons k v) alist)) - (ac-comphist-tab db)) - (list alist))) - -(defun ac-comphist-deserialize (sexp) - (condition-case nil - (ac-comphist-make (let ((tab (ac-comphist-make-tab))) - (mapc (lambda (cons) - (puthash (car cons) (cdr cons) tab)) - (nth 0 sexp)) - tab)) - (error (message "Invalid comphist db.") nil))) - -(defun ac-comphist-init () - (ac-comphist-load) - (add-hook 'kill-emacs-hook 'ac-comphist-save)) - -(defun ac-comphist-load () - (interactive) - (let ((db (if (file-exists-p ac-comphist-file) - (ignore-errors - (with-temp-buffer - (insert-file-contents ac-comphist-file) - (goto-char (point-min)) - (ac-comphist-deserialize (read (current-buffer)))))))) - (setq ac-comphist (or db (ac-comphist-make))))) - -(defun ac-comphist-save () - (interactive) - (require 'pp) - (ignore-errors - (with-temp-buffer - (pp (ac-comphist-serialize ac-comphist) (current-buffer)) - (write-region (point-min) (point-max) ac-comphist-file)))) - - - -;;;; Dictionary -(defvar ac-buffer-dictionary nil) -(defvar ac-file-dictionary (make-hash-table :test 'equal)) - -(defun ac-clear-dictionary-cache () - (interactive) - (dolist (buffer (buffer-list)) - (with-current-buffer buffer - (if (local-variable-p 'ac-buffer-dictionary) - (kill-local-variable 'ac-buffer-dictionary)))) - (clrhash ac-file-dictionary)) - -(defun ac-file-dictionary (filename) - (let ((cache (gethash filename ac-file-dictionary 'none))) - (if (and cache (not (eq cache 'none))) - cache - (let (result) - (ignore-errors - (with-temp-buffer - (insert-file-contents filename) - (setq result (split-string (buffer-string) "\n" t)))) - (puthash filename result ac-file-dictionary) - result)))) - -(defun ac-mode-dictionary (mode) - (loop for name in (cons (symbol-name mode) - (ignore-errors (list (file-name-extension (buffer-file-name))))) - append (loop for dir in ac-dictionary-directories - for file = (concat dir "/" name) - if (file-exists-p file) - append (ac-file-dictionary file)))) - -(defun ac-buffer-dictionary (&optional buffer) - (with-current-buffer (or buffer (current-buffer)) - (if (local-variable-p 'ac-buffer-dictionary) - ac-buffer-dictionary - (make-local-variable 'ac-buffer-dictionary) - (setq ac-buffer-dictionary - (apply 'append - ac-user-dictionary - (ac-mode-dictionary major-mode) - (mapcar 'ac-file-dictionary ac-dictionary-files)))))) - - - -;;;; Auto completion internals - -(defun ac-menu-at-wrapper-line-p () - "Return non-nil if current line is long and wrapped to next visual line." - (and (not truncate-lines) - (eq (line-beginning-position) - (save-excursion - (vertical-motion 1) - (line-beginning-position))))) - -(defun ac-stop-word-p (word) - (or (member word ac-stop-words) - (if ac-use-dictionary-as-stop-words - (member word (ac-buffer-dictionary))))) - -(defun ac-prefix-default () - "Same as `ac-prefix-symbol' but ignore a number prefix." - (let ((start (ac-prefix-symbol))) - (when start - (loop with end = (point) - for pos from start below end - for c = (char-after pos) - if (not (and (<= ?0 c) (<= c ?9))) - return start)))) - -(defun ac-prefix-symbol () - "Default prefix definition function." - (require 'thingatpt) - (car-safe (bounds-of-thing-at-point 'symbol))) - -(defun ac-prefix-file () - "File prefix." - (let ((point (re-search-backward "[\"<>' \t\r\n]" nil t))) - (if point (1+ point)))) - -(defsubst ac-windows-remote-file-p (file) - (and (memq system-type '(ms-dos windows-nt cygwin)) - (string-match-p "\\`\\(?://\\|\\\\\\\\\\)" file))) - -(defun ac-prefix-valid-file () - "Existed (or to be existed) file prefix." - (let* ((line-beg (line-beginning-position)) - (end (point)) - (start (or (let ((point (re-search-backward "[\"<>'= \t\r\n]" line-beg t))) - (if point (1+ point))) - line-beg)) - (file (buffer-substring start end))) - (if (and file (or (string-match "^/" file) - (and (setq file (and (string-match "^[^/]*/" file) - (match-string 0 file))) - (file-directory-p file)))) - (unless (ac-windows-remote-file-p file) - start)))) - -(defun ac-prefix-c-dot () - "C-like languages dot(.) prefix." - (if (re-search-backward "\\.\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t) - (match-beginning 1))) - -(defun ac-prefix-c-dot-ref () - "C-like languages dot(.) and reference(->) prefix." - (if (re-search-backward "\\(?:\\.\\|->\\)\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t) - (match-beginning 1))) - -(defun ac-prefix-cc-member () - "C-like languages member(.)(->)(::) prefix." - (when (re-search-backward "\\(?:\\.\\|->\\|::\\)\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t) - (match-beginning 1))) - -(defun ac-define-prefix (name prefix) - "Define new prefix definition. -You can not use it in source definition like (prefix . `NAME')." - (push (cons name prefix) ac-prefix-definitions)) - -(defun ac-match-substring (prefix candidates) - (loop with regexp = (regexp-quote prefix) - for candidate in candidates - if (string-match regexp candidate) - collect candidate)) - -(defsubst ac-source-entity (source) - (if (symbolp source) - (symbol-value source) - source)) - -(defun ac-source-available-p (source) - (if (and (symbolp source) - (get source 'available)) - (eq (get source 'available) t) - (let* ((src (ac-source-entity source)) - (avail-pair (assq 'available src)) - (avail-cond (cdr avail-pair)) - (available (and (if avail-pair - (cond - ((symbolp avail-cond) - (funcall avail-cond)) - ((listp avail-cond) - (eval avail-cond))) - t) - (loop for feature in (assoc-default 'depends src) - unless (require feature nil t) return nil - finally return t)))) - (if (symbolp source) - (put source 'available (if available t 'no))) - available))) - -(defun ac-compile-sources (sources) - "Compiled `SOURCES' into expanded sources style." - (loop for source in sources - if (ac-source-available-p source) - do - (setq source (ac-source-entity source)) - ;; prefix - (let* ((prefix (assoc 'prefix source)) - (real (assoc-default (cdr prefix) ac-prefix-definitions))) - (cond - (real - (add-to-list 'source (cons 'prefix real))) - ((null prefix) - (add-to-list 'source (cons 'prefix 'ac-prefix-default))))) - ;; match - (let ((match (assq 'match source))) - (cond - ((eq (cdr match) 'substring) - (setcdr match 'ac-match-substring)))) - and collect source)) - -(defun ac-compiled-sources () - (or ac-compiled-sources - (setq ac-compiled-sources - (ac-compile-sources ac-sources)))) - -(defsubst ac-menu-live-p () - (popup-live-p ac-menu)) - -(defun ac-menu-create (point width height) - (setq ac-menu - (popup-create point width height - :around t - :face 'ac-candidate-face - :max-width ac-max-width - :mouse-face 'ac-candidate-mouse-face - :selection-face 'ac-selection-face - :symbol t - :scroll-bar t - :margin-left 1 - :keymap ac-menu-map - ))) - -(defun ac-menu-delete () - (when ac-menu - (popup-delete ac-menu) - (setq ac-menu))) - -(defsubst ac-inline-overlay () - (nth 0 ac-inline)) - -(defsubst ac-inline-live-p () - (and ac-inline (ac-inline-overlay) t)) - -(defun ac-inline-show (point string) - (unless ac-inline - (setq ac-inline (list nil))) - (save-excursion - (let ((overlay (ac-inline-overlay)) - (width 0) - (string-width (string-width string)) - (length 0) - (original-string string)) - ;; Calculate string space to show completion - (goto-char point) - (let (c) - (while (and (not (eolp)) - (< width string-width) - (setq c (char-after)) - (not (eq c ?\t))) ; special case for tab - (incf width (char-width c)) - (incf length) - (forward-char))) - - ;; Show completion - (goto-char point) - (cond - ((= width 0) - ;; End-of-line - ;; Do nothing - ) - ((<= width string-width) - ;; No space to show - ;; Do nothing - ) - ((> width string-width) - ;; Need to fill space - (setq string (concat string (make-string (- width string-width) ? ))))) - (setq string (propertize string 'face 'ac-completion-face)) - (if overlay - (progn - (move-overlay overlay point (+ point length)) - (overlay-put overlay 'invisible nil)) - (setq overlay (make-overlay point (+ point length))) - (setf (nth 0 ac-inline) overlay) - (overlay-put overlay 'priority 9999) - ;; Help prefix-overlay in some cases - (overlay-put overlay 'keymap ac-current-map)) - ;; TODO no width but char - (if (eq length 0) - ;; Case: End-of-line - (progn - (put-text-property 0 1 'cursor t string) - (overlay-put overlay 'after-string string)) - (let ((display (substring string 0 1)) - (after-string (substring string 1))) - (overlay-put overlay 'display display) - (overlay-put overlay 'after-string after-string))) - (overlay-put overlay 'string original-string)))) - -(defun ac-inline-delete () - (when (ac-inline-live-p) - (ac-inline-hide) - (delete-overlay (ac-inline-overlay)) - (setq ac-inline nil))) - -(defun ac-inline-hide () - (when (ac-inline-live-p) - (let ((overlay (ac-inline-overlay)) - (buffer-undo-list t)) - (when overlay - (move-overlay overlay (point-min) (point-min)) - (overlay-put overlay 'invisible t) - (overlay-put overlay 'display nil) - (overlay-put overlay 'after-string nil))))) - -(defun ac-inline-update () - (if (and ac-completing ac-prefix (stringp ac-common-part)) - (let ((common-part-length (length ac-common-part)) - (prefix-length (length ac-prefix))) - (if (> common-part-length prefix-length) - (progn - (ac-inline-hide) - (ac-inline-show (point) (substring ac-common-part prefix-length))) - (ac-inline-delete))) - (ac-inline-delete))) - -(defun ac-put-prefix-overlay () - (unless ac-prefix-overlay - (let (newline) - ;; Insert newline to make sure that cursor always on the overlay - (when (eobp) - (popup-save-buffer-state - (insert "\n")) - (setq newline t)) - (setq ac-prefix-overlay (make-overlay ac-point (1+ (point)) nil t t)) - (overlay-put ac-prefix-overlay 'priority 9999) - (overlay-put ac-prefix-overlay 'keymap (make-sparse-keymap)) - (overlay-put ac-prefix-overlay 'newline newline)))) - -(defun ac-remove-prefix-overlay () - (when ac-prefix-overlay - (when (overlay-get ac-prefix-overlay 'newline) - ;; Remove inserted newline - (popup-save-buffer-state - (goto-char (point-max)) - (if (eq (char-before) ?\n) - (delete-char -1)))) - (delete-overlay ac-prefix-overlay))) - -(defun ac-activate-completing-map () - (if (and ac-show-menu ac-use-menu-map) - (set-keymap-parent ac-current-map ac-menu-map)) - (when (and ac-use-overriding-local-map - (null overriding-terminal-local-map)) - (setq overriding-terminal-local-map ac-current-map)) - (when ac-prefix-overlay - (set-keymap-parent (overlay-get ac-prefix-overlay 'keymap) ac-current-map))) - -(defun ac-deactivate-completing-map () - (set-keymap-parent ac-current-map ac-completing-map) - (when (and ac-use-overriding-local-map - (eq overriding-terminal-local-map ac-current-map)) - (setq overriding-terminal-local-map nil)) - (when ac-prefix-overlay - (set-keymap-parent (overlay-get ac-prefix-overlay 'keymap) nil))) - -(defsubst ac-selected-candidate () - (if ac-menu - (popup-selected-item ac-menu))) - -(defun ac-prefix (requires ignore-list) - (loop with current = (point) - with point - with prefix-def - with sources - for source in (ac-compiled-sources) - for prefix = (assoc-default 'prefix source) - for req = (or (assoc-default 'requires source) requires 1) - - if (null prefix-def) - do - (unless (member prefix ignore-list) - (save-excursion - (setq point (cond - ((symbolp prefix) - (funcall prefix)) - ((stringp prefix) - (and (re-search-backward (concat prefix "\\=") nil t) - (or (match-beginning 1) (match-beginning 0)))) - ((stringp (car-safe prefix)) - (let ((regexp (nth 0 prefix)) - (end (nth 1 prefix)) - (group (nth 2 prefix))) - (and (re-search-backward (concat regexp "\\=") nil t) - (funcall (if end 'match-end 'match-beginning) - (or group 0))))) - (t - (eval prefix)))) - (if (and point - (integerp req) - (< (- current point) req)) - (setq point nil)) - (if point - (setq prefix-def prefix)))) - - if (equal prefix prefix-def) do (push source sources) - - finally return - (and point (list prefix-def point (nreverse sources))))) - -(defun ac-init () - "Initialize current sources to start completion." - (setq ac-candidates-cache nil) - (loop for source in ac-current-sources - for function = (assoc-default 'init source) - if function do - (save-excursion - (cond - ((functionp function) - (funcall function)) - (t - (eval function)))))) - -(defun ac-candidates-1 (source) - (let* ((do-cache (assq 'cache source)) - (function (assoc-default 'candidates source)) - (action (assoc-default 'action source)) - (document (assoc-default 'document source)) - (symbol (assoc-default 'symbol source)) - (ac-limit (or (assoc-default 'limit source) ac-limit)) - (face (or (assoc-default 'face source) (assoc-default 'candidate-face source))) - (selection-face (assoc-default 'selection-face source)) - (cache (and do-cache (assq source ac-candidates-cache))) - (candidates (cdr cache))) - (unless cache - (setq candidates (save-excursion - (cond - ((functionp function) - (funcall function)) - (t - (eval function))))) - ;; Convert (name value) format candidates into name with text properties. - (setq candidates (mapcar (lambda (candidate) - (if (consp candidate) - (propertize (car candidate) 'value (cdr candidate)) - candidate)) - candidates)) - (when do-cache - (push (cons source candidates) ac-candidates-cache))) - (setq candidates (funcall (or (assoc-default 'match source) - ac-match-function) - ac-prefix candidates)) - ;; Remove extra items regarding to ac-limit - (if (and (integerp ac-limit) (> ac-limit 1) (> (length candidates) ac-limit)) - (setcdr (nthcdr (1- ac-limit) candidates) nil)) - ;; Put candidate properties - (setq candidates (mapcar (lambda (candidate) - (popup-item-propertize candidate - 'action action - 'symbol symbol - 'document document - 'popup-face face - 'selection-face selection-face)) - candidates)) - candidates)) - -(defun ac-candidates () - "Produce candidates for current sources." - (loop with completion-ignore-case = (or (eq ac-ignore-case t) - (and (eq ac-ignore-case 'smart) - (let ((case-fold-search nil)) (not (string-match "[[:upper:]]" ac-prefix))))) - with case-fold-search = completion-ignore-case - with prefix-len = (length ac-prefix) - for source in ac-current-sources - append (ac-candidates-1 source) into candidates - finally return - (progn - (delete-dups candidates) - (if (and ac-use-comphist ac-comphist) - (if ac-show-menu - (let* ((pair (ac-comphist-sort ac-comphist candidates prefix-len ac-comphist-threshold)) - (n (car pair)) - (result (cdr pair)) - (cons (if (> n 0) (nthcdr (1- n) result))) - (cdr (cdr cons))) - (if cons (setcdr cons nil)) - (setq ac-common-part (try-completion ac-prefix result)) - (setq ac-whole-common-part (try-completion ac-prefix candidates)) - (if cons (setcdr cons cdr)) - result) - (setq candidates (ac-comphist-sort ac-comphist candidates prefix-len)) - (setq ac-common-part (if candidates (popup-x-to-string (car candidates)))) - (setq ac-whole-common-part (try-completion ac-prefix candidates)) - candidates) - (setq ac-common-part (try-completion ac-prefix candidates)) - (setq ac-whole-common-part ac-common-part) - candidates)))) - -(defun ac-update-candidates (cursor scroll-top) - "Update candidates of menu to `ac-candidates' and redraw it." - (setf (popup-cursor ac-menu) cursor - (popup-scroll-top ac-menu) scroll-top) - (setq ac-dwim-enable (= (length ac-candidates) 1)) - (if ac-candidates - (progn - (setq ac-completing t) - (ac-activate-completing-map)) - (setq ac-completing nil) - (ac-deactivate-completing-map)) - (unless ac-disable-inline - (ac-inline-update)) - (popup-set-list ac-menu ac-candidates) - (if (and (not ac-fuzzy-enable) - (<= (length ac-candidates) ac-candidate-menu-min)) - (popup-hide ac-menu) - (if ac-show-menu - (popup-draw ac-menu)))) - -(defun ac-reposition () - "Force to redraw candidate menu with current `ac-candidates'." - (let ((cursor (popup-cursor ac-menu)) - (scroll-top (popup-scroll-top ac-menu)) - (height (popup-height ac-menu))) - (ac-menu-delete) - (ac-menu-create ac-point (popup-preferred-width ac-candidates) height) - (ac-update-candidates cursor scroll-top))) - -(defun ac-cleanup () - "Cleanup auto completion." - (if ac-cursor-color - (set-cursor-color ac-cursor-color)) - (when (and ac-use-comphist ac-comphist) - (when (and (null ac-selected-candidate) - (member ac-prefix ac-candidates)) - ;; Assume candidate is selected by just typing - (setq ac-selected-candidate ac-prefix) - (setq ac-last-point ac-point)) - (when ac-selected-candidate - (ac-comphist-add ac-comphist - ac-selected-candidate - (if ac-last-point - (- ac-last-point ac-point) - (length ac-prefix))))) - (ac-deactivate-completing-map) - (ac-remove-prefix-overlay) - (ac-remove-quick-help) - (ac-inline-delete) - (ac-menu-delete) - (ac-cancel-timer) - (ac-cancel-show-menu-timer) - (ac-cancel-quick-help-timer) - (setq ac-cursor-color nil - ac-inline nil - ac-show-menu nil - ac-menu nil - ac-completing nil - ac-point nil - ac-last-point nil - ac-prefix nil - ac-prefix-overlay nil - ac-selected-candidate nil - ac-common-part nil - ac-whole-common-part nil - ac-triggered nil - ac-limit nil - ac-candidates nil - ac-candidates-cache nil - ac-fuzzy-enable nil - ac-dwim-enable nil - ac-compiled-sources nil - ac-current-sources nil - ac-current-prefix-def nil - ac-ignoring-prefix-def nil)) - -(defsubst ac-abort () - "Abort completion." - (ac-cleanup)) - -(defun ac-expand-string (string &optional remove-undo-boundary) - "Expand `STRING' into the buffer and update `ac-prefix' to `STRING'. -This function records deletion and insertion sequences by `undo-boundary'. -If `remove-undo-boundary' is non-nil, this function also removes `undo-boundary' -that have been made before in this function. When `buffer-undo-list' is -`t', `remove-undo-boundary' has no effect." - (when (eq buffer-undo-list t) - (setq remove-undo-boundary nil)) - (when (not (equal string (buffer-substring ac-point (point)))) - (undo-boundary) - ;; We can't use primitive-undo since it undoes by - ;; groups, divided by boundaries. - ;; We don't want boundary between deletion and insertion. - ;; So do it manually. - ;; Delete region silently for undo: - (if remove-undo-boundary - (progn - (let (buffer-undo-list) - (save-excursion - (delete-region ac-point (point)))) - (setq buffer-undo-list - (nthcdr 2 buffer-undo-list))) - (delete-region ac-point (point))) - (insert (substring-no-properties string)) - ;; Sometimes, possible when omni-completion used, (insert) added - ;; to buffer-undo-list strange record about position changes. - ;; Delete it here: - (when (and remove-undo-boundary - (integerp (cadr buffer-undo-list))) - (setcdr buffer-undo-list (nthcdr 2 buffer-undo-list))) - (undo-boundary) - (setq ac-selected-candidate string) - (setq ac-prefix string))) - -(defun ac-set-trigger-key (key) - "Set `ac-trigger-key' to `KEY'. It is recommemded to use this function instead of calling `setq'." - ;; Remove old mapping - (when ac-trigger-key - (define-key ac-mode-map (read-kbd-macro ac-trigger-key) nil)) - - ;; Make new mapping - (setq ac-trigger-key key) - (when key - (define-key ac-mode-map (read-kbd-macro key) 'ac-trigger-key-command))) - -(defun ac-set-timer () - (unless ac-timer - (setq ac-timer (run-with-idle-timer ac-delay ac-delay 'ac-update-greedy)))) - -(defun ac-cancel-timer () - (when (timerp ac-timer) - (cancel-timer ac-timer) - (setq ac-timer nil))) - -(defun ac-update (&optional force) - (when (and auto-complete-mode - ac-prefix - (or ac-triggered - force) - (not isearch-mode)) - (ac-put-prefix-overlay) - (setq ac-candidates (ac-candidates)) - (let ((preferred-width (popup-preferred-width ac-candidates))) - ;; Reposition if needed - (when (or (null ac-menu) - (>= (popup-width ac-menu) preferred-width) - (<= (popup-width ac-menu) (- preferred-width 10)) - (and (> (popup-direction ac-menu) 0) - (ac-menu-at-wrapper-line-p))) - (ac-inline-hide) ; Hide overlay to calculate correct column - (ac-remove-quick-help) - (ac-menu-delete) - (ac-menu-create ac-point preferred-width ac-menu-height))) - (ac-update-candidates 0 0) - t)) - -(defun ac-update-greedy (&optional force) - (let (result) - (while (when (and (setq result (ac-update force)) - (null ac-candidates)) - (add-to-list 'ac-ignoring-prefix-def ac-current-prefix-def) - (ac-start :force-init t) - ac-current-prefix-def)) - result)) - -(defun ac-set-show-menu-timer () - (when (and (or (integerp ac-auto-show-menu) (floatp ac-auto-show-menu)) - (null ac-show-menu-timer)) - (setq ac-show-menu-timer (run-with-idle-timer ac-auto-show-menu ac-auto-show-menu 'ac-show-menu)))) - -(defun ac-cancel-show-menu-timer () - (when (timerp ac-show-menu-timer) - (cancel-timer ac-show-menu-timer) - (setq ac-show-menu-timer nil))) - -(defun ac-show-menu () - (when (not (eq ac-show-menu t)) - (setq ac-show-menu t) - (ac-inline-hide) - (ac-remove-quick-help) - (ac-update t))) - -(defun ac-help (&optional persist) - (interactive "P") - (when ac-menu - (popup-menu-show-help ac-menu persist))) - -(defun ac-persist-help () - (interactive) - (ac-help t)) - -(defun ac-last-help (&optional persist) - (interactive "P") - (when ac-last-completion - (popup-item-show-help (cdr ac-last-completion) persist))) - -(defun ac-last-persist-help () - (interactive) - (ac-last-help t)) - -(defun ac-set-quick-help-timer () - (when (and ac-use-quick-help - (null ac-quick-help-timer)) - (setq ac-quick-help-timer (run-with-idle-timer ac-quick-help-delay ac-quick-help-delay 'ac-quick-help)))) - -(defun ac-cancel-quick-help-timer () - (when (timerp ac-quick-help-timer) - (cancel-timer ac-quick-help-timer) - (setq ac-quick-help-timer nil))) - -(defun ac-pos-tip-show-quick-help (menu &optional item &rest args) - (let* ((point (plist-get args :point)) - (around nil) - (parent-offset (popup-offset menu)) - (doc (popup-menu-documentation menu item))) - (when (stringp doc) - (if (popup-hidden-p menu) - (setq around t) - (setq point nil)) - (with-no-warnings - (pos-tip-show doc - 'popup-tip-face - (or point - (and menu - (popup-child-point menu parent-offset)) - (point)) - nil 300 - popup-tip-max-width - nil nil - (and (not around) 0)) - (unless (plist-get args :nowait) - (clear-this-command-keys) - (unwind-protect - (push (read-event (plist-get args :prompt)) unread-command-events) - (pos-tip-hide)) - t))))) - -(defun ac-quick-help-use-pos-tip-p () - (and ac-quick-help-prefer-pos-tip - window-system - (featurep 'pos-tip))) - -(defun ac-quick-help (&optional force) - (interactive) - ;; TODO don't use FORCE - (when (and (or force - (with-no-warnings - ;; called-interactively-p can take no args - (called-interactively-p)) - ;; ac-isearch'ing - (null this-command)) - (ac-menu-live-p) - (null ac-quick-help)) - (setq ac-quick-help - (funcall (if (ac-quick-help-use-pos-tip-p) - 'ac-pos-tip-show-quick-help - 'popup-menu-show-quick-help) - ac-menu nil - :point ac-point - :height ac-quick-help-height - :nowait t)))) - -(defun ac-remove-quick-help () - (when (ac-quick-help-use-pos-tip-p) - (with-no-warnings - (pos-tip-hide))) - (when ac-quick-help - (popup-delete ac-quick-help) - (setq ac-quick-help nil))) - -(defun ac-last-quick-help () - (interactive) - (when (and ac-last-completion - (eq (marker-buffer (car ac-last-completion)) - (current-buffer))) - (let ((doc (popup-item-documentation (cdr ac-last-completion))) - (point (marker-position (car ac-last-completion)))) - (when (stringp doc) - (if (ac-quick-help-use-pos-tip-p) - (with-no-warnings (pos-tip-show doc nil point nil 300)) - (popup-tip doc - :point point - :around t - :scroll-bar t - :margin t)))))) - -(defmacro ac-define-quick-help-command (name arglist &rest body) - (declare (indent 2)) - `(progn - (defun ,name ,arglist ,@body) - (put ',name 'ac-quick-help-command t))) - -(ac-define-quick-help-command ac-quick-help-scroll-down () - (interactive) - (when ac-quick-help - (popup-scroll-down ac-quick-help))) - -(ac-define-quick-help-command ac-quick-help-scroll-up () - (interactive) - (when ac-quick-help - (popup-scroll-up ac-quick-help))) - - - -;;;; Auto completion isearch - -(defun ac-isearch-callback (list) - (setq ac-dwim-enable (eq (length list) 1))) - -(defun ac-isearch () - (interactive) - (when (ac-menu-live-p) - (ac-cancel-show-menu-timer) - (ac-show-menu) - (if ac-use-quick-help - (let ((popup-menu-show-quick-help-function - (if (ac-quick-help-use-pos-tip-p) - 'ac-pos-tip-show-quick-help - 'popup-menu-show-quick-help))) - (popup-isearch ac-menu - :callback 'ac-isearch-callback - :help-delay ac-quick-help-delay)) - (popup-isearch ac-menu :callback 'ac-isearch-callback)))) - - - -;;;; Auto completion commands - -(defun* auto-complete-1 (&key sources (triggered 'command)) - (let ((menu-live (ac-menu-live-p)) - (inline-live (ac-inline-live-p)) - started) - (ac-abort) - (let ((ac-sources (or sources ac-sources))) - (if (or ac-show-menu-immediately-on-auto-complete - inline-live) - (setq ac-show-menu t)) - (setq started (ac-start :triggered triggered))) - (when (ac-update-greedy t) - ;; TODO Not to cause inline completion to be disrupted. - (if (ac-inline-live-p) - (ac-inline-hide)) - ;; Not to expand when it is first time to complete - (when (and (or (and (not ac-expand-on-auto-complete) - (> (length ac-candidates) 1) - (not menu-live)) - (not (let ((ac-common-part ac-whole-common-part)) - (ac-expand-common)))) - ac-use-fuzzy - (null ac-candidates)) - (ac-fuzzy-complete))) - started)) - -;;;###autoload -(defun auto-complete (&optional sources) - "Start auto-completion at current point." - (interactive) - (auto-complete-1 :sources sources)) - -(defun ac-fuzzy-complete () - "Start fuzzy completion at current point." - (interactive) - (if (not (require 'fuzzy nil t)) - (message "Please install fuzzy.el if you use fuzzy completion") - (unless (ac-menu-live-p) - (ac-start)) - (let ((ac-match-function 'fuzzy-all-completions)) - (unless ac-cursor-color - (setq ac-cursor-color (frame-parameter (selected-frame) 'cursor-color))) - (if ac-fuzzy-cursor-color - (set-cursor-color ac-fuzzy-cursor-color)) - (setq ac-show-menu t) - (setq ac-fuzzy-enable t) - (setq ac-triggered nil) - (ac-update t))) - t) - -(defun ac-next () - "Select next candidate." - (interactive) - (when (ac-menu-live-p) - (when (popup-hidden-p ac-menu) - (ac-show-menu)) - (popup-next ac-menu) - (if (eq this-command 'ac-next) - (setq ac-dwim-enable t)))) - -(defun ac-previous () - "Select previous candidate." - (interactive) - (when (ac-menu-live-p) - (when (popup-hidden-p ac-menu) - (ac-show-menu)) - (popup-previous ac-menu) - (if (eq this-command 'ac-previous) - (setq ac-dwim-enable t)))) - -(defun ac-expand () - "Try expand, and if expanded twice, select next candidate." - (interactive) - (unless (ac-expand-common) - (let ((string (ac-selected-candidate))) - (when string - (when (equal ac-prefix string) - (ac-next) - (setq string (ac-selected-candidate))) - (ac-expand-string string (eq last-command this-command)) - ;; Do reposition if menu at long line - (if (and (> (popup-direction ac-menu) 0) - (ac-menu-at-wrapper-line-p)) - (ac-reposition)) - (setq ac-show-menu t) - string)))) - -(defun ac-expand-common () - "Try to expand meaningful common part." - (interactive) - (if (and ac-dwim ac-dwim-enable) - (ac-complete) - (when (and (ac-inline-live-p) - ac-common-part) - (ac-inline-hide) - (ac-expand-string ac-common-part (eq last-command this-command)) - (setq ac-common-part nil) - t))) - -(defun ac-complete-1 (candidate) - (let ((action (popup-item-property candidate 'action)) - (fallback nil)) - (when candidate - (unless (ac-expand-string candidate) - (setq fallback t)) - ;; Remember to show help later - (when (and ac-point candidate) - (unless ac-last-completion - (setq ac-last-completion (cons (make-marker) nil))) - (set-marker (car ac-last-completion) ac-point ac-buffer) - (setcdr ac-last-completion candidate))) - (ac-abort) - (cond - (action - (funcall action)) - (fallback - (ac-fallback-command))) - candidate)) - -(defun ac-complete () - "Try complete." - (interactive) - (ac-complete-1 (ac-selected-candidate))) - -(defun* ac-start (&key - requires - force-init - (triggered (or ac-triggered t))) - "Start completion." - (interactive) - (if (not auto-complete-mode) - (message "auto-complete-mode is not enabled") - (let* ((info (ac-prefix requires ac-ignoring-prefix-def)) - (prefix-def (nth 0 info)) - (point (nth 1 info)) - (sources (nth 2 info)) - prefix - (init (or force-init (not (eq ac-point point))))) - (if (or (null point) - (progn - (setq prefix (buffer-substring-no-properties point (point))) - (and (not (eq triggered 'command)) - (ac-stop-word-p prefix)))) - (prog1 nil - (ac-abort)) - (unless ac-cursor-color - (setq ac-cursor-color (frame-parameter (selected-frame) 'cursor-color))) - (setq ac-show-menu (or ac-show-menu (if (eq ac-auto-show-menu t) t)) - ac-current-sources sources - ac-buffer (current-buffer) - ac-point point - ac-prefix prefix - ac-limit ac-candidate-limit - ac-triggered triggered - ac-current-prefix-def prefix-def) - (when (or init (null ac-prefix-overlay)) - (ac-init)) - (ac-set-timer) - (ac-set-show-menu-timer) - (ac-set-quick-help-timer) - (ac-put-prefix-overlay) - t)))) - -(defun ac-stop () - "Stop completiong." - (interactive) - (setq ac-selected-candidate nil) - (ac-abort)) - -(defun ac-ignore (&rest ignore) - "Same as `ignore'." - (interactive)) - -(defun ac-mouse-1 (event) - (interactive "e") - (popup-awhen (popup-menu-item-of-mouse-event event) - (ac-complete-1 it))) - -(defun ac-mouse-4 (event) - (interactive "e") - (ac-previous)) - -(defun ac-mouse-5 (event) - (interactive "e") - (ac-next)) - -(defun ac-trigger-key-command (&optional force) - (interactive "P") - (let (started) - (when (or force (ac-trigger-command-p last-command)) - (setq started (auto-complete-1 :triggered 'trigger-key))) - (unless started - (ac-fallback-command 'ac-trigger-key-command)))) - - - -;;;; Basic cache facility - -(defvar ac-clear-variables-every-minute-timer nil) -(defvar ac-clear-variables-after-save nil) -(defvar ac-clear-variables-every-minute nil) -(defvar ac-minutes-counter 0) - -(defun ac-clear-variable-after-save (variable &optional pred) - (add-to-list 'ac-clear-variables-after-save (cons variable pred))) - -(defun ac-clear-variables-after-save () - (dolist (pair ac-clear-variables-after-save) - (if (or (null (cdr pair)) - (funcall (cdr pair))) - (set (car pair) nil)))) - -(defun ac-clear-variable-every-minutes (variable minutes) - (add-to-list 'ac-clear-variables-every-minute (cons variable minutes))) - -(defun ac-clear-variable-every-minute (variable) - (ac-clear-variable-every-minutes variable 1)) - -(defun ac-clear-variable-every-10-minutes (variable) - (ac-clear-variable-every-minutes variable 10)) - -(defun ac-clear-variables-every-minute () - (incf ac-minutes-counter) - (dolist (pair ac-clear-variables-every-minute) - (if (eq (% ac-minutes-counter (cdr pair)) 0) - (set (car pair) nil)))) - - - -;;;; Auto complete mode - -(defun ac-cursor-on-diable-face-p (&optional point) - (memq (get-text-property (or point (point)) 'face) ac-disable-faces)) - -(defun ac-trigger-command-p (command) - "Return non-nil if `COMMAND' is a trigger command." - (and (symbolp command) - (not (memq command ac-non-trigger-commands)) - (or (memq command ac-trigger-commands) - (string-match "self-insert-command" (symbol-name command)) - (string-match "electric" (symbol-name command))))) - -(defun ac-fallback-key-sequence () - (setq unread-command-events - (append (this-single-command-raw-keys) - unread-command-events)) - (read-key-sequence-vector "")) - -(defun ac-fallback-command (&optional except-command) - (let* ((auto-complete-mode nil) - (keys (ac-fallback-key-sequence)) - (command (and keys (key-binding keys)))) - (when (and (commandp command) - (not (eq command except-command))) - (setq this-command command) - (call-interactively command)))) - -(defun ac-compatible-package-command-p (command) - "Return non-nil if `COMMAND' is compatible with auto-complete." - (and (symbolp command) - (string-match ac-compatible-packages-regexp (symbol-name command)))) - -(defun ac-handle-pre-command () - (condition-case var - (if (or (setq ac-triggered (and (not ac-fuzzy-enable) ; ignore key storkes in fuzzy mode - (or (eq this-command 'auto-complete) ; special case - (ac-trigger-command-p this-command) - (and ac-completing - (memq this-command ac-trigger-commands-on-completing))) - (not (ac-cursor-on-diable-face-p)) - (or ac-triggered t))) - (ac-compatible-package-command-p this-command)) - (progn - (if (or (not (symbolp this-command)) - (not (get this-command 'ac-quick-help-command))) - (ac-remove-quick-help)) - ;; Not to cause inline completion to be disrupted. - (ac-inline-hide)) - (ac-abort)) - (error (ac-error var)))) - -(defun ac-handle-post-command () - (condition-case var - (when (and ac-triggered - (or ac-auto-start - ac-completing) - (not isearch-mode)) - (setq ac-last-point (point)) - (ac-start :requires (unless ac-completing ac-auto-start)) - (unless ac-disable-inline - (ac-inline-update))) - (error (ac-error var)))) - -(defvar ac-flycheck-poll-completion-end-timer nil - "Timer to poll end of completion.") - -(defun ac-syntax-checker-workaround () - (if ac-stop-flymake-on-completing - (progn - (make-local-variable 'ac-flycheck-poll-completion-end-timer) - (when (require 'flymake nil t) - (defadvice flymake-on-timer-event (around ac-flymake-stop-advice activate) - (unless ac-completing - ad-do-it))) - (when (require 'flycheck nil t) - (defadvice flycheck-handle-idle-change (around ac-flycheck-stop-advice activate) - (if ac-completing - (setq ac-flycheck-poll-completion-end-timer - (run-at-time ac-flycheck-poll-completion-end-interval - nil - #'flycheck-handle-idle-change)) - ad-do-it)))) - (when (featurep 'flymake) - (ad-disable-advice 'flymake-on-timer-event 'around 'ac-flymake-stop-advice)) - (when (featurep 'flycheck) - (ad-disable-advice 'flycheck-handle-idle-change 'around 'ac-flycheck-stop-advice)))) - -(defun ac-setup () - (if ac-trigger-key - (ac-set-trigger-key ac-trigger-key)) - (if ac-use-comphist - (ac-comphist-init)) - (unless ac-clear-variables-every-minute-timer - (setq ac-clear-variables-every-minute-timer (run-with-timer 60 60 'ac-clear-variables-every-minute))) - (ac-syntax-checker-workaround)) - -;;;###autoload -(define-minor-mode auto-complete-mode - "AutoComplete mode" - :lighter " AC" - :keymap ac-mode-map - :group 'auto-complete - (if auto-complete-mode - (progn - (ac-setup) - (add-hook 'pre-command-hook 'ac-handle-pre-command nil t) - (add-hook 'post-command-hook 'ac-handle-post-command nil t) - (add-hook 'after-save-hook 'ac-clear-variables-after-save nil t) - (run-hooks 'auto-complete-mode-hook)) - (remove-hook 'pre-command-hook 'ac-handle-pre-command t) - (remove-hook 'post-command-hook 'ac-handle-post-command t) - (remove-hook 'after-save-hook 'ac-clear-variables-after-save t) - (ac-abort))) - -(defun auto-complete-mode-maybe () - "What buffer `auto-complete-mode' prefers." - (if (and (not (minibufferp (current-buffer))) - (memq major-mode ac-modes)) - (auto-complete-mode 1))) - -;;;###autoload -(define-global-minor-mode global-auto-complete-mode - auto-complete-mode auto-complete-mode-maybe - :group 'auto-complete) - - - -;;;; Compatibilities with other extensions - -(defun ac-flyspell-workaround () - "Flyspell uses `sit-for' for delaying its process. Unfortunatelly, -it stops auto completion which is trigger with `run-with-idle-timer'. -This workaround avoid flyspell processes when auto completion is being started." - (interactive) - (defadvice flyspell-post-command-hook (around ac-flyspell-workaround activate) - (unless ac-triggered - ad-do-it))) - -(defun ac-linum-workaround () - "linum-mode tries to display the line numbers even for the -completion menu. This workaround stops that annoying behavior." - (interactive) - (defadvice linum-update (around ac-linum-update-workaround activate) - (unless ac-completing - ad-do-it))) - - - -;;;; Standard sources - -(defmacro ac-define-source (name source) - "Source definition macro. It defines a complete command also." - (declare (indent 1)) - `(progn - (defvar ,(intern (format "ac-source-%s" name))) - ;; Use `setq' to reset ac-source-NAME every time - ;; `ac-define-source' is called. This is useful, for example - ;; when evaluating `ac-define-source' using C-M-x (`eval-defun'). - (setq ,(intern (format "ac-source-%s" name)) ,source) - (defun ,(intern (format "ac-complete-%s" name)) () - (interactive) - (auto-complete '(,(intern (format "ac-source-%s" name))))))) - -;; Words in buffer source -(defvar ac-word-index nil) - -(defun ac-candidate-words-in-buffer (point prefix limit) - (let ((i 0) - candidate - candidates - (regexp (concat "\\_<" (regexp-quote prefix) "\\(\\sw\\|\\s_\\)+\\_>"))) - (save-excursion - ;; Search backward - (goto-char point) - (while (and (or (not (integerp limit)) (< i limit)) - (re-search-backward regexp nil t)) - (setq candidate (match-string-no-properties 0)) - (unless (member candidate candidates) - (push candidate candidates) - (incf i))) - ;; Search backward - (goto-char (+ point (length prefix))) - (while (and (or (not (integerp limit)) (< i limit)) - (re-search-forward regexp nil t)) - (setq candidate (match-string-no-properties 0)) - (unless (member candidate candidates) - (push candidate candidates) - (incf i))) - (nreverse candidates)))) - -(defun ac-incremental-update-word-index () - (unless (local-variable-p 'ac-word-index) - (make-local-variable 'ac-word-index)) - (if (null ac-word-index) - (setq ac-word-index (cons nil nil))) - ;; Mark incomplete - (if (car ac-word-index) - (setcar ac-word-index nil)) - (let ((index (cdr ac-word-index)) - (words (ac-candidate-words-in-buffer ac-point ac-prefix (or (and (integerp ac-limit) ac-limit) 10)))) - (dolist (word words) - (unless (member word index) - (push word index) - (setcdr ac-word-index index))))) - -(defun ac-update-word-index-1 () - (unless (local-variable-p 'ac-word-index) - (make-local-variable 'ac-word-index)) - (when (and (not (car ac-word-index)) - (< (buffer-size) 1048576)) - ;; Complete index - (setq ac-word-index - (cons t - (split-string (buffer-substring-no-properties (point-min) (point-max)) - "\\(?:^\\|\\_>\\).*?\\(?:\\_<\\|$\\)"))))) - -(defun ac-update-word-index () - (dolist (buffer (buffer-list)) - (when (or ac-fuzzy-enable - (not (eq buffer (current-buffer)))) - (with-current-buffer buffer - (ac-update-word-index-1))))) - -(defun ac-word-candidates (&optional buffer-pred) - (loop initially (unless ac-fuzzy-enable (ac-incremental-update-word-index)) - for buffer in (buffer-list) - if (and (or (not (integerp ac-limit)) (< (length candidates) ac-limit)) - (if buffer-pred (funcall buffer-pred buffer) t)) - append (funcall ac-match-function - ac-prefix - (and (local-variable-p 'ac-word-index buffer) - (cdr (buffer-local-value 'ac-word-index buffer)))) - into candidates - finally return candidates)) - -(ac-define-source words-in-buffer - '((candidates . ac-word-candidates))) - -(ac-define-source words-in-all-buffer - '((init . ac-update-word-index) - (candidates . ac-word-candidates))) - -(ac-define-source words-in-same-mode-buffers - '((init . ac-update-word-index) - (candidates . (ac-word-candidates - (lambda (buffer) - (derived-mode-p (buffer-local-value 'major-mode buffer))))))) - -;; Lisp symbols source -(defvar ac-symbols-cache nil) -(ac-clear-variable-every-10-minutes 'ac-symbols-cache) - -(defun ac-symbol-file (symbol type) - (if (fboundp 'find-lisp-object-file-name) - (find-lisp-object-file-name symbol type) - (let ((file-name (with-no-warnings - (describe-simplify-lib-file-name - (symbol-file symbol type))))) - (when (equal file-name "loaddefs.el") - ;; Find the real def site of the preloaded object. - (let ((location (condition-case nil - (if (eq type 'defun) - (find-function-search-for-symbol symbol nil - "loaddefs.el") - (find-variable-noselect symbol file-name)) - (error nil)))) - (when location - (with-current-buffer (car location) - (when (cdr location) - (goto-char (cdr location))) - (when (re-search-backward - "^;;; Generated autoloads from \\(.*\\)" nil t) - (setq file-name (match-string 1))))))) - (if (and (null file-name) - (or (eq type 'defun) - (integerp (get symbol 'variable-documentation)))) - ;; It's a object not defined in Elisp but in C. - (if (get-buffer " *DOC*") - (if (eq type 'defun) - (help-C-file-name (symbol-function symbol) 'subr) - (help-C-file-name symbol 'var)) - 'C-source) - file-name)))) - -(defun ac-symbol-documentation (symbol) - (if (stringp symbol) - (setq symbol (intern-soft symbol))) - (ignore-errors - (with-temp-buffer - (let ((standard-output (current-buffer))) - (prin1 symbol) - (princ " is ") - (cond - ((fboundp symbol) - ;; import help-xref-following - (require 'help-mode) - (let ((help-xref-following t) - (major-mode 'help-mode)) ; avoid error in Emacs 24 - (describe-function-1 symbol)) - (buffer-string)) - ((boundp symbol) - (let ((file-name (ac-symbol-file symbol 'defvar))) - (princ "a variable") - (when file-name - (princ " defined in `") - (princ (if (eq file-name 'C-source) - "C source code" - (file-name-nondirectory file-name)))) - (princ "'.\n\n") - (princ (or (documentation-property symbol 'variable-documentation t) - "Not documented.")) - (buffer-string))) - ((facep symbol) - (let ((file-name (ac-symbol-file symbol 'defface))) - (princ "a face") - (when file-name - (princ " defined in `") - (princ (if (eq file-name 'C-source) - "C source code" - (file-name-nondirectory file-name)))) - (princ "'.\n\n") - (princ (or (documentation-property symbol 'face-documentation t) - "Not documented.")) - (buffer-string))) - (t - (let ((doc (documentation-property symbol 'group-documentation t))) - (when doc - (princ "a group.\n\n") - (princ doc) - (buffer-string))))))))) - -(defun ac-symbol-candidates () - (or ac-symbols-cache - (setq ac-symbols-cache - (loop for x being the symbols - if (or (fboundp x) - (boundp x) - (symbol-plist x)) - collect (symbol-name x))))) - -(ac-define-source symbols - '((candidates . ac-symbol-candidates) - (document . ac-symbol-documentation) - (symbol . "s") - (cache))) - -;; Lisp functions source -(defvar ac-functions-cache nil) -(ac-clear-variable-every-10-minutes 'ac-functions-cache) - -(defun ac-function-candidates () - (or ac-functions-cache - (setq ac-functions-cache - (loop for x being the symbols - if (fboundp x) - collect (symbol-name x))))) - -(ac-define-source functions - '((candidates . ac-function-candidates) - (document . ac-symbol-documentation) - (symbol . "f") - (prefix . "(\\(\\(?:\\sw\\|\\s_\\)+\\)") - (cache))) - -;; Lisp variables source -(defvar ac-variables-cache nil) -(ac-clear-variable-every-10-minutes 'ac-variables-cache) - -(defun ac-variable-candidates () - (or ac-variables-cache - (setq ac-variables-cache - (loop for x being the symbols - if (boundp x) - collect (symbol-name x))))) - -(ac-define-source variables - '((candidates . ac-variable-candidates) - (document . ac-symbol-documentation) - (symbol . "v") - (cache))) - -;; Lisp features source -(defvar ac-emacs-lisp-features nil) -(ac-clear-variable-every-10-minutes 'ac-emacs-lisp-features) - -(defun ac-emacs-lisp-feature-candidates () - (or ac-emacs-lisp-features - (if (fboundp 'find-library-suffixes) - (let ((suffix (concat (regexp-opt (find-library-suffixes) t) "\\'"))) - (setq ac-emacs-lisp-features - (append (mapcar 'prin1-to-string features) - (loop for dir in load-path - if (file-directory-p dir) - append (loop for file in (directory-files dir) - if (string-match suffix file) - collect (substring file 0 (match-beginning 0)))))))))) - -(ac-define-source features - '((depends find-func) - (candidates . ac-emacs-lisp-feature-candidates) - (prefix . "require +'\\(\\(?:\\sw\\|\\s_\\)*\\)") - (requires . 0))) - -(defvaralias 'ac-source-emacs-lisp-features 'ac-source-features) - -;; Abbrev source -(ac-define-source abbrev - '((candidates . (mapcar 'popup-x-to-string (append (vconcat local-abbrev-table global-abbrev-table) nil))) - (action . expand-abbrev) - (symbol . "a") - (cache))) - -;; Files in current directory source -(ac-define-source files-in-current-dir - '((candidates . (directory-files default-directory)) - (cache))) - -;; Filename source -(defvar ac-filename-cache nil) - -(defun ac-filename-candidate () - (let (file-name-handler-alist) - (unless (or (and comment-start-skip - (string-match comment-start-skip ac-prefix)) - (file-regular-p ac-prefix)) - (ignore-errors - (loop with dir = (file-name-directory ac-prefix) - with files = (or (assoc-default dir ac-filename-cache) - (let ((files (directory-files dir nil "^[^.]"))) - (push (cons dir files) ac-filename-cache) - files)) - for file in files - for path = (concat dir file) - collect (if (file-directory-p path) - (concat path "/") - path)))))) - -(ac-define-source filename - '((init . (setq ac-filename-cache nil)) - (candidates . ac-filename-candidate) - (prefix . valid-file) - (requires . 0) - (action . ac-start) - (limit . nil))) - -;; Dictionary source -(ac-define-source dictionary - '((candidates . ac-buffer-dictionary) - (symbol . "d"))) - -(provide 'auto-complete) -;;; auto-complete.el ends here diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/c++-mode b/emacs.d/elpa/auto-complete-20140824.1658/dict/c++-mode deleted file mode 100644 index 2579e9f..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/dict/c++-mode +++ /dev/null @@ -1,84 +0,0 @@ -alignas -alignof -and -and_eq -asm -auto -bitand -bitor -bool -break -case -catch -char -char16_t -char32_t -class -compl -const -const_cast -constexpr -continue -decltype -default -delete -do -double -dynamic_cast -else -enum -explicit -export -extern -false -float -for -friend -goto -if -inline -int -long -mutable -namespace -new -noexcept -not -not_eq -nullptr -operator -or -or_eq -private -protected -public -register -reinterpret_cast -return -short -signed -sizeof -static -static_assert -static_cast -struct -switch -template -this -thread_local -throw -true -try -typedef -typeid -typename -union -unsigned -using -virtual -void -volatile -wchar_t -while -xor -xor_eq diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/c-mode b/emacs.d/elpa/auto-complete-20140824.1658/dict/c-mode deleted file mode 100644 index ec262c7..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/dict/c-mode +++ /dev/null @@ -1,44 +0,0 @@ -auto -_Alignas -_Alignof -_Atomic -_Bool -break -case -char -_Complex -const -continue -default -do -double -else -enum -extern -float -for -goto -_Generic -if -_Imaginary -inline -int -long -_Noreturn -register -restrict -return -short -signed -sizeof -static -struct -switch -_Static_assert -typedef -_Thread_local -union -unsigned -void -volatile -while diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/css-mode b/emacs.d/elpa/auto-complete-20140824.1658/dict/css-mode deleted file mode 100644 index 6ab36ec..0000000 --- a/emacs.d/elpa/auto-complete-20140824.1658/dict/css-mode +++ /dev/null @@ -1,874 +0,0 @@ -!important -@font-face -@font-feature-values -@keyframes -ActiveBorder -ActiveCaption -Alpha -AppWorkspace -Background -Barn -BasicImage -Blinds -Blur -ButtonFace -ButtonHighlight -ButtonShadow -ButtonText -CaptionText -CheckerBoard -Chroma -Compositor -CradientWipe -DXImageTransform -DropShadow -Emboss -Engrave -Fade -FlipH -FlipV -Glow -Gray -GrayText -Highlight -HighlightText -Hz -ICMFilter -InactiveBorder -InactiveCaption -InactiveCaptionText -InfoBackground -InfoText -Inset -Invert -Iris -Light -MaskFilter -Matrix -Menu -MenuText -Microsoft -MotionBlur -Pixelate -RadialWipe -RandomBars -RandomDissolve -RevealTrans -Scrollbar -Shadow -Slide -Spiral -Stretch -Strips -ThreeDDarkShadow -ThreeDFace -ThreeDHighlight -ThreeDLightShadow -ThreeDShadow -Wave -Wheel -Window -WindowFrame -WindowText -Xray -Zigzag -_azimuth -_background -_background-position-x -_background-position-y -_border -_bottom -_caption -_clear -_clip -_color -_content -_counter -_cue -_cursor -_direction -_display -_elevation -_empty -_filter -_filter:progid:DXImageTransform.Microsoft -_float -_font -_height -_ime -_ime-mode -_layout -_layout-flow -_layout-grid -_layout-grid-char -_layout-grid-line -_layout-grid-mode -_layout-grid-type -_left -_letter -_line -_line-break -_list -_margin -_orphans -_outline -_overflow -_overflow-x -_overflow-y -_padding -_page -_pause -_pitch -_play -_position -_quotes -_richness -_right -_ruby -_ruby-align -_ruby-overhang -_ruby-position -_scrollbar -_scrollbar-3dlight-color -_scrollbar-arrow-color -_scrollbar-base-color -_scrollbar-darkshadow-color -_scrollbar-face-color -_scrollbar-highlight-color -_scrollbar-track-color -_speak -_speech -_stress -_table -_text -_text-align-last -_text-autospace -_text-justify -_text-kashida-space -_text-overflow -_text-underline-position -_top -_unicode -_vertical -_visibility -_voice -_volume -_white -_widows -_width -_word -_word-break -_word-wrap -_writing -_writing-mode -_z -_zoom -above -active -adjust -after -aliceblue -align -align-content -align-items -align-self -always -animation -animation-delay -animation-direction -animation-duration -animation-fill-mode -animation-iteration-count -animation-name -animation-play-state -animation-timing-function -antiquewhite -aqua -aquamarine -armenian -arrow -attachment -auto -autospace -avoid -azimuth -azure -backface-visibility -background -background-attachment -background-clip -background-color -background-image -background-origin -background-position -background-repeat -background-size -bar -base -baseline -before -behind -beige -below -bidi -bidi-override -bisque -black -blanchedalmond -blink -block -blue -blueviolet -bold -bolder -border -border-bottom -border-bottom-color -border-bottom-left-radius -border-bottom-right-radius -border-bottom-style -border-bottom-width -border-collapse -border-color -border-image -border-image-outset -border-image-repeat -border-image-slice -border-image-source -border-image-width -border-left -border-left-color -border-left-style -border-left-width -border-radius -border-right -border-right-color -border-right-style -border-right-width -border-spacing -border-style -border-top -border-top-color -border-top-left-radius -border-top-right-radius -border-top-style -border-top-width -border-width -both -bottom -box -box-decoration-break -box-shadow -box-sizing -break -break-after -break-before -break-inside -brown -burlwood -cadetblue -capitalize -caps -caption -caption-side -cell -cells -center -center-left -center-right -char -chartreuse -chocolate -circle -cjk -cjk-ideographic -clear -clip -close -close-quote -cm -code -collapse -color -column -column-count -column-fill -column-gap -column-rule -column-rule-color -column-rule-style -column-rule-width -column-span -column-width -columns -compact -condensed -content -continuous -coral -cornflowerblue -cornsilk -counter -counter-increment -counter-reset -crimson -crop -cross -crosshair -cue -cue-after -cue-before -cursive -cursor -cyan -darkblue -darkcyan -darkgoldenrod -darkgray -darkgreen -darkkhaki -darkmagenta -darkolivegreen -darkorange -darkorchid -darkred -darksalmon -darkseagreen -darkshadow -darkslateblue -darkslategray -darkturquoise -darkviolet -dashed -decimal -decimal-leading-zero -decoration -deeppink -deepskyblue -default -deg -digits -dimgray -direction -disc -display -dodgerblue -dotted -double -during -e -e-resize -elevation -em -embed -empty -empty-cells -ex -expanded -extra -extra-condensed -extra-expanded -face -family -fantasy -far -far-left -far-right -fast -faster -filter -firebrick -first -first-child -first-letter -first-line -fixed -flex -flex-basis -flex-direction -flex-flow -flex-grow -flex-shrink -flex-wrap -float -floralwhite -flow -focus -font -font-family -font-feature-setting -font-kerning -font-language-override -font-size -font-size-adjust -font-stretch -font-style -font-synthesis -font-variant -font-variant-alternates -font-variant-caps -font-variant-east-asian -font-variant-ligatures -font-variant-numeric -font-variant-position -font-weight -footer -forestgreen -fuchsia -gainsboro -georgian -ghostwhite -gold -goldenrod -gray -greek -green -greenyellow -grid -groove -group -hanging-punctuation -header -hebrew -height -help -hidden -hide -high -higher -hiragana -hiragana-iroha -honeydew -hotpink -hover -hyphens -icon -ideographic -image -image-orientation -image-rendering -image-resolution -ime-mode -in -increment -indent -index -indianred -indigo -inherit -inline -inline-block -inline-table -inset -inside -iroha -italic -item -ivory -justify -justify-content -kHz -kashida -katakana -katakana-iroha -khaki -landscape -lang() -large -larger -last -latin -lavender -lavenderblush -lawngreen -layout -leading -left -left-side -leftwards -lenonchiffon -letter -letter-spacing -level -lightblue -lightcoral -lightcyan -lighter -lightgoldenrodyellow -lightgray -lightgreen -lightgrey -lightpink -lightsalmon -lightseagreen -lightskyblue -lightslategray -lightsteelblue -lightyellow -lime -limegreen -line -line-break -line-height -line-through -linen -link -list -list-item -list-style -list-style-image -list-style-position -list-style-type -loud -low -lower -lower-alpha -lower-greek -lower-latin -lower-roman -lowercase -ltr -magenta -margin -margin-bottom -margin-left -margin-right -margin-top -mark -mark-after -mark-before -marker -marker-offset -marks -maroon -marquee-direction -marquee-play-count -marquee-speed -marquee-style -mask -mask-type -max -max-height -max-width -medium -mediumaquamarine -mediumblue -mediumorchid -mediumpurple -mediumseagreen -mediumslateblue -mediumspringgreen -mediumturquoise -mediumvioletred -menu -message -message-box -middle -midnightblue -min -min-height -min-width -mintcream -mistyrose -mix -mm -moccasin -mode -monospace -move -ms -n -n-resize -naby -narrower -nav-down -nav-index -nav-left -nav-right -nav-up -navajowhite -ne -ne-resize -no -no-close-quote -no-open-quote -no-repeat -none -normal -nowrap -number -numeral -nw -nw-resize -object-fit -object-position -oblique -offset -oldlace -olive -olivedrab -once -opacity -open -open-quote -orange -orangered -orchid -order -orphans -out -outline -outline-color -outline-offset -outline-style -outline-width -outset -outside -overflow -overflow-wrap -overflow-x -overflow-y -overhang -overline -override -padding -padding-bottom -padding-left -padding-right -padding-top -page -page-break-after -page-break-before -page-break-inside -palegoldenrod -palegreen -paleturquoise -palevioletred -papayawhip -pause -pause-after -pause-before -pc -peachpuff -perspective -perspective-origin -peru -phonemes -pink -pitch -pitch-range -play -play-during -plum -pointer -portarait -position -powderblue -pre -pre-line -pre-wrap -progid -progress -pt -punctuation -purple -px -quote -quotes -rad -range -rate -red -relative -repeat -repeat-x -repeat-y -reset -resize -rest -rest-after -rest-before -richness -ridge -right -right-side -rightwards -roman -rosybrown -row -royalblue -rtl -run -run-in -s -s-resize -saddlebrown -salmon -sandybrown -sans-serif -scroll -se -se-resize -seagreen -seashell -semi -semi-condensed -semi-expanded -separate -serif -shadow -show -side -sienna -silent -silever -silver -size -skyblue -slateblue -slategray -slow -slower -small -small-caps -small-caption -smaller -snow -soft -solid -space -spacing -speak -speak-header -speak-numeral -speak-punctuation -specific -specific-voice -speech -speech-rate -spell -spell-out -springgreen -square -static -status -status-bar -steelblue -stress -stretch -style -sub -super -sw -sw-resize -tab-size -table -table-caption -table-cell -table-column -table-column-group -table-footer-group -table-header-group -table-layout -table-row -table-row-group -tan -teal -text -text-align -text-align-last -text-bottom -text-combine-horizontal -text-decoration -text-decoration-color -text-decoration-line -text-decoration-style -text-indent -text-justify -text-orientation -text-overflow -text-shadow -text-top -text-transform -text-underline-position -thick -thin -thistle -through -tomato -top -track -transform -transform-origin -transform-style -transition -transition-delay -transition-duration -transition-property -transition-timing-function -transparent -turquoise -type -ultra -ultra-condensed -ultra-expanded -underline -unicode -unicode-bidi -upper -upper-alpha -upper-latin -upper-roman -uppercase -variant -vertical -vertical-align -violet -visibility -visible -visited -voice -voice-balance -voice-duration -voice-family -voice-pitch -voice-pitch-range -voice-rate -voice-stress -voice-volume -volume -w -w-resize -wait -weight -wheat -white -white-space -whitesmoke -wider -widows -width -word -word-break -word-spacing -word-wrap -wrap -writing-mode -x -x-fast -x-high -x-large -x-loud -x-low -x-slow -x-small -x-soft -xx -xx-large -xx-small -y -yellow -yellowgreen -z -z-index -zero diff --git a/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-autoloads.el b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-autoloads.el new file mode 100644 index 0000000..6fa5af7 --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-autoloads.el @@ -0,0 +1,64 @@ +;;; auto-complete-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "auto-complete" "auto-complete.el" (21837 24217 +;;;;;; 0 0)) +;;; Generated autoloads from auto-complete.el + +(autoload 'auto-complete "auto-complete" "\ +Start auto-completion at current point. + +\(fn &optional SOURCES)" t nil) + +(autoload 'auto-complete-mode "auto-complete" "\ +AutoComplete mode + +\(fn &optional ARG)" t nil) + +(defvar global-auto-complete-mode nil "\ +Non-nil if Global-Auto-Complete mode is enabled. +See the command `global-auto-complete-mode' for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `global-auto-complete-mode'.") + +(custom-autoload 'global-auto-complete-mode "auto-complete" nil) + +(autoload 'global-auto-complete-mode "auto-complete" "\ +Toggle Auto-Complete mode in all buffers. +With prefix ARG, enable Global-Auto-Complete mode if ARG is positive; +otherwise, disable it. If called from Lisp, enable the mode if +ARG is omitted or nil. + +Auto-Complete mode is enabled in all buffers where +`auto-complete-mode-maybe' would do it. +See `auto-complete-mode' for more information on Auto-Complete mode. + +\(fn &optional ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "auto-complete-config" "auto-complete-config.el" +;;;;;; (21837 24217 0 0)) +;;; Generated autoloads from auto-complete-config.el + +(autoload 'ac-config-default "auto-complete-config" "\ + + +\(fn)" nil nil) + +;;;*** + +;;;### (autoloads nil nil ("auto-complete-pkg.el") (21837 24217 489567 +;;;;;; 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; auto-complete-autoloads.el ends here diff --git a/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-config.el b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-config.el new file mode 100644 index 0000000..021bdbd --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-config.el @@ -0,0 +1,543 @@ +;;; auto-complete-config.el --- auto-complete additional configuations + +;; Copyright (C) 2009, 2010 Tomohiro Matsuyama + +;; Author: Tomohiro Matsuyama +;; Keywords: convenience +;; Version: 1.5.0 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'cl-lib) +(require 'auto-complete) + + + +;;;; Additional sources + +;; imenu + +(defvar ac-imenu-index nil) + +(ac-clear-variable-every-10-minutes 'ac-imenu-index) + +(defun ac-imenu-candidates () + (cl-loop with i = 0 + with stack = (progn + (unless (local-variable-p 'ac-imenu-index) + (make-local-variable 'ac-imenu-index)) + (or ac-imenu-index + (setq ac-imenu-index + (ignore-errors + (with-no-warnings + (imenu--make-index-alist)))))) + with result + while (and stack (or (not (integerp ac-limit)) + (< i ac-limit))) + for node = (pop stack) + if (consp node) + do + (let ((car (car node)) + (cdr (cdr node))) + (if (consp cdr) + (mapc (lambda (child) + (push child stack)) + cdr) + (when (and (stringp car) + (string-match (concat "^" (regexp-quote ac-prefix)) car)) + ;; Remove extra characters + (if (string-match "^.*\\(()\\|=\\|<>\\)$" car) + (setq car (substring car 0 (match-beginning 1)))) + (push car result) + (cl-incf i)))) + finally return (nreverse result))) + +(ac-define-source imenu + '((depends imenu) + (candidates . ac-imenu-candidates) + (symbol . "s"))) + +;; gtags + +(defface ac-gtags-candidate-face + '((t (:inherit ac-candidate-face :foreground "navy"))) + "Face for gtags candidate" + :group 'auto-complete) + +(defface ac-gtags-selection-face + '((t (:inherit ac-selection-face :background "navy"))) + "Face for the gtags selected candidate." + :group 'auto-complete) + +(defun ac-gtags-candidate () + (ignore-errors + (split-string (shell-command-to-string (format "global -ciq %s" ac-prefix)) "\n"))) + +(ac-define-source gtags + '((candidates . ac-gtags-candidate) + (candidate-face . ac-gtags-candidate-face) + (selection-face . ac-gtags-selection-face) + (requires . 3) + (symbol . "s"))) + +;; yasnippet + +(defface ac-yasnippet-candidate-face + '((t (:inherit ac-candidate-face + :background "sandybrown" :foreground "black"))) + "Face for yasnippet candidate." + :group 'auto-complete) + +(defface ac-yasnippet-selection-face + '((t (:inherit ac-selection-face :background "coral3"))) + "Face for the yasnippet selected candidate." + :group 'auto-complete) + +(defun ac-yasnippet-table-hash (table) + (cond + ((fboundp 'yas/snippet-table-hash) + (yas/snippet-table-hash table)) + ((fboundp 'yas/table-hash) + (yas/table-hash table)))) + +(defun ac-yasnippet-table-parent (table) + (cond + ((fboundp 'yas/snippet-table-parent) + (yas/snippet-table-parent table)) + ((fboundp 'yas/table-parent) + (yas/table-parent table)))) + +(defun ac-yasnippet-candidate-1 (table) + (with-no-warnings + (let ((hashtab (ac-yasnippet-table-hash table)) + (parent (ac-yasnippet-table-parent table)) + candidates) + (maphash (lambda (key value) + (push key candidates)) + hashtab) + (setq candidates (all-completions ac-prefix (nreverse candidates))) + (if parent + (setq candidates + (append candidates (ac-yasnippet-candidate-1 parent)))) + candidates))) + +(defun ac-yasnippet-candidates () + (with-no-warnings + (cond (;; 0.8 onwards + (fboundp 'yas-active-keys) + (all-completions ac-prefix (yas-active-keys))) + (;; >0.6.0 + (fboundp 'yas/get-snippet-tables) + (apply 'append (mapcar 'ac-yasnippet-candidate-1 + (condition-case nil + (yas/get-snippet-tables major-mode) + (wrong-number-of-arguments + (yas/get-snippet-tables))))) + ) + (t + (let ((table + (if (fboundp 'yas/snippet-table) + ;; <0.6.0 + (yas/snippet-table major-mode) + ;; 0.6.0 + (yas/current-snippet-table)))) + (if table + (ac-yasnippet-candidate-1 table))))))) + +(ac-define-source yasnippet + '((depends yasnippet) + (candidates . ac-yasnippet-candidates) + (action . yas/expand) + (candidate-face . ac-yasnippet-candidate-face) + (selection-face . ac-yasnippet-selection-face) + (symbol . "a"))) + +;; semantic + +(defun ac-semantic-candidates (prefix) + (with-no-warnings + (delete "" ; semantic sometimes returns an empty string + (mapcar (lambda (elem) + (cons (semantic-tag-name elem) + (semantic-tag-clone elem))) + (ignore-errors + (or (semantic-analyze-possible-completions + (semantic-analyze-current-context)) + (senator-find-tag-for-completion prefix))))))) + +(defun ac-semantic-doc (symbol) + (with-no-warnings + (let* ((proto (semantic-format-tag-summarize-with-file symbol nil t)) + (doc (semantic-documentation-for-tag symbol)) + (res proto)) + (when doc + (setq res (concat res "\n\n" doc))) + res))) + +(defun ac-semantic-action () + (when (and (boundp 'yas-minor-mode) yas-minor-mode) + (let* ((tag (car (last (oref (semantic-analyze-current-context) prefix)))) + (class (semantic-tag-class tag)) + (args)) + (when (eq class 'function) + (setq args (semantic-tag-function-arguments tag)) + (yas-expand-snippet + (concat "(" + (mapconcat + (lambda (arg) + (let ((arg-type (semantic-format-tag-type arg nil)) + (arg-name (semantic-format-tag-name arg nil))) + (concat "${" + (if (string= arg-name "") + arg-type + (concat arg-type " " arg-name)) + "}"))) + args + ", ") + ")$0")))))) + +(ac-define-source semantic + '((available . (or (require 'semantic-ia nil t) + (require 'semantic/ia nil t))) + (candidates . (ac-semantic-candidates ac-prefix)) + (document . ac-semantic-doc) + (action . ac-semantic-action) + (prefix . cc-member) + (requires . 0) + (symbol . "m"))) + +(ac-define-source semantic-raw + '((available . (or (require 'semantic-ia nil t) + (require 'semantic/ia nil t))) + (candidates . (ac-semantic-candidates ac-prefix)) + (document . ac-semantic-doc) + (action . ac-semantic-action) + (symbol . "s"))) + +;; eclim + +(defun ac-eclim-candidates () + (with-no-warnings + (cl-loop for c in (eclim/java-complete) + collect (nth 1 c)))) + +(ac-define-source eclim + '((candidates . ac-eclim-candidates) + (prefix . c-dot) + (requires . 0) + (symbol . "f"))) + +;; css + +;; Copied from company-css.el +(defconst ac-css-property-alist + ;; see http://www.w3.org/TR/CSS21/propidx.html + '(("azimuth" angle "left-side" "far-left" "left" "center-left" "center" + "center-right" "right" "far-right" "right-side" "behind" "leftwards" + "rightwards") + ("background" background-color background-image background-repeat + background-attachment background-position) + ("background-attachment" "scroll" "fixed") + ("background-color" color "transparent") + ("background-image" uri "none") + ("background-position" percentage length "left" "center" "right" percentage + length "top" "center" "bottom" "left" "center" "right" "top" "center" + "bottom") + ("background-repeat" "repeat" "repeat-x" "repeat-y" "no-repeat") + ("border" border-width border-style border-color) + ("border-bottom" border) + ("border-bottom-color" border-color) + ("border-bottom-style" border-style) + ("border-bottom-width" border-width) + ("border-collapse" "collapse" "separate") + ("border-color" color "transparent") + ("border-left" border) + ("border-left-color" border-color) + ("border-left-style" border-style) + ("border-left-width" border-width) + ("border-right" border) + ("border-right-color" border-color) + ("border-right-style" border-style) + ("border-right-width" border-width) + ("border-spacing" length length) + ("border-style" border-style) + ("border-top" border) + ("border-top-color" border-color) + ("border-top-style" border-style) + ("border-top-width" border-width) + ("border-width" border-width) + ("bottom" length percentage "auto") + ("caption-side" "top" "bottom") + ("clear" "none" "left" "right" "both") + ("clip" shape "auto") + ("color" color) + ("content" "normal" "none" string uri counter "attr()" "open-quote" + "close-quote" "no-open-quote" "no-close-quote") + ("counter-increment" identifier integer "none") + ("counter-reset" identifier integer "none") + ("cue" cue-before cue-after) + ("cue-after" uri "none") + ("cue-before" uri "none") + ("cursor" uri "*" "auto" "crosshair" "default" "pointer" "move" "e-resize" + "ne-resize" "nw-resize" "n-resize" "se-resize" "sw-resize" "s-resize" + "w-resize" "text" "wait" "help" "progress") + ("direction" "ltr" "rtl") + ("display" "inline" "block" "list-item" "run-in" "inline-block" "table" + "inline-table" "table-row-group" "table-header-group" "table-footer-group" + "table-row" "table-column-group" "table-column" "table-cell" + "table-caption" "none") + ("elevation" angle "below" "level" "above" "higher" "lower") + ("empty-cells" "show" "hide") + ("float" "left" "right" "none") + ("font" font-style font-variant font-weight font-size "/" line-height + font-family "caption" "icon" "menu" "message-box" "small-caption" + "status-bar") + ("font-family" family-name generic-family) + ("font-size" absolute-size relative-size length percentage) + ("font-style" "normal" "italic" "oblique") + ("font-variant" "normal" "small-caps") + ("font-weight" "normal" "bold" "bolder" "lighter" "100" "200" "300" "400" + "500" "600" "700" "800" "900") + ("height" length percentage "auto") + ("left" length percentage "auto") + ("letter-spacing" "normal" length) + ("line-height" "normal" number length percentage) + ("list-style" list-style-type list-style-position list-style-image) + ("list-style-image" uri "none") + ("list-style-position" "inside" "outside") + ("list-style-type" "disc" "circle" "square" "decimal" "decimal-leading-zero" + "lower-roman" "upper-roman" "lower-greek" "lower-latin" "upper-latin" + "armenian" "georgian" "lower-alpha" "upper-alpha" "none") + ("margin" margin-width) + ("margin-bottom" margin-width) + ("margin-left" margin-width) + ("margin-right" margin-width) + ("margin-top" margin-width) + ("max-height" length percentage "none") + ("max-width" length percentage "none") + ("min-height" length percentage) + ("min-width" length percentage) + ("orphans" integer) + ("outline" outline-color outline-style outline-width) + ("outline-color" color "invert") + ("outline-style" border-style) + ("outline-width" border-width) + ("overflow" "visible" "hidden" "scroll" "auto") + ("padding" padding-width) + ("padding-bottom" padding-width) + ("padding-left" padding-width) + ("padding-right" padding-width) + ("padding-top" padding-width) + ("page-break-after" "auto" "always" "avoid" "left" "right") + ("page-break-before" "auto" "always" "avoid" "left" "right") + ("page-break-inside" "avoid" "auto") + ("pause" time percentage) + ("pause-after" time percentage) + ("pause-before" time percentage) + ("pitch" frequency "x-low" "low" "medium" "high" "x-high") + ("pitch-range" number) + ("play-during" uri "mix" "repeat" "auto" "none") + ("position" "static" "relative" "absolute" "fixed") + ("quotes" string string "none") + ("richness" number) + ("right" length percentage "auto") + ("speak" "normal" "none" "spell-out") + ("speak-header" "once" "always") + ("speak-numeral" "digits" "continuous") + ("speak-punctuation" "code" "none") + ("speech-rate" number "x-slow" "slow" "medium" "fast" "x-fast" "faster" + "slower") + ("stress" number) + ("table-layout" "auto" "fixed") + ("text-align" "left" "right" "center" "justify") + ("text-decoration" "none" "underline" "overline" "line-through" "blink") + ("text-indent" length percentage) + ("text-transform" "capitalize" "uppercase" "lowercase" "none") + ("top" length percentage "auto") + ("unicode-bidi" "normal" "embed" "bidi-override") + ("vertical-align" "baseline" "sub" "super" "top" "text-top" "middle" + "bottom" "text-bottom" percentage length) + ("visibility" "visible" "hidden" "collapse") + ("voice-family" specific-voice generic-voice "*" specific-voice + generic-voice) + ("volume" number percentage "silent" "x-soft" "soft" "medium" "loud" + "x-loud") + ("white-space" "normal" "pre" "nowrap" "pre-wrap" "pre-line") + ("widows" integer) + ("width" length percentage "auto") + ("word-spacing" "normal" length) + ("z-index" "auto" integer)) + "A list of CSS properties and their possible values.") + +(defconst ac-css-value-classes + '((absolute-size "xx-small" "x-small" "small" "medium" "large" "x-large" + "xx-large") + (border-style "none" "hidden" "dotted" "dashed" "solid" "double" "groove" + "ridge" "inset" "outset") + (color "aqua" "black" "blue" "fuchsia" "gray" "green" "lime" "maroon" "navy" + "olive" "orange" "purple" "red" "silver" "teal" "white" "yellow" + "rgb") + (counter "counter") + (family-name "Courier" "Helvetica" "Times") + (generic-family "serif" "sans-serif" "cursive" "fantasy" "monospace") + (generic-voice "male" "female" "child") + (margin-width "auto") ;; length percentage + (relative-size "larger" "smaller") + (shape "rect") + (uri "url")) + "A list of CSS property value classes and their contents.") + +(defconst ac-css-pseudo-classes + '("active" "after" "before" "first" "first-child" "first-letter" "first-line" + "focus" "hover" "lang" "left" "link" "right" "visited") + "Identifiers for CSS pseudo-elements and pseudo-classes.") + +(defvar ac-css-property nil + "Current editing property.") + +(defun ac-css-prefix () + (when (save-excursion (re-search-backward "\\_<\\(.+?\\)\\_>\\s *:[^;]*\\=" nil t)) + (setq ac-css-property (match-string 1)) + (or (ac-prefix-symbol) (point)))) + +(defun ac-css-property-candidates () + (let ((list (assoc-default ac-css-property ac-css-property-alist))) + (if list + (cl-loop with seen + with value + while (setq value (pop list)) + if (symbolp value) + do (unless (memq value seen) + (push value seen) + (setq list + (append list + (or (assoc-default value ac-css-value-classes) + (assoc-default (symbol-name value) ac-css-property-alist))))) + else collect value) + ac-css-pseudo-classes))) + +(ac-define-source css-property + '((candidates . ac-css-property-candidates) + (prefix . ac-css-prefix) + (requires . 0))) + +;; slime +(ac-define-source slime + '((depends slime) + (candidates . (car (slime-simple-completions ac-prefix))) + (symbol . "s") + (cache))) + +;; ghc-mod +(ac-define-source ghc-mod + '((depends ghc) + (candidates . (ghc-select-completion-symbol)) + (symbol . "s") + (cache))) + + + +;;;; Not maintained sources + +;; ropemacs + +(defvar ac-ropemacs-loaded nil) +(defun ac-ropemacs-require () + (with-no-warnings + (unless ac-ropemacs-loaded + (pymacs-load "ropemacs" "rope-") + (if (boundp 'ropemacs-enable-autoimport) + (setq ropemacs-enable-autoimport t)) + (setq ac-ropemacs-loaded t)))) + +(defun ac-ropemacs-setup () + (ac-ropemacs-require) + ;(setq ac-sources (append (list 'ac-source-ropemacs) ac-sources)) + (setq ac-omni-completion-sources '(("\\." ac-source-ropemacs)))) + +(defun ac-ropemacs-initialize () + (autoload 'pymacs-apply "pymacs") + (autoload 'pymacs-call "pymacs") + (autoload 'pymacs-eval "pymacs" nil t) + (autoload 'pymacs-exec "pymacs" nil t) + (autoload 'pymacs-load "pymacs" nil t) + (add-hook 'python-mode-hook 'ac-ropemacs-setup) + t) + +(defvar ac-ropemacs-completions-cache nil) +(defvar ac-source-ropemacs + '((init + . (lambda () + (setq ac-ropemacs-completions-cache + (mapcar + (lambda (completion) + (concat ac-prefix completion)) + (ignore-errors + (rope-completions)))))) + (candidates . ac-ropemacs-completions-cache))) + +;; rcodetools + +(defvar ac-source-rcodetools + '((init . (lambda () + (require 'rcodetools) + (condition-case x + (save-excursion + (rct-exec-and-eval rct-complete-command-name "--completion-emacs-icicles")) + (error) (setq rct-method-completion-table nil)))) + (candidates . (lambda () + (all-completions + ac-prefix + (mapcar + (lambda (completion) + (replace-regexp-in-string "\t.*$" "" (car completion))) + rct-method-completion-table)))))) + + + +;;;; Default settings + +(defun ac-common-setup () + ;(add-to-list 'ac-sources 'ac-source-filename) + ) + +(defun ac-emacs-lisp-mode-setup () + (setq ac-sources (append '(ac-source-features ac-source-functions ac-source-yasnippet ac-source-variables ac-source-symbols) ac-sources))) + +(defun ac-cc-mode-setup () + (setq ac-sources (append '(ac-source-yasnippet ac-source-gtags) ac-sources))) + +(defun ac-ruby-mode-setup ()) + +(defun ac-css-mode-setup () + (setq ac-sources (append '(ac-source-css-property) ac-sources))) + +;;;###autoload +(defun ac-config-default () + (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) + (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup) + (add-hook 'c-mode-common-hook 'ac-cc-mode-setup) + (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup) + (add-hook 'css-mode-hook 'ac-css-mode-setup) + (add-hook 'auto-complete-mode-hook 'ac-common-setup) + (global-auto-complete-mode t)) + +(provide 'auto-complete-config) +;;; auto-complete-config.el ends here diff --git a/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-pkg.el b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-pkg.el new file mode 100644 index 0000000..235cec1 --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete-pkg.el @@ -0,0 +1,6 @@ +(define-package "auto-complete" "20150408.1132" "Auto Completion for GNU Emacs" + '((popup "0.5.0") + (cl-lib "0.5"))) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/auto-complete-20150408.1132/auto-complete.el b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete.el new file mode 100644 index 0000000..9208e47 --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/auto-complete.el @@ -0,0 +1,2162 @@ +;;; auto-complete.el --- Auto Completion for GNU Emacs + +;; Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Tomohiro Matsuyama + +;; Author: Tomohiro Matsuyama +;; URL: https://github.com/auto-complete/auto-complete +;; Keywords: completion, convenience +;; Version: 1.5.0 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;; +;; This extension provides a way to complete with popup menu like: +;; +;; def-!- +;; +-----------------+ +;; |defun::::::::::::| +;; |defvar | +;; |defmacro | +;; | ... | +;; +-----------------+ +;; +;; You can complete by typing and selecting menu. +;; +;; Entire documents are located in doc/ directory. +;; Take a look for information. +;; +;; Enjoy! + +;;; Code: + + + +(defconst ac-version "1.5.0" + "Version of auto-complete in string format. +Use `version-to-list' to get version component.") + +(defconst ac-version-major (car (version-to-list ac-version)) + "Major version number of auto-complete") + +(defconst ac-version-minor (cadr (version-to-list ac-version)) + "Minor version number of auto-complete") + +(require 'cl-lib) +(require 'popup) + +;;;; Global stuff + +(defun ac-error (&optional var) + "Report an error and disable `auto-complete-mode'." + (ignore-errors + (message "auto-complete error: %s" var) + (auto-complete-mode -1) + var)) + + + +;;;; Customization + +(defgroup auto-complete nil + "Auto completion." + :group 'completion + :prefix "ac-") + +(defcustom ac-delay 0.1 + "Delay to completions will be available." + :type 'float + :group 'auto-complete) + +(defcustom ac-auto-show-menu 0.8 + "Non-nil means completion menu will be automatically shown." + :type '(choice (const :tag "Yes" t) + (const :tag "Never" nil) + (float :tag "Timer")) + :group 'auto-complete) + +(defcustom ac-show-menu-immediately-on-auto-complete t + "Non-nil means menu will be showed immediately on `auto-complete'." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-expand-on-auto-complete t + "Non-nil means expand whole common part on first time `auto-complete'." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-disable-faces '(font-lock-comment-face font-lock-string-face font-lock-doc-face) + "Non-nil means disable automatic completion on specified faces." + :type '(repeat symbol) + :group 'auto-complete) + +(defcustom ac-stop-flymake-on-completing t + "Non-nil means disble flymake temporarily on completing." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-flycheck-poll-completion-end-interval 0.5 + "Polling interval to restart automatically flycheck's checking after completion is end." + :type 'float + :group 'auto-complete) + +(defcustom ac-use-fuzzy (and (locate-library "fuzzy") t) + "Non-nil means use fuzzy matching." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-fuzzy-cursor-color "red" + "Cursor color in fuzzy mode." + :type 'string + :group 'auto-complete) + +(defcustom ac-use-comphist t + "Non-nil means use intelligent completion history." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-comphist-threshold 0.7 + "Percentage of ignoring low scored candidates." + :type 'float + :group 'auto-complete) + +(defcustom ac-comphist-file + (expand-file-name (concat (if (boundp 'user-emacs-directory) + user-emacs-directory + "~/.emacs.d/") + "/ac-comphist.dat")) + "Completion history file name." + :type 'string + :group 'auto-complete) + +(defcustom ac-user-dictionary nil + "User defined dictionary" + :type '(repeat string) + :group 'auto-complete) + +(defcustom ac-dictionary-files '("~/.dict") + "Dictionary files." + :type '(repeat string) + :group 'auto-complete) +(defvaralias 'ac-user-dictionary-files 'ac-dictionary-files) + +(defcustom ac-dictionary-directories + (ignore-errors + (when load-file-name + (let ((installed-dir (file-name-directory load-file-name))) + (cl-loop for name in '("ac-dict" "dict") + for dir = (concat installed-dir name) + if (file-directory-p dir) + collect dir)))) + "Dictionary directories." + :type '(repeat string) + :group 'auto-complete) + +(defcustom ac-use-quick-help t + "Non-nil means use quick help." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-quick-help-delay 1.5 + "Delay to show quick help." + :type 'float + :group 'auto-complete) + +(defcustom ac-menu-height 10 + "Max height of candidate menu." + :type 'integer + :group 'auto-complete) +(defvaralias 'ac-candidate-menu-height 'ac-menu-height) + +(defcustom ac-quick-help-height 20 + "Max height of quick help." + :type 'integer + :group 'auto-complete) + +(defcustom ac-quick-help-prefer-pos-tip t + "Prefer native tooltip with pos-tip than overlay popup for displaying quick help." + :type 'boolean + :group 'auto-complete) +(defvaralias 'ac-quick-help-prefer-x 'ac-quick-help-prefer-pos-tip) + +(defcustom ac-candidate-limit nil + "Limit number of candidates. Non-integer means no limit." + :type 'integer + :group 'auto-complete) +(defvaralias 'ac-candidate-max 'ac-candidate-limit) + +(defcustom ac-modes + '(emacs-lisp-mode lisp-mode lisp-interaction-mode + slime-repl-mode + c-mode cc-mode c++-mode go-mode + java-mode malabar-mode clojure-mode clojurescript-mode scala-mode + scheme-mode + ocaml-mode tuareg-mode coq-mode haskell-mode agda-mode agda2-mode + perl-mode cperl-mode python-mode ruby-mode lua-mode tcl-mode + ecmascript-mode javascript-mode js-mode js2-mode php-mode css-mode less-css-mode + makefile-mode sh-mode fortran-mode f90-mode ada-mode + xml-mode sgml-mode web-mode + ts-mode + sclang-mode + verilog-mode + qml-mode) + "Major modes `auto-complete-mode' can run on." + :type '(repeat symbol) + :group 'auto-complete) + +(defcustom ac-compatible-packages-regexp + "^ac-" + "Regexp to indicate what packages can work with auto-complete." + :type 'string + :group 'auto-complete) + +(defcustom ac-non-trigger-commands + '(*table--cell-self-insert-command + electric-buffer-list) + "Commands that can't be used as triggers of `auto-complete'." + :type '(repeat symbol) + :group 'auto-complete) + +(defcustom ac-trigger-commands + '(self-insert-command) + "Trigger commands that specify whether `auto-complete' should start or not." + :type '(repeat symbol) + :group 'auto-complete) + +(defcustom ac-trigger-commands-on-completing + '(delete-backward-char + backward-delete-char + backward-delete-char-untabify + ;; autopair + autopair-backspace + ;; paredit + paredit-backward-delete + paredit-backward-delete-word) + "Trigger commands that specify whether `auto-complete' should continue or not." + :type '(repeat symbol) + :group 'auto-complete) + +(defcustom ac-trigger-key nil + "Non-nil means `auto-complete' will start by typing this key. +If you specify this TAB, for example, `auto-complete' will start by typing TAB, +and if there is no completions, an original command will be fallbacked." + :type '(choice (const :tag "None" nil) + (string :tag "Key")) + :group 'auto-complete + :set (lambda (symbol value) + (set-default symbol value) + (when (and value + (fboundp 'ac-set-trigger-key)) + (ac-set-trigger-key value)))) + +(defcustom ac-auto-start 2 + "Non-nil means completion will be started automatically. +Positive integer means if a length of a word you entered is larger than the value, +completion will be started automatically. +If you specify `nil', never be started automatically." + :type '(choice (const :tag "Yes" t) + (const :tag "Never" nil) + (integer :tag "Require")) + :group 'auto-complete) + +(defcustom ac-stop-words nil + "List of string to stop completion." + :type '(repeat string) + :group 'auto-complete) +(defvaralias 'ac-ignores 'ac-stop-words) + +(defcustom ac-use-dictionary-as-stop-words t + "Non-nil means a buffer related dictionary will be thought of as stop words." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-ignore-case 'smart + "Non-nil means auto-complete ignores case. +If this value is `smart', auto-complete ignores case only when +a prefix doesn't contain any upper case letters." + :type '(choice (const :tag "Yes" t) + (const :tag "Smart" smart) + (const :tag "No" nil)) + :group 'auto-complete) + +(defcustom ac-dwim t + "Non-nil means `auto-complete' works based on Do What I Mean." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-use-menu-map nil + "Non-nil means a special keymap `ac-menu-map' on completing menu will be used." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-use-overriding-local-map nil + "Non-nil means `overriding-local-map' will be used to hack for overriding key events on auto-completion." + :type 'boolean + :group 'auto-complete) + +(defcustom ac-disable-inline nil + "Non-nil disable inline completion visibility" + :type 'boolean + :group 'auto-complete) + +(defcustom ac-candidate-menu-min 1 + "Number of candidates required to display menu" + :type 'integer + :group 'auto-complete) + +(defcustom ac-max-width nil + "Maximum width for auto-complete menu to have" + :type '(choice (const :tag "No limit" nil) + (const :tag "Character Limit" 25) + (const :tag "Window Ratio Limit" 0.5)) + :group 'auto-complete) + +(defface ac-completion-face + '((t (:foreground "darkgray" :underline t))) + "Face for inline completion" + :group 'auto-complete) + +(defface ac-candidate-face + '((t (:inherit popup-face))) + "Face for candidate." + :group 'auto-complete) + +(defface ac-candidate-mouse-face + '((t (:inherit popup-menu-mouse-face))) + "Mouse face for candidate." + :group 'auto-complete) + +(defface ac-selection-face + '((t (:inherit popup-menu-selection-face))) + "Face for selected candidate." + :group 'auto-complete) + +(defvar auto-complete-mode-hook nil + "Hook for `auto-complete-mode'.") + + + +;;;; Internal variables + +(defvar auto-complete-mode nil + "Dummy variable to suppress compiler warnings.") + +(defvar ac-cursor-color nil + "Old cursor color.") + +(defvar ac-inline nil + "Inline completion instance.") + +(defvar ac-menu nil + "Menu instance.") + +(defvar ac-show-menu nil + "Flag to show menu on timer tick.") + +(defvar ac-last-completion nil + "Cons of prefix marker and selected item of last completion.") + +(defvar ac-quick-help nil + "Quick help instance") + +(defvar ac-completing nil + "Non-nil means `auto-complete-mode' is now working on completion.") + +(defvar ac-buffer nil + "Buffer where auto-complete is started.") + +(defvar ac-point nil + "Start point of prefix.") + +(defvar ac-last-point nil + "Last point of updating pattern.") + +(defvar ac-prefix nil + "Prefix string.") +(defvaralias 'ac-target 'ac-prefix) + +(defvar ac-selected-candidate nil + "Last selected candidate.") + +(defvar ac-common-part nil + "Common part string of meaningful candidates. +If there is no common part, this will be nil.") + +(defvar ac-whole-common-part nil + "Common part string of whole candidates. +If there is no common part, this will be nil.") + +(defvar ac-prefix-overlay nil + "Overlay for prefix string.") + +(defvar ac-timer nil + "Completion idle timer.") + +(defvar ac-show-menu-timer nil + "Show menu idle timer.") + +(defvar ac-quick-help-timer nil + "Quick help idle timer.") + +(defvar ac-triggered nil + "Flag to update.") + +(defvar ac-limit nil + "Limit number of candidates for each sources.") + +(defvar ac-candidates nil + "Current candidates.") + +(defvar ac-candidates-cache nil + "Candidates cache for individual sources.") + +(defvar ac-fuzzy-enable nil + "Non-nil means fuzzy matching is enabled.") + +(defvar ac-dwim-enable nil + "Non-nil means DWIM completion will be allowed.") + +(defvar ac-mode-map (make-sparse-keymap) + "Auto-complete mode map. It is also used for trigger key command. See also `ac-trigger-key'.") + +(defvar ac-completing-map + (let ((map (make-sparse-keymap))) + (define-key map "\t" 'ac-expand) + (define-key map [tab] 'ac-expand) + (define-key map "\r" 'ac-complete) + (define-key map (kbd "M-TAB") 'auto-complete) + + (define-key map "\M-n" 'ac-next) + (define-key map "\M-p" 'ac-previous) + (define-key map [down] 'ac-next) + (define-key map [up] 'ac-previous) + + (define-key map [f1] 'ac-help) + (define-key map [M-f1] 'ac-persist-help) + (define-key map (kbd "C-?") 'ac-help) + (define-key map (kbd "C-M-?") 'ac-persist-help) + + (define-key map [C-down] 'ac-quick-help-scroll-down) + (define-key map [C-up] 'ac-quick-help-scroll-up) + (define-key map "\C-\M-n" 'ac-quick-help-scroll-down) + (define-key map "\C-\M-p" 'ac-quick-help-scroll-up) + + (dotimes (i 9) + (let ((symbol (intern (format "ac-complete-select-%d" (1+ i))))) + (fset symbol + `(lambda () + (interactive) + (when (and (ac-menu-live-p) (popup-select ac-menu ,i)) + (ac-complete)))) + (define-key map (read-kbd-macro (format "M-%s" (1+ i))) symbol))) + + map) + "Keymap for completion.") +(defvaralias 'ac-complete-mode-map 'ac-completing-map) + +(defvar ac-menu-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map ac-completing-map) + (define-key map (kbd "RET") 'ac-complete) + (define-key map "\C-n" 'ac-next) + (define-key map "\C-p" 'ac-previous) + (define-key map "\C-s" 'ac-isearch) + (define-key map [mouse-1] 'ac-mouse-1) + (define-key map [down-mouse-1] 'ac-ignore) + (define-key map [mouse-4] 'ac-mouse-4) + (define-key map [mouse-5] 'ac-mouse-5) + map) + "Keymap for completion on completing menu.") + +(defvar ac-current-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map ac-completing-map) + map)) + +(defvar ac-match-function 'all-completions + "Default match function.") + +(defvar ac-prefix-definitions + '((symbol . ac-prefix-symbol) + (file . ac-prefix-file) + (valid-file . ac-prefix-valid-file) + (c-dot . ac-prefix-c-dot) + (c-dot-ref . ac-prefix-c-dot-ref) + (cc-member . ac-prefix-cc-member)) + "Prefix definitions for common use.") + +(defvar ac-sources '(ac-source-words-in-same-mode-buffers) + "Sources for completion.") +(make-variable-buffer-local 'ac-sources) + +(defvar ac-compiled-sources nil + "Compiled source of `ac-sources'.") + +(defvar ac-current-sources nil + "Current working sources. This is sublist of `ac-compiled-sources'.") + +(defvar ac-omni-completion-sources nil + "Do not use this anymore.") + +(defvar ac-current-prefix-def nil) + +(defvar ac-ignoring-prefix-def nil) + + + +;;;; Intelligent completion history + +(defvar ac-comphist nil + "Database of completion history.") + +(defsubst ac-comphist-make-tab () + (make-hash-table :test 'equal)) + +(defsubst ac-comphist-tab (db) + (nth 0 db)) + +(defsubst ac-comphist-cache (db) + (nth 1 db)) + +(defun ac-comphist-make (&optional tab) + (list (or tab (ac-comphist-make-tab)) (make-hash-table :test 'equal :weakness t))) + +(defun ac-comphist-get (db string &optional create) + (let* ((tab (ac-comphist-tab db)) + (index (gethash string tab))) + (when (and create (null index)) + (setq index (make-vector (length string) 0)) + (puthash string index tab)) + index)) + +(defun ac-comphist-add (db string prefix) + (setq prefix (min prefix (1- (length string)))) + (when (<= 0 prefix) + (setq string (substring-no-properties string)) + (let ((stat (ac-comphist-get db string t))) + (cl-incf (aref stat prefix)) + (remhash string (ac-comphist-cache db))))) + +(defun ac-comphist-score (db string prefix) + (setq prefix (min prefix (1- (length string)))) + (if (<= 0 prefix) + (let ((cache (gethash string (ac-comphist-cache db)))) + (or (and cache (aref cache prefix)) + (let ((stat (ac-comphist-get db string)) + (score 0.0)) + (when stat + (cl-loop for p from 0 below (length string) + ;; sigmoid function + with a = 5 + with b = (/ 700.0 a) ; bounds for avoiding range error in `exp' + with d = (/ 6.0 a) + for x = (max (- b) (min b (- d (abs (- prefix p))))) + for r = (/ 1.0 (1+ (exp (* (- a) x)))) + do + (cl-incf score (* (aref stat p) r)))) + ;; Weight by distance + (cl-incf score (max 0.0 (- 0.3 (/ (- (length string) prefix) 100.0)))) + (unless cache + (setq cache (make-vector (length string) nil)) + (puthash string cache (ac-comphist-cache db))) + (aset cache prefix score) + score))) + 0.0)) + +(defun ac-comphist-sort (db collection prefix &optional threshold) + (let (result + (n 0) + (total 0) + (cur 0)) + (setq result (mapcar (lambda (a) + (when (and cur threshold) + (if (>= cur (* total threshold)) + (setq cur nil) + (cl-incf n) + (cl-incf cur (cdr a)))) + (car a)) + (sort (mapcar (lambda (string) + (let ((score (ac-comphist-score db string prefix))) + (cl-incf total score) + (cons string score))) + collection) + (lambda (a b) (< (cdr b) (cdr a)))))) + (if threshold + (cons n result) + result))) + +(defun ac-comphist-serialize (db) + (let (alist) + (maphash (lambda (k v) + (push (cons k v) alist)) + (ac-comphist-tab db)) + (list alist))) + +(defun ac-comphist-deserialize (sexp) + (condition-case nil + (ac-comphist-make (let ((tab (ac-comphist-make-tab))) + (mapc (lambda (cons) + (puthash (car cons) (cdr cons) tab)) + (nth 0 sexp)) + tab)) + (error (message "Invalid comphist db.") nil))) + +(defun ac-comphist-init () + (ac-comphist-load) + (add-hook 'kill-emacs-hook 'ac-comphist-save)) + +(defun ac-comphist-load () + (interactive) + (let ((db (if (file-exists-p ac-comphist-file) + (ignore-errors + (with-temp-buffer + (insert-file-contents ac-comphist-file) + (goto-char (point-min)) + (ac-comphist-deserialize (read (current-buffer)))))))) + (setq ac-comphist (or db (ac-comphist-make))))) + +(defun ac-comphist-save () + (interactive) + (require 'pp) + (ignore-errors + (with-temp-buffer + (pp (ac-comphist-serialize ac-comphist) (current-buffer)) + (write-region (point-min) (point-max) ac-comphist-file)))) + + + +;;;; Dictionary +(defvar ac-buffer-dictionary nil) +(defvar ac-file-dictionary (make-hash-table :test 'equal)) + +(defun ac-clear-dictionary-cache () + (interactive) + (dolist (buffer (buffer-list)) + (with-current-buffer buffer + (if (local-variable-p 'ac-buffer-dictionary) + (kill-local-variable 'ac-buffer-dictionary)))) + (clrhash ac-file-dictionary)) + +(defun ac-file-dictionary (filename) + (let ((cache (gethash filename ac-file-dictionary 'none))) + (if (and cache (not (eq cache 'none))) + cache + (let (result) + (ignore-errors + (with-temp-buffer + (insert-file-contents filename) + (setq result (split-string (buffer-string) "\n" t)))) + (puthash filename result ac-file-dictionary) + result)))) + +(defun ac-mode-dictionary (mode) + (cl-loop for name in (cons (symbol-name mode) + (ignore-errors (list (file-name-extension (buffer-file-name))))) + append (cl-loop for dir in ac-dictionary-directories + for file = (concat dir "/" name) + if (file-exists-p file) + append (ac-file-dictionary file)))) + +(defun ac-buffer-dictionary (&optional buffer) + (with-current-buffer (or buffer (current-buffer)) + (if (local-variable-p 'ac-buffer-dictionary) + ac-buffer-dictionary + (make-local-variable 'ac-buffer-dictionary) + (setq ac-buffer-dictionary + (apply 'append + ac-user-dictionary + (ac-mode-dictionary major-mode) + (mapcar 'ac-file-dictionary ac-dictionary-files)))))) + + + +;;;; Auto completion internals + +(defun ac-menu-at-wrapper-line-p () + "Return non-nil if current line is long and wrapped to next visual line." + (and (not truncate-lines) + (eq (line-beginning-position) + (save-excursion + (vertical-motion 1) + (line-beginning-position))))) + +(defun ac-stop-word-p (word) + (or (member word ac-stop-words) + (if ac-use-dictionary-as-stop-words + (member word (ac-buffer-dictionary))))) + +(defun ac-prefix-default () + "Same as `ac-prefix-symbol' but ignore a number prefix." + (let ((start (ac-prefix-symbol))) + (when start + (cl-loop with end = (point) + for pos from start below end + for c = (char-after pos) + if (not (and (<= ?0 c) (<= c ?9))) + return start)))) + +(defun ac-prefix-symbol () + "Default prefix definition function." + (require 'thingatpt) + (car-safe (bounds-of-thing-at-point 'symbol))) + +(defun ac-prefix-file () + "File prefix." + (let ((point (re-search-backward "[\"<>' \t\r\n]" nil t))) + (if point (1+ point)))) + +(defsubst ac-windows-remote-file-p (file) + (and (memq system-type '(ms-dos windows-nt cygwin)) + (string-match-p "\\`\\(?://\\|\\\\\\\\\\)" file))) + +(defun ac-prefix-valid-file () + "Existed (or to be existed) file prefix." + (let* ((line-beg (line-beginning-position)) + (end (point)) + (start (or (let ((point (re-search-backward "[\"<>'= \t\r\n]" line-beg t))) + (if point (1+ point))) + line-beg)) + (file (buffer-substring start end))) + (if (and file (or (string-match "^/" file) + (and (setq file (and (string-match "^[^/]*/" file) + (match-string 0 file))) + (file-directory-p file)))) + (unless (ac-windows-remote-file-p file) + start)))) + +(defun ac-prefix-c-dot () + "C-like languages dot(.) prefix." + (if (re-search-backward "\\.\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t) + (match-beginning 1))) + +(defun ac-prefix-c-dot-ref () + "C-like languages dot(.) and reference(->) prefix." + (if (re-search-backward "\\(?:\\.\\|->\\)\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t) + (match-beginning 1))) + +(defun ac-prefix-cc-member () + "C-like languages member(.)(->)(::) prefix." + (when (re-search-backward "\\(?:\\.\\|->\\|::\\)\\(\\(?:[a-zA-Z0-9][_a-zA-Z0-9]*\\)?\\)\\=" nil t) + (match-beginning 1))) + +(defun ac-define-prefix (name prefix) + "Define new prefix definition. +You can not use it in source definition like (prefix . `NAME')." + (push (cons name prefix) ac-prefix-definitions)) + +(defun ac-match-substring (prefix candidates) + (cl-loop with regexp = (regexp-quote prefix) + for candidate in candidates + if (string-match regexp candidate) + collect candidate)) + +(defsubst ac-source-entity (source) + (if (symbolp source) + (symbol-value source) + source)) + +(defun ac-source-available-p (source) + (if (and (symbolp source) + (get source 'available)) + (eq (get source 'available) t) + (let* ((src (ac-source-entity source)) + (avail-pair (assq 'available src)) + (avail-cond (cdr avail-pair)) + (available (and (if avail-pair + (cond + ((symbolp avail-cond) + (funcall avail-cond)) + ((listp avail-cond) + (eval avail-cond))) + t) + (cl-loop for feature in (assoc-default 'depends src) + unless (require feature nil t) return nil + finally return t)))) + (if (symbolp source) + (put source 'available (if available t 'no))) + available))) + +(defun ac-compile-sources (sources) + "Compiled `SOURCES' into expanded sources style." + (cl-loop for source in sources + if (ac-source-available-p source) + do + (setq source (ac-source-entity source)) + ;; prefix + (let* ((prefix (assoc 'prefix source)) + (real (assoc-default (cdr prefix) ac-prefix-definitions))) + (cond + (real + (add-to-list 'source (cons 'prefix real))) + ((null prefix) + (add-to-list 'source (cons 'prefix 'ac-prefix-default))))) + ;; match + (let ((match (assq 'match source))) + (cond + ((eq (cdr match) 'substring) + (setcdr match 'ac-match-substring)))) + and collect source)) + +(defun ac-compiled-sources () + (or ac-compiled-sources + (setq ac-compiled-sources + (ac-compile-sources ac-sources)))) + +(defsubst ac-menu-live-p () + (popup-live-p ac-menu)) + +(defun ac-menu-create (point width height) + (setq ac-menu + (popup-create point width height + :around t + :face 'ac-candidate-face + :max-width ac-max-width + :mouse-face 'ac-candidate-mouse-face + :selection-face 'ac-selection-face + :symbol t + :scroll-bar t + :margin-left 1 + :keymap ac-menu-map + ))) + +(defun ac-menu-delete () + (when ac-menu + (popup-delete ac-menu) + (setq ac-menu))) + +(defsubst ac-inline-overlay () + (nth 0 ac-inline)) + +(defsubst ac-inline-live-p () + (and ac-inline (ac-inline-overlay) t)) + +(defun ac-inline-show (point string) + (unless ac-inline + (setq ac-inline (list nil))) + (save-excursion + (let ((overlay (ac-inline-overlay)) + (width 0) + (string-width (string-width string)) + (length 0) + (original-string string)) + ;; Calculate string space to show completion + (goto-char point) + (let (c) + (while (and (not (eolp)) + (< width string-width) + (setq c (char-after)) + (not (eq c ?\t))) ; special case for tab + (cl-incf width (char-width c)) + (cl-incf length) + (forward-char))) + + ;; Show completion + (goto-char point) + (cond + ((= width 0) + ;; End-of-line + ;; Do nothing + ) + ((<= width string-width) + ;; No space to show + ;; Do nothing + ) + ((> width string-width) + ;; Need to fill space + (setq string (concat string (make-string (- width string-width) ? ))))) + (setq string (propertize string 'face 'ac-completion-face)) + (if overlay + (progn + (move-overlay overlay point (+ point length)) + (overlay-put overlay 'invisible nil)) + (setq overlay (make-overlay point (+ point length))) + (setf (nth 0 ac-inline) overlay) + (overlay-put overlay 'priority 9999) + ;; Help prefix-overlay in some cases + (overlay-put overlay 'keymap ac-current-map)) + ;; TODO no width but char + (if (eq length 0) + ;; Case: End-of-line + (progn + (put-text-property 0 1 'cursor t string) + (overlay-put overlay 'after-string string)) + (let ((display (substring string 0 1)) + (after-string (substring string 1))) + (overlay-put overlay 'display display) + (overlay-put overlay 'after-string after-string))) + (overlay-put overlay 'string original-string)))) + +(defun ac-inline-delete () + (when (ac-inline-live-p) + (ac-inline-hide) + (delete-overlay (ac-inline-overlay)) + (setq ac-inline nil))) + +(defun ac-inline-hide () + (when (ac-inline-live-p) + (let ((overlay (ac-inline-overlay)) + (buffer-undo-list t)) + (when overlay + (move-overlay overlay (point-min) (point-min)) + (overlay-put overlay 'invisible t) + (overlay-put overlay 'display nil) + (overlay-put overlay 'after-string nil))))) + +(defun ac-inline-update () + (if (and ac-completing ac-prefix (stringp ac-common-part)) + (let ((common-part-length (length ac-common-part)) + (prefix-length (length ac-prefix))) + (if (> common-part-length prefix-length) + (progn + (ac-inline-hide) + (ac-inline-show (point) (substring ac-common-part prefix-length))) + (ac-inline-delete))) + (ac-inline-delete))) + +(defun ac-put-prefix-overlay () + (unless ac-prefix-overlay + (let (newline) + ;; Insert newline to make sure that cursor always on the overlay + (when (eobp) + (popup-save-buffer-state + (insert "\n")) + (setq newline t)) + (setq ac-prefix-overlay (make-overlay ac-point (1+ (point)) nil t t)) + (overlay-put ac-prefix-overlay 'priority 9999) + (overlay-put ac-prefix-overlay 'keymap (make-sparse-keymap)) + (overlay-put ac-prefix-overlay 'newline newline)))) + +(defun ac-remove-prefix-overlay () + (when ac-prefix-overlay + (when (overlay-get ac-prefix-overlay 'newline) + ;; Remove inserted newline + (popup-save-buffer-state + (goto-char (point-max)) + (if (eq (char-before) ?\n) + (delete-char -1)))) + (delete-overlay ac-prefix-overlay))) + +(defun ac-activate-completing-map () + (if (and ac-show-menu ac-use-menu-map) + (set-keymap-parent ac-current-map ac-menu-map)) + (when (and ac-use-overriding-local-map + (null overriding-terminal-local-map)) + (setq overriding-terminal-local-map ac-current-map)) + (when ac-prefix-overlay + (set-keymap-parent (overlay-get ac-prefix-overlay 'keymap) ac-current-map))) + +(defun ac-deactivate-completing-map () + (set-keymap-parent ac-current-map ac-completing-map) + (when (and ac-use-overriding-local-map + (eq overriding-terminal-local-map ac-current-map)) + (setq overriding-terminal-local-map nil)) + (when ac-prefix-overlay + (set-keymap-parent (overlay-get ac-prefix-overlay 'keymap) nil))) + +(defsubst ac-selected-candidate () + (if ac-menu + (popup-selected-item ac-menu))) + +(defun ac-prefix (requires ignore-list) + (cl-loop with current = (point) + with point + with point-def + with prefix-def + with sources + for source in (ac-compiled-sources) + for prefix = (assoc-default 'prefix source) + for req = (or (assoc-default 'requires source) requires 1) + + do + (unless (member prefix ignore-list) + (save-excursion + (setq point (cond + ((symbolp prefix) + (funcall prefix)) + ((stringp prefix) + (and (re-search-backward (concat prefix "\\=") nil t) + (or (match-beginning 1) (match-beginning 0)))) + ((stringp (car-safe prefix)) + (let ((regexp (nth 0 prefix)) + (end (nth 1 prefix)) + (group (nth 2 prefix))) + (and (re-search-backward (concat regexp "\\=") nil t) + (funcall (if end 'match-end 'match-beginning) + (or group 0))))) + (t + (eval prefix)))) + (if (and point + (integerp req) + (< (- current point) req)) + (setq point nil)) + (when point + (if (null prefix-def) + (setq prefix-def prefix + point-def point)) + (if (equal point point-def) + (push source sources))))) + + finally return + (and point-def (list prefix-def point-def (nreverse sources))))) + +(defun ac-init () + "Initialize current sources to start completion." + (setq ac-candidates-cache nil) + (cl-loop for source in ac-current-sources + for function = (assoc-default 'init source) + if function do + (save-excursion + (cond + ((functionp function) + (funcall function)) + (t + (eval function)))))) + +(defun ac-candidates-1 (source) + (let* ((do-cache (assq 'cache source)) + (function (assoc-default 'candidates source)) + (action (assoc-default 'action source)) + (document (assoc-default 'document source)) + (symbol (assoc-default 'symbol source)) + (ac-limit (or (assoc-default 'limit source) ac-limit)) + (face (or (assoc-default 'face source) (assoc-default 'candidate-face source))) + (selection-face (assoc-default 'selection-face source)) + (cache (and do-cache (assq source ac-candidates-cache))) + (candidates (cdr cache))) + (unless cache + (setq candidates (save-excursion + (cond + ((functionp function) + (funcall function)) + (t + (eval function))))) + ;; Convert (name value) format candidates into name with text properties. + (setq candidates (mapcar (lambda (candidate) + (if (consp candidate) + (propertize (car candidate) 'value (cdr candidate)) + candidate)) + candidates)) + (when do-cache + (push (cons source candidates) ac-candidates-cache))) + (setq candidates (funcall (or (assoc-default 'match source) + ac-match-function) + ac-prefix candidates)) + ;; Remove extra items regarding to ac-limit + (if (and (integerp ac-limit) (> ac-limit 1) (> (length candidates) ac-limit)) + (setcdr (nthcdr (1- ac-limit) candidates) nil)) + ;; Put candidate properties + (setq candidates (mapcar (lambda (candidate) + (popup-item-propertize candidate + 'action action + 'symbol symbol + 'document document + 'popup-face face + 'selection-face selection-face)) + candidates)) + candidates)) + +(defun ac-delete-duplicated-candidates (candidates) + (cl-delete-duplicates + candidates + :test (lambda (x y) + ;; We assume two candidates are same if their titles are + ;; equal and their actions are equal. + (and (equal x y) + (eq (popup-item-property x 'action) + (popup-item-property y 'action)))) + :from-end t)) + +(defun ac-reduce-candidates (candidates) + ;; Call `ac-delete-duplicated-candidates' on first portion of + ;; candidate list for speed. + (let ((size 20)) + (if (< (length candidates) size) + (ac-delete-duplicated-candidates candidates) + (cl-loop for c on candidates by 'cdr + repeat (1- size) + finally return + (let ((rest (cdr c))) + (setcdr c nil) + (append (ac-delete-duplicated-candidates candidates) (copy-sequence rest))))))) + +(defun ac-candidates () + "Produce candidates for current sources." + (cl-loop with completion-ignore-case = (or (eq ac-ignore-case t) + (and (eq ac-ignore-case 'smart) + (let ((case-fold-search nil)) (not (string-match "[[:upper:]]" ac-prefix))))) + with case-fold-search = completion-ignore-case + with prefix-len = (length ac-prefix) + for source in ac-current-sources + append (ac-candidates-1 source) into candidates + finally return + (progn + (if (and ac-use-comphist ac-comphist) + (if ac-show-menu + (let* ((pair (ac-comphist-sort ac-comphist candidates prefix-len ac-comphist-threshold)) + (n (car pair)) + (result (ac-reduce-candidates (cdr pair))) + (cons (if (> n 0) (nthcdr (1- n) result))) + (cdr (cdr cons))) + ;; XXX ugly + (if cons (setcdr cons nil)) + (setq ac-common-part (try-completion ac-prefix result)) + (setq ac-whole-common-part (try-completion ac-prefix candidates)) + (if cons (setcdr cons cdr)) + result) + (setq candidates (ac-comphist-sort ac-comphist candidates prefix-len)) + (setq ac-common-part (if candidates (popup-x-to-string (car candidates)))) + (setq ac-whole-common-part (try-completion ac-prefix candidates)) + candidates) + (when ac-show-menu + (setq candidates (ac-reduce-candidates candidates))) + (setq ac-common-part (try-completion ac-prefix candidates)) + (setq ac-whole-common-part ac-common-part) + candidates)))) + +(defun ac-update-candidates (cursor scroll-top) + "Update candidates of menu to `ac-candidates' and redraw it." + (setf (popup-cursor ac-menu) cursor + (popup-scroll-top ac-menu) scroll-top) + (setq ac-dwim-enable (= (length ac-candidates) 1)) + (if ac-candidates + (progn + (setq ac-completing t) + (ac-activate-completing-map)) + (setq ac-completing nil) + (ac-deactivate-completing-map)) + (unless ac-disable-inline + (ac-inline-update)) + (popup-set-list ac-menu ac-candidates) + (if (and (not ac-fuzzy-enable) + (<= (length ac-candidates) ac-candidate-menu-min)) + (popup-hide ac-menu) + (if ac-show-menu + (popup-draw ac-menu)))) + +(defun ac-reposition () + "Force to redraw candidate menu with current `ac-candidates'." + (let ((cursor (popup-cursor ac-menu)) + (scroll-top (popup-scroll-top ac-menu)) + (height (popup-height ac-menu))) + (ac-menu-delete) + (ac-menu-create ac-point (popup-preferred-width ac-candidates) height) + (ac-update-candidates cursor scroll-top))) + +(defun ac-cleanup () + "Cleanup auto completion." + (if ac-cursor-color + (set-cursor-color ac-cursor-color)) + (when (and ac-use-comphist ac-comphist) + (when (and (null ac-selected-candidate) + (member ac-prefix ac-candidates)) + ;; Assume candidate is selected by just typing + (setq ac-selected-candidate ac-prefix) + (setq ac-last-point ac-point)) + (when ac-selected-candidate + (ac-comphist-add ac-comphist + ac-selected-candidate + (if ac-last-point + (- ac-last-point ac-point) + (length ac-prefix))))) + (ac-deactivate-completing-map) + (ac-remove-prefix-overlay) + (ac-remove-quick-help) + (ac-inline-delete) + (ac-menu-delete) + (ac-cancel-timer) + (ac-cancel-show-menu-timer) + (ac-cancel-quick-help-timer) + (setq ac-cursor-color nil + ac-inline nil + ac-show-menu nil + ac-menu nil + ac-completing nil + ac-point nil + ac-last-point nil + ac-prefix nil + ac-prefix-overlay nil + ac-selected-candidate nil + ac-common-part nil + ac-whole-common-part nil + ac-triggered nil + ac-limit nil + ac-candidates nil + ac-candidates-cache nil + ac-fuzzy-enable nil + ac-dwim-enable nil + ac-compiled-sources nil + ac-current-sources nil + ac-current-prefix-def nil + ac-ignoring-prefix-def nil)) + +(defsubst ac-abort () + "Abort completion." + (ac-cleanup)) + +(defun ac-extend-region-to-delete (string) + "Determine the boundary of the region to delete before +inserting the completed string. This will be either the position +of current point, or the end of the symbol at point, if the text +from point to end of symbol is the right part of the completed +string." + (let* ((end-of-symbol (or (cdr-safe (bounds-of-thing-at-point 'symbol)) + (point))) + (remaindar (buffer-substring-no-properties (point) end-of-symbol)) + (remaindar-length (length remaindar))) + (if (and (>= (length string) remaindar-length) + (string= (substring-no-properties string (- remaindar-length)) + remaindar)) + end-of-symbol + (point)))) + +(defun ac-expand-string (string &optional remove-undo-boundary) + "Expand `STRING' into the buffer and update `ac-prefix' to `STRING'. +This function records deletion and insertion sequences by `undo-boundary'. +If `remove-undo-boundary' is non-nil, this function also removes `undo-boundary' +that have been made before in this function. When `buffer-undo-list' is +`t', `remove-undo-boundary' has no effect." + (when (eq buffer-undo-list t) + (setq remove-undo-boundary nil)) + (when (not (equal string (buffer-substring ac-point (point)))) + (undo-boundary) + ;; We can't use primitive-undo since it undoes by + ;; groups, divided by boundaries. + ;; We don't want boundary between deletion and insertion. + ;; So do it manually. + ;; Delete region silently for undo: + (if remove-undo-boundary + (progn + (let (buffer-undo-list) + (save-excursion + (delete-region ac-point (ac-extend-region-to-delete string)))) + (setq buffer-undo-list + (nthcdr 2 buffer-undo-list))) + (delete-region ac-point (ac-extend-region-to-delete string))) + (insert (substring-no-properties string)) + ;; Sometimes, possible when omni-completion used, (insert) added + ;; to buffer-undo-list strange record about position changes. + ;; Delete it here: + (when (and remove-undo-boundary + (integerp (cadr buffer-undo-list))) + (setcdr buffer-undo-list (nthcdr 2 buffer-undo-list))) + (undo-boundary) + (setq ac-selected-candidate string) + (setq ac-prefix string))) + +(defun ac-set-trigger-key (key) + "Set `ac-trigger-key' to `KEY'. It is recommemded to use this function instead of calling `setq'." + ;; Remove old mapping + (when ac-trigger-key + (define-key ac-mode-map (read-kbd-macro ac-trigger-key) nil)) + + ;; Make new mapping + (setq ac-trigger-key key) + (when key + (define-key ac-mode-map (read-kbd-macro key) 'ac-trigger-key-command))) + +(defun ac-set-timer () + (unless ac-timer + (setq ac-timer (run-with-idle-timer ac-delay ac-delay 'ac-update-greedy)))) + +(defun ac-cancel-timer () + (when (timerp ac-timer) + (cancel-timer ac-timer) + (setq ac-timer nil))) + +(defun ac-update (&optional force) + (when (and auto-complete-mode + ac-prefix + (or ac-triggered + force) + (not isearch-mode)) + (ac-put-prefix-overlay) + (setq ac-candidates (ac-candidates)) + (let ((preferred-width (popup-preferred-width ac-candidates))) + ;; Reposition if needed + (when (or (null ac-menu) + (>= (popup-width ac-menu) preferred-width) + (<= (popup-width ac-menu) (- preferred-width 10)) + (and (> (popup-direction ac-menu) 0) + (ac-menu-at-wrapper-line-p))) + (ac-inline-hide) ; Hide overlay to calculate correct column + (ac-remove-quick-help) + (ac-menu-delete) + (ac-menu-create ac-point preferred-width ac-menu-height))) + (ac-update-candidates 0 0) + t)) + +(defun ac-update-greedy (&optional force) + (let (result) + (while (when (and (setq result (ac-update force)) + (null ac-candidates)) + (add-to-list 'ac-ignoring-prefix-def ac-current-prefix-def) + (ac-start :force-init t) + ac-current-prefix-def)) + result)) + +(defun ac-set-show-menu-timer () + (when (and (or (integerp ac-auto-show-menu) (floatp ac-auto-show-menu)) + (null ac-show-menu-timer)) + (setq ac-show-menu-timer (run-with-idle-timer ac-auto-show-menu ac-auto-show-menu 'ac-show-menu)))) + +(defun ac-cancel-show-menu-timer () + (when (timerp ac-show-menu-timer) + (cancel-timer ac-show-menu-timer) + (setq ac-show-menu-timer nil))) + +(defun ac-show-menu () + (when (not (eq ac-show-menu t)) + (setq ac-show-menu t) + (ac-inline-hide) + (ac-remove-quick-help) + (ac-update t))) + +(defun ac-help (&optional persist) + (interactive "P") + (when ac-menu + (popup-menu-show-help ac-menu persist))) + +(defun ac-persist-help () + (interactive) + (ac-help t)) + +(defun ac-last-help (&optional persist) + (interactive "P") + (when ac-last-completion + (popup-item-show-help (cdr ac-last-completion) persist))) + +(defun ac-last-persist-help () + (interactive) + (ac-last-help t)) + +(defun ac-set-quick-help-timer () + (when (and ac-use-quick-help + (null ac-quick-help-timer)) + (setq ac-quick-help-timer (run-with-idle-timer ac-quick-help-delay ac-quick-help-delay 'ac-quick-help)))) + +(defun ac-cancel-quick-help-timer () + (when (timerp ac-quick-help-timer) + (cancel-timer ac-quick-help-timer) + (setq ac-quick-help-timer nil))) + +(defun ac-pos-tip-show-quick-help (menu &optional item &rest args) + (let* ((point (plist-get args :point)) + (around nil) + (parent-offset (popup-offset menu)) + (doc (popup-menu-documentation menu item))) + (when (stringp doc) + (if (popup-hidden-p menu) + (setq around t) + (setq point nil)) + (with-no-warnings + (pos-tip-show doc + 'popup-tip-face + (or point + (and menu + (popup-child-point menu parent-offset)) + (point)) + nil 300 + popup-tip-max-width + nil nil + (and (not around) 0)) + (unless (plist-get args :nowait) + (clear-this-command-keys) + (unwind-protect + (push (read-event (plist-get args :prompt)) unread-command-events) + (pos-tip-hide)) + t))))) + +(defun ac-quick-help-use-pos-tip-p () + (and ac-quick-help-prefer-pos-tip + window-system + (featurep 'pos-tip))) + +(defun ac-quick-help (&optional force) + (interactive) + ;; TODO don't use FORCE + (when (and (or force + (with-no-warnings + ;; called-interactively-p can take no args + (called-interactively-p)) + ;; ac-isearch'ing + (null this-command)) + (ac-menu-live-p) + (null ac-quick-help)) + (setq ac-quick-help + (funcall (if (ac-quick-help-use-pos-tip-p) + 'ac-pos-tip-show-quick-help + 'popup-menu-show-quick-help) + ac-menu nil + :point ac-point + :height ac-quick-help-height + :nowait t)))) + +(defun ac-remove-quick-help () + (when (ac-quick-help-use-pos-tip-p) + (with-no-warnings + (pos-tip-hide))) + (when ac-quick-help + (popup-delete ac-quick-help) + (setq ac-quick-help nil))) + +(defun ac-last-quick-help () + (interactive) + (when (and ac-last-completion + (eq (marker-buffer (car ac-last-completion)) + (current-buffer))) + (let ((doc (popup-item-documentation (cdr ac-last-completion))) + (point (marker-position (car ac-last-completion)))) + (when (stringp doc) + (if (ac-quick-help-use-pos-tip-p) + (with-no-warnings (pos-tip-show doc nil point nil 300)) + (popup-tip doc + :point point + :around t + :scroll-bar t + :margin t)))))) + +(defmacro ac-define-quick-help-command (name arglist &rest body) + (declare (indent 2)) + `(progn + (defun ,name ,arglist ,@body) + (put ',name 'ac-quick-help-command t))) + +(ac-define-quick-help-command ac-quick-help-scroll-down () + (interactive) + (when ac-quick-help + (popup-scroll-down ac-quick-help))) + +(ac-define-quick-help-command ac-quick-help-scroll-up () + (interactive) + (when ac-quick-help + (popup-scroll-up ac-quick-help))) + + + +;;;; Auto completion isearch + +(defun ac-isearch-callback (list) + (setq ac-dwim-enable (eq (length list) 1))) + +(defun ac-isearch () + (interactive) + (when (ac-menu-live-p) + (ac-cancel-show-menu-timer) + (ac-show-menu) + (if ac-use-quick-help + (let ((popup-menu-show-quick-help-function + (if (ac-quick-help-use-pos-tip-p) + 'ac-pos-tip-show-quick-help + 'popup-menu-show-quick-help))) + (popup-isearch ac-menu + :callback 'ac-isearch-callback + :help-delay ac-quick-help-delay)) + (popup-isearch ac-menu :callback 'ac-isearch-callback)))) + + + +;;;; Auto completion commands + +(cl-defun auto-complete-1 (&key sources (triggered 'command)) + (let ((menu-live (ac-menu-live-p)) + (inline-live (ac-inline-live-p)) + started) + (ac-abort) + (let ((ac-sources (or sources ac-sources))) + (if (or ac-show-menu-immediately-on-auto-complete + inline-live) + (setq ac-show-menu t)) + (setq started (ac-start :triggered triggered))) + (when (ac-update-greedy t) + ;; TODO Not to cause inline completion to be disrupted. + (if (ac-inline-live-p) + (ac-inline-hide)) + ;; Not to expand when it is first time to complete + (when (and (or (and (not ac-expand-on-auto-complete) + (> (length ac-candidates) 1) + (not menu-live)) + (not (let ((ac-common-part ac-whole-common-part)) + (ac-expand-common)))) + ac-use-fuzzy + (null ac-candidates)) + (ac-fuzzy-complete))) + started)) + +;;;###autoload +(defun auto-complete (&optional sources) + "Start auto-completion at current point." + (interactive) + (auto-complete-1 :sources sources)) + +(defun ac-fuzzy-complete () + "Start fuzzy completion at current point." + (interactive) + (if (not (require 'fuzzy nil t)) + (message "Please install fuzzy.el if you use fuzzy completion") + (unless (ac-menu-live-p) + (ac-start)) + (let ((ac-match-function 'fuzzy-all-completions)) + (when ac-fuzzy-cursor-color + (unless ac-cursor-color + (setq ac-cursor-color (frame-parameter (selected-frame) 'cursor-color))) + (set-cursor-color ac-fuzzy-cursor-color)) + (setq ac-show-menu t) + (setq ac-fuzzy-enable t) + (setq ac-triggered nil) + (ac-update t))) + t) + +(defun ac-next () + "Select next candidate." + (interactive) + (when (ac-menu-live-p) + (when (popup-hidden-p ac-menu) + (ac-show-menu)) + (popup-next ac-menu) + (if (eq this-command 'ac-next) + (setq ac-dwim-enable t)))) + +(defun ac-previous () + "Select previous candidate." + (interactive) + (when (ac-menu-live-p) + (when (popup-hidden-p ac-menu) + (ac-show-menu)) + (popup-previous ac-menu) + (if (eq this-command 'ac-previous) + (setq ac-dwim-enable t)))) + +(defun ac-expand (arg) + "Try expand, and if expanded twice, select next candidate. +If given a prefix argument, select the previous candidate." + (interactive "P") + (unless (ac-expand-common) + (let ((string (ac-selected-candidate))) + (when string + (when (equal ac-prefix string) + (if (not arg) + (ac-next) + (ac-previous)) + (setq string (ac-selected-candidate))) + (ac-expand-string string + (or (eq last-command 'ac-expand) + (eq last-command 'ac-expand-previous))) + ;; Do reposition if menu at long line + (if (and (> (popup-direction ac-menu) 0) + (ac-menu-at-wrapper-line-p)) + (ac-reposition)) + (setq ac-show-menu t) + string)))) + +(defun ac-expand-previous (arg) + "Like `ac-expand', but select previous candidate." + (interactive "P") + (ac-expand (not arg))) + +(defun ac-expand-common () + "Try to expand meaningful common part." + (interactive) + (if (and ac-dwim ac-dwim-enable) + (ac-complete) + (when (and (ac-inline-live-p) + ac-common-part) + (ac-inline-hide) + (ac-expand-string ac-common-part (eq last-command this-command)) + (setq ac-common-part nil) + t))) + +(defun ac-complete-1 (candidate) + (let ((action (popup-item-property candidate 'action)) + (fallback nil)) + (when candidate + (unless (ac-expand-string candidate) + (setq fallback t)) + ;; Remember to show help later + (when (and ac-point candidate) + (unless ac-last-completion + (setq ac-last-completion (cons (make-marker) nil))) + (set-marker (car ac-last-completion) ac-point ac-buffer) + (setcdr ac-last-completion candidate))) + (ac-abort) + (cond + (action + (funcall action)) + (fallback + (ac-fallback-command))) + candidate)) + +(defun ac-complete () + "Try complete." + (interactive) + (ac-complete-1 (ac-selected-candidate))) + +(cl-defun ac-start (&key + requires + force-init + (triggered (or ac-triggered t))) + "Start completion." + (interactive) + (if (not auto-complete-mode) + (message "auto-complete-mode is not enabled") + (let* ((info (ac-prefix requires ac-ignoring-prefix-def)) + (prefix-def (nth 0 info)) + (point (nth 1 info)) + (sources (nth 2 info)) + prefix + (init (or force-init (not (eq ac-point point))))) + (if (or (null point) + (progn + (setq prefix (buffer-substring-no-properties point (point))) + (and (not (eq triggered 'command)) + (ac-stop-word-p prefix)))) + (prog1 nil + (ac-abort)) + (when (and ac-use-fuzzy ac-fuzzy-cursor-color) + (unless ac-cursor-color + (setq ac-cursor-color (frame-parameter (selected-frame) 'cursor-color)))) + (setq ac-show-menu (or ac-show-menu (if (eq ac-auto-show-menu t) t)) + ac-current-sources sources + ac-buffer (current-buffer) + ac-point point + ac-prefix prefix + ac-limit ac-candidate-limit + ac-triggered triggered + ac-current-prefix-def prefix-def) + (when (or init (null ac-prefix-overlay)) + (ac-init)) + (ac-set-timer) + (ac-set-show-menu-timer) + (ac-set-quick-help-timer) + (ac-put-prefix-overlay) + t)))) + +(defun ac-stop () + "Stop completiong." + (interactive) + (setq ac-selected-candidate nil) + (ac-abort)) + +(defun ac-ignore (&rest ignore) + "Same as `ignore'." + (interactive)) + +(defun ac-mouse-1 (event) + (interactive "e") + (popup-awhen (popup-menu-item-of-mouse-event event) + (ac-complete-1 it))) + +(defun ac-mouse-4 (event) + (interactive "e") + (ac-previous)) + +(defun ac-mouse-5 (event) + (interactive "e") + (ac-next)) + +(defun ac-trigger-key-command (&optional force) + (interactive "P") + (let (started) + (when (or force (ac-trigger-command-p last-command)) + (setq started (auto-complete-1 :triggered 'trigger-key))) + (unless started + (ac-fallback-command 'ac-trigger-key-command)))) + + + +;;;; Basic cache facility + +(defvar ac-clear-variables-every-minute-timer nil) +(defvar ac-clear-variables-after-save nil) +(defvar ac-clear-variables-every-minute nil) +(defvar ac-minutes-counter 0) + +(defun ac-clear-variable-after-save (variable &optional pred) + (add-to-list 'ac-clear-variables-after-save (cons variable pred))) + +(defun ac-clear-variables-after-save () + (dolist (pair ac-clear-variables-after-save) + (if (or (null (cdr pair)) + (funcall (cdr pair))) + (set (car pair) nil)))) + +(defun ac-clear-variable-every-minutes (variable minutes) + (add-to-list 'ac-clear-variables-every-minute (cons variable minutes))) + +(defun ac-clear-variable-every-minute (variable) + (ac-clear-variable-every-minutes variable 1)) + +(defun ac-clear-variable-every-10-minutes (variable) + (ac-clear-variable-every-minutes variable 10)) + +(defun ac-clear-variables-every-minute () + (cl-incf ac-minutes-counter) + (dolist (pair ac-clear-variables-every-minute) + (if (eq (% ac-minutes-counter (cdr pair)) 0) + (set (car pair) nil)))) + + + +;;;; Auto complete mode + +(defun ac-cursor-on-diable-face-p (&optional point) + (memq (get-text-property (or point (point)) 'face) ac-disable-faces)) + +(defun ac-trigger-command-p (command) + "Return non-nil if `COMMAND' is a trigger command." + (and (symbolp command) + (not (memq command ac-non-trigger-commands)) + (or (memq command ac-trigger-commands) + (string-match "self-insert-command" (symbol-name command)) + (string-match "electric" (symbol-name command))))) + +(defun ac-fallback-key-sequence () + (setq unread-command-events + (append (this-single-command-raw-keys) + unread-command-events)) + (read-key-sequence-vector "")) + +(defun ac-fallback-command (&optional except-command) + (let* ((auto-complete-mode nil) + (keys (ac-fallback-key-sequence)) + (command (and keys (key-binding keys)))) + (when (and (commandp command) + (not (eq command except-command))) + (setq this-command command) + (call-interactively command)))) + +(defun ac-compatible-package-command-p (command) + "Return non-nil if `COMMAND' is compatible with auto-complete." + (and (symbolp command) + (string-match ac-compatible-packages-regexp (symbol-name command)))) + +(defun ac-handle-pre-command () + (condition-case var + (if (or (setq ac-triggered (and (not ac-fuzzy-enable) ; ignore key storkes in fuzzy mode + (or (eq this-command 'auto-complete) ; special case + (ac-trigger-command-p this-command) + (and ac-completing + (memq this-command ac-trigger-commands-on-completing))) + (not (ac-cursor-on-diable-face-p)) + (or ac-triggered t))) + (ac-compatible-package-command-p this-command)) + (progn + (if (or (not (symbolp this-command)) + (not (get this-command 'ac-quick-help-command))) + (ac-remove-quick-help)) + ;; Not to cause inline completion to be disrupted. + (ac-inline-hide)) + (ac-abort)) + (error (ac-error var)))) + +(defun ac-handle-post-command () + (condition-case var + (when (and ac-triggered + (or ac-auto-start + ac-completing) + (not isearch-mode)) + (setq ac-last-point (point)) + (ac-start :requires (unless ac-completing ac-auto-start)) + (unless ac-disable-inline + (ac-inline-update))) + (error (ac-error var)))) + +(defvar ac-flycheck-poll-completion-end-timer nil + "Timer to poll end of completion.") + +(defun ac-syntax-checker-workaround () + (if ac-stop-flymake-on-completing + (progn + (make-local-variable 'ac-flycheck-poll-completion-end-timer) + (when (require 'flymake nil t) + (defadvice flymake-on-timer-event (around ac-flymake-stop-advice activate) + (unless ac-completing + ad-do-it))) + (when (require 'flycheck nil t) + (defadvice flycheck-handle-idle-change (around ac-flycheck-stop-advice activate) + (if ac-completing + (setq ac-flycheck-poll-completion-end-timer + (run-at-time ac-flycheck-poll-completion-end-interval + nil + #'flycheck-handle-idle-change)) + ad-do-it)))) + (when (featurep 'flymake) + (ad-disable-advice 'flymake-on-timer-event 'around 'ac-flymake-stop-advice)) + (when (featurep 'flycheck) + (ad-disable-advice 'flycheck-handle-idle-change 'around 'ac-flycheck-stop-advice)))) + +(defun ac-setup () + (if ac-trigger-key + (ac-set-trigger-key ac-trigger-key)) + (if ac-use-comphist + (ac-comphist-init)) + (unless ac-clear-variables-every-minute-timer + (setq ac-clear-variables-every-minute-timer (run-with-timer 60 60 'ac-clear-variables-every-minute))) + (ac-syntax-checker-workaround)) + +;;;###autoload +(define-minor-mode auto-complete-mode + "AutoComplete mode" + :lighter " AC" + :keymap ac-mode-map + :group 'auto-complete + (if auto-complete-mode + (progn + (ac-setup) + (add-hook 'pre-command-hook 'ac-handle-pre-command nil t) + (add-hook 'post-command-hook 'ac-handle-post-command nil t) + (add-hook 'after-save-hook 'ac-clear-variables-after-save nil t) + (run-hooks 'auto-complete-mode-hook)) + (remove-hook 'pre-command-hook 'ac-handle-pre-command t) + (remove-hook 'post-command-hook 'ac-handle-post-command t) + (remove-hook 'after-save-hook 'ac-clear-variables-after-save t) + (ac-abort))) + +(defun auto-complete-mode-maybe () + "What buffer `auto-complete-mode' prefers." + (if (and (not (minibufferp (current-buffer))) + (memq major-mode ac-modes)) + (auto-complete-mode 1))) + +;;;###autoload +(define-global-minor-mode global-auto-complete-mode + auto-complete-mode auto-complete-mode-maybe + :group 'auto-complete) + + + +;;;; Compatibilities with other extensions + +(defun ac-flyspell-workaround () + "Flyspell uses `sit-for' for delaying its process. Unfortunatelly, +it stops auto completion which is trigger with `run-with-idle-timer'. +This workaround avoid flyspell processes when auto completion is being started." + (interactive) + (defadvice flyspell-post-command-hook (around ac-flyspell-workaround activate) + (unless ac-triggered + ad-do-it))) + +(defun ac-linum-workaround () + "linum-mode tries to display the line numbers even for the +completion menu. This workaround stops that annoying behavior." + (interactive) + (defadvice linum-update (around ac-linum-update-workaround activate) + (unless ac-completing + ad-do-it))) + + + +;;;; Standard sources + +(defmacro ac-define-source (name source) + "Source definition macro. It defines a complete command also." + (declare (indent 1)) + `(progn + (defvar ,(intern (format "ac-source-%s" name))) + ;; Use `setq' to reset ac-source-NAME every time + ;; `ac-define-source' is called. This is useful, for example + ;; when evaluating `ac-define-source' using C-M-x (`eval-defun'). + (setq ,(intern (format "ac-source-%s" name)) ,source) + (defun ,(intern (format "ac-complete-%s" name)) () + (interactive) + (auto-complete '(,(intern (format "ac-source-%s" name))))))) + +;; Words in buffer source +(defvar ac-word-index nil) + +(defun ac-candidate-words-in-buffer (point prefix limit) + (let ((i 0) + candidate + candidates + (regexp (concat "\\_<" (regexp-quote prefix) "\\(\\sw\\|\\s_\\)+\\_>"))) + (save-excursion + ;; Search backward + (goto-char point) + (while (and (or (not (integerp limit)) (< i limit)) + (re-search-backward regexp nil t)) + (setq candidate (match-string-no-properties 0)) + (unless (member candidate candidates) + (push candidate candidates) + (cl-incf i))) + ;; Search backward + (goto-char (+ point (length prefix))) + (while (and (or (not (integerp limit)) (< i limit)) + (re-search-forward regexp nil t)) + (setq candidate (match-string-no-properties 0)) + (unless (member candidate candidates) + (push candidate candidates) + (cl-incf i))) + (nreverse candidates)))) + +(defun ac-incremental-update-word-index () + (unless (local-variable-p 'ac-word-index) + (make-local-variable 'ac-word-index)) + (if (null ac-word-index) + (setq ac-word-index (cons nil nil))) + ;; Mark incomplete + (if (car ac-word-index) + (setcar ac-word-index nil)) + (let ((index (cdr ac-word-index)) + (words (ac-candidate-words-in-buffer ac-point ac-prefix (or (and (integerp ac-limit) ac-limit) 10)))) + (dolist (word words) + (unless (member word index) + (push word index) + (setcdr ac-word-index index))))) + +(defun ac-update-word-index-1 () + (unless (local-variable-p 'ac-word-index) + (make-local-variable 'ac-word-index)) + (when (and (not (car ac-word-index)) + (< (buffer-size) 1048576)) + ;; Complete index + (setq ac-word-index + (cons t + (split-string (buffer-substring-no-properties (point-min) (point-max)) + "\\(?:^\\|\\_>\\).*?\\(?:\\_<\\|$\\)"))))) + +(defun ac-update-word-index () + (dolist (buffer (buffer-list)) + (when (or ac-fuzzy-enable + (not (eq buffer (current-buffer)))) + (with-current-buffer buffer + (ac-update-word-index-1))))) + +(defun ac-word-candidates (&optional buffer-pred) + (cl-loop initially (unless ac-fuzzy-enable (ac-incremental-update-word-index)) + for buffer in (buffer-list) + if (and (or (not (integerp ac-limit)) (< (length candidates) ac-limit)) + (if buffer-pred (funcall buffer-pred buffer) t)) + append (funcall ac-match-function + ac-prefix + (and (local-variable-p 'ac-word-index buffer) + (cdr (buffer-local-value 'ac-word-index buffer)))) + into candidates + finally return (delete-dups candidates))) + +(ac-define-source words-in-buffer + '((candidates . ac-word-candidates))) + +(ac-define-source words-in-all-buffer + '((init . ac-update-word-index) + (candidates . ac-word-candidates))) + +(ac-define-source words-in-same-mode-buffers + '((init . ac-update-word-index) + (candidates . (ac-word-candidates + (lambda (buffer) + (derived-mode-p (buffer-local-value 'major-mode buffer))))))) + +;; Lisp symbols source +(defvar ac-symbols-cache nil) +(ac-clear-variable-every-10-minutes 'ac-symbols-cache) + +(defun ac-symbol-file (symbol type) + (if (fboundp 'find-lisp-object-file-name) + (find-lisp-object-file-name symbol type) + (let ((file-name (with-no-warnings + (describe-simplify-lib-file-name + (symbol-file symbol type))))) + (when (equal file-name "loaddefs.el") + ;; Find the real def site of the preloaded object. + (let ((location (condition-case nil + (if (eq type 'defun) + (find-function-search-for-symbol symbol nil + "loaddefs.el") + (find-variable-noselect symbol file-name)) + (error nil)))) + (when location + (with-current-buffer (car location) + (when (cdr location) + (goto-char (cdr location))) + (when (re-search-backward + "^;;; Generated autoloads from \\(.*\\)" nil t) + (setq file-name (match-string 1))))))) + (if (and (null file-name) + (or (eq type 'defun) + (integerp (get symbol 'variable-documentation)))) + ;; It's a object not defined in Elisp but in C. + (if (get-buffer " *DOC*") + (if (eq type 'defun) + (help-C-file-name (symbol-function symbol) 'subr) + (help-C-file-name symbol 'var)) + 'C-source) + file-name)))) + +(defun ac-symbol-documentation (symbol) + (if (stringp symbol) + (setq symbol (intern-soft symbol))) + (ignore-errors + (with-temp-buffer + (let ((standard-output (current-buffer))) + (prin1 symbol) + (princ " is ") + (cond + ((fboundp symbol) + ;; import help-xref-following + (require 'help-mode) + (let ((help-xref-following t) + (major-mode 'help-mode)) ; avoid error in Emacs 24 + (describe-function-1 symbol)) + (buffer-string)) + ((boundp symbol) + (let ((file-name (ac-symbol-file symbol 'defvar))) + (princ "a variable") + (when file-name + (princ " defined in `") + (princ (if (eq file-name 'C-source) + "C source code" + (file-name-nondirectory file-name)))) + (princ "'.\n\n") + (princ (or (documentation-property symbol 'variable-documentation t) + "Not documented.")) + (buffer-string))) + ((facep symbol) + (let ((file-name (ac-symbol-file symbol 'defface))) + (princ "a face") + (when file-name + (princ " defined in `") + (princ (if (eq file-name 'C-source) + "C source code" + (file-name-nondirectory file-name)))) + (princ "'.\n\n") + (princ (or (documentation-property symbol 'face-documentation t) + "Not documented.")) + (buffer-string))) + (t + (let ((doc (documentation-property symbol 'group-documentation t))) + (when doc + (princ "a group.\n\n") + (princ doc) + (buffer-string))))))))) + +(defun ac-symbol-candidates () + (or ac-symbols-cache + (setq ac-symbols-cache + (cl-loop for x being the symbols + if (or (fboundp x) + (boundp x) + (symbol-plist x)) + collect (symbol-name x))))) + +(ac-define-source symbols + '((candidates . ac-symbol-candidates) + (document . ac-symbol-documentation) + (symbol . "s") + (cache))) + +;; Lisp functions source +(defvar ac-functions-cache nil) +(ac-clear-variable-every-10-minutes 'ac-functions-cache) + +(defun ac-function-candidates () + (or ac-functions-cache + (setq ac-functions-cache + (cl-loop for x being the symbols + if (fboundp x) + collect (symbol-name x))))) + +(ac-define-source functions + '((candidates . ac-function-candidates) + (document . ac-symbol-documentation) + (symbol . "f") + (prefix . "(\\(\\(?:\\sw\\|\\s_\\)+\\)") + (cache))) + +;; Lisp variables source +(defvar ac-variables-cache nil) +(ac-clear-variable-every-10-minutes 'ac-variables-cache) + +(defun ac-variable-candidates () + (or ac-variables-cache + (setq ac-variables-cache + (cl-loop for x being the symbols + if (boundp x) + collect (symbol-name x))))) + +(ac-define-source variables + '((candidates . ac-variable-candidates) + (document . ac-symbol-documentation) + (symbol . "v") + (cache))) + +;; Lisp features source +(defvar ac-emacs-lisp-features nil) +(ac-clear-variable-every-10-minutes 'ac-emacs-lisp-features) + +(defun ac-emacs-lisp-feature-candidates () + (or ac-emacs-lisp-features + (if (fboundp 'find-library-suffixes) + (let ((suffix (concat (regexp-opt (find-library-suffixes) t) "\\'"))) + (setq ac-emacs-lisp-features + (append (mapcar 'prin1-to-string features) + (cl-loop for dir in load-path + if (file-directory-p dir) + append (cl-loop for file in (directory-files dir) + if (string-match suffix file) + collect (substring file 0 (match-beginning 0)))))))))) + +(ac-define-source features + '((depends find-func) + (candidates . ac-emacs-lisp-feature-candidates) + (prefix . "require +'\\(\\(?:\\sw\\|\\s_\\)*\\)") + (requires . 0))) + +(defvaralias 'ac-source-emacs-lisp-features 'ac-source-features) + +;; Abbrev source +(ac-define-source abbrev + '((candidates . (mapcar 'popup-x-to-string (append (vconcat local-abbrev-table global-abbrev-table) nil))) + (action . expand-abbrev) + (symbol . "a") + (cache))) + +;; Files in current directory source +(ac-define-source files-in-current-dir + '((candidates . (directory-files default-directory)) + (cache))) + +;; Filename source +(defvar ac-filename-cache nil) + +(defun ac-filename-candidate () + (let (file-name-handler-alist) + (unless (or (and comment-start-skip + (string-match comment-start-skip ac-prefix)) + (file-regular-p ac-prefix)) + (ignore-errors + (cl-loop with dir = (file-name-directory ac-prefix) + with files = (or (assoc-default dir ac-filename-cache) + (let ((files (directory-files dir nil "^[^.]"))) + (push (cons dir files) ac-filename-cache) + files)) + for file in files + for path = (concat dir file) + collect (if (file-directory-p path) + (concat path "/") + path)))))) + +(ac-define-source filename + '((init . (setq ac-filename-cache nil)) + (candidates . ac-filename-candidate) + (prefix . valid-file) + (requires . 0) + (action . ac-start) + (limit . nil))) + +;; Dictionary source +(ac-define-source dictionary + '((candidates . ac-buffer-dictionary) + (symbol . "d"))) + +(provide 'auto-complete) +;;; auto-complete.el ends here diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/ada-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/ada-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/ada-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/ada-mode diff --git a/emacs.d/elpa/auto-complete-20150408.1132/dict/c++-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/c++-mode new file mode 100644 index 0000000..292dd8a --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/dict/c++-mode @@ -0,0 +1,99 @@ +alignas +alignof +and +and_eq +asm +auto +bitand +bitor +bool +break +case +catch +char +char16_t +char32_t +class +compl +concept +const +const_cast +constexpr +continue +decltype +default +define +defined +delete +do +double +dynamic_cast +elif +else +endif +enum +error +explicit +export +extern +false +final +float +for +friend +goto +if +ifdef +ifndef +include +inline +int +line +long +mutable +namespace +new +noexcept +not +not_eq +nullptr +operator +or +or_eq +override +pragma +_Pragma +private +protected +public +register +reinterpret_cast +requires +return +short +signed +sizeof +static +static_assert +static_cast +struct +switch +template +this +thread_local +throw +true +try +typedef +typeid +typename +union +unsigned +using +virtual +void +volatile +wchar_t +while +xor +xor_eq diff --git a/emacs.d/elpa/auto-complete-20150408.1132/dict/c-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/c-mode new file mode 100644 index 0000000..a4a8bac --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/dict/c-mode @@ -0,0 +1,55 @@ +auto +_Alignas +_Alignof +_Atomic +_Bool +break +case +char +_Complex +const +continue +default +define +defined +do +double +elif +else +endif +enum +error +extern +float +for +goto +_Generic +if +ifdef +ifndef +_Imaginary +include +inline +int +line +long +_Noreturn +pragma +register +restrict +return +short +signed +sizeof +static +struct +switch +_Static_assert +typedef +_Thread_local +undef +union +unsigned +void +volatile +while diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/caml-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/caml-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/caml-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/caml-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/clojure-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/clojure-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/clojure-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/clojure-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/clojurescript-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/clojurescript-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/clojurescript-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/clojurescript-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/coq-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/coq-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/coq-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/coq-mode diff --git a/emacs.d/elpa/auto-complete-20150408.1132/dict/css-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/css-mode new file mode 100644 index 0000000..f25e400 --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/dict/css-mode @@ -0,0 +1,874 @@ +!important +@font-face +@font-feature-values +@keyframes +ActiveBorder +ActiveCaption +Alpha +AppWorkspace +Background +Barn +BasicImage +Blinds +Blur +ButtonFace +ButtonHighlight +ButtonShadow +ButtonText +CaptionText +CheckerBoard +Chroma +Compositor +CradientWipe +DXImageTransform +DropShadow +Emboss +Engrave +Fade +FlipH +FlipV +Glow +Gray +GrayText +Highlight +HighlightText +Hz +ICMFilter +InactiveBorder +InactiveCaption +InactiveCaptionText +InfoBackground +InfoText +Inset +Invert +Iris +Light +MaskFilter +Matrix +Menu +MenuText +Microsoft +MotionBlur +Pixelate +RadialWipe +RandomBars +RandomDissolve +RevealTrans +Scrollbar +Shadow +Slide +Spiral +Stretch +Strips +ThreeDDarkShadow +ThreeDFace +ThreeDHighlight +ThreeDLightShadow +ThreeDShadow +Wave +Wheel +Window +WindowFrame +WindowText +Xray +Zigzag +_azimuth +_background +_background-position-x +_background-position-y +_border +_bottom +_caption +_clear +_clip +_color +_content +_counter +_cue +_cursor +_direction +_display +_elevation +_empty +_filter +_filter:progid:DXImageTransform.Microsoft +_float +_font +_height +_ime +_ime-mode +_layout +_layout-flow +_layout-grid +_layout-grid-char +_layout-grid-line +_layout-grid-mode +_layout-grid-type +_left +_letter +_line +_line-break +_list +_margin +_orphans +_outline +_overflow +_overflow-x +_overflow-y +_padding +_page +_pause +_pitch +_play +_position +_quotes +_richness +_right +_ruby +_ruby-align +_ruby-overhang +_ruby-position +_scrollbar +_scrollbar-3dlight-color +_scrollbar-arrow-color +_scrollbar-base-color +_scrollbar-darkshadow-color +_scrollbar-face-color +_scrollbar-highlight-color +_scrollbar-track-color +_speak +_speech +_stress +_table +_text +_text-align-last +_text-autospace +_text-justify +_text-kashida-space +_text-overflow +_text-underline-position +_top +_unicode +_vertical +_visibility +_voice +_volume +_white +_widows +_width +_word +_word-break +_word-wrap +_writing +_writing-mode +_z +_zoom +above +active +adjust +after +aliceblue +align +align-content +align-items +align-self +always +animation +animation-delay +animation-direction +animation-duration +animation-fill-mode +animation-iteration-count +animation-name +animation-play-state +animation-timing-function +antiquewhite +aqua +aquamarine +armenian +arrow +attachment +auto +autospace +avoid +azimuth +azure +backface-visibility +background +background-attachment +background-clip +background-color +background-image +background-origin +background-position +background-repeat +background-size +bar +base +baseline +before +behind +beige +below +bidi +bidi-override +bisque +black +blanchedalmond +blink +block +blue +blueviolet +bold +bolder +border +border-bottom +border-bottom-color +border-bottom-left-radius +border-bottom-right-radius +border-bottom-style +border-bottom-width +border-collapse +border-color +border-image +border-image-outset +border-image-repeat +border-image-slice +border-image-source +border-image-width +border-left +border-left-color +border-left-style +border-left-width +border-radius +border-right +border-right-color +border-right-style +border-right-width +border-spacing +border-style +border-top +border-top-color +border-top-left-radius +border-top-right-radius +border-top-style +border-top-width +border-width +both +bottom +box +box-decoration-break +box-shadow +box-sizing +break +break-after +break-before +break-inside +brown +burlwood +cadetblue +capitalize +caps +caption +caption-side +cell +cells +center +center-left +center-right +char +chartreuse +chocolate +circle +cjk +cjk-ideographic +clear +clip +close +close-quote +cm +code +collapse +color +column +column-count +column-fill +column-gap +column-rule +column-rule-color +column-rule-style +column-rule-width +column-span +column-width +columns +compact +condensed +content +continuous +coral +cornflowerblue +cornsilk +counter +counter-increment +counter-reset +crimson +crop +cross +crosshair +cue +cue-after +cue-before +cursive +cursor +cyan +darkblue +darkcyan +darkgoldenrod +darkgray +darkgreen +darkkhaki +darkmagenta +darkolivegreen +darkorange +darkorchid +darkred +darksalmon +darkseagreen +darkshadow +darkslateblue +darkslategray +darkturquoise +darkviolet +dashed +decimal +decimal-leading-zero +decoration +deeppink +deepskyblue +default +deg +digits +dimgray +direction +disc +display +dodgerblue +dotted +double +during +e +e-resize +elevation +em +embed +empty +empty-cells +ex +expanded +extra +extra-condensed +extra-expanded +face +family +fantasy +far +far-left +far-right +fast +faster +filter +firebrick +first +first-child +first-letter +first-line +fixed +flex +flex-basis +flex-direction +flex-flow +flex-grow +flex-shrink +flex-wrap +float +floralwhite +flow +focus +font +font-family +font-feature-setting +font-kerning +font-language-override +font-size +font-size-adjust +font-stretch +font-style +font-synthesis +font-variant +font-variant-alternates +font-variant-caps +font-variant-east-asian +font-variant-ligatures +font-variant-numeric +font-variant-position +font-weight +footer +forestgreen +fuchsia +gainsboro +georgian +ghostwhite +gold +goldenrod +gray +greek +green +greenyellow +grid +groove +group +hanging-punctuation +header +hebrew +height +help +hidden +hide +high +higher +hiragana +hiragana-iroha +honeydew +hotpink +hover +hyphens +icon +ideographic +image +image-orientation +image-rendering +image-resolution +ime-mode +in +increment +indent +index +indianred +indigo +inherit +inline +inline-block +inline-table +inset +inside +iroha +italic +item +ivory +justify +justify-content +kHz +kashida +katakana +katakana-iroha +khaki +landscape +lang() +large +larger +last +latin +lavender +lavenderblush +lawngreen +layout +leading +left +left-side +leftwards +lenonchiffon +letter +letter-spacing +level +lightblue +lightcoral +lightcyan +lighter +lightgoldenrodyellow +lightgray +lightgreen +lightgrey +lightpink +lightsalmon +lightseagreen +lightskyblue +lightslategray +lightsteelblue +lightyellow +lime +limegreen +line +line-break +line-height +line-through +linen +link +list +list-item +list-style +list-style-image +list-style-position +list-style-type +loud +low +lower +lower-alpha +lower-greek +lower-latin +lower-roman +lowercase +ltr +magenta +margin +margin-bottom +margin-left +margin-right +margin-top +mark +mark-after +mark-before +marker +marker-offset +marks +maroon +marquee-direction +marquee-play-count +marquee-speed +marquee-style +mask +mask-type +max +max-height +max-width +medium +mediumaquamarine +mediumblue +mediumorchid +mediumpurple +mediumseagreen +mediumslateblue +mediumspringgreen +mediumturquoise +mediumvioletred +menu +message +message-box +middle +midnightblue +min +min-height +min-width +mintcream +mistyrose +mix +mm +moccasin +mode +monospace +move +ms +n +n-resize +naby +narrower +nav-down +nav-index +nav-left +nav-right +nav-up +navajowhite +ne +ne-resize +no +no-close-quote +no-open-quote +no-repeat +none +normal +nowrap +number +numeral +nw +nw-resize +object-fit +object-position +oblique +offset +oldlace +olive +olivedrab +once +opacity +open +open-quote +orange +orangered +orchid +order +orphans +out +outline +outline-color +outline-offset +outline-style +outline-width +outset +outside +overflow +overflow-wrap +overflow-x +overflow-y +overhang +overline +override +padding +padding-bottom +padding-left +padding-right +padding-top +page +page-break-after +page-break-before +page-break-inside +palegoldenrod +palegreen +paleturquoise +palevioletred +papayawhip +pause +pause-after +pause-before +pc +peachpuff +perspective +perspective-origin +peru +phonemes +pink +pitch +pitch-range +play +play-during +plum +pointer +portrait +position +powderblue +pre +pre-line +pre-wrap +progid +progress +pt +punctuation +purple +px +quote +quotes +rad +range +rate +red +relative +repeat +repeat-x +repeat-y +reset +resize +rest +rest-after +rest-before +richness +ridge +right +right-side +rightwards +roman +rosybrown +row +royalblue +rtl +run +run-in +s +s-resize +saddlebrown +salmon +sandybrown +sans-serif +scroll +se +se-resize +seagreen +seashell +semi +semi-condensed +semi-expanded +separate +serif +shadow +show +side +sienna +silent +silever +silver +size +skyblue +slateblue +slategray +slow +slower +small +small-caps +small-caption +smaller +snow +soft +solid +space +spacing +speak +speak-header +speak-numeral +speak-punctuation +specific +specific-voice +speech +speech-rate +spell +spell-out +springgreen +square +static +status +status-bar +steelblue +stress +stretch +style +sub +super +sw +sw-resize +tab-size +table +table-caption +table-cell +table-column +table-column-group +table-footer-group +table-header-group +table-layout +table-row +table-row-group +tan +teal +text +text-align +text-align-last +text-bottom +text-combine-horizontal +text-decoration +text-decoration-color +text-decoration-line +text-decoration-style +text-indent +text-justify +text-orientation +text-overflow +text-shadow +text-top +text-transform +text-underline-position +thick +thin +thistle +through +tomato +top +track +transform +transform-origin +transform-style +transition +transition-delay +transition-duration +transition-property +transition-timing-function +transparent +turquoise +type +ultra +ultra-condensed +ultra-expanded +underline +unicode +unicode-bidi +upper +upper-alpha +upper-latin +upper-roman +uppercase +variant +vertical +vertical-align +violet +visibility +visible +visited +voice +voice-balance +voice-duration +voice-family +voice-pitch +voice-pitch-range +voice-rate +voice-stress +voice-volume +volume +w +w-resize +wait +weight +wheat +white +white-space +whitesmoke +wider +widows +width +word +word-break +word-spacing +word-wrap +wrap +writing-mode +x +x-fast +x-high +x-large +x-loud +x-low +x-slow +x-small +x-soft +xx +xx-large +xx-small +y +yellow +yellowgreen +z +z-index +zero diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/erlang-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/erlang-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/erlang-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/erlang-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/go-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/go-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/go-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/go-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/haskell-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/haskell-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/haskell-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/haskell-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/java-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/java-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/java-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/java-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/javascript-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/js-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/javascript-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/js-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/lua-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/lua-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/lua-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/lua-mode diff --git a/emacs.d/elpa/auto-complete-20150408.1132/dict/octave-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/octave-mode new file mode 100644 index 0000000..77c4ea1 --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/dict/octave-mode @@ -0,0 +1,46 @@ +# GNU Octave, and probably proprietary MATLAB +# https://www.gnu.org/software/octave/doc/interpreter/Keywords.html + +__FILE__ +__LINE__ +break +case +catch +classdef +continue +do +else +elseif +end +end_try_catch +end_unwind_protect +endclassdef +endenumeration +endevents +endfor +endfunction +endif +endmethods +endparfor +endproperties +endswitch +endwhile +enumeration +events +for +function +global +if +methods +otherwise +parfor +persistent +properties +return +static +switch +try +unitl +unwind_protect +unwind_protect_cleanup +while diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/php-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/php-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/php-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/php-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/python-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/python-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/python-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/python-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/qml-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/qml-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/qml-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/qml-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/ruby-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/ruby-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/ruby-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/ruby-mode diff --git a/emacs.d/elpa/auto-complete-20150408.1132/dict/scala-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/scala-mode new file mode 100644 index 0000000..b1ed3a4 --- /dev/null +++ b/emacs.d/elpa/auto-complete-20150408.1132/dict/scala-mode @@ -0,0 +1,1347 @@ +_ +: += +=> +<<: +<% +>: +# +@ +abstract +case +catch +class +def +do +else +extends +false +final +finally +for +forSome +if +implicit +import +lazy +match +new +null +object +override +package +private +protected +requires +return +sealed +super +this +throw +trait +true +try +type +val +var +while +with +yield + +scala +scala.actors +scala.actors.remote +scala.annotation.unchecked +scala.collection +scala.collection.immutable +scala.collection.jcl +scala.collection.mutable +scala.compat +scala.concurrent +scala.io +scala.mobile +scala.ref +scala.reflect +scala.runtime +scala.swing +scala.swing.event +scala.swing.test +scala.testing +scala.text +scala.util +scala.util.automata +scala.util.grammar +scala.util.logging +scala.util.matching +scala.util.parsing +scala.util.parsing.ast +scala.util.parsing.combinator +scala.util.parsing.combinator.lexical +scala.util.parsing.combinator.syntactical +scala.util.parsing.combinator.testing +scala.util.parsing.combinatorold +scala.util.parsing.combinatorold.lexical +scala.util.parsing.combinatorold.syntactical +scala.util.parsing.combinatorold.testing +scala.util.parsing.input +scala.util.parsing.json +scala.util.parsing.syntax +scala.util.regexp +scala.xml +scala.xml.dtd +scala.xml.factory +scala.xml.include +scala.xml.include.sax +scala.xml.parsing +scala.xml.path +scala.xml.persistent +scala.xml.pull +scala.xml.transform + +! +:: +AbstractActor +AbstractButton +AbstractSyntax +AbstractSyntax.Element +AbstractSyntax.NameElement +Action +Action.Trigger +Action.Trigger.Wrapper +ActionEvent +Actor +AdjustingEvent +Annotation +Any +AnyRef +AnyVal +Applet +Applet.UI +Application +Apply0 +Array +Array.Array0 +Array.ArrayLike +Array.Projection +ArrayBuffer +ArrayList +ArrayStack +Atom +AttListDecl +AttrDecl +Attribute +BackgroundChanged +Base +Base.Alt +Base.Meta +Base.RegExp +Base.Sequ +Base.Star +BaseBerrySethi +BasicTransformer +BasicTransformer.NeedsCopy +BeanDescription +BeanDisplayName +BeanInfo +BeanInfoSkip +BeanProperty +Benchmark +BigDecimal +BigInt +Binder +Binders +Binders.BinderEnv +Binders.BindingSensitive +Binders.BoundElement +Binders.ReturnAndDo +Binders.Scope +Binders.UnboundElement +Binders.UnderBinder +BindingParsers +BitSet +Boolean +BorderPanel +BoxPanel +Buffer +Buffer.DefaultBufferIterator +Buffer.Projection +Buffer.Projection0 +Buffer.Projection0.MapProjection +Buffer.Range +Buffer.Range.RangeIterator +BufferIterator +BufferProxy +BufferWrapper +BufferWrapper.IteratorWrapper +BufferWrapper.Range +BufferedIterator +BufferedIterator.Advanced +BufferedIterator.Default +BufferedIterator.PutBack +BufferedSource +Button +ButtonClicked +ButtonGroup +ByNameFunction +Byte +BytePickle.Def +BytePickle.PU +BytePickle.PicklerEnv +BytePickle.PicklerState +BytePickle.Ref +BytePickle.RefDef +BytePickle.SPU +BytePickle.UnPicklerEnv +BytePickle.UnPicklerState +CachedFileStorage +CaretUpdate +Cell +Channel +Channel.LinkedList +Char +CharArrayPosition +CharArrayReader +CharInputStreamIterator +CharSequenceReader +CheckBox +CheckMenuItem +CircularIncludeException +ClassfileAnnotation +ClassfileAttribute +CloneableCollection +Code +Collection +Collection.Projection +CollectionProxy +CollectionWrapper +ComboBox +ComboBox.BuiltInEditor +ComboBox.BuiltInEditor.DelegatedEditor +ComboBox.Editor +Comment +Component +Component.SuperMixin +ComponentAdded +ComponentEvent +ComponentHidden +ComponentMoved +ComponentRemoved +ComponentResized +ComponentShown +ConsRHS +ConsoleLogger +ConstructingHandler +ConstructingParser +Container +Container.Wrapper +Container.Wrapper.Content +ContainerEvent +ContentModel +ContentModel.ElemName +CountedIterator +CustomObjectInputStream +DEFAULT +DFAContentModel +DTD +Debug +Decl +DefaultDecl +DefaultEntry +DefaultMapModel +DefaultMarkupHandler +DetWordAutom +DocCons +DocGroup +DocNest +DocText +DocType +Document +Double +DoubleLinkedList +DtdTypeSymbol +DynamicVariable +ELEMENTS +EditDone +Either +Either.LeftProjection +Either.RightProjection +Elem +ElemDecl +ElementValidator +EmptyMap +EmptySet +EntityDecl +EntityDef +EntityRef +Enumeration +Enumeration.Set32 +Enumeration.Set64 +Enumeration.SetXX +Enumeration.Val +Enumeration.Value +Equiv +EvComment +EvElemEnd +EvElemStart +EvEntityRef +EvProcInstr +EvText +Event +Exit +ExitFun +Expression.Attrib +Expression.Child +Expression.Cond +Expression.DescOrSelf +Expression.Equals +Expression.Exists +Expression.Expr +Expression.FExp +Expression.GenExp +Expression.NameTest +Expression.Test +ExtDef +ExternalID +ExternalSources +FJTaskScheduler2 +FactoryAdapter +FatalError +FileChooser +FlatHashTable +Float +FlowPanel +FocusEvent +FocusGained +FocusLost +FontChanged +ForegroundChanged +FormattedTextField +Frame +Function0 +Function1 +Function10 +Function11 +Function12 +Function13 +Function14 +Function15 +Function16 +Function17 +Function18 +Function19 +Function2 +Function20 +Function21 +Function22 +Function3 +Function4 +Function5 +Function6 +Function7 +Function8 +Function9 +Future +GBTree +GUIApplication +GridBagPanel +GridBagPanel.Constraints +GridPanel +Group +HasKeyValue +HashEntry +HashMap +HashSet +HashTable +Hashtable +HedgeRHS +History +IScheduler +Ident +IdentityHashMap +ImmutableIterator +ImmutableMapAdaptor +ImmutableSetAdaptor +ImplicitConversions +Include +Inclusion +Index +IndexedStorage +InputChannel +InputEvent +InsertTree +Int +IntDef +IntMap +Iterable +Iterable.Projection +IterableProxy +IterableWrapper +Iterator +Iterator.PredicatedIterator +Iterator.TakeWhileIterator +JavaMapAdaptor +JavaSerializer +JavaSetAdaptor +JavaTokenParsers +Label +LabelledRHS +LayoutContainer +Left +Lexer +Lexical +LinkToFun +LinkedHashMap +LinkedHashSet +LinkedList +LinkedListQueueCreator +List +ListBuffer +ListChange +ListChanged +ListElementsAdded +ListElementsRemoved +ListEvent +ListMap +ListMap.Node +ListQueueCreator +ListSelectionChanged +ListSelectionEvent +ListSet +ListSet.Node +ListView +ListView.AbstractRenderer +ListView.ModelWrapper +ListView.Renderer +ListView.Renderer.Wrapped +ListView.selection.Indices +LocalApply0 +Location +Locator +Lock +Logged +LoggedNodeFactory +Long +LongMap +MIXED +MailBox +MainFrame +MalformedAttributeException +Map +Map.Filter +Map.KeySet +Map.Lense +Map.MapTo +Map.MutableIterableProjection +Map.Projection +Map1 +Map2 +Map3 +Map4 +MapProxy +MapWrapper +MapWrapper.IteratorWrapper +MapWrapper.KeySet +MapWrapper.ValueSet +Mappable +Mappable.Mappable +Mappable.Mapper +MarkupDecl +MarkupHandler +MarkupParser +MatchError +Menu +MenuBar +MenuItem +Message +MessageQueue +MessageQueueElement +MetaData +MouseButtonEvent +MouseClicked +MouseDragged +MouseEntered +MouseEvent +MouseExited +MouseMotionEvent +MouseMoved +MousePressed +MouseReleased +MouseWheelMoved +MultiMap +MutableIterable +MutableIterable.Filter +MutableIterable.Map +MutableIterable.Projection +MutableIterator +MutableIterator.Map +MutableIterator.Wrapper +MutableList +MutableSeq +MutableSeq.DefaultSeqIterator +MutableSeq.Filter +MutableSeq.Filter.FilterIterator +MutableSeq.Map +MutableSeq.Projection +NamedSend +NamespaceBinding +NetKernel +NoBindingFactoryAdapter +Node +NodeBuffer +NodeFactory +NodeSeq +NodeTraverser +NonLocalReturnException +NondetWordAutom +NotDefinedError +NotNull +NotationDecl +Nothing +Null +Number +ObservableBuffer +ObservableMap +ObservableSet +OffsetPosition +OpenHashMap +Option +Ordered +Ordering +Orientable +Oriented +OutputChannel +PCData +PCDataMarkupParser +PEReference +PagedSeq +PagedSeqReader +Panel +ParameterEntityDecl +ParsedEntityDecl +Parser +Parsers +Parsers.Error +Parsers.Failure +Parsers.NoSuccess +Parsers.OnceParser +Parsers.ParseResult +Parsers.Parser +Parsers.Success +Parsers.UnitOnceParser +Parsers.UnitParser +Parsers.~ +PartialFunction +PartialOrdering +PartiallyOrdered +PasswordField +PhantomReference +PointedHedgeExp +PointedHedgeExp.Node +PointedHedgeExp.TopIter +Position +Positional +Predef.ArrowAssoc +Predef.Ensuring +PrefixedAttribute +PrettyPrinter +PrettyPrinter.Box +PrettyPrinter.BrokenException +PrettyPrinter.Item +PrettyPrinter.Para +PriorityQueue +PriorityQueueProxy +ProcInstr +Product +Product1 +Product10 +Product11 +Product12 +Product13 +Product14 +Product15 +Product16 +Product17 +Product18 +Product19 +Product2 +Product20 +Product21 +Product22 +Product3 +Product4 +Product5 +Product6 +Product7 +Product8 +Product9 +ProgressBar +Proxy +PublicID +Publisher +Queue +QueueModule +QueueProxy +RadioButton +RadioMenuItem +Random +RandomAccessSeq +RandomAccessSeq.Mutable +RandomAccessSeq.MutableProjection +RandomAccessSeq.Projection +RandomAccessSeq.Projection.MapProjection +RandomAccessSeqProxy +Range +Range.Inclusive +Ranged +Ranged.Comparator +Reaction +Reactions +Reactions.Impl +Reactions.StronglyReferenced +Reactions.Wrapper +Reactor +Reader +RedBlack +RedBlack.BlackTree +RedBlack.NonEmpty +RedBlack.RedTree +RedBlack.Tree +RefBuffer +Reference +ReferenceQueue +ReferenceQueue.Wrapper +ReferenceWrapper +Regex +Regex.Match +Regex.MatchData +Regex.MatchIterator +RegexParsers +RemoteApply0 +Remove +Reset +ResizableArray +Responder +RevertableHistory +RewriteRule +RichBoolean +RichByte +RichChar +RichDouble +RichException +RichFloat +RichInt +RichLong +RichShort +RichSorting +RichString +RichStringBuilder +Right +RollbackIterator +RootPanel +RuleTransformer +SUnit.Assert +SUnit.AssertFailed +SUnit.Test +SUnit.TestCase +SUnit.TestConsoleMain +SUnit.TestFailure +SUnit.TestResult +SUnit.TestSuite +ScalaBeanInfo +ScalaObject +Scanner +Scanners +Scanners.Scanner +SchedulerAdapter +Script +Scriptable +ScrollPane +Scrollable +SelectionChanged +SelectionEvent +SendTo +Separator +Seq +Seq.Projection +Seq.Projection.ComputeSize +Seq.Projection.MapProjection +Seq.singleton +SeqIterator +SeqIterator.Map +SeqProxy +SequentialContainer +SequentialContainer.Wrapper +SerialVersionUID +Serializer +Service +Set +Set.Filter +Set.Projection +Set1 +Set2 +Set3 +Set4 +SetProxy +SetStorage +SetWrapper +Short +Show +Show.SymApply +SimpleApplet +SimpleGUIApplication +SimpleTokenizer +SingleLinkedList +SingleThreadedScheduler +Slider +SoftReference +Some +Sorted +SortedMap +SortedMap.DefaultKeySet +SortedMap.Filter +SortedMap.KeySet +SortedMap.Lense +SortedMap.Projection +SortedMap.Range +SortedMap.Range.Filter +SortedMapWrapper +SortedMapWrapper.KeySet +SortedMapWrapper.Range +SortedSet +SortedSet.Filter +SortedSet.Projection +SortedSet.Range +SortedSetWrapper +SortedSetWrapper.Range +Source +SpecialNode +SplitPane +Stack +Stack.Node +StackProxy +StandardTokenParsers +StaticAnnotation +StaticAttribute +StdLexical +StdTokenParsers +StdTokens +StdTokens.Identifier +StdTokens.Keyword +StdTokens.NumericLit +StdTokens.StringLit +Str +Stream +Stream.Definite +StreamReader +StringBuilder +Subscriber +SubsetConstruction +Swing.Embossing +Symbol +SyncChannel +SyncVar +SynchronizedBuffer +SynchronizedMap +SynchronizedPriorityQueue +SynchronizedQueue +SynchronizedSet +SynchronizedStack +SyntaxError +SystemID +TabbedPane +TabbedPane.Page +Table +Table.AbstractRenderer +Table.LabelRenderer +Table.Renderer +Table.selection.SelectionSet +TableChange +TableChanged +TableColumnsSelected +TableEvent +TableResized +TableRowsAdded +TableRowsRemoved +TableRowsSelected +TableStructureChanged +TableUpdated +TcpService +TcpServiceWorker +Tester +Text +TextArea +TextBuffer +TextComponent +TextComponent.Caret +TextComponent.HasColumns +TextComponent.HasRows +TextField +TickedScheduler +ToggleButton +TokenParsers +TokenTests +Tokens +Tokens.ErrorToken +Tokens.Token +Tree +TreeHashMap +TreeMap +TreeRHS +TreeSet +Tuple1 +Tuple10 +Tuple11 +Tuple12 +Tuple13 +Tuple14 +Tuple15 +Tuple16 +Tuple17 +Tuple18 +Tuple19 +Tuple2 +Tuple20 +Tuple21 +Tuple22 +Tuple3 +Tuple4 +Tuple5 +Tuple6 +Tuple7 +Tuple8 +Tuple9 +TypeConstraint +TypeSymbol +UIElement +UIEvent +UnavailableResourceException +UnbalancedTreeMap +UnbalancedTreeMap.Node +Undoable +UninitializedError +UninitializedFieldError +Unit +UnlinkFromFun +Unparsed +UnparsedEntityDecl +UnprefixedAttribute +Update +ValidatingMarkupHandler +ValidationException +ValueChanged +WeakHashMap +WeakReference +WindowActivated +WindowClosed +WindowClosing +WindowDeactivated +WindowDeiconified +WindowEvent +WindowIconified +WindowOpened +WordBerrySethi +WordExp +WordExp.Label +WordExp.Letter +WordExp.Wildcard +WorkerThread +WorkerThreadScheduler +XIncludeException +XIncludeFilter +XIncluder +XMLEvent +XMLEventReader +XMLEventReader.Parser +XhtmlParser +cloneable +deprecated +inline +jolib.Asynchr +jolib.Join +jolib.Signal +jolib.Synchr +native +noinline +pilib.Chan +pilib.GP +pilib.Product +pilib.Spawn +pilib.Sum +pilib.UChan +pilib.UGP +remote +serializable +throws +transient +unchecked +uncheckedStable +uncheckedVariance +unsealed +volatile +~ + +! +:: +ANY +Action +Action.NoAction +Action.Trigger +ActionEvent +Actor +ActorGC +Alignment +AnyHedgeRHS +AnyTreeRHS +Apply0 +Array +AttListDecl +AttrDecl +BackgroundChanged +Base.Eps +BigDecimal +BigDecimal.RoundingMode +BigInt +Binders.EmptyBinderEnv +Binders.UnderBinder +BorderPanel +BorderPanel.Position +Buffer +BufferedIterator +BufferedSource +ButtonApp +ButtonClicked +BytePickle +CaretUpdate +Cell +CelsiusConverter +CelsiusConverter2 +CharArrayReader +CharSequenceReader +Collection +ComboBox +ComboBox.selection +ComboBoxes +Comment +Component +Component.Mouse +ComponentAdded +ComponentHidden +ComponentMoved +ComponentRemoved +ComponentResized +ComponentShown +ConsRHS +Console +ConstructingParser +Container +ContentModel +ContentModel.Translator +ContentModelParser +Conversions +CountButton +DEFAULT +Debug +Dialog +Dialog.Message +Dialog.Options +Dialog.Result +Dialogs +DocBreak +DocCons +DocGroup +DocNest +DocNil +DocText +DocType +Document +ELEMENTS +EMPTY +EditDone +Either +Elem +ElemDecl +EmptyHedgeRHS +EncodingHeuristics +End +EntityRef +EvComment +EvElemEnd +EvElemStart +EvEntityRef +EvProcInstr +EvText +Exit +Expression +Expression.Root +Expression.WildcardTest +ExtDef +FatalError +FileChooser +FileChooser.Result +FileChooser.SelectionMode +FlowPanel +FlowPanel.Alignment +FocusGained +FocusLost +FontChanged +ForegroundChanged +FormattedTextField +FormattedTextField.FocusLostBehavior +FreshNameCreator +Function +Futures +GridBagDemo +GridBagPanel +GridBagPanel.Anchor +GridBagPanel.Fill +GridPanel +Group +HashMap +HashSet +HelloWorld +IMPLIED +Ident +ImmutableIterator +ImmutableIterator.Empty +Include +Index +IntDef +IntMap +Iterable +Iterator +JSON +Key +LabelledRHS +Left +LinkedHashMap +LinkedHashSet +List +ListChanged +ListElementsAdded +ListElementsRemoved +ListMap +ListSelectionChanged +ListSet +ListView +ListView.GenericRenderer +ListView.IntervalMode +ListView.Renderer +ListView.selection +ListView.selection.indices +ListView.selection.items +LocalApply0 +Location +Locator +LongMap +MIXED +Main +MakeValidationException +MalformedAttributeException +Map +Marshal +Math +MetaData +MouseClicked +MouseDragged +MouseEntered +MouseExited +MouseMoved +MousePressed +MouseReleased +MouseWheelMoved +MutableIterable +MutableIterator +MutableSeq +NA +NamedSend +Nil +NoPosition +Node +NodeSeq +None +NotationDecl +Null +Number +OffsetPosition +OpenHashMap +Option +Orientation +PCDATA +PCData +PEReference +PagedSeq +PagedSeqReader +ParameterEntityDecl +ParsedEntityDecl +Parsing +Platform +PointedHedgeExp.Point +Position +Predef +Predef.Pair +Predef.Triple +PrettyPrinter.Break +ProcInstr +Product1 +Product10 +Product11 +Product12 +Product13 +Product14 +Product15 +Product16 +Product17 +Product18 +Product19 +Product2 +Product20 +Product21 +Product22 +Product3 +Product4 +Product5 +Product6 +Product7 +Product8 +Product9 +Properties +PublicID +QNode +Queue +REQUIRED +RandomAccessSeq +Range +Reactions +RedBlack.Empty +Regex +Regex.Match +RegexTest +RemoteActor +RemoteApply0 +Remove +Reset +Responder +RichString +Right +SUnit +Scheduler +SelectionChanged +SendTo +Seq +SequentialContainer +Set +SimpleApplet.ui +Some +SortedMap +SortedSet +Sorting +Source +Stack +Start +Str +Stream +Stream.cons +Stream.lazy_:: +StreamReader +StringBuilder +Swing +Swing.EmptyIcon +Swing.Lowered +Swing.Raised +SwingApp +Symbol +SystemID +TIMEOUT +TabbedPane +TabbedPane.Layout +TabbedPane.pages +TabbedPane.selection +Table +Table.AutoResizeMode +Table.ElementMode +Table.IntervalMode +Table.selection +Table.selection.columns +Table.selection.rows +TableChanged +TableColumnsSelected +TableResized +TableRowsAdded +TableRowsRemoved +TableRowsSelected +TableSelection +TableStructureChanged +TableUpdated +TcpService +Terminate +Text +TextBuffer +TextComponent +TextComponent.caret +Tokens.EOF +TopScope +TreeHashMap +TreeMap +TreeSet +Tuple1 +Tuple10 +Tuple11 +Tuple12 +Tuple13 +Tuple14 +Tuple15 +Tuple16 +Tuple17 +Tuple18 +Tuple19 +Tuple2 +Tuple20 +Tuple21 +Tuple22 +Tuple3 +Tuple4 +Tuple5 +Tuple6 +Tuple7 +Tuple8 +Tuple9 +UIDemo +UTF8Codec +UnbalancedTreeMap +UninitializedFieldError +Unparsed +UnparsedEntityDecl +Update +Utility +ValidationException +ValueChanged +WindowActivated +WindowClosed +WindowClosing +WindowDeactivated +WindowDeiconified +WindowIconified +WindowOpened +XML +Xhtml +XhtmlEntities +XhtmlParser +jolib +mkTilde +ops +pilib +~ + +ArrayIndexOutOfBoundsException +Character +Class +ClassCastException +Error +Exception +Function +IllegalArgumentException +IndexOutOfBoundsException +Integer +Map +NoSuchElementException +NullPointerException +NumberFormatException +Pair +Runnable +RuntimeException +Set +String +StringIndexOutOfBoundsException +Throwable +Triple +Tuple +UnsupportedOperationException +any2ArrowAssoc +any2Ensuring +any2stringadd +assert +assume +boolean +boolean2Boolean +booleanWrapper +byte +byte2Byte +byte2double +byte2float +byte2int +byte2long +byte2short +byteWrapper +char +char2Character +char2double +char2float +char2int +char2long +charWrapper +classOf +currentThread +double +double2Double +doubleWrapper +error +exceptionWrapper +exit +float +float2Float +float2double +floatWrapper +forceArrayProjection +forceRandomAccessCharSeq +format +identity +int +int2Integer +int2double +int2float +int2long +intWrapper +iterable2ordered +lazyStreamToConsable +long +long2Long +long2double +long2float +longWrapper +print +printf +println +readBoolean +readByte +readChar +readDouble +readFloat +readInt +readLine +readLong +readShort +readf +readf1 +readf2 +readf3 +require +seqToCharSequence +short +short2Short +short2double +short2float +short2int +short2long +shortWrapper +stringBuilderWrapper +stringWrapper +tuple22ordered +tuple32ordered +tuple42ordered +tuple52ordered +tuple62ordered +tuple72ordered +tuple82ordered +tuple92ordered +unit +unit2ordered diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/scheme-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/scheme-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/scheme-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/scheme-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/sclang-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/sclang-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/sclang-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/sclang-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/sh-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/sh-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/sh-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/sh-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/tcl-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/tcl-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/tcl-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/tcl-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/ts-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/ts-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/ts-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/ts-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/tuareg-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/tuareg-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/tuareg-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/tuareg-mode diff --git a/emacs.d/elpa/auto-complete-20140824.1658/dict/verilog-mode b/emacs.d/elpa/auto-complete-20150408.1132/dict/verilog-mode similarity index 100% rename from emacs.d/elpa/auto-complete-20140824.1658/dict/verilog-mode rename to emacs.d/elpa/auto-complete-20150408.1132/dict/verilog-mode diff --git a/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-autoloads.el b/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-autoloads.el deleted file mode 100644 index f2524b0..0000000 --- a/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-autoloads.el +++ /dev/null @@ -1,16 +0,0 @@ -;;; auto-complete-etags-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("auto-complete-etags.el") (21570 25620 -;;;;;; 582723 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; auto-complete-etags-autoloads.el ends here diff --git a/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-pkg.el b/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-pkg.el deleted file mode 100644 index 442433c..0000000 --- a/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "auto-complete-etags" "0.2" "Auto-complete etags" '((auto-complete "1.3"))) diff --git a/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags.el b/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags.el deleted file mode 100644 index cf936e1..0000000 --- a/emacs.d/elpa/auto-complete-etags-0.2/auto-complete-etags.el +++ /dev/null @@ -1,69 +0,0 @@ -;;; auto-complete-etags.el --- Auto-complete etags - -;; Copyright 2009 Yen-Chin,Lee -;; -;; Author: Yen-Chin,Lee -;; Version: 0.2 -;; $Id: auto-complete-etags.el,v 0.2 2009/04/23 00:38:01 coldnew Exp $ -;; Keywords: -;; X-URL: not distributed yet -;; Package-Requires: ((auto-complete "1.3")) - - -;; Change Log: -;; 08-Feb-2011 Matthew L. Fidler -;; Changed to match ELPA standards - - - -;; 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -;;; Commentary: - -;; - -;; Put this file into your load-path and the following into your ~/.emacs: -;; (require 'auto-complete-etags) - -;;; Code: - -(provide 'auto-complete-etags) -(require 'auto-complete) -(eval-when-compile - (require 'cl)) - - -;;;;########################################################################## -;;;; User Options, Variables -;;;;########################################################################## - -(defface ac-etags-candidate-face - '((t (:background "gainsboro" :foreground "deep sky blue"))) - "Face for etags candidate") - -(defface ac-etags-selection-face - '((t (:background "deep sky blue" :foreground "white"))) - "Face for the etags selected candidate.") - -(defvar ac-source-etags - '((candidates . (lambda () - (all-completions ac-target (tags-completion-table)))) - (candidate-face . ac-etags-candidate-face) - (selection-face . ac-etags-selection-face) - (requires . 3)) - "Source for etags.") - -(provide 'auto-complete-etags) -;;; auto-complete-etags.el ends here diff --git a/emacs.d/elpa/bison-mode-20141119.43/bison-mode-autoloads.el b/emacs.d/elpa/bison-mode-20141119.43/bison-mode-autoloads.el deleted file mode 100644 index 042d4d0..0000000 --- a/emacs.d/elpa/bison-mode-20141119.43/bison-mode-autoloads.el +++ /dev/null @@ -1,28 +0,0 @@ -;;; bison-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "bison-mode" "bison-mode.el" (21739 37356 0 -;;;;;; 0)) -;;; Generated autoloads from bison-mode.el - -(add-to-list 'auto-mode-alist '("\\.y\\'" . bison-mode)) - -(add-to-list 'auto-mode-alist '("\\.l\\'" . bison-mode)) - -(add-to-list 'auto-mode-alist '("\\.jison\\'" . jison-mode)) - -(autoload 'bison-mode "bison-mode" "\ -Major mode for editing bison/yacc files. - -\(fn)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; bison-mode-autoloads.el ends here diff --git a/emacs.d/elpa/bison-mode-20141119.43/bison-mode-pkg.el b/emacs.d/elpa/bison-mode-20141119.43/bison-mode-pkg.el deleted file mode 100644 index b867662..0000000 --- a/emacs.d/elpa/bison-mode-20141119.43/bison-mode-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "bison-mode" "20141119.43" "Major mode for editing bison, yacc and lex files." 'nil :keywords '("bison-mode" "yacc-mode")) diff --git a/emacs.d/elpa/bison-mode-20141119.43/bison-mode.el b/emacs.d/elpa/bison-mode-20141119.43/bison-mode.el deleted file mode 100644 index 664c0fe..0000000 --- a/emacs.d/elpa/bison-mode-20141119.43/bison-mode.el +++ /dev/null @@ -1,908 +0,0 @@ -;;; bison-mode.el --- Major mode for editing bison, yacc and lex files. - -;; Copyright (C) 1998 Eric Beuscher -;; -;; Author: Eric Beuscher -;; Created: 2 Feb 1998 -;; Version: 20141119.43 -;; X-Original-Version: 0.2 -;; Keywords: bison-mode, yacc-mode - -;; 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 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. - -;;; Commentary: - -;;;; I wrote this since I saw one mode for yacc files out there roaming the -;;;; world. I was daunted by the fact the it was written in 1990, and Emacs -;;;; has evolved so much since then (this I assume based on its evolution since -;;;; i started using it). So I figured if i wanted one, I should make it -;;;; myself. Please excuse idiosyncrasies, as this was my first major mode -;;;; of this kind. The indentation code may be a bit weird, I am not sure, -;;;; it was my first go at doing Emacs indentation, so I look at how other -;;;; modes did it, but then basically did what I thought was right - -;;;; I hope this is useful to other hackers, and happy Bison/Yacc hacking -;;;; If you have ideas/suggestions/problems with this code, I can be reached at -;;;; beuscher@eecs.tulane.edu - -;;;; Eric --- Sat Mar 7 1:40:20 CDT 1998 - -;;;; Bison Sections: -;;;; there are five sections to a bison file (if you include the area above the -;;;; C declarations section. most everything in this file either does -;;;; actions based on which section you are deemed to be in, or based on an -;;;; assumption that the function will only be called from certain sections. -;;;; the function `bison--section-p' is the section parser - -;;;; Indentation: -;;;; indentations are done based on the section of code you are in. there is -;;;; a procedure `bison--within-braced-c-expression-p' that checks for being in -;;;; C code. if you are within c-code, indentations should occur based on -;;;; how you have your C indentation set up. i am pretty sure this is the -;;;; case. -;;;; there are four variables, which control bison indentation within either -;;;; the bison declarations section or the bison grammar section -;;;; `bison-rule-separator-column' -;;;; `bison-rule-separator-column' -;;;; `bison-decl-type-column' -;;;; `bison-decl-token-column' - -;;;; flaw: indentation works on a per-line basis, unless within braced C sexp, -;;;; i should fix this someday -;;;; and to make matters worse, i never took out c-indent-region, so that is -;;;; still the state of the `indent-region-function' variable - -;;;; Electricity: -;;;; by default, there are electric -colon, -pipe, -open-brace, -close-brace, -;;;; -semicolon, -percent, -less-than, -greater-than -;;;; the indentation caused by these work closely with the 4 indentation -;;;; variables mentioned above. -;;;; any of these can be turned off individually by setting the appropriate -;;;; `bison-electric-...' variable. or all of them can be turned off by -;;;; setting `bison-all-electricity-off' - -;;;; todo: should make available a way to use C-electricity if in C sexps - -;;; Code: - -(require 'cc-mode) - -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.y\\'" . bison-mode)) -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.l\\'" . bison-mode)) -;;;###autoload -(add-to-list 'auto-mode-alist '("\\.jison\\'" . jison-mode)) - -;; *************** internal vars *************** - -(defvar bison--declarers '("%union" "%token" "%type" - "%left" "%right" "%nonassoc") - "commands which can declare a token or state type") - -(defvar bison--word-constituent-re "\\(\\sw\\|_\\)") -(defvar bison--production-re - (concat "^" bison--word-constituent-re "+:")) - -(defvar bison--pre-c-decls-section 0 - "section before c-declarations-section, if that section exists") -(defvar bison--c-decls-section 1 - "section denoted by %{ and $} for c-declarations at the top of a bison file") -(defvar bison--bison-decls-section 2 - "section before the rules section") -(defvar bison--grammar-rules-section 3 - "section delimited by %%'s where productions and rules are enumerated") -(defvar bison--c-code-section 4 - "section after the second %% where c-code can be placed") - -(defvar bison--c-decls-section-opener "%{") -(defvar bison--c-decls-section-closer "%}") -(defvar bison--grammar-rules-section-delimeter "%%") - - -;; *************** user-definable vars *************** - -(defvar bison-rule-separator-column 8 - "column for rule and production separators \"|\" and \";\"") -(defvar bison-rule-enumeration-column 16 - "column for beginning enumeration of a production's rules") -(defvar bison-decl-type-column 8 - "columnn in which tokens' and states' types should be when declared") -(defvar bison-decl-token-column 24 - "column in which tokens and states are listed when declared, -as with %token, %type, ...") - - -(defvar bison-all-electricity-off nil - "non-nil means all electric keys will be disabled, -nil means that a bison-electric-* key will be on or off based on the individual -key's electric variable") - -;;; i know lisp has the dual name spaces, but i find it more aesthetically -;;; pleasing to not take advantage of that -(defvar bison-electric-colon-v t - "non-nil means use an electric colon") -(defvar bison-electric-pipe-v t - "non-nil means use an electric pipe") -(defvar bison-electric-open-brace-v t - "non-nil means use an electric open-brace") -(defvar bison-electric-close-brace-v t - "non-nil means use an electric close-brace") -(defvar bison-electric-semicolon-v t - "non-nil means use an electric semicolon") -(defvar bison-electric-percent-v t - "non-nil means use an electric percent") -(defvar bison-electric-less-than-v t - "non-nil means use an electric less-than") -(defvar bison-electric-greater-than-v t - "non-nil means use an electric greater-than") - - -(defconst bison-font-lock-keywords - (append - (list - (cons (concat "^\\(" (regexp-opt bison--declarers) "\\)") - '(1 font-lock-keyword-face)) - ) - c-font-lock-keywords) - "Default expressions to highlight in Bison mode") - -;; *************** utilities *************** - -(defun just-no-space () - "Delete all spaces and tabs around point, leaving no spaces." - (interactive "*") - (skip-chars-backward " \t") - (delete-region (point) (progn (skip-chars-forward " \t") (point))) - t) - -(defun previous-white-space-p () - "return t if there is whitespace between the beginning of the line and the -current (point)" - (save-excursion - (let ((current-point (point))) - (beginning-of-line) - (if (re-search-forward "\\s " current-point t) - t - nil)))) - -(defun previous-non-ws-p () - "return t if there are non-whitespace characters between beginning of line -and \(point\)" - (save-excursion - (let ((current-point (point))) - (beginning-of-line) - (re-search-forward "[^ \t]" current-point t) - ))) - -(defun following-non-ws-p () - "return t if there are non-whitespace characters on the line" - (save-excursion - (let ((current-point (point))) - (end-of-line) - (re-search-backward "[^ \t]+" current-point t) - ))) - -(defun line-of-whitespace-p () - "return t if the line consists of nothiing but whitespace, nil otherwise" - (save-excursion - (let ((eol (progn (end-of-line) (point)))) - (beginning-of-line) ;; should already be there anyway - (not (re-search-forward "[^ \t\n]" eol t))))) - -;; *************** bison-mode *************** - -;;;###autoload -(define-derived-mode bison-mode c-mode "Bison" - "Major mode for editing bison/yacc files." - - ;; try to set the indentation correctly - (setq c-basic-offset 4) - - (c-set-offset 'knr-argdecl-intro 0) - - ;; remove auto and hungry anything - (c-toggle-auto-hungry-state -1) - (c-toggle-auto-newline -1) - (c-toggle-hungry-state -1) - - (use-local-map bison-mode-map) - - (define-key bison-mode-map ":" 'bison-electric-colon) - (define-key bison-mode-map "|" 'bison-electric-pipe) - (define-key bison-mode-map "{" 'bison-electric-open-brace) - (define-key bison-mode-map "}" 'bison-electric-close-brace) - (define-key bison-mode-map ";" 'bison-electric-semicolon) - (define-key bison-mode-map "%" 'bison-electric-percent) - (define-key bison-mode-map "<" 'bison-electric-less-than) - (define-key bison-mode-map ">" 'bison-electric-greater-than) - - (define-key bison-mode-map [tab] 'bison-indent-line) - - (make-local-variable 'indent-line-function) - (setq indent-line-function 'bison-indent-new-line) - (make-local-variable 'comment-start) - (make-local-variable 'comment-end) - (setq comment-start "/*" - comment-end "*/") - (make-local-variable 'font-lock-keywords) - (setq font-lock-keywords nil) - (set (make-local-variable 'font-lock-defaults) '(bison-font-lock-keywords))) - - -;; *************** section parsers *************** - -(defun bison--section-p () - "Return the section that user is currently in" - (save-excursion - (let ((bound (point))) - (goto-char (point-min)) - (bison--section-p-helper bound)))) - -(defun bison--section-p-helper (bound) - (if (re-search-forward - (concat "^" bison--c-decls-section-opener) - bound t) - (if (re-search-forward - (concat "^" bison--c-decls-section-closer) - bound t) - (if (re-search-forward - (concat "^" bison--grammar-rules-section-delimeter) - bound t) - (if (re-search-forward - (concat "^" bison--grammar-rules-section-delimeter) - bound t) - bison--c-code-section - bison--grammar-rules-section) - bison--bison-decls-section) - bison--c-decls-section) - (if (re-search-forward - (concat "^" bison--grammar-rules-section-delimeter) - bound t) - (if (re-search-forward - (concat "^" bison--grammar-rules-section-delimeter) - bound t) - bison--c-code-section - bison--grammar-rules-section) - (if (re-search-forward - (concat "^" bison--c-decls-section-opener) - nil t) - bison--pre-c-decls-section - (if (re-search-forward - (concat "^" bison--grammar-rules-section-delimeter) - nil t) - bison--bison-decls-section - bison--pre-c-decls-section))))) - - -;; *************** syntax parsers *************** - -(defun bison--production-p () - "return t if the \(point\) rests immediately after a production" - (save-excursion - (let ((current-point (point))) - (beginning-of-line) - (let ((position (re-search-forward - bison--production-re current-point t))) - (and position - (not (previous-white-space-p)) - (= position current-point)))))) - -(defun bison--find-production-opener () - "return and goto the point of the nearest production opener above \(point\)" - (re-search-backward bison--production-re nil t)) - - -(defun bison--find-next-production () - "return the position of the beginning of the next production, -or nil if there isnt one" - (save-excursion - (if (re-search-forward bison--production-re nil t) - (progn - (beginning-of-line) - (point)) - nil))) - -(defun bison--find-grammar-end () - "return the position of the end of the grammar rules (assuming we are within -the grammar rules section), or nil if there isnt one" - (save-excursion - (if (re-search-forward - (concat "^" bison--grammar-rules-section-delimeter) - nil t) - (progn - (beginning-of-line) - (point)) - nil))) - -(defun bison--find-grammar-begin () - "return the position of the beginning of the grammar rules (assuming we are -within the grammar rules section), or nil if there isnt one" - (save-excursion - (if (re-search-backward - (concat "^" bison--grammar-rules-section-delimeter) - nil t) - (point) - nil))) - -(defun bison--within-started-production-p () - "is used by bison-electric-* functions to determine actions -return t if within a production, nil if not - -a point is within a production if there is some non whitespace text before -either the beginnings of another production or the end of the grammar rules" - (save-excursion - (let ((bound (cond ((bison--find-next-production)) - ((bison--find-grammar-end)) - (t nil)))) - (if bound - (let ((sval (re-search-forward - (concat "\\(\\s \\|" ;; whitespace or - ;; comments - (regexp-quote comment-start) - "\\(.\\|\n\\)*" ;; comment body - (regexp-quote comment-end) - "\\)+") ;; end or - bound t))) - (if sval - (not (= sval bound)) - nil)) - nil)))) - -(defun bison--within-some-sexp-p (starter ender) - "return t if the \(point\) is within the sexp marked by the re's STARTER and -ENDER" - (save-excursion - (let ((current-point (point))) - (if (re-search-backward starter nil t) ;; find nearest starter - ;; look for ender, if found, then not within sexp - (progn - (goto-char (match-end 0)) - (not (re-search-forward ender current-point t))))))) - -(defun bison--within-c-comment-p () - "return t if the point is within a c comment delimited by \"/*\" \"*/\"" - (bison--within-some-sexp-p (regexp-quote comment-start) - (regexp-quote comment-end))) - - -(defun bison--within-string-p (&optional point) - " -start from the beginning of the buffer and toggle state as un-escaped \"'s are -found." - (let ((point (or point (point))) - (in-p nil)) - (save-excursion - (goto-char (point-min)) - - (while (re-search-forward "[^\\]\"" point t) - (setq in-p (not in-p))) - - in-p))) - -;;; bison--within-braced-c-expression-p -;;; new and improved, no more recursion, does not break when literal strings -;;; contain un-matched braces -(defun bison--within-braced-c-expression-p (section) - "return t if the point is within an sexp delimited by braces \({,}\) -" - (save-excursion - (bison--within-braced-c-expression-p-h section (point)))) - -(defun bison--within-braced-c-expression-p-h (section low-pt) - " -Notes: -save excursion is done higher up, so i dont concern myself here. -" - (cond ((= section bison--pre-c-decls-section) nil) - ((= section bison--c-decls-section) - (let ((opener (save-excursion (search-backward "%{")))) - (bison--within-braced-c-expression-p-h-h opener low-pt))) - ((= section bison--bison-decls-section) - (let ((opener (save-excursion - (or (search-backward "%}" nil t) - (point-min))))) - (bison--within-braced-c-expression-p-h-h opener low-pt))) - ((= section bison--grammar-rules-section) - (let ((opener (save-excursion (bison--find-production-opener)))) - (if opener - (bison--within-braced-c-expression-p-h-h opener low-pt) - nil))) - ((= section bison--c-code-section) - t))) - -(defun bison--within-braced-c-expression-p-h-h (high-pt low-pt) - " -Notes: -HIGH-PT goes toward (point-min), LOW-PT goes toward (point-max) -save excursion is done higher up, so i dont concern myself here. -" - (let ((pt (point))) - (let ((success nil) (count 1) (done nil)) - ;; loop until open brace found, that is not in comment or string literal - (while (and (not done) - (re-search-backward "[^%]{" high-pt t count)) ;find nearest - ;starter - (goto-char (match-end 0)) - (if (or (bison--within-c-comment-p) - (bison--within-string-p)) - - (setq count (+ count 1)) - (progn - (setq success t) - (setq done t)))) - - (if success - (let ((end-pt - (condition-case nil - (progn - (backward-char) - (forward-sexp) - (point)) - (error nil)))) - (if end-pt - (if (> end-pt low-pt) - t ; then in braced-c-exp - nil) - t)) ; if no sexp close brace, then w/in - nil)))) - - -(defun bison--bison-decl-opener-p (bol eol) - "return t if the current line is a bison declaration starter -\(i.e. has a %type, %token, %right, ...\)" - (save-excursion - (goto-char bol) - (re-search-forward - (concat "^" (regexp-opt (copy-sequence bison--declarers))) eol t))) - -(defun bison--production-opener-p (bol eol) - "return t if the current line is a line that introduces a new production" - (save-excursion - (goto-char bol) - (re-search-forward bison--production-re eol t))) - -(defun bison--find-bison-semicolon () - "return the position of next semicolon not within braces, nil otherwise" - (save-excursion - (if (search-forward ";" nil t) - (if (not (bison--within-braced-c-expression-p (bison--section-p))) - (point) - (bison--find-bison-semicolon)) - nil))) - -(defun bison--within-production-body-p (section) - "return t if the \(point\) is within the body of a production - -this procedure will fail if it is in a production header" - (save-excursion - (if (= section bison--grammar-rules-section) - (let ((current-point (point))) - (if (re-search-backward bison--production-re nil t) - t - nil)) - nil))) - -(defun bison--production-alternative-p (bol eol section) - "return t if the current line contains a \"|\" used to designate a rule -alternative" - (save-excursion - (goto-char bol) - (if (search-forward "|" eol t) - (not (bison--within-braced-c-expression-p section)) - nil))) - - -;; *************** indent functions *************** - -(defun bison--handle-indent-c-sexp (section indent-column bol) - (let* ((o-brace (re-search-backward "[^%]{" bol t)) - ) - (if o-brace - (if (save-excursion - (goto-char o-brace) - (bison--within-braced-c-expression-p section)) - (c-indent-line) - (if (= (current-indentation) o-brace) ;; if o-brace is first char - (if (not (= o-brace indent-column)) ;; but not in right spot - (progn - (back-to-indentation) - (just-no-space) - (indent-to-column indent-column)) - ;; else all is good - ) - ;; else, non-ws before o-brace, leave it alone - )) - (c-indent-line)))) - -(defun bison-indent-new-line (&optional c-sexp) - "Indent a fresh line of bison code - -assumes indenting a new line, i.e. at column 0 -" - (interactive) - - (let* ((section (bison--section-p)) - (c-sexp (or c-sexp (bison--within-braced-c-expression-p section))) - ) - (cond - (c-sexp - (cond - ((= section bison--grammar-rules-section) - (c-indent-line - (save-excursion - (forward-line -1) - (let ((bol (save-excursion (beginning-of-line) (point))) - (eol (save-excursion (end-of-line) (point)))) - (if (bison--production-opener-p bol eol) - (list - (cons 'defun-block-intro - (progn - (re-search-forward bison--production-re) ; SIGERR - (- (re-search-forward "[^ \t]") ; SIGERR - 1)))) - nil))))) - (t (c-indent-line)))) - ((= section bison--pre-c-decls-section) - (c-indent-line)) - ((= section bison--bison-decls-section) - (indent-to-column bison-decl-token-column)) - ((= section bison--grammar-rules-section) - (indent-to-column - (save-excursion - (let* ((bound (or (save-excursion (bison--find-production-opener)) - (bison--find-grammar-begin))) - (prev-semi (search-backward ";" bound t)) - ) - (if prev-semi - (if (bison--within-braced-c-expression-p section) ; CRACK - bison-rule-enumeration-column - 0) - (if (save-excursion (bison--find-production-opener)) - bison-rule-enumeration-column - 0)))))) - ((= section bison--c-code-section)) ;;leave-alone - ))) - -(defun bison-indent-line () - "Indent a line of bison code." - (interactive) - - (let* ((pos (- (point-max) (point))) - (reset-pt (function (lambda () - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos)))))) - (bol (save-excursion (beginning-of-line) (point))) - (eol (save-excursion (end-of-line) (point))) - ) - (let* ((section (bison--section-p)) - (c-sexp (bison--within-braced-c-expression-p section)) - (ws-line (line-of-whitespace-p)) - ) - (cond - ;; if you are a line of whitespace, let indent-new-line take care of it - (ws-line - (bison-indent-new-line c-sexp)) - - ((= section bison--pre-c-decls-section) - ;; leave things alone - ) - - ((= section bison--c-decls-section) - (if c-sexp - (bison--handle-indent-c-sexp section 0 bol) - (if (not (= (current-indentation) 0)) - (progn - (back-to-indentation) - (just-no-space) - (funcall reset-pt))))) - - ((= section bison--bison-decls-section) - (let ((opener (bison--bison-decl-opener-p bol eol))) - (cond - (opener - (goto-char opener) - (skip-chars-forward " \t" eol) - (if (looking-at "{") - (save-excursion - (if (following-non-ws-p) - (progn - (forward-char 1) - (just-no-space) - (newline) - (bison-indent-new-line t)))) - (let ((complete-type t)) - (if (looking-at "<") - (progn - (setq complete-type nil) - (if (not (= (current-column) bison-decl-type-column)) - (progn - (just-no-space) - (indent-to-column bison-decl-type-column)) - (and (re-search-forward - (concat "<" bison--word-constituent-re "+>") - eol t) - (setq complete-type t))))) - (and complete-type - (skip-chars-forward " \t" eol) - (looking-at - (concat "\\(" bison--word-constituent-re "\\|'\\)")) - (if (not (= (current-column) bison-decl-token-column)) - (progn - (just-no-space) - (indent-to-column bison-decl-token-column)))))) - (funcall reset-pt)) - (c-sexp - (bison--handle-indent-c-sexp section 0 bol)) - (t - (back-to-indentation) - ;; only tab in names, leave comments alone - (cond (;; put word-constiuents in bison-decl-token-column - (looking-at bison--word-constituent-re) - (if (not (= (current-column) bison-decl-token-column)) - (progn - (just-no-space) - (indent-to-column bison-decl-token-column)))) - ;; put/keep close-brace in the 0 column - ((looking-at "}") - (if (not (= (current-column) 0)) - (just-no-space))) - ;; leave comments alone - ((looking-at (regexp-quote comment-start)) nil) - ;; else do nothing - ) - (funcall reset-pt))))) - ((= section bison--grammar-rules-section) - (cond - ((bison--production-opener-p bol eol) - (beginning-of-line) - (re-search-forward bison--production-re);; SIGERR - (if (following-non-ws-p) - (if (> (current-column) bison-rule-enumeration-column) - (progn - (just-no-space) - (newline) - (indent-to-column bison-rule-enumeration-column)) - (save-excursion - (re-search-forward bison--word-constituent-re);; SIGERR - (let ((col (current-column))) - (cond ((> col (+ 1 bison-rule-enumeration-column)) - (forward-char -1) - (just-no-space) - (indent-to-column bison-rule-enumeration-column)) - ((< col (+ 1 bison-rule-enumeration-column)) - (forward-char -1) - (indent-to-column - bison-rule-enumeration-column))))))) - (funcall reset-pt)) - ((bison--production-alternative-p bol eol section) - (back-to-indentation);; should put point on "|" - (if (not (= (current-column) bison-rule-separator-column)) - (progn - (just-no-space) - (indent-to-column bison-rule-separator-column))) - (forward-char 1) - (if (following-non-ws-p) - (save-excursion - (re-search-forward bison--word-constituent-re);; SIGERR - (let ((col (current-column))) - (cond ((> col (+ 1 bison-rule-enumeration-column)) - (forward-char -1) - (just-no-space) - (indent-to-column bison-rule-enumeration-column)) - ((< col (+ 1 bison-rule-enumeration-column)) - (forward-char -1) - (indent-to-column - bison-rule-enumeration-column)))))) - (funcall reset-pt)) - (c-sexp - (bison--handle-indent-c-sexp - section bison-rule-enumeration-column bol) - (funcall reset-pt)) - ((bison--within-production-body-p section) - (back-to-indentation) - (if (not (= (current-column) bison-rule-enumeration-column)) - (progn - (just-no-space) - (indent-to-column - bison-rule-enumeration-column))) - (funcall reset-pt)) - (t - (let ((cur-ind (current-indentation))) - (if (eq (save-excursion (search-backward "}" bol t)) - cur-ind) - (if (not (= cur-ind bison-rule-enumeration-column)) - (progn - (back-to-indentation) - (just-no-space) - (indent-to-column bison-rule-enumeration-column) - (funcall reset-pt))) - ;; else leave alone - ))))) - ((= section bison--c-code-section) - (c-indent-line)) - )))) - -;; *************** electric-functions *************** - -(defun bison-electric-colon (arg) - "If the colon <:> delineates a production, - then insert a semicolon on the next line in the BISON-RULE-SEPARATOR-COLUMN, - put the cursor in the BISON-RULE-ENUMERATION-COLUMN for the beginning - of the rule - else just run self-insert-command -A colon delineates a production by the fact that it is immediately preceded by -a word(alphanumerics or '_''s), and there is no previous white space. -" - (interactive "P") - - (self-insert-command (prefix-numeric-value arg)) - (if (and bison-electric-colon-v - (not bison-all-electricity-off)) - (if (and (= bison--grammar-rules-section (bison--section-p)) - (bison--production-p) - (not (bison--within-started-production-p))) - (progn - (save-excursion ; put in a closing semicolon - (newline) - (indent-to-column bison-rule-separator-column) - (insert ";")) - (save-excursion ; remove opening whitespace - (if (re-search-backward - "\\s " - (save-excursion (beginning-of-line) (point)) - t) - (just-no-space))) - (if (not (< (current-column) bison-rule-enumeration-column)) - (newline)) - (indent-to-column bison-rule-enumeration-column))))) - -(defun bison-electric-pipe (arg) - "If the pipe <|> is used as a rule separator within a production, - then move it into BISON-RULE-SEPARATOR-COLUMN - indent to BISON-RULE-ENUMERATION-COLUMN on the same line - else just run self-insert-command -" - (interactive "P") - - (if (and bison-electric-pipe-v - (not bison-all-electricity-off) - (= bison--grammar-rules-section (bison--section-p)) - (line-of-whitespace-p) - ) - (progn - (beginning-of-line) - (just-no-space) - (indent-to-column bison-rule-separator-column) - (self-insert-command (prefix-numeric-value arg)) - (indent-to-column bison-rule-enumeration-column) - ) - (self-insert-command (prefix-numeric-value arg)))) - -(defun bison-electric-open-brace (arg) - "used for the opening brace of a C action definition for production rules, -if there is only whitespace before \(point\), then put open-brace in -bison-rule-enumeration-column" - (interactive "P") - - (if (and bison-electric-open-brace-v - (not bison-all-electricity-off)) - (let ((section (bison--section-p))) - (cond ((and (= section bison--grammar-rules-section) - (not (bison--within-braced-c-expression-p section)) - (not (previous-non-ws-p))) - (if (not (= (current-column) bison-rule-enumeration-column)) - (progn - (just-no-space) - (indent-to-column bison-rule-enumeration-column)))) - ((and (= section bison--bison-decls-section) - (not (bison--within-braced-c-expression-p section)) - (not (previous-non-ws-p))) - (if (not (= (current-column) 0)) - (progn - (just-no-space) - (indent-to-column 0))))))) - - (self-insert-command (prefix-numeric-value arg))) - - -(defun bison-electric-close-brace (arg) - "If the close-brace \"}\" is used as the c-declarations section closer -in \"%}\", then make sure the \"%}\" indents to the beginning of the line" - (interactive "P") - - (self-insert-command (prefix-numeric-value arg)) - - (if (and bison-electric-close-brace-v - (not bison-all-electricity-off)) - (cond ((search-backward "%}" (- (point) 2) t) - (if (= (bison--section-p) bison--c-decls-section) - (progn - (just-no-space) - (forward-char 2)) ; for "%}" - (forward-char 1))) - ))) - -(defun bison-electric-semicolon (arg) - "if the semicolon is used to end a production, then place it in -bison-rule-separator-column - -a semicolon is deemed to be used for ending a production if it is not found -within braces - -this is just self-insert-command as i have yet to write the actual -bison-electric-semicolon function yet -" - (interactive "P") - - (self-insert-command (prefix-numeric-value arg))) - -(defun bison-electric-percent (arg) - "If the percent is a declarer in the bison declaration's section, -then put it in the 0 column." - (interactive "P") - - (if (and bison-electric-percent-v - (not bison-all-electricity-off)) - (let ((section (bison--section-p))) - (if (and (= section bison--bison-decls-section) - (not (bison--within-braced-c-expression-p section)) - (not (previous-non-ws-p)) - (not (= (current-column) 0))) - (just-no-space)))) - - (self-insert-command (prefix-numeric-value arg))) - -(defun bison-electric-less-than (arg) - "If the less-than is a type declarer opener for tokens in the bison -declaration section, then put it in the bison-decl-type-column column." - (interactive "P") - - (if (and bison-electric-less-than-v - (not bison-all-electricity-off)) - (if (and (= (bison--section-p) bison--bison-decls-section) - (bison--bison-decl-opener-p - (save-excursion (beginning-of-line) (point)) - (point))) - (progn - (just-no-space) - (indent-to-column bison-decl-type-column)))) - - (self-insert-command (prefix-numeric-value arg))) - -(defun bison-electric-greater-than (arg) - "If the greater-than is a type declarer closer for tokens in the bison -declaration section, then indent to bison-decl-token-column." - (interactive "P") - - (self-insert-command (prefix-numeric-value arg)) - - (if (and bison-electric-greater-than-v - (not bison-all-electricity-off)) - (let ((current-pt (point)) - (bol (save-excursion (beginning-of-line) (point)))) - (if (and (= (bison--section-p) bison--bison-decls-section) - (bison--bison-decl-opener-p bol (point))) - (if (search-backward "<" bol t) - (if (re-search-forward - (concat "<" bison--word-constituent-re "+>") - current-pt t) - (if (not (following-non-ws-p)) - (progn - (just-no-space) - (indent-to-column bison-decl-token-column))))))))) - -(define-derived-mode jison-mode bison-mode - "Major mode for editing jison files.") - -(provide 'bison-mode) -(provide 'jison-mode) -;;; bison-mode.el ends here diff --git a/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-autoloads.el b/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-autoloads.el deleted file mode 100644 index f01ddc7..0000000 --- a/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-autoloads.el +++ /dev/null @@ -1,23 +0,0 @@ -;;; centered-cursor-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "centered-cursor-mode" "centered-cursor-mode.el" -;;;;;; (21570 28355 0 0)) -;;; Generated autoloads from centered-cursor-mode.el - -(autoload 'centered-cursor-mode "centered-cursor-mode" "\ -Makes the cursor stay vertically in a defined -position (usually centered). - -\(fn &optional ARG)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; centered-cursor-mode-autoloads.el ends here diff --git a/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-pkg.el b/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-pkg.el deleted file mode 100644 index 8315d51..0000000 --- a/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "centered-cursor-mode" "20131121.1237" "cursor stays vertically centered" 'nil :url "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el" :keywords '("convenience")) diff --git a/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode.el b/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode.el deleted file mode 100644 index 9935374..0000000 --- a/emacs.d/elpa/centered-cursor-mode-20131121.1237/centered-cursor-mode.el +++ /dev/null @@ -1,423 +0,0 @@ -;;; centered-cursor-mode.el --- cursor stays vertically centered - -;; Copyright (C) 2007 André Riemann - -;; Author: André Riemann -;; Maintainer: André Riemann -;; Created: 2007-09-14 -;; Keywords: convenience - -;; URL: http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el -;; Compatibility: only tested with GNU Emacs 23.0 -;; Version: 20131121.1237 -;; X-Original-Version: 0.5.2 -;; Last-Updated: 2009-08-31 - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the Free -;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -;; MA 02110-1301, USA. - -;;; Commentary: - -;; 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. - -;;; TODO: -;; - the code is a mess -;; - ccm-vpos-inverted doesn't work with ccm-vpos == 0, because first -;; position from top is 0 and from bottom -1 -;; - interactive first start isn't animated when calling global-... -;; because it starts the modes for each buffer and interactive-p fails -;; for that -;; - more bugs? - -;;; Change Log: -;; 2009-08-31 andre-r -;; * replaced window-body-height with window-text-height -;; (partially visible lines are not counted in window-text-height) -;; * bug fixed in ccm-vpos-recenter -;; (some parentheses where wrong after the last update) -;; 2009-02-23 andre-r -;; * some simplifications -;; 2009-02-22 andre-r -;; * some tips from Drew Adams: -;; - new local variable coding:utf-8 -;; - made recenter-sequence a defvar -;; - added groups scrolling and convenience -;; - replaced mouse-4 and mouse-5 with -;; mouse-wheel-up-event and mouse-wheel-down-event -;; - added scroll-bar-toolkit-scroll to ccm-ignored-commands -;; - made ccm-ignored-commands customisable -;; * removed a bug where it didn't work with more than one window -;; displaying the same buffer -;; * added function for page up and down scrolling -;; (standard ones didn't work well with this mode) -;; * made the animation delay customisable -;; * made the initial vertical position customisable -;; * made the behaviour at the end of the file customisable -;; 2008-02-02 andre-r -;; * fixed bug that led to wrong-type-argument -;; when opening a new buffer -;; * some other minor stuff -;; 2007-09-24 andre-r -;; * added global minor mode -;; 2007-09-21 andre-r -;; * not recentering at end of buffer -;; * defvar animate-first-start-p -;; 2007-09-14 andre-r -;; * inital release - -;; This file is *NOT* part of GNU Emacs. - -;;; Code: - -(defgroup centered-cursor nil - "Makes the cursor stay vertically in a defined position (usually centered). -Instead the cursor the text moves around the cursor." - :group 'scrolling - :group 'convenience - :link '(emacs-library-link :tag "Source Lisp File" "centered-cursor-mode.el") - :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el")) - -(defcustom ccm-step-size 2 - "Step size when animated recentering." - :group 'centered-cursor - :tag "Animation step size" - :type 'integer) - -(defcustom ccm-step-delay 0.02 - "Delay between animation steps. -If you want a different animation speed." - :group 'centered-cursor - :tag "Animation step delay" - :type 'number) - -(defcustom ccm-ignored-commands '(mouse-drag-region - mouse-set-point - widget-button-click - scroll-bar-toolkit-scroll) - "After these commands recentering is ignored. -This is to prevent unintentional jumping (especially when mouse -clicking). Following commands (except the ignored ones) will -cause an animated recentering to give a feedback and not just -jumping to the center." - :group 'centered-cursor - :tag "Ignored commands" - :type '(repeat (symbol :tag "Command"))) - -(defcustom ccm-vpos-init '(round (window-text-height) 2) - "This is the screen line position where the cursor initially stays." - :group 'centered-cursor - :tag "Vertical cursor position" - :type '(choice (const :tag "Center" (round (window-text-height) 2)) - (const :tag "Golden ratio" (round (* 21 (window-text-height)) 34)) - (integer :tag "Lines from top" :value 10))) -(make-variable-buffer-local 'ccm-vpos-init) - -(defcustom ccm-vpos-inverted 1 - "Inverted vertical cursor position. -Defines if the initial vertical position `ccm-vpos-init' is -measured from the bottom instead from the top." - :group 'centered-cursor - :tag "Inverted cursor position" - :type '(choice (const :tag "Inverted" -1) - (const :tag "Not inverted" 1))) -(make-variable-buffer-local 'ccm-vpos-inverted) - -(defcustom ccm-recenter-at-end-of-file nil - "Recenter at the end of the file. -If non-nil the end of the file is recentered. If nil the end of -the file stays at the end of the window." - :group 'centered-cursor - :tag "Recenter at EOF" - :type '(choice (const :tag "Don't recenter at the end of the file" nil) - (const :tag "Recenter at the end of the file" t))) -(make-variable-buffer-local 'ccm-recenter-end-of-file) - -(defvar ccm-vpos nil - "This is the screen line position where the cursor stays.") -(make-variable-buffer-local 'ccm-vpos) - -(defvar animate-first-start-p nil - "Whether or not to animate at first start. It is set to nil, if -centered-cursor-mode is called non-interactively.") -(make-variable-buffer-local 'animate-first-start-p) - -(defvar recenter-sequence nil - "Before animated recentering a list is generated first with positions -to successively recenter to") -(make-variable-buffer-local 'recenter-sequence) - -(defvar ccm-map - (let ((ccm-map (make-sparse-keymap))) - (define-key ccm-map [(control meta -)] 'ccm-vpos-up) - (define-key ccm-map [(control meta +)] 'ccm-vpos-down) - (define-key ccm-map [(control meta =)] 'ccm-vpos-down) - (define-key ccm-map [(control meta ?0)] 'ccm-vpos-recenter) - (when mouse-wheel-mode - (mapc (lambda (key) - (define-key ccm-map key 'ccm-mwheel-scroll)) - (list (vector mouse-wheel-up-event) - (vector mouse-wheel-down-event) - (vector (list 'control mouse-wheel-up-event)) - (vector (list 'control mouse-wheel-down-event)) - (vector (list 'shift mouse-wheel-up-event)) - (vector (list 'shift mouse-wheel-down-event))))) - (define-key ccm-map [(meta v)] 'ccm-scroll-down) - (define-key ccm-map [(control v)] 'ccm-scroll-up) - (define-key ccm-map [prior] 'ccm-scroll-down) - (define-key ccm-map [next] 'ccm-scroll-up) - ccm-map) - "Keymap used in centered-cursor-mode.") - - -(defun ccm-mwheel-scroll (event) - "Very similar to `mwheel-scroll', but does not use `scroll-down' -and `scroll-up' but `previous-line' and `next-line', that is, the -cursor is moved and thus the text in the window is scrolled -due to `recenter'. - -The customizable variable `mouse-wheel-scroll-amount' is used to -determine how much to scroll, where nil instead of a number means -the same as in mwheel-scroll, scroll by a near full screen. - -This command exists, because mwheel-scroll caused strange -behaviour with automatic recentering." -;; (interactive (list last-input-event)) - (interactive "e") - (let* ((mods (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) - (amt (assoc mods mouse-wheel-scroll-amount))) - ;;(message "%S" mods) - (if amt - (setq amt (or (cdr amt) - (- (window-text-height) - next-screen-context-lines))) - (let ((list-elt mouse-wheel-scroll-amount)) - (while (consp (setq amt (pop list-elt)))))) - (if mouse-wheel-follow-mouse - (select-window (posn-window (event-start event)))) - (let ((button (mwheel-event-button event))) - (cond - ((eq button mouse-wheel-down-event) - (forward-line (- amt))) - ;;(princ amt)) - ((eq button mouse-wheel-up-event) - (forward-line amt)) - ;;(princ amt)) - (t (error "Bad binding in ccm-mwheel-scroll")))))) - -(defun ccm-scroll-down (&optional arg) - "Replaces `scroll-down' because with scroll-down -`centered-cursor-mode' sometimes doesn't reach the top of the -buffer. This version actually moves the cursor with -`previous-line'. Since with centered-cursor-mode the cursor is in -a fixed position the movement appears as page up." - (interactive "P") - (let ((amt (or arg (- (window-text-height) - next-screen-context-lines)))) - (forward-line (- amt)))) - -(defun ccm-scroll-up (&optional arg) - "Replaces `scroll-up' to be consistent with `ccm-scroll-down'. -This version actually moves the cursor with `previous-line'. -Since with centered-cursor-mode the cursor is in a fixed position -the movement appears as page up." - (interactive "P") - (let ((amt (or arg (- (window-text-height) - next-screen-context-lines)))) - (forward-line amt))) - - -(defun ccm-vpos-down (arg) - "Adjust the value of the screen line (where the cursor stays) by arg. -Negative values for arg are possible. Just the variable ccm-vpos -is set." - (interactive "p") - (or arg (setq arg 1)) - (let ((new-pos (if (< ccm-vpos 0) - (- ccm-vpos arg) - (+ ccm-vpos arg))) - ;; see pos-visible-in-window-p - (vpos-max (if (< ccm-vpos 0) - -1 - (- (window-text-height) 1))) - (vpos-min (if (< ccm-vpos 0) - (- (window-text-height)) - 0))) - (setq ccm-vpos - (cond - ((< new-pos vpos-min) - vpos-min) - ((> new-pos vpos-max) - vpos-max) - (t - new-pos))))) - -(defun ccm-vpos-up (arg) - "See `ccm-vpos-down'." - (interactive "p") - (or arg (setq arg 1)) - (ccm-vpos-down (- arg))) - -(defun ccm-vpos-recenter () - "Set the value of the screen line (where the cursor stays) in -the center. Just the variable ccm-vpos is set." - (interactive) - (if (equal (current-buffer) - (window-buffer (selected-window))) - (setq ccm-vpos (* (eval ccm-vpos-init) - ccm-vpos-inverted)))) - -(defun ccm-position-cursor () - "Do the actual recentering at the position `ccm-vpos'." - (unless (member this-command ccm-ignored-commands) - (unless ccm-vpos - (ccm-vpos-recenter)) - (unless (minibufferp (current-buffer)) - (if (equal (current-buffer) - (window-buffer (selected-window))) - (let* ((current-line - (if (< ccm-vpos 0) - ;; one-based, from bottom, negative - (- (count-lines (point) - ;; window-end is sometimes < 0 - ;; when opening a help buffer - (if (> (window-end) 0) - (window-end) - 1))) - ;; zero-based, from top, positive - (+ (count-lines (window-start) (point)) - ;; count-lines returns different value in column 0 - (if (= (current-column) 0) 0 -1)))) - (diff (- ccm-vpos current-line)) - (step-size ccm-step-size) - (step-delay ccm-step-delay) - (vpos-inverted ccm-vpos-inverted) - (recenter-at-end-of-file ccm-recenter-at-end-of-file)) - - (let* ((bottom-vpos (if (< ccm-vpos 0) - (- ccm-vpos) - (- (window-text-height) ccm-vpos))) - (correction (save-excursion - (if (or (= (point) (point-max)) - (progn - (goto-char (point-max)) - (zerop (current-column)))) - 1 0))) - ;; lines from point to end of buffer - (bottom-lines (+ (count-lines (point) (point-max)) - correction))) - - ;; only animate if the point was moved rather far away - ;; before by a mouseclick (see ccm-ignored-commands) - ;; or if minor mode is just entered interactively - (if (not (and (> (abs diff) 4) - (or (member last-command ccm-ignored-commands) - animate-first-start-p))) - - (recenter (if (and (< bottom-lines bottom-vpos) - (not recenter-at-end-of-file)) - ;; if near the bottom, recenter in the - ;; negative screen line that equals the - ;; bottom buffer line, i.e. if we are in - ;; the second last line (-2) of the - ;; buffer, the cursor will be recentered - ;; in -2 - (- bottom-lines) - ccm-vpos)) - - (setq animate-first-start-p nil) - ;; first build a list with positions to successively recenter to - (setq recenter-sequence - ;; reverse: because we build the list not FROM -> TO but - ;; TO -> FROM because if step size in number-sequence is - ;; bigger than one, TO might not included, that means the - ;; ccm-vpos would not be reached - ;; cdr: don't recenter the current-line - (if (and (< bottom-lines bottom-vpos) - (not recenter-at-end-of-file)) - ;; this one is for animation near the bottom - (cdr (reverse (number-sequence - (- bottom-lines) - (if (< ccm-vpos 0) - current-line - (- (- (window-text-height) current-line))) - (* (/ diff (abs diff)) (- step-size))))) - (cdr (reverse (number-sequence - ccm-vpos - current-line - (* (/ diff (abs diff)) (- step-size))))))) - ;; (message "%d %d %d (%d): %S" current-line ccm-vpos bottom-lines diff recenter-sequence) - (while recenter-sequence - ;; actual animation - (recenter (pop recenter-sequence)) - (if (car recenter-sequence) (sit-for step-delay t)))))))))) - -(defun ccm-first-start (animate) - "Called from centered-cursor-mode. Animate at first start, if -centered-cursor-mode is called interactively." - (let ((animate-first-start-p animate)) - (ccm-vpos-recenter) - (ccm-position-cursor))) - -;;(defalias 'ccm 'centered-cursor-mode) -;;;###autoload -(define-minor-mode centered-cursor-mode - "Makes the cursor stay vertically in a defined -position (usually centered)." - :init-value nil -;; :lighter nil - :lighter " ¢" - :keymap ccm-map - (cond - (centered-cursor-mode - (ccm-first-start (interactive-p)) - (add-hook 'post-command-hook 'ccm-position-cursor t t) - (add-hook 'window-configuration-change-hook 'ccm-vpos-recenter t t)) - (t - (remove-hook 'post-command-hook 'ccm-position-cursor t) - (remove-hook 'window-configuration-change-hook 'ccm-vpos-recenter t)))) - - -(define-global-minor-mode global-centered-cursor-mode centered-cursor-mode - centered-cursor-mode) - -(provide 'centered-cursor-mode) - -;;; Help: -;; (info "(elisp)Defining Minor Modes") -;; (info "(elisp)Screen Lines") -;; (info "(elisp)Hooks") -;; (info "(elisp)Customization") -;; (find-function 'mwheel-scroll) - -;; Local Variables: -;; coding: utf-8 -;; End: - -;;; centered-cursor-mode.el ends here diff --git a/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-autoloads.el b/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-autoloads.el new file mode 100644 index 0000000..b2d5df0 --- /dev/null +++ b/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-autoloads.el @@ -0,0 +1,23 @@ +;;; centered-cursor-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "centered-cursor-mode" "centered-cursor-mode.el" +;;;;;; (21837 24217 0 0)) +;;; Generated autoloads from centered-cursor-mode.el + +(autoload 'centered-cursor-mode "centered-cursor-mode" "\ +Makes the cursor stay vertically in a defined +position (usually centered). + +\(fn &optional ARG)" t nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; centered-cursor-mode-autoloads.el ends here diff --git a/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-pkg.el b/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-pkg.el new file mode 100644 index 0000000..73d54db --- /dev/null +++ b/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode-pkg.el @@ -0,0 +1 @@ +(define-package "centered-cursor-mode" "20150420.1942" "cursor stays vertically centered" 'nil :url "http://www.emacswiki.org/emacs/centered-cursor-mode.el" :keywords '("convenience")) diff --git a/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode.el b/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode.el new file mode 100644 index 0000000..0174c02 --- /dev/null +++ b/emacs.d/elpa/centered-cursor-mode-20150420.1942/centered-cursor-mode.el @@ -0,0 +1,430 @@ +;;; centered-cursor-mode.el --- cursor stays vertically centered + +;; Copyright (C) 2007 André Riemann + +;; Author: André Riemann +;; Maintainer: André Riemann +;; Created: 2007-09-14 +;; Keywords: convenience +;; Package-Version: 20150420.1942 + +;; URL: http://www.emacswiki.org/emacs/centered-cursor-mode.el +;; Compatibility: tested with GNU Emacs 23.0, 24 +;; Version: 0.5.4 +;; Last-Updated: 2015-04-20 + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This file is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +;; MA 02110-1301, USA. + +;;; Commentary: + +;; 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. + +;;; TODO: +;; - the code is a mess +;; - ccm-vpos-inverted doesn't work with ccm-vpos == 0, because first +;; position from top is 0 and from bottom -1 +;; - interactive first start isn't animated when calling global-... +;; because it starts the modes for each buffer and interactive-p fails +;; for that +;; - more bugs? + +;;; Change Log: +;; 2015-04-20 andre-r +;; * corrected URL in header +;; 2015-03-01 andre-r +;; * fixed bug where Emacs without X support (emacs-nox) didn't find mouse-wheel-mode +;; 2009-08-31 andre-r +;; * replaced window-body-height with window-text-height +;; (partially visible lines are not counted in window-text-height) +;; * bug fixed in ccm-vpos-recenter +;; (some parentheses where wrong after the last update) +;; 2009-02-23 andre-r +;; * some simplifications +;; 2009-02-22 andre-r +;; * some tips from Drew Adams: +;; - new local variable coding:utf-8 +;; - made recenter-sequence a defvar +;; - added groups scrolling and convenience +;; - replaced mouse-4 and mouse-5 with +;; mouse-wheel-up-event and mouse-wheel-down-event +;; - added scroll-bar-toolkit-scroll to ccm-ignored-commands +;; - made ccm-ignored-commands customisable +;; * removed a bug where it didn't work with more than one window +;; displaying the same buffer +;; * added function for page up and down scrolling +;; (standard ones didn't work well with this mode) +;; * made the animation delay customisable +;; * made the initial vertical position customisable +;; * made the behaviour at the end of the file customisable +;; 2008-02-02 andre-r +;; * fixed bug that led to wrong-type-argument +;; when opening a new buffer +;; * some other minor stuff +;; 2007-09-24 andre-r +;; * added global minor mode +;; 2007-09-21 andre-r +;; * not recentering at end of buffer +;; * defvar animate-first-start-p +;; 2007-09-14 andre-r +;; * inital release + +;; This file is *NOT* part of GNU Emacs. + +;;; Code: + + +(require 'mouse-wheel-mode nil 'noerror) + +(defgroup centered-cursor nil + "Makes the cursor stay vertically in a defined position (usually centered). +Instead the cursor the text moves around the cursor." + :group 'scrolling + :group 'convenience + :link '(emacs-library-link :tag "Source Lisp File" "centered-cursor-mode.el") + :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el")) + +(defcustom ccm-step-size 2 + "Step size when animated recentering." + :group 'centered-cursor + :tag "Animation step size" + :type 'integer) + +(defcustom ccm-step-delay 0.02 + "Delay between animation steps. +If you want a different animation speed." + :group 'centered-cursor + :tag "Animation step delay" + :type 'number) + +(defcustom ccm-ignored-commands '(mouse-drag-region + mouse-set-point + widget-button-click + scroll-bar-toolkit-scroll) + "After these commands recentering is ignored. +This is to prevent unintentional jumping (especially when mouse +clicking). Following commands (except the ignored ones) will +cause an animated recentering to give a feedback and not just +jumping to the center." + :group 'centered-cursor + :tag "Ignored commands" + :type '(repeat (symbol :tag "Command"))) + +(defcustom ccm-vpos-init '(round (window-text-height) 2) + "This is the screen line position where the cursor initially stays." + :group 'centered-cursor + :tag "Vertical cursor position" + :type '(choice (const :tag "Center" (round (window-text-height) 2)) + (const :tag "Golden ratio" (round (* 21 (window-text-height)) 34)) + (integer :tag "Lines from top" :value 10))) +(make-variable-buffer-local 'ccm-vpos-init) + +(defcustom ccm-vpos-inverted 1 + "Inverted vertical cursor position. +Defines if the initial vertical position `ccm-vpos-init' is +measured from the bottom instead from the top." + :group 'centered-cursor + :tag "Inverted cursor position" + :type '(choice (const :tag "Inverted" -1) + (const :tag "Not inverted" 1))) +(make-variable-buffer-local 'ccm-vpos-inverted) + +(defcustom ccm-recenter-at-end-of-file nil + "Recenter at the end of the file. +If non-nil the end of the file is recentered. If nil the end of +the file stays at the end of the window." + :group 'centered-cursor + :tag "Recenter at EOF" + :type '(choice (const :tag "Don't recenter at the end of the file" nil) + (const :tag "Recenter at the end of the file" t))) +(make-variable-buffer-local 'ccm-recenter-end-of-file) + +(defvar ccm-vpos nil + "This is the screen line position where the cursor stays.") +(make-variable-buffer-local 'ccm-vpos) + +(defvar animate-first-start-p nil + "Whether or not to animate at first start. It is set to nil, if +centered-cursor-mode is called non-interactively.") +(make-variable-buffer-local 'animate-first-start-p) + +(defvar recenter-sequence nil + "Before animated recentering a list is generated first with positions +to successively recenter to") +(make-variable-buffer-local 'recenter-sequence) + +(defvar ccm-map + (let ((ccm-map (make-sparse-keymap))) + (define-key ccm-map [(control meta -)] 'ccm-vpos-up) + (define-key ccm-map [(control meta +)] 'ccm-vpos-down) + (define-key ccm-map [(control meta =)] 'ccm-vpos-down) + (define-key ccm-map [(control meta ?0)] 'ccm-vpos-recenter) + (when (and (boundp 'mouse-wheel-mode) mouse-wheel-mode) + (mapc (lambda (key) + (define-key ccm-map key 'ccm-mwheel-scroll)) + (list (vector mouse-wheel-up-event) + (vector mouse-wheel-down-event) + (vector (list 'control mouse-wheel-up-event)) + (vector (list 'control mouse-wheel-down-event)) + (vector (list 'shift mouse-wheel-up-event)) + (vector (list 'shift mouse-wheel-down-event))))) + (define-key ccm-map [(meta v)] 'ccm-scroll-down) + (define-key ccm-map [(control v)] 'ccm-scroll-up) + (define-key ccm-map [prior] 'ccm-scroll-down) + (define-key ccm-map [next] 'ccm-scroll-up) + ccm-map) + "Keymap used in centered-cursor-mode.") + + +(defun ccm-mwheel-scroll (event) + "Very similar to `mwheel-scroll', but does not use `scroll-down' +and `scroll-up' but `previous-line' and `next-line', that is, the +cursor is moved and thus the text in the window is scrolled +due to `recenter'. + +The customizable variable `mouse-wheel-scroll-amount' is used to +determine how much to scroll, where nil instead of a number means +the same as in mwheel-scroll, scroll by a near full screen. + +This command exists, because mwheel-scroll caused strange +behaviour with automatic recentering." +;; (interactive (list last-input-event)) + (interactive "e") + (let* ((mods (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) + (amt (assoc mods mouse-wheel-scroll-amount))) + ;;(message "%S" mods) + (if amt + (setq amt (or (cdr amt) + (- (window-text-height) + next-screen-context-lines))) + (let ((list-elt mouse-wheel-scroll-amount)) + (while (consp (setq amt (pop list-elt)))))) + (if mouse-wheel-follow-mouse + (select-window (posn-window (event-start event)))) + (let ((button (mwheel-event-button event))) + (cond + ((eq button mouse-wheel-down-event) + (forward-line (- amt))) + ;;(princ amt)) + ((eq button mouse-wheel-up-event) + (forward-line amt)) + ;;(princ amt)) + (t (error "Bad binding in ccm-mwheel-scroll")))))) + +(defun ccm-scroll-down (&optional arg) + "Replaces `scroll-down' because with scroll-down +`centered-cursor-mode' sometimes doesn't reach the top of the +buffer. This version actually moves the cursor with +`previous-line'. Since with centered-cursor-mode the cursor is in +a fixed position the movement appears as page up." + (interactive "P") + (let ((amt (or arg (- (window-text-height) + next-screen-context-lines)))) + (forward-line (- amt)))) + +(defun ccm-scroll-up (&optional arg) + "Replaces `scroll-up' to be consistent with `ccm-scroll-down'. +This version actually moves the cursor with `previous-line'. +Since with centered-cursor-mode the cursor is in a fixed position +the movement appears as page up." + (interactive "P") + (let ((amt (or arg (- (window-text-height) + next-screen-context-lines)))) + (forward-line amt))) + + +(defun ccm-vpos-down (arg) + "Adjust the value of the screen line (where the cursor stays) by arg. +Negative values for arg are possible. Just the variable ccm-vpos +is set." + (interactive "p") + (or arg (setq arg 1)) + (let ((new-pos (if (< ccm-vpos 0) + (- ccm-vpos arg) + (+ ccm-vpos arg))) + ;; see pos-visible-in-window-p + (vpos-max (if (< ccm-vpos 0) + -1 + (- (window-text-height) 1))) + (vpos-min (if (< ccm-vpos 0) + (- (window-text-height)) + 0))) + (setq ccm-vpos + (cond + ((< new-pos vpos-min) + vpos-min) + ((> new-pos vpos-max) + vpos-max) + (t + new-pos))))) + +(defun ccm-vpos-up (arg) + "See `ccm-vpos-down'." + (interactive "p") + (or arg (setq arg 1)) + (ccm-vpos-down (- arg))) + +(defun ccm-vpos-recenter () + "Set the value of the screen line (where the cursor stays) in +the center. Just the variable ccm-vpos is set." + (interactive) + (if (equal (current-buffer) + (window-buffer (selected-window))) + (setq ccm-vpos (* (eval ccm-vpos-init) + ccm-vpos-inverted)))) + +(defun ccm-position-cursor () + "Do the actual recentering at the position `ccm-vpos'." + (unless (member this-command ccm-ignored-commands) + (unless ccm-vpos + (ccm-vpos-recenter)) + (unless (minibufferp (current-buffer)) + (if (equal (current-buffer) + (window-buffer (selected-window))) + (let* ((current-line + (if (< ccm-vpos 0) + ;; one-based, from bottom, negative + (- (count-lines (point) + ;; window-end is sometimes < 0 + ;; when opening a help buffer + (if (> (window-end) 0) + (window-end) + 1))) + ;; zero-based, from top, positive + (+ (count-lines (window-start) (point)) + ;; count-lines returns different value in column 0 + (if (= (current-column) 0) 0 -1)))) + (diff (- ccm-vpos current-line)) + (step-size ccm-step-size) + (step-delay ccm-step-delay) + (vpos-inverted ccm-vpos-inverted) + (recenter-at-end-of-file ccm-recenter-at-end-of-file)) + + (let* ((bottom-vpos (if (< ccm-vpos 0) + (- ccm-vpos) + (- (window-text-height) ccm-vpos))) + (correction (save-excursion + (if (or (= (point) (point-max)) + (progn + (goto-char (point-max)) + (zerop (current-column)))) + 1 0))) + ;; lines from point to end of buffer + (bottom-lines (+ (count-lines (point) (point-max)) + correction))) + + ;; only animate if the point was moved rather far away + ;; before by a mouseclick (see ccm-ignored-commands) + ;; or if minor mode is just entered interactively + (if (not (and (> (abs diff) 4) + (or (member last-command ccm-ignored-commands) + animate-first-start-p))) + + (recenter (if (and (< bottom-lines bottom-vpos) + (not recenter-at-end-of-file)) + ;; if near the bottom, recenter in the + ;; negative screen line that equals the + ;; bottom buffer line, i.e. if we are in + ;; the second last line (-2) of the + ;; buffer, the cursor will be recentered + ;; in -2 + (- bottom-lines) + ccm-vpos)) + + (setq animate-first-start-p nil) + ;; first build a list with positions to successively recenter to + (setq recenter-sequence + ;; reverse: because we build the list not FROM -> TO but + ;; TO -> FROM because if step size in number-sequence is + ;; bigger than one, TO might not included, that means the + ;; ccm-vpos would not be reached + ;; cdr: don't recenter the current-line + (if (and (< bottom-lines bottom-vpos) + (not recenter-at-end-of-file)) + ;; this one is for animation near the bottom + (cdr (reverse (number-sequence + (- bottom-lines) + (if (< ccm-vpos 0) + current-line + (- (- (window-text-height) current-line))) + (* (/ diff (abs diff)) (- step-size))))) + (cdr (reverse (number-sequence + ccm-vpos + current-line + (* (/ diff (abs diff)) (- step-size))))))) + ;; (message "%d %d %d (%d): %S" current-line ccm-vpos bottom-lines diff recenter-sequence) + (while recenter-sequence + ;; actual animation + (recenter (pop recenter-sequence)) + (if (car recenter-sequence) (sit-for step-delay t)))))))))) + +(defun ccm-first-start (animate) + "Called from centered-cursor-mode. Animate at first start, if +centered-cursor-mode is called interactively." + (let ((animate-first-start-p animate)) + (ccm-vpos-recenter) + (ccm-position-cursor))) + +;;(defalias 'ccm 'centered-cursor-mode) +;;;###autoload +(define-minor-mode centered-cursor-mode + "Makes the cursor stay vertically in a defined +position (usually centered)." + :init-value nil +;; :lighter nil + :lighter " ¢" + :keymap ccm-map + (cond + (centered-cursor-mode + (ccm-first-start (interactive-p)) + (add-hook 'post-command-hook 'ccm-position-cursor t t) + (add-hook 'window-configuration-change-hook 'ccm-vpos-recenter t t)) + (t + (remove-hook 'post-command-hook 'ccm-position-cursor t) + (remove-hook 'window-configuration-change-hook 'ccm-vpos-recenter t)))) + + +(define-global-minor-mode global-centered-cursor-mode centered-cursor-mode + centered-cursor-mode) + +(provide 'centered-cursor-mode) + +;;; Help: +;; (info "(elisp)Defining Minor Modes") +;; (info "(elisp)Screen Lines") +;; (info "(elisp)Hooks") +;; (info "(elisp)Customization") +;; (find-function 'mwheel-scroll) + +;; Local Variables: +;; coding: utf-8 +;; End: + +;;; centered-cursor-mode.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-autoloads.el b/emacs.d/elpa/company-20141014.1517/company-autoloads.el deleted file mode 100644 index 469fda4..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-autoloads.el +++ /dev/null @@ -1,293 +0,0 @@ -;;; company-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "company" "company.el" (21570 28046 0 0)) -;;; Generated autoloads from company.el - -(autoload 'company-mode "company" "\ -\"complete anything\"; is an in-buffer completion framework. -Completion starts automatically, depending on the values -`company-idle-delay' and `company-minimum-prefix-length'. - -Completion can be controlled with the commands: -`company-complete-common', `company-complete-selection', `company-complete', -`company-select-next', `company-select-previous'. If these commands are -called before `company-idle-delay', completion will also start. - -Completions can be searched with `company-search-candidates' or -`company-filter-candidates'. These can be used while completion is -inactive, as well. - -The completion data is retrieved using `company-backends' and displayed -using `company-frontends'. If you want to start a specific back-end, call -it interactively or use `company-begin-backend'. - -regular keymap (`company-mode-map'): - -\\{company-mode-map} -keymap during active completions (`company-active-map'): - -\\{company-active-map} - -\(fn &optional ARG)" t nil) - -(defvar global-company-mode nil "\ -Non-nil if Global-Company mode is enabled. -See the command `global-company-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `global-company-mode'.") - -(custom-autoload 'global-company-mode "company" nil) - -(autoload 'global-company-mode "company" "\ -Toggle Company mode in all buffers. -With prefix ARG, enable Global-Company mode if ARG is positive; -otherwise, disable it. If called from Lisp, enable the mode if -ARG is omitted or nil. - -Company mode is enabled in all buffers where -`company-mode-on' would do it. -See `company-mode' for more information on Company mode. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "company-abbrev" "company-abbrev.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-abbrev.el - -(autoload 'company-abbrev "company-abbrev" "\ -`company-mode' completion back-end for abbrev. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-bbdb" "company-bbdb.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-bbdb.el - -(autoload 'company-bbdb "company-bbdb" "\ -`company-mode' completion back-end for `bbdb'. - -\(fn COMMAND &optional ARG &rest IGNORE)" t nil) - -;;;*** - -;;;### (autoloads nil "company-css" "company-css.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-css.el - -(autoload 'company-css "company-css" "\ -`company-mode' completion back-end for `css-mode'. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-dabbrev" "company-dabbrev.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-dabbrev.el - -(autoload 'company-dabbrev "company-dabbrev" "\ -dabbrev-like `company-mode' completion back-end. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-dabbrev-code" "company-dabbrev-code.el" -;;;;;; (21570 28046 0 0)) -;;; Generated autoloads from company-dabbrev-code.el - -(autoload 'company-dabbrev-code "company-dabbrev-code" "\ -dabbrev-like `company-mode' back-end for code. -The back-end looks for all symbols in the current buffer that aren't in -comments or strings. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-elisp" "company-elisp.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-elisp.el - -(autoload 'company-elisp "company-elisp" "\ -`company-mode' completion back-end for Emacs Lisp. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-etags" "company-etags.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-etags.el - -(autoload 'company-etags "company-etags" "\ -`company-mode' completion back-end for etags. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-files" "company-files.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-files.el - -(autoload 'company-files "company-files" "\ -`company-mode' completion back-end existing file names. -Completions works for proper absolute and relative files paths. -File paths with spaces are only supported inside strings. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-gtags" "company-gtags.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-gtags.el - -(autoload 'company-gtags "company-gtags" "\ -`company-mode' completion back-end for GNU Global. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-ispell" "company-ispell.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-ispell.el - -(autoload 'company-ispell "company-ispell" "\ -`company-mode' completion back-end using Ispell. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-keywords" "company-keywords.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-keywords.el - -(autoload 'company-keywords "company-keywords" "\ -`company-mode' back-end for programming language keywords. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-nxml" "company-nxml.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-nxml.el - -(autoload 'company-nxml "company-nxml" "\ -`company-mode' completion back-end for `nxml-mode'. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-oddmuse" "company-oddmuse.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-oddmuse.el - -(autoload 'company-oddmuse "company-oddmuse" "\ -`company-mode' completion back-end for `oddmuse-mode'. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-pysmell" "company-pysmell.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-pysmell.el - -(autoload 'company-pysmell "company-pysmell" "\ -`company-mode' completion back-end for pysmell. -This requires pysmell.el and pymacs.el. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-semantic" "company-semantic.el" (21570 -;;;;;; 28046 0 0)) -;;; Generated autoloads from company-semantic.el - -(autoload 'company-semantic "company-semantic" "\ -`company-mode' completion back-end using CEDET Semantic. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-tempo" "company-tempo.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-tempo.el - -(autoload 'company-tempo "company-tempo" "\ -`company-mode' completion back-end for tempo. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-xcode" "company-xcode.el" (21570 28046 -;;;;;; 0 0)) -;;; Generated autoloads from company-xcode.el - -(autoload 'company-xcode "company-xcode" "\ -`company-mode' completion back-end for Xcode projects. - -\(fn COMMAND &optional ARG &rest IGNORED)" t nil) - -;;;*** - -;;;### (autoloads nil "company-yasnippet" "company-yasnippet.el" -;;;;;; (21570 28046 0 0)) -;;; Generated autoloads from company-yasnippet.el - -(autoload 'company-yasnippet "company-yasnippet" "\ -`company-mode' back-end for `yasnippet'. - -This back-end should be used with care, because as long as there are -snippets defined for the current major mode, this back-end will always -shadow back-ends that come after it. Recommended usages: - -* In a buffer-local value of `company-backends', grouped with a back-end or - several that provide actual text completions. - - (add-hook 'js-mode-hook - (lambda () - (set (make-local-variable 'company-backends) - '((company-dabbrev-code company-yasnippet))))) - -* After keyword `:with', grouped with other back-ends. - - (push '(company-semantic :with company-yasnippet) company-backends) - -* Not in `company-backends', just bound to a key. - - (global-set-key (kbd \"C-c y\") 'company-yasnippet) - -\(fn COMMAND &optional ARG &rest IGNORE)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("company-capf.el" "company-clang.el" "company-cmake.el" -;;;;;; "company-eclim.el" "company-pkg.el" "company-ropemacs.el" -;;;;;; "company-template.el") (21570 28046 173750 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; company-autoloads.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-bbdb.el b/emacs.d/elpa/company-20141014.1517/company-bbdb.el deleted file mode 100644 index 22741a2..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-bbdb.el +++ /dev/null @@ -1,52 +0,0 @@ -;;; company-bbdb.el --- company-mode completion back-end for BBDB in message-mode - -;; Copyright (C) 2013-2014 Free Software Foundation, Inc. - -;; Author: Jan Tatarik - -;; 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 . - -(require 'company) -(require 'cl-lib) - -(declare-function bbdb-record-get-field "bbdb") -(declare-function bbdb-records "bbdb") -(declare-function bbdb-dwim-mail "bbdb-com") -(declare-function bbdb-search "bbdb-com") - -(defun company-bbdb--candidates (arg) - (cl-mapcan (lambda (record) - (mapcar (lambda (mail) (bbdb-dwim-mail record mail)) - (bbdb-record-get-field record 'mail))) - (eval '(bbdb-search (bbdb-records) arg nil arg)))) - -;;;###autoload -(defun company-bbdb (command &optional arg &rest ignore) - "`company-mode' completion back-end for `bbdb'." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-bbdb)) - (prefix (and (eq major-mode 'message-mode) - (featurep 'bbdb-com) - (looking-back "^\\(To\\|Cc\\|Bcc\\):.*" - (line-beginning-position)) - (company-grab-symbol))) - (candidates (company-bbdb--candidates arg)) - (sorted t) - (no-cache t))) - -(provide 'company-bbdb) -;;; company-bbdb.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-capf.el b/emacs.d/elpa/company-20141014.1517/company-capf.el deleted file mode 100644 index b630025..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-capf.el +++ /dev/null @@ -1,148 +0,0 @@ -;;; company-capf.el --- company-mode completion-at-point-functions back-end -*- lexical-binding: t -*- - -;; Copyright (C) 2013-2014 Free Software Foundation, Inc. - -;; Author: Stefan Monnier - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defvar company--capf-cache nil) - -(defun company--capf-data () - (let ((cache company--capf-cache)) - (if (and (equal (current-buffer) (car cache)) - (equal (point) (car (setq cache (cdr cache)))) - (equal (buffer-chars-modified-tick) (car (setq cache (cdr cache))))) - (cadr cache) - (let ((data (company--capf-data-real))) - (setq company--capf-cache - (list (current-buffer) (point) (buffer-chars-modified-tick) data)) - data)))) - -(defun company--capf-data-real () - (cl-letf* (((default-value 'completion-at-point-functions) - ;; Ignore tags-completion-at-point-function because it subverts - ;; company-etags in the default value of company-backends, where - ;; the latter comes later. - (remove 'tags-completion-at-point-function - (default-value 'completion-at-point-functions))) - (data (run-hook-wrapped 'completion-at-point-functions - ;; Ignore misbehaving functions. - #'completion--capf-wrapper 'optimist))) - (when (and (consp (cdr data)) (numberp (nth 1 data))) data))) - -(defun company-capf (command &optional arg &rest _args) - "`company-mode' back-end using `completion-at-point-functions'." - (interactive (list 'interactive)) - (pcase command - (`interactive (company-begin-backend 'company-capf)) - (`prefix - (let ((res (company--capf-data))) - (when res - (if (> (nth 2 res) (point)) - 'stop - (buffer-substring-no-properties (nth 1 res) (point)))))) - (`candidates - (let ((res (company--capf-data))) - (when res - (let* ((table (nth 3 res)) - (pred (plist-get (nthcdr 4 res) :predicate)) - (meta (completion-metadata - (buffer-substring (nth 1 res) (nth 2 res)) - table pred)) - (sortfun (cdr (assq 'display-sort-function meta))) - (candidates (completion-all-completions arg table pred (length arg))) - (last (last candidates)) - (base-size (and (numberp (cdr last)) (cdr last)))) - (when base-size - (setcdr last nil)) - (when sortfun - (setq candidates (funcall sortfun candidates))) - (if (not (zerop (or base-size 0))) - (let ((before (substring arg 0 base-size))) - (mapcar (lambda (candidate) - (concat before candidate)) - candidates)) - candidates))))) - (`sorted - (let ((res (company--capf-data))) - (when res - (let ((meta (completion-metadata - (buffer-substring (nth 1 res) (nth 2 res)) - (nth 3 res) (plist-get (nthcdr 4 res) :predicate)))) - (cdr (assq 'display-sort-function meta)))))) - (`match - ;; Can't just use 0 when base-size (see above) is non-zero. - (let ((start (if (get-text-property 0 'font-lock-face arg) - 0 - (next-single-property-change 0 'font-lock-face arg)))) - (when start - ;; completions-common-part comes first, but we can't just look for this - ;; value because it can be in a list. - (or - (let ((value (get-text-property start 'font-lock-face arg))) - (text-property-not-all start (length arg) - 'font-lock-face value arg)) - (length arg))))) - (`duplicates t) - (`no-cache t) ;Not much can be done here, as long as we handle - ;non-prefix matches. - (`meta - (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-docsig))) - (when f (funcall f arg)))) - (`doc-buffer - (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-doc-buffer))) - (when f (funcall f arg)))) - (`location - (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-location))) - (when f (funcall f arg)))) - (`annotation - (save-excursion - ;; FIXME: `company-begin' sets `company-point' after calling - ;; `company--begin-new'. We shouldn't rely on `company-point' here, - ;; better to cache the capf-data value instead. However: we can't just - ;; save the last capf-data value in `prefix', because that command can - ;; get called more often than `candidates', and at any point in the - ;; buffer (https://github.com/company-mode/company-mode/issues/153). - ;; We could try propertizing the returned prefix string, but it's not - ;; passed to `annotation', and `company-prefix' is set only after - ;; `company--strip-duplicates' is called. - (when company-point - (goto-char company-point)) - (let ((f (plist-get (nthcdr 4 (company--capf-data)) :annotation-function))) - (when f (funcall f arg))))) - (`require-match - (plist-get (nthcdr 4 (company--capf-data)) :company-require-match)) - (`init nil) ;Don't bother: plenty of other ways to initialize the code. - (`post-completion - (let* ((res (company--capf-data)) - (exit-function (plist-get (nthcdr 4 res) :exit-function))) - (if exit-function - (funcall exit-function arg 'finished)))) - )) - -(provide 'company-capf) - -;;; company-capf.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-clang.el b/emacs.d/elpa/company-20141014.1517/company-clang.el deleted file mode 100644 index 90757a8..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-clang.el +++ /dev/null @@ -1,327 +0,0 @@ -;;; company-clang.el --- company-mode completion back-end for Clang -*- lexical-binding: t -*- - -;; Copyright (C) 2009, 2011, 2013-2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'company-template) -(require 'cl-lib) - -(defgroup company-clang nil - "Completion back-end for Clang." - :group 'company) - -(defcustom company-clang-executable - (executable-find "clang") - "Location of clang executable." - :type 'file) - -(defcustom company-clang-begin-after-member-access t - "When non-nil, automatic completion will start whenever the current -symbol is preceded by \".\", \"->\" or \"::\", ignoring -`company-minimum-prefix-length'. - -If `company-begin-commands' is a list, it should include `c-electric-lt-gt' -and `c-electric-colon', for automatic completion right after \">\" and -\":\".") - -(defcustom company-clang-arguments nil - "Additional arguments to pass to clang when completing. -Prefix files (-include ...) can be selected with `company-clang-set-prefix' -or automatically through a custom `company-clang-prefix-guesser'." - :type '(repeat (string :tag "Argument"))) - -(defcustom company-clang-prefix-guesser 'company-clang-guess-prefix - "A function to determine the prefix file for the current buffer." - :type '(function :tag "Guesser function" nil)) - -(defvar company-clang-modes '(c-mode c++-mode objc-mode) - "Major modes which clang may complete.") - -(defcustom company-clang-insert-arguments t - "When non-nil, insert function arguments as a template after completion." - :type 'boolean - :package-version '(company . "0.8.0")) - -;; prefix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar company-clang--prefix nil) - -(defsubst company-clang--guess-pch-file (file) - (let ((dir (directory-file-name (file-name-directory file)))) - (when (equal (file-name-nondirectory dir) "Classes") - (setq dir (file-name-directory dir))) - (car (directory-files dir t "\\([^.]h\\|[^h]\\).pch\\'" t)))) - -(defsubst company-clang--file-substring (file beg end) - (with-temp-buffer - (insert-file-contents-literally file nil beg end) - (buffer-string))) - -(defun company-clang-guess-prefix () - "Try to guess the prefix file for the current buffer." - ;; Prefixes seem to be called .pch. Pre-compiled headers do, too. - ;; So we look at the magic number to rule them out. - (let* ((file (company-clang--guess-pch-file buffer-file-name)) - (magic-number (and file (company-clang--file-substring file 0 4)))) - (unless (member magic-number '("CPCH" "gpch")) - file))) - -(defun company-clang-set-prefix (&optional prefix) - "Use PREFIX as a prefix (-include ...) file for clang completion." - (interactive (let ((def (funcall company-clang-prefix-guesser))) - (unless (stringp def) - (setq def default-directory)) - (list (read-file-name "Prefix file: " - (when def (file-name-directory def)) - def t (when def (file-name-nondirectory def)))))) - ;; TODO: pre-compile? - (setq company-clang--prefix (and (stringp prefix) - (file-regular-p prefix) - prefix))) - -;; Clean-up on exit. -(add-hook 'kill-emacs-hook 'company-clang-set-prefix) - -;; parsing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; TODO: Handle Pattern (syntactic hints would be neat). -;; Do we ever see OVERLOAD (or OVERRIDE)? -(defconst company-clang--completion-pattern - "^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:<>]*\\)\\(?: : \\(.*\\)$\\)?$") - -(defconst company-clang--error-buffer-name "*clang-error*") - -(defun company-clang--lang-option () - (if (eq major-mode 'objc-mode) - (if (string= "m" (file-name-extension buffer-file-name)) - "objective-c" "objective-c++") - (substring (symbol-name major-mode) 0 -5))) - -(defun company-clang--parse-output (prefix _objc) - (goto-char (point-min)) - (let ((pattern (format company-clang--completion-pattern - (regexp-quote prefix))) - (case-fold-search nil) - lines match) - (while (re-search-forward pattern nil t) - (setq match (match-string-no-properties 1)) - (unless (equal match "Pattern") - (save-match-data - (when (string-match ":" match) - (setq match (substring match 0 (match-beginning 0))))) - (let ((meta (match-string-no-properties 2))) - (when (and meta (not (string= match meta))) - (put-text-property 0 1 'meta - (company-clang--strip-formatting meta) - match))) - (push match lines))) - lines)) - -(defun company-clang--meta (candidate) - (get-text-property 0 'meta candidate)) - -(defun company-clang--annotation (candidate) - (let ((meta (company-clang--meta candidate))) - (cond - ((null meta) nil) - ((string-match "[^:]:[^:]" meta) - (substring meta (1+ (match-beginning 0)))) - ((string-match "\\((.*)[ a-z]*\\'\\)" meta) - (match-string 1 meta))))) - -(defun company-clang--strip-formatting (text) - (replace-regexp-in-string - "#]" " " - (replace-regexp-in-string "[<{[]#\\|#[>}]" "" text t) - t)) - -(defun company-clang--handle-error (res args) - (goto-char (point-min)) - (let* ((buf (get-buffer-create company-clang--error-buffer-name)) - (cmd (concat company-clang-executable " " (mapconcat 'identity args " "))) - (pattern (format company-clang--completion-pattern "")) - (err (if (re-search-forward pattern nil t) - (buffer-substring-no-properties (point-min) - (1- (match-beginning 0))) - ;; Warn the user more aggressively if no match was found. - (message "clang failed with error %d:\n%s" res cmd) - (buffer-string)))) - - (with-current-buffer buf - (let ((inhibit-read-only t)) - (erase-buffer) - (insert (current-time-string) - (format "\nclang failed with error %d:\n" res) - cmd "\n\n") - (insert err) - (setq buffer-read-only t) - (goto-char (point-min)))))) - -(defun company-clang--start-process (prefix callback &rest args) - (let ((objc (derived-mode-p 'objc-mode)) - (buf (get-buffer-create "*clang-output*"))) - (with-current-buffer buf (erase-buffer)) - (if (get-buffer-process buf) - (funcall callback nil) - (let ((process (apply #'start-process "company-clang" buf - company-clang-executable args))) - (set-process-sentinel - process - (lambda (proc status) - (unless (string-match-p "hangup" status) - (funcall - callback - (let ((res (process-exit-status proc))) - (with-current-buffer buf - (unless (eq 0 res) - (company-clang--handle-error res args)) - ;; Still try to get any useful input. - (company-clang--parse-output prefix objc))))))) - (unless (company-clang--auto-save-p) - (send-region process (point-min) (point-max)) - (send-string process "\n") - (process-send-eof process)))))) - -(defsubst company-clang--build-location (pos) - (save-excursion - (goto-char pos) - (format "%s:%d:%d" - (if (company-clang--auto-save-p) buffer-file-name "-") - (line-number-at-pos) - (1+ (length - (encode-coding-region - (line-beginning-position) - (point) - 'utf-8 - t)))))) - -(defsubst company-clang--build-complete-args (pos) - (append '("-fsyntax-only" "-Xclang" "-code-completion-macros") - (unless (company-clang--auto-save-p) - (list "-x" (company-clang--lang-option))) - company-clang-arguments - (when (stringp company-clang--prefix) - (list "-include" (expand-file-name company-clang--prefix))) - (list "-Xclang" (format "-code-completion-at=%s" - (company-clang--build-location pos))) - (list (if (company-clang--auto-save-p) buffer-file-name "-")))) - -(defun company-clang--candidates (prefix callback) - (and (company-clang--auto-save-p) - (buffer-modified-p) - (basic-save-buffer)) - (when (null company-clang--prefix) - (company-clang-set-prefix (or (funcall company-clang-prefix-guesser) - 'none))) - (apply 'company-clang--start-process - prefix - callback - (company-clang--build-complete-args (- (point) (length prefix))))) - -(defun company-clang--prefix () - (if company-clang-begin-after-member-access - (company-grab-symbol-cons "\\.\\|->\\|::" 2) - (company-grab-symbol))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst company-clang-required-version 1.1) - -(defvar company-clang--version nil) - -(defun company-clang--auto-save-p () - (< company-clang--version 2.9)) - -(defsubst company-clang-version () - "Return the version of `company-clang-executable'." - (with-temp-buffer - (call-process company-clang-executable nil t nil "--version") - (goto-char (point-min)) - (if (re-search-forward "clang\\(?: version \\|-\\)\\([0-9.]+\\)" nil t) - (let ((ver (string-to-number (match-string-no-properties 1)))) - (if (> ver 100) - (/ ver 100) - ver)) - 0))) - -(defun company-clang-objc-templatify (selector) - (let* ((end (point-marker)) - (beg (- (point) (length selector) 1)) - (templ (company-template-declare-template beg end)) - (cnt 0)) - (save-excursion - (goto-char beg) - (catch 'stop - (while (search-forward ":" end t) - (when (looking-at "([^)]*) ?") - (delete-region (match-beginning 0) (match-end 0))) - (company-template-add-field templ (point) (format "arg%d" cnt)) - (if (< (point) end) - (insert " ") - (throw 'stop t)) - (cl-incf cnt)))) - (company-template-move-to-first templ))) - -(defun company-clang (command &optional arg &rest ignored) - "`company-mode' completion back-end for Clang. -Clang is a parser for C and ObjC. Clang version 1.1 or newer is required. - -Additional command line arguments can be specified in -`company-clang-arguments'. Prefix files (-include ...) can be selected -with `company-clang-set-prefix' or automatically through a custom -`company-clang-prefix-guesser'. - -With Clang versions before 2.9, we have to save the buffer before -performing completion. With Clang 2.9 and later, buffer contents are -passed via standard input." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-clang)) - (init (when (memq major-mode company-clang-modes) - (unless company-clang-executable - (error "Company found no clang executable")) - (setq company-clang--version (company-clang-version)) - (when (< company-clang--version company-clang-required-version) - (error "Company requires clang version 1.1")))) - (prefix (and (memq major-mode company-clang-modes) - buffer-file-name - company-clang-executable - (not (company-in-string-or-comment)) - (or (company-clang--prefix) 'stop))) - (candidates (cons :async - (lambda (cb) (company-clang--candidates arg cb)))) - (meta (company-clang--meta arg)) - (annotation (company-clang--annotation arg)) - (post-completion (let ((anno (company-clang--annotation arg))) - (when (and company-clang-insert-arguments anno) - (insert anno) - (if (string-match "\\`:[^:]" anno) - (company-clang-objc-templatify anno) - (company-template-c-like-templatify - (concat arg anno)))))))) - -(provide 'company-clang) -;;; company-clang.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-cmake.el b/emacs.d/elpa/company-20141014.1517/company-cmake.el deleted file mode 100644 index a466f60..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-cmake.el +++ /dev/null @@ -1,129 +0,0 @@ -;;; company-cmake.el --- company-mode completion back-end for CMake - -;; Copyright (C) 2013 Free Software Foundation, Inc. - -;; Author: Chen Bin -;; Version: 0.1 - -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: -;; -;; company-cmake offers completions for module names, variable names and -;; commands used by CMake. And their descriptions. - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defgroup company-cmake nil - "Completion back-end for CMake." - :group 'company) - -(defcustom company-cmake-executable - (executable-find "cmake") - "Location of cmake executable." - :type 'file) - -(defvar company-cmake-executable-arguments - '("--help-command-list" - "--help-module-list" - "--help-variable-list") - "The arguments we pass to cmake, separately. -They affect which types of symbols we get completion candidates for.") - -(defvar company-cmake--completion-pattern - "^\\(%s[a-zA-Z0-9_]%s\\)$" - "Regexp to match the candidates.") - -(defvar company-cmake-modes '(cmake-mode) - "Major modes in which cmake may complete.") - -(defvar company-cmake--meta-command-cache nil - "Cache for command arguments to retrieve descriptions for the candidates.") - -(defun company-cmake--parse-output (prefix cmd) - "Analyze the temp buffer and collect lines." - (goto-char (point-min)) - (let ((pattern (format company-cmake--completion-pattern - (regexp-quote prefix) - (if (zerop (length prefix)) "+" "*"))) - (case-fold-search nil) - lines match) - (while (re-search-forward pattern nil t) - (setq match (match-string-no-properties 1)) - (puthash match cmd company-cmake--meta-command-cache) - (push match lines)) - lines)) - -(defun company-cmake--candidates (prefix) - (let ((res 0) - results - cmd) - (setq company-cmake--meta-command-cache (make-hash-table :test 'equal)) - (dolist (arg company-cmake-executable-arguments) - (with-temp-buffer - (setq res (call-process company-cmake-executable nil t nil arg)) - (unless (eq 0 res) - (message "cmake executable exited with error=%d" res)) - (setq cmd (replace-regexp-in-string "-list$" "" arg) ) - (setq results (nconc results (company-cmake--parse-output prefix cmd))))) - results)) - -(defun company-cmake--meta (prefix) - (let ((cmd-opts (gethash prefix company-cmake--meta-command-cache)) - result) - (with-temp-buffer - (call-process company-cmake-executable nil t nil cmd-opts prefix) - ;; Go to the third line, trim it and return the result. - ;; Tested with cmake 2.8.9. - (goto-char (point-min)) - (forward-line 2) - (setq result (buffer-substring-no-properties (line-beginning-position) - (line-end-position))) - (setq result (replace-regexp-in-string "^[ \t\n\r]+" "" result)) - result))) - -(defun company-cmake--doc-buffer (prefix) - (let ((cmd-opts (gethash prefix company-cmake--meta-command-cache))) - (with-temp-buffer - (call-process company-cmake-executable nil t nil cmd-opts prefix) - ;; Go to the third line, trim it and return the doc buffer. - ;; Tested with cmake 2.8.9. - (goto-char (point-min)) - (forward-line 2) - (company-doc-buffer - (buffer-substring-no-properties (line-beginning-position) - (point-max)))))) - -(defun company-cmake (command &optional arg &rest ignored) - "`company-mode' completion back-end for CMake. -CMake is a cross-platform, open-source make system." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-cmake)) - (init (when (memq major-mode company-cmake-modes) - (unless company-cmake-executable - (error "Company found no cmake executable")))) - (prefix (and (memq major-mode company-cmake-modes) - (not (company-in-string-or-comment)) - (company-grab-symbol))) - (candidates (company-cmake--candidates arg)) - (meta (company-cmake--meta arg)) - (doc-buffer (company-cmake--doc-buffer arg)) - )) - -(provide 'company-cmake) -;;; company-cmake.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-dabbrev.el b/emacs.d/elpa/company-20141014.1517/company-dabbrev.el deleted file mode 100644 index 7519caf..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-dabbrev.el +++ /dev/null @@ -1,163 +0,0 @@ -;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end -*- lexical-binding: t -*- - -;; Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defgroup company-dabbrev nil - "dabbrev-like completion back-end." - :group 'company) - -(defcustom company-dabbrev-other-buffers 'all - "Determines whether `company-dabbrev' should search other buffers. -If `all', search all other buffers, except the ignored ones. If t, search -buffers with the same major mode. See also `company-dabbrev-time-limit'." - :type '(choice (const :tag "Off" nil) - (const :tag "Same major mode" t) - (const :tag "All" all))) - -(defcustom company-dabbrev-ignore-buffers "\\`[ *]" - "Regexp matching the names of buffers to ignore." - :type 'regexp) - -(defcustom company-dabbrev-time-limit .1 - "Determines how many seconds `company-dabbrev' should look for matches." - :type '(choice (const :tag "Off" nil) - (number :tag "Seconds"))) - -(defcustom company-dabbrev-char-regexp "\\sw" - "A regular expression matching the characters `company-dabbrev' looks for." - :type 'regexp) - -(defcustom company-dabbrev-ignore-case 'keep-prefix - "Non-nil to ignore case when collecting completion candidates. -When it's `keep-prefix', the text before point will remain unchanged after -candidate is inserted, even some of its characters have different case.") - -(defcustom company-dabbrev-downcase 'case-replace - "Whether to downcase the returned candidates. - -The value of nil means keep them as-is. -`case-replace' means use the value of `case-replace'. -Any other value means downcase. - -If you set this value to nil, you may also want to set -`company-dabbrev-ignore-case' to any value other than `keep-prefix'.") - -(defcustom company-dabbrev-minimum-length 4 - "The minimum length for the completion candidate to be included. -This variable affects both `company-dabbrev' and `company-dabbrev-code'." - :type 'integer - :package-version '(company . "0.8.3")) - -(defmacro company-dabrev--time-limit-while (test start limit &rest body) - (declare (indent 3) (debug t)) - `(let ((company-time-limit-while-counter 0)) - (catch 'done - (while ,test - ,@body - (and ,limit - (eq (cl-incf company-time-limit-while-counter) 25) - (setq company-time-limit-while-counter 0) - (> (float-time (time-since ,start)) ,limit) - (throw 'done 'company-time-out)))))) - -(defsubst company-dabbrev--make-regexp (prefix) - (concat "\\<" (if (equal prefix "") - company-dabbrev-char-regexp - (regexp-quote prefix)) - "\\(" company-dabbrev-char-regexp "\\)*\\>")) - -(defun company-dabbrev--search-buffer (regexp pos symbols start limit - ignore-comments) - (save-excursion - (let (match) - (goto-char (if pos (1- pos) (point-min))) - ;; search before pos - (company-dabrev--time-limit-while (re-search-backward regexp nil t) - start limit - (setq match (match-string-no-properties 0)) - (if (and ignore-comments (company-in-string-or-comment)) - (goto-char (nth 8 (syntax-ppss))) - (when (>= (length match) company-dabbrev-minimum-length) - (push match symbols)))) - (goto-char (or pos (point-min))) - ;; search after pos - (company-dabrev--time-limit-while (re-search-forward regexp nil t) - start limit - (setq match (match-string-no-properties 0)) - (if (and ignore-comments (company-in-string-or-comment)) - (re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t) - (when (>= (length match) company-dabbrev-minimum-length) - (push match symbols)))) - symbols))) - -(defun company-dabbrev--search (regexp &optional limit other-buffer-modes - ignore-comments) - (let* ((start (current-time)) - (symbols (company-dabbrev--search-buffer regexp (point) nil start limit - ignore-comments))) - (when other-buffer-modes - (cl-dolist (buffer (delq (current-buffer) (buffer-list))) - (with-current-buffer buffer - (when (if (eq other-buffer-modes 'all) - (not (string-match-p company-dabbrev-ignore-buffers - (buffer-name))) - (apply #'derived-mode-p other-buffer-modes)) - (setq symbols - (company-dabbrev--search-buffer regexp nil symbols start - limit ignore-comments)))) - (and limit - (> (float-time (time-since start)) limit) - (cl-return)))) - symbols)) - -;;;###autoload -(defun company-dabbrev (command &optional arg &rest ignored) - "dabbrev-like `company-mode' completion back-end." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-dabbrev)) - (prefix (company-grab-word)) - (candidates - (let* ((case-fold-search company-dabbrev-ignore-case) - (words (company-dabbrev--search (company-dabbrev--make-regexp arg) - company-dabbrev-time-limit - (pcase company-dabbrev-other-buffers - (`t (list major-mode)) - (`all `all)))) - (downcase-p (if (eq company-dabbrev-downcase 'case-replace) - case-replace - company-dabbrev-downcase))) - (if downcase-p - (mapcar 'downcase words) - words))) - (ignore-case company-dabbrev-ignore-case) - (duplicates t))) - -(provide 'company-dabbrev) -;;; company-dabbrev.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-etags.el b/emacs.d/elpa/company-20141014.1517/company-etags.el deleted file mode 100644 index c7ba608..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-etags.el +++ /dev/null @@ -1,94 +0,0 @@ -;;; company-etags.el --- company-mode completion back-end for etags - -;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) -(require 'etags) - -(defgroup company-etags nil - "Completion back-end for etags." - :group 'company) - -(defcustom company-etags-use-main-table-list t - "Always search `tags-table-list' if set. -If this is disabled, `company-etags' will try to find the one table for each -buffer automatically." - :type '(choice (const :tag "off" nil) - (const :tag "on" t))) - -(defcustom company-etags-ignore-case nil - "Non-nil to ignore case in completion candidates." - :type 'boolean - :package-version '(company . "0.7.3")) - -(defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode - jde-mode pascal-mode perl-mode python-mode)) - -(defvar-local company-etags-buffer-table 'unknown) - -(defun company-etags-find-table () - (let ((file (locate-dominating-file (or buffer-file-name - default-directory) - "TAGS"))) - (when file - (list (expand-file-name file))))) - -(defun company-etags-buffer-table () - (or (and company-etags-use-main-table-list tags-table-list) - (if (eq company-etags-buffer-table 'unknown) - (setq company-etags-buffer-table (company-etags-find-table)) - company-etags-buffer-table))) - -(defun company-etags--candidates (prefix) - (let ((tags-table-list (company-etags-buffer-table)) - (completion-ignore-case company-etags-ignore-case)) - (and (or tags-file-name tags-table-list) - (fboundp 'tags-completion-table) - (save-excursion - (visit-tags-table-buffer) - (all-completions prefix (tags-completion-table)))))) - -;;;###autoload -(defun company-etags (command &optional arg &rest ignored) - "`company-mode' completion back-end for etags." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-etags)) - (prefix (and (apply 'derived-mode-p company-etags-modes) - (not (company-in-string-or-comment)) - (company-etags-buffer-table) - (or (company-grab-symbol) 'stop))) - (candidates (company-etags--candidates arg)) - (location (let ((tags-table-list (company-etags-buffer-table))) - (when (fboundp 'find-tag-noselect) - (save-excursion - (let ((buffer (find-tag-noselect arg))) - (cons buffer (with-current-buffer buffer (point)))))))) - (ignore-case company-etags-ignore-case))) - -(provide 'company-etags) -;;; company-etags.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-files.el b/emacs.d/elpa/company-20141014.1517/company-files.el deleted file mode 100644 index baaeaca..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-files.el +++ /dev/null @@ -1,104 +0,0 @@ -;;; company-files.el --- company-mode completion back-end for file paths - -;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defun company-files--directory-files (dir prefix) - (ignore-errors - (if (equal prefix "") - (directory-files dir nil "\\`[^.]\\|\\`.[^.]") - (file-name-all-completions prefix dir)))) - -(defvar company-files--regexps - (let* ((root (if (eq system-type 'windows-nt) - "[a-zA-Z]:/" - "/")) - (begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)"))) - (list (concat "\"\\(" begin "[^\"\n]*\\)") - (concat "\'\\(" begin "[^\'\n]*\\)") - (concat "\\(?:[ \t]\\|^\\)\\(" begin "[^ \t\n]*\\)")))) - -(defun company-files--grab-existing-name () - ;; Grab the file name. - ;; When surrounded with quotes, it can include spaces. - (let (file dir) - (and (cl-dolist (regexp company-files--regexps) - (when (setq file (company-grab-line regexp 1)) - (cl-return file))) - (setq dir (file-name-directory file)) - (not (string-match "//" dir)) - (file-exists-p dir) - (file-name-all-completions (file-name-nondirectory file) dir) - file))) - -(defvar company-files--completion-cache nil) - -(defun company-files--complete (prefix) - (let* ((dir (file-name-directory prefix)) - (key (list (file-name-nondirectory prefix) - (expand-file-name dir) - (nth 5 (file-attributes dir)))) - (file (file-name-nondirectory prefix)) - candidates directories) - (unless (company-file--keys-match-p key (car company-files--completion-cache)) - (dolist (file (company-files--directory-files dir file)) - (setq file (concat dir file)) - (push file candidates) - (when (file-directory-p file) - (push file directories))) - (dolist (directory (reverse directories)) - ;; Add one level of children. - (dolist (child (company-files--directory-files directory "")) - (push (concat directory - (unless (eq (aref directory (1- (length directory))) ?/) "/") - child) candidates))) - (setq company-files--completion-cache (cons key (nreverse candidates)))) - (all-completions prefix - (cdr company-files--completion-cache)))) - -(defun company-file--keys-match-p (new old) - (and (equal (cdr old) (cdr new)) - (string-prefix-p (car old) (car new)))) - -;;;###autoload -(defun company-files (command &optional arg &rest ignored) - "`company-mode' completion back-end existing file names. -Completions works for proper absolute and relative files paths. -File paths with spaces are only supported inside strings." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-files)) - (prefix (company-files--grab-existing-name)) - (candidates (company-files--complete arg)) - (location (cons (dired-noselect - (file-name-directory (directory-file-name arg))) 1)) - (sorted t) - (no-cache t))) - -(provide 'company-files) -;;; company-files.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-gtags.el b/emacs.d/elpa/company-20141014.1517/company-gtags.el deleted file mode 100644 index aaa22b9..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-gtags.el +++ /dev/null @@ -1,115 +0,0 @@ -;;; company-gtags.el --- company-mode completion back-end for GNU Global - -;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defgroup company-gtags nil - "Completion back-end for GNU Global." - :group 'company) - -(defcustom company-gtags-executable - (executable-find "global") - "Location of GNU global executable." - :type 'string) - -(define-obsolete-variable-alias - 'company-gtags-gnu-global-program-name - 'company-gtags-executable "earlier") - -(defcustom company-gtags-insert-arguments t - "When non-nil, insert function arguments as a template after completion." - :type 'boolean - :package-version '(company . "0.8.1")) - -(defvar-local company-gtags--tags-available-p 'unknown) - -(defcustom company-gtags-modes '(prog-mode jde-mode) - "Modes that use `company-gtags'. -In all these modes (and their derivatives) `company-gtags' will perform -completion." - :type '(repeat (symbol :tag "Major mode")) - :package-version '(company . "0.8.4")) - -(defun company-gtags--tags-available-p () - (if (eq company-gtags--tags-available-p 'unknown) - (setq company-gtags--tags-available-p - (locate-dominating-file buffer-file-name "GTAGS")) - company-gtags--tags-available-p)) - -(defun company-gtags--fetch-tags (prefix) - (with-temp-buffer - (let (tags) - (when (= 0 (call-process company-gtags-executable nil - (list (current-buffer) nil) nil "-xGq" (concat "^" prefix))) - (goto-char (point-min)) - (cl-loop while - (re-search-forward (concat - "^" - "\\([^ ]*\\)" ;; completion - "[ \t]+\\([[:digit:]]+\\)" ;; linum - "[ \t]+\\([^ \t]+\\)" ;; file - "[ \t]+\\(.*\\)" ;; definition - "$" - ) nil t) - collect - (propertize (match-string 1) - 'meta (match-string 4) - 'location (cons (expand-file-name (match-string 3)) - (string-to-number (match-string 2))) - )))))) - -(defun company-gtags--annotation (arg) - (let ((meta (get-text-property 0 'meta arg))) - (when (string-match (concat arg "\\((.*)\\).*") meta) - (match-string 1 meta)))) - -;;;###autoload -(defun company-gtags (command &optional arg &rest ignored) - "`company-mode' completion back-end for GNU Global." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-gtags)) - (prefix (and company-gtags-executable - buffer-file-name - (apply #'derived-mode-p company-gtags-modes) - (not (company-in-string-or-comment)) - (company-gtags--tags-available-p) - (or (company-grab-symbol) 'stop))) - (candidates (company-gtags--fetch-tags arg)) - (sorted t) - (duplicates t) - (annotation (company-gtags--annotation arg)) - (meta (get-text-property 0 'meta arg)) - (location (get-text-property 0 'location arg)) - (post-completion (let ((anno (company-gtags--annotation arg))) - (when (and company-gtags-insert-arguments anno) - (insert anno) - (company-template-c-like-templatify anno)))))) - -(provide 'company-gtags) -;;; company-gtags.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-ispell.el b/emacs.d/elpa/company-20141014.1517/company-ispell.el deleted file mode 100644 index 1561bee..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-ispell.el +++ /dev/null @@ -1,69 +0,0 @@ -;;; company-ispell.el --- company-mode completion back-end using Ispell - -;; Copyright (C) 2009-2011 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) -(require 'ispell) - -(defgroup company-ispell nil - "Completion back-end using Ispell." - :group 'company) - -(defcustom company-ispell-dictionary nil - "Dictionary to use for `company-ispell'. -If nil, use `ispell-complete-word-dict'." - :type '(choice (const :tag "default (nil)" nil) - (file :tag "dictionary" t))) - -(defvar company-ispell-available 'unknown) - -(defun company-ispell-available () - (when (eq company-ispell-available 'unknown) - (condition-case err - (progn - (lookup-words "WHATEVER") - (setq company-ispell-available t)) - (error - (message "Company: ispell-look-command not found") - (setq company-ispell-available nil)))) - company-ispell-available) - -;;;###autoload -(defun company-ispell (command &optional arg &rest ignored) - "`company-mode' completion back-end using Ispell." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-ispell)) - (prefix (when (company-ispell-available) - (company-grab-word))) - (candidates (lookup-words arg (or company-ispell-dictionary - ispell-complete-word-dict))) - (sorted t) - (ignore-case 'keep-prefix))) - -(provide 'company-ispell) -;;; company-ispell.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-pkg.el b/emacs.d/elpa/company-20141014.1517/company-pkg.el deleted file mode 100644 index 5325899..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-pkg.el +++ /dev/null @@ -1,8 +0,0 @@ -(define-package "company" "20141014.1517" "Modular text completion framework" - '((emacs "24.1") - (cl-lib "0.5")) - :url "http://company-mode.github.io/" :keywords - '("abbrev" "convenience" "matching")) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/company-20141014.1517/company-pysmell.el b/emacs.d/elpa/company-20141014.1517/company-pysmell.el deleted file mode 100644 index 8a69e76..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-pysmell.el +++ /dev/null @@ -1,69 +0,0 @@ -;;; company-pysmell.el --- company-mode completion back-end for pysmell.el - -;; Copyright (C) 2009-2011, 2013-2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; -;; The main problem with using this backend is installing Pysmell. -;; I couldn't manage to do that. --Dmitry - -;;; Code: - -(if t (require 'pysmell)) ;Don't load during compilation. -(require 'company) -(require 'cl-lib) - -(defvar-local company-pysmell--available-p 'unknown) - -(defun company-pysmell--available-p () - (if (eq company-pysmell--available-p 'unknown) - (setq company-pysmell--available-p - (locate-dominating-file buffer-file-name "PYSMELLTAGS")) - company-pysmell--available-p)) - -(defun company-pysmell--grab-symbol () - (let ((symbol (company-grab-symbol))) - (when symbol - (cons symbol - (save-excursion - (let ((pos (point))) - (goto-char (- (point) (length symbol))) - (while (eq (char-before) ?.) - (goto-char (1- (point))) - (skip-syntax-backward "w_")) - (- pos (point)))))))) - -;;;###autoload -(defun company-pysmell (command &optional arg &rest ignored) - "`company-mode' completion back-end for pysmell. -This requires pysmell.el and pymacs.el." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-pysmell)) - (prefix (and (derived-mode-p 'python-mode) - buffer-file-name - (not (company-in-string-or-comment)) - (company-pysmell--available-p) - (company-pysmell--grab-symbol))) - (candidates (delete "" (pysmell-get-all-completions))))) - -(provide 'company-pysmell) -;;; company-pysmell.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-ropemacs.el b/emacs.d/elpa/company-20141014.1517/company-ropemacs.el deleted file mode 100644 index 4fc3813..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-ropemacs.el +++ /dev/null @@ -1,72 +0,0 @@ -;;; company-ropemacs.el --- company-mode completion back-end for ropemacs - -;; Copyright (C) 2009-2011, 2013-2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'cl-lib) - -(defun company-ropemacs--grab-symbol () - (let ((symbol (company-grab-symbol))) - (when symbol - (cons symbol - (save-excursion - (let ((pos (point))) - (goto-char (- (point) (length symbol))) - (while (eq (char-before) ?.) - (goto-char (1- (point))) - (skip-syntax-backward "w_")) - (- pos (point)))))))) - -(defun company-ropemacs-doc-buffer (candidate) - "Return buffer with docstring of CANDIDATE if it is available." - (let ((doc (company-with-candidate-inserted candidate (rope-get-doc)))) - (when doc - (company-doc-buffer doc)))) - -(defun company-ropemacs-location (candidate) - "Return location of CANDIDATE in cons form (FILE . LINE) if it is available." - (let ((location (company-with-candidate-inserted candidate - (rope-definition-location)))) - (when location - (cons (elt location 0) (elt location 1))))) - -(defun company-ropemacs (command &optional arg &rest ignored) - "`company-mode' completion back-end for ropemacs. - -Depends on third-party code: Pymacs (both Python and Emacs packages), -rope, ropemacs and ropemode. Requires `ropemacs-mode' to be on." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-ropemacs)) - (prefix (and (bound-and-true-p ropemacs-mode) - (not (company-in-string-or-comment)) - (company-ropemacs--grab-symbol))) - (candidates (mapcar (lambda (element) (concat arg element)) - (rope-completions))) - (doc-buffer (company-ropemacs-doc-buffer arg)) - (location (company-ropemacs-location arg)))) - -(provide 'company-ropemacs) -;;; company-ropemacs.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-semantic.el b/emacs.d/elpa/company-20141014.1517/company-semantic.el deleted file mode 100644 index 6c020a3..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-semantic.el +++ /dev/null @@ -1,146 +0,0 @@ -;;; company-semantic.el --- company-mode completion back-end using Semantic - -;; Copyright (C) 2009-2011, 2013 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defvar semantic-idle-summary-function) -(declare-function semantic-documentation-for-tag "semantic/doc" ) -(declare-function semantic-analyze-current-context "semantic/analyze") -(declare-function semantic-analyze-possible-completions "semantic/complete") -(declare-function semantic-analyze-find-tags-by-prefix "semantic/analyze/fcn") -(declare-function semantic-tag-class "semantic/tag") -(declare-function semantic-tag-name "semantic/tag") -(declare-function semantic-tag-start "semantic/tag") -(declare-function semantic-tag-buffer "semantic/tag") -(declare-function semantic-active-p "semantic") - -(defgroup company-semantic nil - "Completion back-end using Semantic." - :group 'company) - -(defcustom company-semantic-metadata-function 'company-semantic-summary-and-doc - "The function turning a semantic tag into doc information." - :type 'function) - -(defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode)) - -(defvar-local company-semantic--current-tags nil - "Tags for the current context.") - -(defun company-semantic-documentation-for-tag (tag) - (when (semantic-tag-buffer tag) - ;; When TAG's buffer is unknown, the function below raises an error. - (semantic-documentation-for-tag tag))) - -(defun company-semantic-doc-or-summary (tag) - (or (company-semantic-documentation-for-tag tag) - (and (require 'semantic-idle nil t) - (require 'semantic/idle nil t) - (funcall semantic-idle-summary-function tag nil t)))) - -(defun company-semantic-summary-and-doc (tag) - (let ((doc (company-semantic-documentation-for-tag tag)) - (summary (funcall semantic-idle-summary-function tag nil t))) - (and (stringp doc) - (string-match "\n*\\(.*\\)$" doc) - (setq doc (match-string 1 doc))) - (concat summary - (when doc - (if (< (+ (length doc) (length summary) 4) (window-width)) - " -- " - "\n")) - doc))) - -(defun company-semantic-doc-buffer (tag) - (let ((doc (company-semantic-documentation-for-tag tag))) - (when doc - (company-doc-buffer - (concat (funcall semantic-idle-summary-function tag nil t) - "\n" - doc))))) - -(defsubst company-semantic-completions (prefix) - (ignore-errors - (let ((completion-ignore-case nil) - (context (semantic-analyze-current-context))) - (setq company-semantic--current-tags - (semantic-analyze-possible-completions context)) - (all-completions prefix company-semantic--current-tags)))) - -(defun company-semantic-completions-raw (prefix) - (setq company-semantic--current-tags nil) - (dolist (tag (semantic-analyze-find-tags-by-prefix prefix)) - (unless (eq (semantic-tag-class tag) 'include) - (push tag company-semantic--current-tags))) - (delete "" (mapcar 'semantic-tag-name company-semantic--current-tags))) - -(defun company-semantic--pre-prefix-length (prefix-length) - "Sum up the length of all chained symbols before POS. -Symbols are chained by \".\" or \"->\"." - (save-excursion - (let ((pos (point))) - (goto-char (- (point) prefix-length)) - (while (looking-back "->\\|\\.") - (goto-char (match-beginning 0)) - (skip-syntax-backward "w_")) - (- pos (point))))) - -(defun company-semantic--grab () - "Grab the semantic prefix, but return everything before -> or . as length." - (let ((symbol (company-grab-symbol))) - (when symbol - (cons symbol (company-semantic--pre-prefix-length (length symbol)))))) - -;;;###autoload -(defun company-semantic (command &optional arg &rest ignored) - "`company-mode' completion back-end using CEDET Semantic." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-semantic)) - (prefix (and (featurep 'semantic) - (semantic-active-p) - (memq major-mode company-semantic-modes) - (not (company-in-string-or-comment)) - (or (company-semantic--grab) 'stop))) - (candidates (if (and (equal arg "") - (not (looking-back "->\\|\\."))) - (company-semantic-completions-raw arg) - (company-semantic-completions arg))) - (meta (funcall company-semantic-metadata-function - (assoc arg company-semantic--current-tags))) - (doc-buffer (company-semantic-doc-buffer - (assoc arg company-semantic--current-tags))) - ;; Because "" is an empty context and doesn't return local variables. - (no-cache (equal arg "")) - (location (let ((tag (assoc arg company-semantic--current-tags))) - (when (buffer-live-p (semantic-tag-buffer tag)) - (cons (semantic-tag-buffer tag) - (semantic-tag-start tag))))))) - -(provide 'company-semantic) -;;; company-semantic.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-template.el b/emacs.d/elpa/company-20141014.1517/company-template.el deleted file mode 100644 index bc1055c..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-template.el +++ /dev/null @@ -1,197 +0,0 @@ -;;; company-template.el - -;; Copyright (C) 2009, 2010, 2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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 . - -;;; Code: - -(require 'cl-lib) - -(defface company-template-field - '((((background dark)) (:background "yellow" :foreground "black")) - (((background light)) (:background "orange" :foreground "black"))) - "Face used for editable text in template fields." - :group 'company) - -(defvar company-template-nav-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap [tab] 'company-template-forward-field) - (define-key keymap (kbd "TAB") 'company-template-forward-field) - keymap)) - -(defvar-local company-template--buffer-templates nil) - -;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun company-template-templates-at (pos) - (let (os) - (dolist (o (overlays-at pos)) - ;; FIXME: Always return the whole list of templates? - ;; We remove templates not at point after every command. - (when (memq o company-template--buffer-templates) - (push o os))) - os)) - -(defun company-template-move-to-first (templ) - (interactive) - (goto-char (overlay-start templ)) - (company-template-forward-field)) - -(defun company-template-forward-field () - (interactive) - (let* ((start (point)) - (templates (company-template-templates-at (point))) - (minimum (apply 'max (mapcar 'overlay-end templates))) - (fields (cl-loop for templ in templates - append (overlay-get templ 'company-template-fields)))) - (dolist (pos (mapcar 'overlay-start fields)) - (and pos - (> pos (point)) - (< pos minimum) - (setq minimum pos))) - (push-mark) - (goto-char minimum) - (company-template-remove-field (company-template-field-at start)))) - -(defun company-template-field-at (&optional point) - (cl-loop for ovl in (overlays-at (or point (point))) - when (overlay-get ovl 'company-template-parent) - return ovl)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun company-template-declare-template (beg end) - (let ((ov (make-overlay beg end))) - ;; (overlay-put ov 'face 'highlight) - (overlay-put ov 'keymap company-template-nav-map) - (overlay-put ov 'priority 101) - (overlay-put ov 'evaporate t) - (push ov company-template--buffer-templates) - (add-hook 'post-command-hook 'company-template-post-command nil t) - ov)) - -(defun company-template-remove-template (templ) - (mapc 'company-template-remove-field - (overlay-get templ 'company-template-fields)) - (setq company-template--buffer-templates - (delq templ company-template--buffer-templates)) - (delete-overlay templ)) - -(defun company-template-add-field (templ pos text &optional display) - "Add new field to template TEMPL at POS, inserting TEXT. -When DISPLAY is non-nil, set the respective property on the overlay. -Leave point at the end of the field." - (cl-assert templ) - (goto-char pos) - (insert text) - (when (> (point) (overlay-end templ)) - (move-overlay templ (overlay-start templ) (point))) - (let ((ov (make-overlay pos (+ pos (length text)))) - (siblings (overlay-get templ 'company-template-fields))) - ;; (overlay-put ov 'evaporate t) - (overlay-put ov 'intangible t) - (overlay-put ov 'face 'company-template-field) - (when display - (overlay-put ov 'display display)) - (overlay-put ov 'company-template-parent templ) - (overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook)) - (push ov siblings) - (overlay-put templ 'company-template-fields siblings))) - -(defun company-template-remove-field (ovl &optional clear) - (when (overlayp ovl) - (when (overlay-buffer ovl) - (when clear - (delete-region (overlay-start ovl) (overlay-end ovl))) - (delete-overlay ovl)) - (let* ((templ (overlay-get ovl 'company-template-parent)) - (siblings (overlay-get templ 'company-template-fields))) - (setq siblings (delq ovl siblings)) - (overlay-put templ 'company-template-fields siblings)))) - -(defun company-template-clean-up (&optional pos) - "Clean up all templates that don't contain POS." - (let ((local-ovs (overlays-at (or pos (point))))) - (dolist (templ company-template--buffer-templates) - (unless (memq templ local-ovs) - (company-template-remove-template templ))))) - -;; hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun company-template-insert-hook (ovl after-p &rest _ignore) - "Called when a snippet input prompt is modified." - (unless after-p - (company-template-remove-field ovl t))) - -(defun company-template-post-command () - (company-template-clean-up) - (unless company-template--buffer-templates - (remove-hook 'post-command-hook 'company-template-post-command t))) - -;; common ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun company-template-c-like-templatify (call) - (let* ((end (point-marker)) - (beg (- (point) (length call))) - (cnt 0) - (templ (company-template-declare-template beg end)) - paren-open paren-close) - (with-syntax-table (make-char-table 'syntax-table nil) - (modify-syntax-entry ?\( "(") - (modify-syntax-entry ?\) ")") - (modify-syntax-entry ?< "(") - (modify-syntax-entry ?> ")") - (when (search-backward ")" beg t) - (setq paren-close (point-marker)) - (forward-char 1) - (delete-region (point) end) - (backward-sexp) - (forward-char 1) - (setq paren-open (point-marker))) - (when (search-backward ">" beg t) - (let ((angle-close (point-marker))) - (forward-char 1) - (backward-sexp) - (forward-char) - (setq cnt (company-template--c-like-args templ angle-close - cnt)))) - (when paren-open - (goto-char paren-open) - (company-template--c-like-args templ paren-close cnt))) - (if (overlay-get templ 'company-template-fields) - (company-template-move-to-first templ) - (company-template-remove-template templ) - (goto-char end)))) - -(defun company-template--c-like-args (templ end counter) - (let ((last-pos (point))) - (while (re-search-forward "\\([^,]+\\),?" end 'move) - (when (zerop (car (parse-partial-sexp last-pos (point)))) - (let ((sig (buffer-substring-no-properties last-pos (match-end 1)))) - (save-excursion - (company-template-add-field templ last-pos - (format "arg%d" counter) sig) - (delete-region (point) (+ (point) (length sig)))) - (skip-chars-forward " ") - (setq last-pos (point)) - (cl-incf counter))))) - counter) - -(provide 'company-template) -;;; company-template.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-xcode.el b/emacs.d/elpa/company-20141014.1517/company-xcode.el deleted file mode 100644 index 91ae60b..0000000 --- a/emacs.d/elpa/company-20141014.1517/company-xcode.el +++ /dev/null @@ -1,123 +0,0 @@ -;;; company-xcode.el --- company-mode completion back-end for Xcode projects - -;; Copyright (C) 2009-2011 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher - -;; 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: -;; - -;;; Code: - -(require 'company) -(require 'cl-lib) - -(defgroup company-xcode nil - "Completion back-end for Xcode projects." - :group 'company) - -(defcustom company-xcode-xcodeindex-executable (executable-find "xcodeindex") - "Location of xcodeindex executable." - :type 'file) - -(defvar company-xcode-tags nil) - -(defun company-xcode-reset () - "Reset the cached tags." - (interactive) - (setq company-xcode-tags nil)) - -(defcustom company-xcode-types - '("Class" "Constant" "Enum" "Macro" "Modeled Class" "Structure" - "Type" "Union" "Function") - "The types of symbols offered by `company-xcode'. -No context-enabled completion is available. Types like methods will be -offered regardless of whether the class supports them. The defaults should be -valid in most contexts." - :set (lambda (variable value) - (set variable value) - (company-xcode-reset)) - :type '(set (const "Category") (const "Class") (const "Class Method") - (const "Class Variable") (const "Constant") (const "Enum") - (const "Field") (const "Instance Method") - (const "Instance Variable") (const "Macro") - (const "Modeled Class") (const "Modeled Method") - (const "Modeled Property") (const "Property") (const "Protocol") - (const "Structure") (const "Type") (const "Union") - (const "Variable") (const "Function"))) - -(defvar-local company-xcode-project 'unknown) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun company-xcode-fetch (project-bundle) - (setq project-bundle (directory-file-name project-bundle)) - (message "Retrieving dump from %s..." project-bundle) - (with-temp-buffer - (let ((default-directory (file-name-directory project-bundle))) - (call-process company-xcode-xcodeindex-executable nil (current-buffer) - nil "dump" "-project" - (file-name-nondirectory project-bundle) "-quiet") - (goto-char (point-min)) - (let ((regexp (concat "^\\([^\t\n]*\\)\t[^\t\n]*\t" - (regexp-opt company-xcode-types) - "\t[^\t\n]*\t[^\t\n]*")) - candidates) - (while (re-search-forward regexp nil t) - (add-to-list 'candidates (match-string 1))) - (message "Retrieving dump from %s...done" project-bundle) - candidates)))) - -(defun company-xcode-find-project () - (let ((dir (if buffer-file-name - (file-name-directory buffer-file-name) - (expand-file-name default-directory))) - (prev-dir nil) - file) - (while (not (or file (equal dir prev-dir))) - (setq file (car (directory-files dir t ".xcodeproj\\'" t)) - prev-dir dir - dir (file-name-directory (directory-file-name dir)))) - file)) - -(defun company-xcode-tags () - (when (eq company-xcode-project 'unknown) - (setq company-xcode-project (company-xcode-find-project))) - (when company-xcode-project - (cdr (or (assoc company-xcode-project company-xcode-tags) - (car (push (cons company-xcode-project - (company-xcode-fetch company-xcode-project)) - company-xcode-tags)))))) -;;;###autoload -(defun company-xcode (command &optional arg &rest ignored) - "`company-mode' completion back-end for Xcode projects." - (interactive (list 'interactive)) - (cl-case command - (interactive (company-begin-backend 'company-xcode)) - (prefix (and company-xcode-xcodeindex-executable - (company-xcode-tags) - (not (company-in-string-or-comment)) - (or (company-grab-symbol) 'stop))) - (candidates (let ((completion-ignore-case nil)) - (company-xcode-tags) - (all-completions arg (company-xcode-tags)))))) - - -(provide 'company-xcode) -;;; company-xcode.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company.el b/emacs.d/elpa/company-20141014.1517/company.el deleted file mode 100644 index 36086d0..0000000 --- a/emacs.d/elpa/company-20141014.1517/company.el +++ /dev/null @@ -1,2674 +0,0 @@ -;;; company.el --- Modular text completion framework -*- lexical-binding: t -*- - -;; Copyright (C) 2009-2014 Free Software Foundation, Inc. - -;; Author: Nikolaj Schumacher -;; Maintainer: Dmitry Gutov -;; URL: http://company-mode.github.io/ -;; Version: 0.8.6 -;; Keywords: abbrev, convenience, matching -;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) - -;; 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: -;; -;; Company is a modular completion mechanism. Modules for retrieving completion -;; candidates are called back-ends, modules for displaying them are front-ends. -;; -;; Company comes with many back-ends, e.g. `company-elisp'. These are -;; distributed in separate files and can be used individually. -;; -;; Place company.el and the back-ends you want to use in a directory and add the -;; following to your .emacs: -;; (add-to-list 'load-path "/path/to/company") -;; (autoload 'company-mode "company" nil t) -;; -;; Enable company-mode with M-x company-mode. For further information look at -;; the documentation for `company-mode' (C-h f company-mode RET) -;; -;; If you want to start a specific back-end, call it interactively or use -;; `company-begin-backend'. For example: -;; M-x company-abbrev will prompt for and insert an abbrev. -;; -;; To write your own back-end, look at the documentation for `company-backends'. -;; Here is a simple example completing "foo": -;; -;; (defun company-my-backend (command &optional arg &rest ignored) -;; (pcase command -;; (`prefix (when (looking-back "foo\\>") -;; (match-string 0))) -;; (`candidates (list "foobar" "foobaz" "foobarbaz")) -;; (`meta (format "This value is named %s" arg)))) -;; -;; Sometimes it is a good idea to mix several back-ends together, for example to -;; enrich gtags with dabbrev-code results (to emulate local variables). -;; To do this, add a list with both back-ends as an element in company-backends. -;; -;;; Change Log: -;; -;; See NEWS.md in the repository. - -;;; Code: - -(require 'cl-lib) -(require 'newcomment) - -;; FIXME: Use `user-error'. -(add-to-list 'debug-ignored-errors "^.* frontend cannot be used twice$") -(add-to-list 'debug-ignored-errors "^Echo area cannot be used twice$") -(add-to-list 'debug-ignored-errors "^No \\(document\\|loc\\)ation available$") -(add-to-list 'debug-ignored-errors "^Company not ") -(add-to-list 'debug-ignored-errors "^No candidate number ") -(add-to-list 'debug-ignored-errors "^Cannot complete at point$") -(add-to-list 'debug-ignored-errors "^No other back-end$") - -;;; Compatibility -(eval-and-compile - ;; `defvar-local' for Emacs 24.2 and below - (unless (fboundp 'defvar-local) - (defmacro defvar-local (var val &optional docstring) - "Define VAR as a buffer-local variable with default value VAL. -Like `defvar' but additionally marks the variable as being automatically -buffer-local wherever it is set." - (declare (debug defvar) (doc-string 3)) - `(progn - (defvar ,var ,val ,docstring) - (make-variable-buffer-local ',var))))) - -(defgroup company nil - "Extensible inline text completion mechanism" - :group 'abbrev - :group 'convenience - :group 'matching) - -(defface company-tooltip - '((default :foreground "black") - (((class color) (min-colors 88) (background light)) - (:background "cornsilk")) - (((class color) (min-colors 88) (background dark)) - (:background "yellow"))) - "Face used for the tooltip.") - -(defface company-tooltip-selection - '((default :inherit company-tooltip) - (((class color) (min-colors 88) (background light)) - (:background "light blue")) - (((class color) (min-colors 88) (background dark)) - (:background "orange1")) - (t (:background "green"))) - "Face used for the selection in the tooltip.") - -(defface company-tooltip-search - '((default :inherit company-tooltip-selection)) - "Face used for the search string in the tooltip.") - -(defface company-tooltip-mouse - '((default :inherit highlight)) - "Face used for the tooltip item under the mouse.") - -(defface company-tooltip-common - '((default :inherit company-tooltip) - (((background light)) - :foreground "darkred") - (((background dark)) - :foreground "red")) - "Face used for the common completion in the tooltip.") - -(defface company-tooltip-common-selection - '((default :inherit company-tooltip-selection) - (((background light)) - :foreground "darkred") - (((background dark)) - :foreground "red")) - "Face used for the selected common completion in the tooltip.") - -(defface company-tooltip-annotation - '((default :inherit company-tooltip) - (((background light)) - :foreground "firebrick4") - (((background dark)) - :foreground "red4")) - "Face used for the annotation in the tooltip.") - -(defface company-scrollbar-fg - '((((background light)) - :background "darkred") - (((background dark)) - :background "red")) - "Face used for the tooltip scrollbar thumb.") - -(defface company-scrollbar-bg - '((default :inherit company-tooltip) - (((background light)) - :background "wheat") - (((background dark)) - :background "gold")) - "Face used for the tooltip scrollbar background.") - -(defface company-preview - '((((background light)) - :inherit company-tooltip-selection) - (((background dark)) - :background "blue4" - :foreground "wheat")) - "Face used for the completion preview.") - -(defface company-preview-common - '((((background light)) - :inherit company-tooltip-selection) - (((background dark)) - :inherit company-preview - :foreground "red")) - "Face used for the common part of the completion preview.") - -(defface company-preview-search - '((((background light)) - :inherit company-tooltip-common-selection) - (((background dark)) - :inherit company-preview - :background "blue1")) - "Face used for the search string in the completion preview.") - -(defface company-echo nil - "Face used for completions in the echo area.") - -(defface company-echo-common - '((((background dark)) (:foreground "firebrick1")) - (((background light)) (:background "firebrick4"))) - "Face used for the common part of completions in the echo area.") - -(defun company-frontends-set (variable value) - ;; Uniquify. - (let ((value (delete-dups (copy-sequence value)))) - (and (memq 'company-pseudo-tooltip-unless-just-one-frontend value) - (memq 'company-pseudo-tooltip-frontend value) - (error "Pseudo tooltip frontend cannot be used twice")) - (and (memq 'company-preview-if-just-one-frontend value) - (memq 'company-preview-frontend value) - (error "Preview frontend cannot be used twice")) - (and (memq 'company-echo value) - (memq 'company-echo-metadata-frontend value) - (error "Echo area cannot be used twice")) - ;; Preview must come last. - (dolist (f '(company-preview-if-just-one-frontend company-preview-frontend)) - (when (cdr (memq f value)) - (setq value (append (delq f value) (list f))))) - (set variable value))) - -(defcustom company-frontends '(company-pseudo-tooltip-unless-just-one-frontend - company-preview-if-just-one-frontend - company-echo-metadata-frontend) - "The list of active front-ends (visualizations). -Each front-end is a function that takes one argument. It is called with -one of the following arguments: - -`show': When the visualization should start. - -`hide': When the visualization should end. - -`update': When the data has been updated. - -`pre-command': Before every command that is executed while the -visualization is active. - -`post-command': After every command that is executed while the -visualization is active. - -The visualized data is stored in `company-prefix', `company-candidates', -`company-common', `company-selection', `company-point' and -`company-search-string'." - :set 'company-frontends-set - :type '(repeat (choice (const :tag "echo" company-echo-frontend) - (const :tag "echo, strip common" - company-echo-strip-common-frontend) - (const :tag "show echo meta-data in echo" - company-echo-metadata-frontend) - (const :tag "pseudo tooltip" - company-pseudo-tooltip-frontend) - (const :tag "pseudo tooltip, multiple only" - company-pseudo-tooltip-unless-just-one-frontend) - (const :tag "preview" company-preview-frontend) - (const :tag "preview, unique only" - company-preview-if-just-one-frontend) - (function :tag "custom function" nil)))) - -(defcustom company-tooltip-limit 10 - "The maximum number of candidates in the tooltip." - :type 'integer) - -(defcustom company-tooltip-minimum 6 - "The minimum height of the tooltip. -If this many lines are not available, prefer to display the tooltip above." - :type 'integer) - -(defcustom company-tooltip-minimum-width 0 - "The minimum width of the tooltip's inner area. -This doesn't include the margins and the scroll bar." - :type 'integer - :package-version '(company . "0.8.0")) - -(defcustom company-tooltip-margin 1 - "Width of margin columns to show around the toolip." - :type 'integer) - -(defcustom company-tooltip-offset-display 'scrollbar - "Method using which the tooltip displays scrolling position. -`scrollbar' means draw a scrollbar to the right of the items. -`lines' means wrap items in lines with \"before\" and \"after\" counters." - :type '(choice (const :tag "Scrollbar" scrollbar) - (const :tag "Two lines" lines))) - -(defcustom company-tooltip-align-annotations nil - "When non-nil, align annotations to the right tooltip border." - :type 'boolean - :package-version '(company . "0.7.1")) - -(defcustom company-tooltip-flip-when-above nil - "Whether to flip the tooltip when it's above the current line." - :type 'boolean - :package-version '(company . "0.8.1")) - -(defvar company-safe-backends - '((company-abbrev . "Abbrev") - (company-bbdb . "BBDB") - (company-capf . "completion-at-point-functions") - (company-clang . "Clang") - (company-cmake . "CMake") - (company-css . "CSS") - (company-dabbrev . "dabbrev for plain text") - (company-dabbrev-code . "dabbrev for code") - (company-eclim . "Eclim (an Eclipse interface)") - (company-elisp . "Emacs Lisp") - (company-etags . "etags") - (company-files . "Files") - (company-gtags . "GNU Global") - (company-ispell . "Ispell") - (company-keywords . "Programming language keywords") - (company-nxml . "nxml") - (company-oddmuse . "Oddmuse") - (company-pysmell . "PySmell") - (company-ropemacs . "ropemacs") - (company-semantic . "Semantic") - (company-tempo . "Tempo templates") - (company-xcode . "Xcode"))) -(put 'company-safe-backends 'risky-local-variable t) - -(defun company-safe-backends-p (backends) - (and (consp backends) - (not (cl-dolist (backend backends) - (unless (if (consp backend) - (company-safe-backends-p backend) - (assq backend company-safe-backends)) - (cl-return t)))))) - -(defcustom company-backends `(,@(unless (version< "24.3.50" emacs-version) - (list 'company-elisp)) - company-bbdb - company-nxml company-css - company-eclim company-semantic company-clang - company-xcode company-ropemacs company-cmake - company-capf - (company-dabbrev-code company-gtags company-etags - company-keywords) - company-oddmuse company-files company-dabbrev) - "The list of active back-ends (completion engines). - -Only one back-end is used at a time. The choice depends on the order of -the items in this list, and on the values they return in response to the -`prefix' command (see below). But a back-end can also be a \"grouped\" -one (see below). - -`company-begin-backend' can be used to start a specific back-end, -`company-other-backend' will skip to the next matching back-end in the list. - -Each back-end is a function that takes a variable number of arguments. -The first argument is the command requested from the back-end. It is one -of the following: - -`prefix': The back-end should return the text to be completed. It must be -text immediately before point. Returning nil passes control to the next -back-end. The function should return `stop' if it should complete but -cannot (e.g. if it is in the middle of a string). Instead of a string, -the back-end may return a cons where car is the prefix and cdr is used in -`company-minimum-prefix-length' test. It must be either number or t, and -in the latter case the test automatically succeeds. - -`candidates': The second argument is the prefix to be completed. The -return value should be a list of candidates that match the prefix. - -Non-prefix matches are also supported (candidates that don't start with the -prefix, but match it in some backend-defined way). Backends that use this -feature must disable cache (return t to `no-cache') and should also respond -to `match'. - -Optional commands: - -`sorted': Return t here to indicate that the candidates are sorted and will -not need to be sorted again. - -`duplicates': If non-nil, company will take care of removing duplicates -from the list. - -`no-cache': Usually company doesn't ask for candidates again as completion -progresses, unless the back-end returns t for this command. The second -argument is the latest prefix. - -`meta': The second argument is a completion candidate. Return a (short) -documentation string for it. - -`doc-buffer': The second argument is a completion candidate. Return a -buffer with documentation for it. Preferably use `company-doc-buffer', - -`location': The second argument is a completion candidate. Return the cons -of buffer and buffer location, or of file and line number where the -completion candidate was defined. - -`annotation': The second argument is a completion candidate. Return a -string to be displayed inline with the candidate in the popup. If -duplicates are removed by company, candidates with equal string values will -be kept if they have different annotations. For that to work properly, -backends should store the related information on candidates using text -properties. - -`match': The second argument is a completion candidate. Backends that -provide non-prefix completions should return the position of the end of -text in the candidate that matches `prefix'. It will be used when -rendering the popup. - -`require-match': If this returns t, the user is not allowed to enter -anything not offered as a candidate. Use with care! The default value nil -gives the user that choice with `company-require-match'. Return value -`never' overrides that option the other way around. - -`init': Called once for each buffer. The back-end can check for external -programs and files and load any required libraries. Raising an error here -will show up in message log once, and the back-end will not be used for -completion. - -`post-completion': Called after a completion candidate has been inserted -into the buffer. The second argument is the candidate. Can be used to -modify it, e.g. to expand a snippet. - -The back-end should return nil for all commands it does not support or -does not know about. It should also be callable interactively and use -`company-begin-backend' to start itself in that case. - -Grouped back-ends: - -An element of `company-backends' can also itself be a list of back-ends, -then it's considered to be a \"grouped\" back-end. - -When possible, commands taking a candidate as an argument are dispatched to -the back-end it came from. In other cases, the first non-nil value among -all the back-ends is returned. - -The latter is the case for the `prefix' command. But if the group contains -the keyword `:with', the back-ends after it are ignored for this command. - -The completions from back-ends in a group are merged (but only from those -that return the same `prefix'). - -Asynchronous back-ends: - -The return value of each command can also be a cons (:async . FETCHER) -where FETCHER is a function of one argument, CALLBACK. When the data -arrives, FETCHER must call CALLBACK and pass it the appropriate return -value, as described above. - -True asynchronous operation is only supported for command `candidates', and -only during idle completion. Other commands will block the user interface, -even if the back-end uses the asynchronous calling convention." - :type `(repeat - (choice - :tag "Back-end" - ,@(mapcar (lambda (b) `(const :tag ,(cdr b) ,(car b))) - company-safe-backends) - (symbol :tag "User defined") - (repeat :tag "Merged Back-ends" - (choice :tag "Back-end" - ,@(mapcar (lambda (b) - `(const :tag ,(cdr b) ,(car b))) - company-safe-backends) - (const :tag "With" :with) - (symbol :tag "User defined")))))) - -(put 'company-backends 'safe-local-variable 'company-safe-backends-p) - -(defcustom company-transformers nil - "Functions to change the list of candidates received from backends, -after sorting and removal of duplicates (if appropriate). -Each function gets called with the return value of the previous one." - :type '(choice - (const :tag "None" nil) - (const :tag "Sort by occurrence" (company-sort-by-occurrence)) - (const :tag "Sort by back-end importance" - (company-sort-by-backend-importance)) - (repeat :tag "User defined" (function)))) - -(defcustom company-completion-started-hook nil - "Hook run when company starts completing. -The hook is called with one argument that is non-nil if the completion was -started manually." - :type 'hook) - -(defcustom company-completion-cancelled-hook nil - "Hook run when company cancels completing. -The hook is called with one argument that is non-nil if the completion was -aborted manually." - :type 'hook) - -(defcustom company-completion-finished-hook nil - "Hook run when company successfully completes. -The hook is called with the selected candidate as an argument. - -If you indend to use it to post-process candidates from a specific -back-end, consider using the `post-completion' command instead." - :type 'hook) - -(defcustom company-minimum-prefix-length 3 - "The minimum prefix length for idle completion." - :type '(integer :tag "prefix length")) - -(defcustom company-abort-manual-when-too-short nil - "If enabled, cancel a manually started completion when the prefix gets -shorter than both `company-minimum-prefix-length' and the length of the -prefix it was started from." - :type 'boolean - :package-version '(company . "0.8.0")) - -(defcustom company-require-match 'company-explicit-action-p - "If enabled, disallow non-matching input. -This can be a function do determine if a match is required. - -This can be overridden by the back-end, if it returns t or `never' to -`require-match'. `company-auto-complete' also takes precedence over this." - :type '(choice (const :tag "Off" nil) - (function :tag "Predicate function") - (const :tag "On, if user interaction took place" - 'company-explicit-action-p) - (const :tag "On" t))) - -(defcustom company-auto-complete nil - "Determines when to auto-complete. -If this is enabled, all characters from `company-auto-complete-chars' -trigger insertion of the selected completion candidate. -This can also be a function." - :type '(choice (const :tag "Off" nil) - (function :tag "Predicate function") - (const :tag "On, if user interaction took place" - 'company-explicit-action-p) - (const :tag "On" t))) - -(defcustom company-auto-complete-chars '(?\ ?\) ?.) - "Determines which characters trigger auto-completion. -See `company-auto-complete'. If this is a string, each string character -tiggers auto-completion. If it is a list of syntax description characters (see -`modify-syntax-entry'), all characters with that syntax auto-complete. - -This can also be a function, which is called with the new input and should -return non-nil if company should auto-complete. - -A character that is part of a valid candidate never triggers auto-completion." - :type '(choice (string :tag "Characters") - (set :tag "Syntax" - (const :tag "Whitespace" ?\ ) - (const :tag "Symbol" ?_) - (const :tag "Opening parentheses" ?\() - (const :tag "Closing parentheses" ?\)) - (const :tag "Word constituent" ?w) - (const :tag "Punctuation." ?.) - (const :tag "String quote." ?\") - (const :tag "Paired delimiter." ?$) - (const :tag "Expression quote or prefix operator." ?\') - (const :tag "Comment starter." ?<) - (const :tag "Comment ender." ?>) - (const :tag "Character-quote." ?/) - (const :tag "Generic string fence." ?|) - (const :tag "Generic comment fence." ?!)) - (function :tag "Predicate function"))) - -(defcustom company-idle-delay .5 - "The idle delay in seconds until completion starts automatically. -The prefix still has to satisfy `company-minimum-prefix-length' before that -happens. The value of nil means no idle completion." - :type '(choice (const :tag "never (nil)" nil) - (const :tag "immediate (0)" 0) - (number :tag "seconds"))) - -(defcustom company-begin-commands '(self-insert-command - org-self-insert-command - orgtbl-self-insert-command - c-scope-operator - c-electric-colon - c-electric-lt-gt - c-electric-slash) - "A list of commands after which idle completion is allowed. -If this is t, it can show completions after any command except a few from a -pre-defined list. See `company-idle-delay'. - -Alternatively, any command with a non-nil `company-begin' property is -treated as if it was on this list." - :type '(choice (const :tag "Any command" t) - (const :tag "Self insert command" '(self-insert-command)) - (repeat :tag "Commands" function)) - :package-version '(company . "0.8.4")) - -(defcustom company-continue-commands '(not save-buffer save-some-buffers - save-buffers-kill-terminal - save-buffers-kill-emacs) - "A list of commands that are allowed during completion. -If this is t, or if `company-begin-commands' is t, any command is allowed. -Otherwise, the value must be a list of symbols. If it starts with `not', -the cdr is the list of commands that abort completion. Otherwise, all -commands except those in that list, or in `company-begin-commands', or -commands in the `company-' namespace, abort completion." - :type '(choice (const :tag "Any command" t) - (cons :tag "Any except" - (const not) - (repeat :tag "Commands" function)) - (repeat :tag "Commands" function))) - -(defcustom company-show-numbers nil - "If enabled, show quick-access numbers for the first ten candidates." - :type '(choice (const :tag "off" nil) - (const :tag "on" t))) - -(defcustom company-selection-wrap-around nil - "If enabled, selecting item before first or after last wraps around." - :type '(choice (const :tag "off" nil) - (const :tag "on" t))) - -(defvar company-async-wait 0.03 - "Pause between checks to see if the value's been set when turning an -asynchronous call into synchronous.") - -(defvar company-async-timeout 2 - "Maximum wait time for a value to be set during asynchronous call.") - -;;; mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar company-mode-map (make-sparse-keymap) - "Keymap used by `company-mode'.") - -(defvar company-active-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap "\e\e\e" 'company-abort) - (define-key keymap "\C-g" 'company-abort) - (define-key keymap (kbd "M-n") 'company-select-next) - (define-key keymap (kbd "M-p") 'company-select-previous) - (define-key keymap (kbd "") 'company-select-next-or-abort) - (define-key keymap (kbd "") 'company-select-previous-or-abort) - (define-key keymap [down-mouse-1] 'ignore) - (define-key keymap [down-mouse-3] 'ignore) - (define-key keymap [mouse-1] 'company-complete-mouse) - (define-key keymap [mouse-3] 'company-select-mouse) - (define-key keymap [up-mouse-1] 'ignore) - (define-key keymap [up-mouse-3] 'ignore) - (define-key keymap [return] 'company-complete-selection) - (define-key keymap (kbd "RET") 'company-complete-selection) - (define-key keymap [tab] 'company-complete-common) - (define-key keymap (kbd "TAB") 'company-complete-common) - (define-key keymap (kbd "") 'company-show-doc-buffer) - (define-key keymap (kbd "C-h") 'company-show-doc-buffer) - (define-key keymap "\C-w" 'company-show-location) - (define-key keymap "\C-s" 'company-search-candidates) - (define-key keymap "\C-\M-s" 'company-filter-candidates) - (dotimes (i 10) - (define-key keymap (read-kbd-macro (format "M-%d" i)) 'company-complete-number)) - keymap) - "Keymap that is enabled during an active completion.") - -(defvar company--disabled-backends nil) - -(defun company-init-backend (backend) - (and (symbolp backend) - (not (fboundp backend)) - (ignore-errors (require backend nil t))) - (cond - ((symbolp backend) - (condition-case err - (progn - (funcall backend 'init) - (put backend 'company-init t)) - (error - (put backend 'company-init 'failed) - (unless (memq backend company--disabled-backends) - (message "Company back-end '%s' could not be initialized:\n%s" - backend (error-message-string err))) - (cl-pushnew backend company--disabled-backends) - nil))) - ;; No initialization for lambdas. - ((functionp backend) t) - (t ;; Must be a list. - (cl-dolist (b backend) - (unless (keywordp b) - (company-init-backend b)))))) - -(defvar company-default-lighter " company") - -(defvar-local company-lighter company-default-lighter) - -;;;###autoload -(define-minor-mode company-mode - "\"complete anything\"; is an in-buffer completion framework. -Completion starts automatically, depending on the values -`company-idle-delay' and `company-minimum-prefix-length'. - -Completion can be controlled with the commands: -`company-complete-common', `company-complete-selection', `company-complete', -`company-select-next', `company-select-previous'. If these commands are -called before `company-idle-delay', completion will also start. - -Completions can be searched with `company-search-candidates' or -`company-filter-candidates'. These can be used while completion is -inactive, as well. - -The completion data is retrieved using `company-backends' and displayed -using `company-frontends'. If you want to start a specific back-end, call -it interactively or use `company-begin-backend'. - -regular keymap (`company-mode-map'): - -\\{company-mode-map} -keymap during active completions (`company-active-map'): - -\\{company-active-map}" - nil company-lighter company-mode-map - (if company-mode - (progn - (when (eq company-idle-delay t) - (setq company-idle-delay 0) - (warn "Setting `company-idle-delay' to t is deprecated. Set it to 0 instead.")) - (add-hook 'pre-command-hook 'company-pre-command nil t) - (add-hook 'post-command-hook 'company-post-command nil t) - (mapc 'company-init-backend company-backends)) - (remove-hook 'pre-command-hook 'company-pre-command t) - (remove-hook 'post-command-hook 'company-post-command t) - (company-cancel) - (kill-local-variable 'company-point))) - -(defcustom company-global-modes t - "Modes for which `company-mode' mode is turned on by `global-company-mode'. -If nil, means no modes. If t, then all major modes have it turned on. -If a list, it should be a list of `major-mode' symbol names for which -`company-mode' should be automatically turned on. The sense of the list is -negated if it begins with `not'. For example: - (c-mode c++-mode) -means that `company-mode' is turned on for buffers in C and C++ modes only. - (not message-mode) -means that `company-mode' is always turned on except in `message-mode' buffers." - :type '(choice (const :tag "none" nil) - (const :tag "all" t) - (set :menu-tag "mode specific" :tag "modes" - :value (not) - (const :tag "Except" not) - (repeat :inline t (symbol :tag "mode"))))) - -;;;###autoload -(define-globalized-minor-mode global-company-mode company-mode company-mode-on) - -(defun company-mode-on () - (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s))) - (cond ((eq company-global-modes t) - t) - ((eq (car-safe company-global-modes) 'not) - (not (memq major-mode (cdr company-global-modes)))) - (t (memq major-mode company-global-modes)))) - (company-mode 1))) - -(defsubst company-assert-enabled () - (unless company-mode - (company-uninstall-map) - (error "Company not enabled"))) - -;;; keymaps ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-my-keymap nil) - -(defvar company-emulation-alist '((t . nil))) - -(defsubst company-enable-overriding-keymap (keymap) - (company-uninstall-map) - (setq company-my-keymap keymap)) - -(defun company-ensure-emulation-alist () - (unless (eq 'company-emulation-alist (car emulation-mode-map-alists)) - (setq emulation-mode-map-alists - (cons 'company-emulation-alist - (delq 'company-emulation-alist emulation-mode-map-alists))))) - -(defun company-install-map () - (unless (or (cdar company-emulation-alist) - (null company-my-keymap)) - (setf (cdar company-emulation-alist) company-my-keymap))) - -(defun company-uninstall-map () - (setf (cdar company-emulation-alist) nil)) - -;; Hack: -;; Emacs calculates the active keymaps before reading the event. That means we -;; cannot change the keymap from a timer. So we send a bogus command. -;; XXX: Even in Emacs 24.4, seems to be needed in the terminal. -(defun company-ignore () - (interactive) - (setq this-command last-command)) - -(global-set-key '[31415926] 'company-ignore) - -(defun company-input-noop () - (push 31415926 unread-command-events)) - -(defun company--posn-col-row (posn) - (let ((col (car (posn-col-row posn))) - ;; `posn-col-row' doesn't work well with lines of different height. - ;; `posn-actual-col-row' doesn't handle multiple-width characters. - (row (cdr (posn-actual-col-row posn)))) - (when (and header-line-format (version< emacs-version "24.3.93.3")) - ;; http://debbugs.gnu.org/18384 - (cl-decf row)) - (cons (+ col (window-hscroll)) row))) - -(defun company--col-row (&optional pos) - (company--posn-col-row (posn-at-point pos))) - -(defun company--row (&optional pos) - (cdr (company--col-row pos))) - -;;; backends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-backend nil) - -(defun company-grab (regexp &optional expression limit) - (when (looking-back regexp limit) - (or (match-string-no-properties (or expression 0)) ""))) - -(defun company-grab-line (regexp &optional expression) - (company-grab regexp expression (point-at-bol))) - -(defun company-grab-symbol () - (if (looking-at "\\_>") - (buffer-substring (point) (save-excursion (skip-syntax-backward "w_") - (point))) - (unless (and (char-after) (memq (char-syntax (char-after)) '(?w ?_))) - ""))) - -(defun company-grab-word () - (if (looking-at "\\>") - (buffer-substring (point) (save-excursion (skip-syntax-backward "w") - (point))) - (unless (and (char-after) (eq (char-syntax (char-after)) ?w)) - ""))) - -(defun company-grab-symbol-cons (idle-begin-after-re &optional max-len) - (let ((symbol (company-grab-symbol))) - (when symbol - (save-excursion - (forward-char (- (length symbol))) - (if (looking-back idle-begin-after-re (if max-len - (- (point) max-len) - (line-beginning-position))) - (cons symbol t) - symbol))))) - -(defun company-in-string-or-comment () - (let ((ppss (syntax-ppss))) - (or (car (setq ppss (nthcdr 3 ppss))) - (car (setq ppss (cdr ppss))) - (nth 3 ppss)))) - -(defun company-call-backend (&rest args) - (company--force-sync #'company-call-backend-raw args company-backend)) - -(defun company--force-sync (fun args backend) - (let ((value (apply fun args))) - (if (not (eq (car-safe value) :async)) - value - (let ((res 'trash) - (start (time-to-seconds))) - (funcall (cdr value) - (lambda (result) (setq res result))) - (while (eq res 'trash) - (if (> (- (time-to-seconds) start) company-async-timeout) - (error "Company: Back-end %s async timeout with args %s" - backend args) - (sleep-for company-async-wait))) - res)))) - -(defun company-call-backend-raw (&rest args) - (condition-case-unless-debug err - (if (functionp company-backend) - (apply company-backend args) - (apply #'company--multi-backend-adapter company-backend args)) - (error (error "Company: Back-end %s error \"%s\" with args %s" - company-backend (error-message-string err) args)))) - -(defun company--multi-backend-adapter (backends command &rest args) - (let ((backends (cl-loop for b in backends - when (not (and (symbolp b) - (eq 'failed (get b 'company-init)))) - collect b))) - (setq backends - (if (eq command 'prefix) - (butlast backends (length (member :with backends))) - (delq :with backends))) - (pcase command - (`candidates - (company--multi-backend-adapter-candidates backends (car args))) - (`sorted nil) - (`duplicates t) - ((or `prefix `ignore-case `no-cache `require-match) - (let (value) - (cl-dolist (backend backends) - (when (setq value (company--force-sync - backend (cons command args) backend)) - (cl-return value))))) - (_ - (let ((arg (car args))) - (when (> (length arg) 0) - (let ((backend (or (get-text-property 0 'company-backend arg) - (car backends)))) - (apply backend command args)))))))) - -(defun company--multi-backend-adapter-candidates (backends prefix) - (let ((pairs (cl-loop for backend in (cdr backends) - when (equal (company--prefix-str - (funcall backend 'prefix)) - prefix) - collect (cons (funcall backend 'candidates prefix) - (let ((b backend)) - (lambda (candidates) - (mapcar - (lambda (str) - (propertize str 'company-backend b)) - candidates))))))) - (when (equal (company--prefix-str (funcall (car backends) 'prefix)) prefix) - ;; Small perf optimization: don't tag the candidates received - ;; from the first backend in the group. - (push (cons (funcall (car backends) 'candidates prefix) - 'identity) - pairs)) - (company--merge-async pairs (lambda (values) (apply #'append values))))) - -(defun company--merge-async (pairs merger) - (let ((async (cl-loop for pair in pairs - thereis - (eq :async (car-safe (car pair)))))) - (if (not async) - (funcall merger (cl-loop for (val . mapper) in pairs - collect (funcall mapper val))) - (cons - :async - (lambda (callback) - (let* (lst pending - (finisher (lambda () - (unless pending - (funcall callback - (funcall merger - (nreverse lst))))))) - (dolist (pair pairs) - (let ((val (car pair)) - (mapper (cdr pair))) - (if (not (eq :async (car-safe val))) - (push (funcall mapper val) lst) - (push nil lst) - (let ((cell lst) - (fetcher (cdr val))) - (push fetcher pending) - (funcall fetcher - (lambda (res) - (setq pending (delq fetcher pending)) - (setcar cell (funcall mapper res)) - (funcall finisher))))))))))))) - -(defun company--prefix-str (prefix) - (or (car-safe prefix) prefix)) - -;;; completion mechanism ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-prefix nil) - -(defvar-local company-candidates nil) - -(defvar-local company-candidates-length nil) - -(defvar-local company-candidates-cache nil) - -(defvar-local company-candidates-predicate nil) - -(defvar-local company-common nil) - -(defvar-local company-selection 0) - -(defvar-local company-selection-changed nil) - -(defvar-local company--manual-action nil - "Non-nil, if manual completion took place.") - -(defvar-local company--manual-prefix nil) - -(defvar company--auto-completion nil - "Non-nil when current candidate is being inserted automatically. -Controlled by `company-auto-complete'.") - -(defvar-local company--point-max nil) - -(defvar-local company-point nil) - -(defvar company-timer nil) - -(defsubst company-strip-prefix (str) - (substring str (length company-prefix))) - -(defun company--insert-candidate (candidate) - (setq candidate (substring-no-properties candidate)) - ;; XXX: Return value we check here is subject to change. - (if (eq (company-call-backend 'ignore-case) 'keep-prefix) - (insert (company-strip-prefix candidate)) - (delete-region (- (point) (length company-prefix)) (point)) - (insert candidate))) - -(defmacro company-with-candidate-inserted (candidate &rest body) - "Evaluate BODY with CANDIDATE temporarily inserted. -This is a tool for back-ends that need candidates inserted before they -can retrieve meta-data for them." - (declare (indent 1)) - `(let ((inhibit-modification-hooks t) - (inhibit-point-motion-hooks t) - (modified-p (buffer-modified-p))) - (company--insert-candidate ,candidate) - (unwind-protect - (progn ,@body) - (delete-region company-point (point)) - (set-buffer-modified-p modified-p)))) - -(defun company-explicit-action-p () - "Return whether explicit completion action was taken by the user." - (or company--manual-action - company-selection-changed)) - -(defun company-reformat (candidate) - ;; company-ispell needs this, because the results are always lower-case - ;; It's mory efficient to fix it only when they are displayed. - ;; FIXME: Adopt the current text's capitalization instead? - (if (eq (company-call-backend 'ignore-case) 'keep-prefix) - (concat company-prefix (substring candidate (length company-prefix))) - candidate)) - -(defun company--should-complete () - (and (eq company-idle-delay 'now) - (not (or buffer-read-only overriding-terminal-local-map - overriding-local-map)) - ;; Check if in the middle of entering a key combination. - (or (equal (this-command-keys-vector) []) - (not (keymapp (key-binding (this-command-keys-vector))))) - (not (and transient-mark-mode mark-active)))) - -(defun company--should-continue () - (or (eq t company-begin-commands) - (eq t company-continue-commands) - (if (eq 'not (car company-continue-commands)) - (not (memq this-command (cdr company-continue-commands))) - (or (memq this-command company-begin-commands) - (memq this-command company-continue-commands) - (and (symbolp this-command) - (string-match-p "\\`company-" (symbol-name this-command))))))) - -(defun company-call-frontends (command) - (dolist (frontend company-frontends) - (condition-case-unless-debug err - (funcall frontend command) - (error (error "Company: Front-end %s error \"%s\" on command %s" - frontend (error-message-string err) command))))) - -(defun company-set-selection (selection &optional force-update) - (setq selection - (if company-selection-wrap-around - (mod selection company-candidates-length) - (max 0 (min (1- company-candidates-length) selection)))) - (when (or force-update (not (equal selection company-selection))) - (company--update-group-lighter (nth selection company-candidates)) - (setq company-selection selection - company-selection-changed t) - (company-call-frontends 'update))) - -(defun company--update-group-lighter (candidate) - (when (listp company-backend) - (let ((backend (or (get-text-property 0 'company-backend candidate) - (car company-backend)))) - (when (and backend (symbolp backend)) - (let ((name (replace-regexp-in-string "company-\\|-company" "" - (symbol-name backend)))) - (setq company-lighter (format " company-<%s>" name))))))) - -(defun company-apply-predicate (candidates predicate) - (let (new) - (dolist (c candidates) - (when (funcall predicate c) - (push c new))) - (nreverse new))) - -(defun company-update-candidates (candidates) - (setq company-candidates-length (length candidates)) - (if (> company-selection 0) - ;; Try to restore the selection - (let ((selected (nth company-selection company-candidates))) - (setq company-selection 0 - company-candidates candidates) - (when selected - (while (and candidates (string< (pop candidates) selected)) - (cl-incf company-selection)) - (unless candidates - ;; Make sure selection isn't out of bounds. - (setq company-selection (min (1- company-candidates-length) - company-selection))))) - (setq company-selection 0 - company-candidates candidates)) - ;; Save in cache: - (push (cons company-prefix company-candidates) company-candidates-cache) - ;; Calculate common. - (let ((completion-ignore-case (company-call-backend 'ignore-case))) - ;; We want to support non-prefix completion, so filtering is the - ;; responsibility of each respective backend, not ours. - ;; On the other hand, we don't want to replace non-prefix input in - ;; `company-complete-common'. - (setq company-common - (if (cdr company-candidates) - (let ((common (try-completion company-prefix company-candidates))) - (if (eq common t) - ;; Mulple equal strings, probably with different - ;; annotations. - company-prefix - common)) - (car company-candidates))))) - -(defun company-calculate-candidates (prefix) - (let ((candidates (cdr (assoc prefix company-candidates-cache))) - (ignore-case (company-call-backend 'ignore-case))) - (or candidates - (when company-candidates-cache - (let ((len (length prefix)) - (completion-ignore-case ignore-case) - prev) - (cl-dotimes (i (1+ len)) - (when (setq prev (cdr (assoc (substring prefix 0 (- len i)) - company-candidates-cache))) - (setq candidates (all-completions prefix prev)) - (cl-return t))))) - ;; no cache match, call back-end - (setq candidates - (company--process-candidates - (company--fetch-candidates prefix)))) - (setq candidates (company--transform-candidates candidates)) - (when candidates - (if (or (cdr candidates) - (not (eq t (compare-strings (car candidates) nil nil - prefix nil nil ignore-case)))) - candidates - ;; Already completed and unique; don't start. - t)))) - -(defun company--fetch-candidates (prefix) - (let ((c (if company--manual-action - (company-call-backend 'candidates prefix) - (company-call-backend-raw 'candidates prefix))) - res) - (if (not (eq (car c) :async)) - c - (let ((buf (current-buffer)) - (win (selected-window)) - (tick (buffer-chars-modified-tick)) - (pt (point)) - (backend company-backend)) - (funcall - (cdr c) - (lambda (candidates) - (if (not (and candidates (eq res 'done))) - ;; Fetcher called us back right away. - (setq res candidates) - (setq company-backend backend - company-candidates-cache - (list (cons prefix - (company--process-candidates - candidates)))) - (company-idle-begin buf win tick pt))))) - ;; FIXME: Relying on the fact that the callers - ;; will interpret nil as "do nothing" is shaky. - ;; A throw-catch would be one possible improvement. - (or res - (progn (setq res 'done) nil))))) - -(defun company--process-candidates (candidates) - (when company-candidates-predicate - (setq candidates - (company-apply-predicate candidates - company-candidates-predicate))) - (unless (company-call-backend 'sorted) - (setq candidates (sort candidates 'string<))) - (when (company-call-backend 'duplicates) - (company--strip-duplicates candidates)) - candidates) - -(defun company--strip-duplicates (candidates) - (let ((c2 candidates)) - (while c2 - (setcdr c2 - (let ((str (car c2)) - (anno 'unk)) - (pop c2) - (while (let ((str2 (car c2))) - (if (not (equal str str2)) - nil - (when (eq anno 'unk) - (setq anno (company-call-backend - 'annotation str))) - (equal anno - (company-call-backend - 'annotation str2)))) - (pop c2)) - c2))))) - -(defun company--transform-candidates (candidates) - (let ((c candidates)) - (dolist (tr company-transformers) - (setq c (funcall tr c))) - c)) - -(defcustom company-occurrence-weight-function - #'company-occurrence-prefer-closest-above - "Function to weigh matches in `company-sort-by-occurrence'. -It's called with three arguments: cursor position, the beginning and the -end of the match." - :type '(choice - (const :tag "First above point, then below point" - company-occurrence-prefer-closest-above) - (const :tag "Prefer closest in any direction" - company-occurrence-prefer-any-closest))) - -(defun company-occurrence-prefer-closest-above (pos match-beg match-end) - "Give priority to the matches above point, then those below point." - (if (< match-beg pos) - (- pos match-end) - (- match-beg (window-start)))) - -(defun company-occurrence-prefer-any-closest (pos _match-beg match-end) - "Give priority to the matches closest to the point." - (abs (- pos match-end))) - -(defun company-sort-by-occurrence (candidates) - "Sort CANDIDATES according to their occurrences. -Searches for each in the currently visible part of the current buffer and -prioritizes the matches according to `company-occurrence-weight-function'. -The rest of the list is appended unchanged. -Keywords and function definition names are ignored." - (let* ((w-start (window-start)) - (w-end (window-end)) - (start-point (point)) - occurs - (noccurs - (save-excursion - (cl-delete-if - (lambda (candidate) - (when (catch 'done - (goto-char w-start) - (while (search-forward candidate w-end t) - (when (and (not (eq (point) start-point)) - (save-match-data - (company--occurrence-predicate))) - (throw 'done t)))) - (push - (cons candidate - (funcall company-occurrence-weight-function - start-point - (match-beginning 0) - (match-end 0))) - occurs) - t)) - candidates)))) - (nconc - (mapcar #'car (sort occurs (lambda (e1 e2) (<= (cdr e1) (cdr e2))))) - noccurs))) - -(defun company--occurrence-predicate () - (let ((beg (match-beginning 0)) - (end (match-end 0))) - (save-excursion - (goto-char end) - (and (not (memq (get-text-property (1- (point)) 'face) - '(font-lock-function-name-face - font-lock-keyword-face))) - (let ((prefix (company--prefix-str - (company-call-backend 'prefix)))) - (and (stringp prefix) - (= (length prefix) (- end beg)))))))) - -(defun company-sort-by-backend-importance (candidates) - "Sort CANDIDATES as two priority groups. -If `company-backend' is a function, do nothing. If it's a list, move -candidates from back-ends before keyword `:with' to the front. Candidates -from the rest of the back-ends in the group, if any, will be left at the end." - (if (functionp company-backend) - candidates - (let ((low-priority (cdr (memq :with company-backend)))) - (if (null low-priority) - candidates - (sort candidates - (lambda (c1 c2) - (and - (let ((b2 (get-text-property 0 'company-backend c2))) - (and b2 (memq b2 low-priority))) - (let ((b1 (get-text-property 0 'company-backend c1))) - (or (not b1) (not (memq b1 low-priority))))))))))) - -(defun company-idle-begin (buf win tick pos) - (and (eq buf (current-buffer)) - (eq win (selected-window)) - (eq tick (buffer-chars-modified-tick)) - (eq pos (point)) - (when (company-auto-begin) - (company-input-noop) - (let ((this-command 'company-idle-begin)) - (company-post-command))))) - -(defun company-auto-begin () - (and company-mode - (not company-candidates) - (let ((company-idle-delay 'now)) - (condition-case-unless-debug err - (company--perform) - (error (message "Company: An error occurred in auto-begin") - (message "%s" (error-message-string err)) - (company-cancel)) - (quit (company-cancel))))) - (unless company-candidates - (setq company-backend nil)) - ;; Return non-nil if active. - company-candidates) - -(defun company-manual-begin () - (interactive) - (company-assert-enabled) - (setq company--manual-action t) - (unwind-protect - (let ((company-minimum-prefix-length 0)) - (company-auto-begin)) - (unless company-candidates - (setq company--manual-action nil)))) - -(defun company-other-backend (&optional backward) - (interactive (list current-prefix-arg)) - (company-assert-enabled) - (let* ((after (if company-backend - (cdr (member company-backend company-backends)) - company-backends)) - (before (cdr (member company-backend (reverse company-backends)))) - (next (if backward - (append before (reverse after)) - (append after (reverse before))))) - (company-cancel) - (cl-dolist (backend next) - (when (ignore-errors (company-begin-backend backend)) - (cl-return t)))) - (unless company-candidates - (error "No other back-end"))) - -(defun company-require-match-p () - (let ((backend-value (company-call-backend 'require-match))) - (or (eq backend-value t) - (and (not (eq backend-value 'never)) - (if (functionp company-require-match) - (funcall company-require-match) - (eq company-require-match t)))))) - -(defun company-auto-complete-p (input) - "Return non-nil, if input starts with punctuation or parentheses." - (and (if (functionp company-auto-complete) - (funcall company-auto-complete) - company-auto-complete) - (if (functionp company-auto-complete-chars) - (funcall company-auto-complete-chars input) - (if (consp company-auto-complete-chars) - (memq (char-syntax (string-to-char input)) - company-auto-complete-chars) - (string-match (substring input 0 1) company-auto-complete-chars))))) - -(defun company--incremental-p () - (and (> (point) company-point) - (> (point-max) company--point-max) - (not (eq this-command 'backward-delete-char-untabify)) - (equal (buffer-substring (- company-point (length company-prefix)) - company-point) - company-prefix))) - -(defun company--continue-failed (new-prefix) - (let ((input (buffer-substring-no-properties (point) company-point))) - (cond - ((company-auto-complete-p input) - ;; auto-complete - (save-excursion - (goto-char company-point) - (let ((company--auto-completion t)) - (company-complete-selection)) - nil)) - ((and (or (not (company-require-match-p)) - ;; Don't require match if the new prefix - ;; doesn't continue the old one, and the latter was a match. - (<= (length new-prefix) (length company-prefix))) - (member company-prefix company-candidates)) - ;; Last input was a success, - ;; but we're treating it as an abort + input anyway, - ;; like the `unique' case below. - (company-cancel 'non-unique)) - ((company-require-match-p) - ;; Wrong incremental input, but required match. - (delete-char (- (length input))) - (ding) - (message "Matching input is required") - company-candidates) - (t (company-cancel))))) - -(defun company--good-prefix-p (prefix) - (and (stringp (company--prefix-str prefix)) ;excludes 'stop - (or (eq (cdr-safe prefix) t) - (let ((len (or (cdr-safe prefix) (length prefix)))) - (if company--manual-prefix - (or (not company-abort-manual-when-too-short) - ;; Must not be less than minimum or initial length. - (>= len (min company-minimum-prefix-length - (length company--manual-prefix)))) - (>= len company-minimum-prefix-length)))))) - -(defun company--continue () - (when (company-call-backend 'no-cache company-prefix) - ;; Don't complete existing candidates, fetch new ones. - (setq company-candidates-cache nil)) - (let* ((new-prefix (company-call-backend 'prefix)) - (c (when (and (company--good-prefix-p new-prefix) - (setq new-prefix (company--prefix-str new-prefix)) - (= (- (point) (length new-prefix)) - (- company-point (length company-prefix)))) - (company-calculate-candidates new-prefix)))) - (cond - ((eq c t) - ;; t means complete/unique. - ;; Handle it like completion was aborted, to differentiate from user - ;; calling one of Company's commands to insert the candidate, - ;; not to trigger template expansion, etc. - (company-cancel 'unique)) - ((consp c) - ;; incremental match - (setq company-prefix new-prefix) - (company-update-candidates c) - c) - ((not (company--incremental-p)) - (company-cancel)) - (t (company--continue-failed new-prefix))))) - -(defun company--begin-new () - (let (prefix c) - (cl-dolist (backend (if company-backend - ;; prefer manual override - (list company-backend) - company-backends)) - (setq prefix - (if (or (symbolp backend) - (functionp backend)) - (when (or (not (symbolp backend)) - (eq t (get backend 'company-init)) - (unless (get backend 'company-init) - (company-init-backend backend))) - (funcall backend 'prefix)) - (company--multi-backend-adapter backend 'prefix))) - (when prefix - (when (company--good-prefix-p prefix) - (setq company-prefix (company--prefix-str prefix) - company-backend backend - c (company-calculate-candidates company-prefix)) - ;; t means complete/unique. We don't start, so no hooks. - (if (not (consp c)) - (when company--manual-action - (message "No completion found")) - (when company--manual-action - (setq company--manual-prefix prefix)) - (if (symbolp backend) - (setq company-lighter (concat " " (symbol-name backend))) - (company--update-group-lighter (car c))) - (company-update-candidates c) - (run-hook-with-args 'company-completion-started-hook - (company-explicit-action-p)) - (company-call-frontends 'show))) - (cl-return c))))) - -(defun company--perform () - (or (and company-candidates (company--continue)) - (and (company--should-complete) (company--begin-new))) - (when company-candidates - (setq company-point (point) - company--point-max (point-max)) - (company-ensure-emulation-alist) - (company-enable-overriding-keymap company-active-map) - (company-call-frontends 'update))) - -(defun company-cancel (&optional result) - (unwind-protect - (when company-prefix - (if (stringp result) - (progn - (company-call-backend 'pre-completion result) - (run-hook-with-args 'company-completion-finished-hook result) - (company-call-backend 'post-completion result)) - (run-hook-with-args 'company-completion-cancelled-hook result))) - (setq company-backend nil - company-prefix nil - company-candidates nil - company-candidates-length nil - company-candidates-cache nil - company-candidates-predicate nil - company-common nil - company-selection 0 - company-selection-changed nil - company--manual-action nil - company--manual-prefix nil - company-lighter company-default-lighter - company--point-max nil - company-point nil) - (when company-timer - (cancel-timer company-timer)) - (company-search-mode 0) - (company-call-frontends 'hide) - (company-enable-overriding-keymap nil)) - ;; Make return value explicit. - nil) - -(defun company-abort () - (interactive) - (company-cancel 'abort)) - -(defun company-finish (result) - (company--insert-candidate result) - (company-cancel result)) - -(defsubst company-keep (command) - (and (symbolp command) (get command 'company-keep))) - -(defun company-pre-command () - (unless (company-keep this-command) - (condition-case-unless-debug err - (when company-candidates - (company-call-frontends 'pre-command) - (unless (company--should-continue) - (company-abort))) - (error (message "Company: An error occurred in pre-command") - (message "%s" (error-message-string err)) - (company-cancel)))) - (when company-timer - (cancel-timer company-timer) - (setq company-timer nil)) - (company-uninstall-map)) - -(defun company-post-command () - (when (null this-command) - ;; Happens when the user presses `C-g' while inside - ;; `flyspell-post-command-hook', for example. - ;; Or any other `post-command-hook' function that can call `sit-for', - ;; or any quittable timer function. - (company-abort) - (setq this-command 'company-abort)) - (unless (company-keep this-command) - (condition-case-unless-debug err - (progn - (unless (equal (point) company-point) - (let (company-idle-delay) ; Against misbehavior while debugging. - (company--perform))) - (if company-candidates - (company-call-frontends 'post-command) - (and (numberp company-idle-delay) - (company--should-begin) - (setq company-timer - (run-with-timer company-idle-delay nil - 'company-idle-begin - (current-buffer) (selected-window) - (buffer-chars-modified-tick) (point)))))) - (error (message "Company: An error occurred in post-command") - (message "%s" (error-message-string err)) - (company-cancel)))) - (company-install-map)) - -(defvar company--begin-inhibit-commands '(company-abort - company-complete-mouse - company-complete - company-complete-common - company-complete-selection - company-complete-number) - "List of commands after which idle completion is (still) disabled when -`company-begin-commands' is t.") - -(defun company--should-begin () - (if (eq t company-begin-commands) - (not (memq this-command company--begin-inhibit-commands)) - (or - (memq this-command company-begin-commands) - (and (symbolp this-command) (get this-command 'company-begin))))) - -;;; search ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-search-string nil) - -(defvar-local company-search-lighter " Search: \"\"") - -(defvar-local company-search-old-map nil) - -(defvar-local company-search-old-selection 0) - -(defun company-search (text lines) - (let ((quoted (regexp-quote text)) - (i 0)) - (cl-dolist (line lines) - (when (string-match quoted line (length company-prefix)) - (cl-return i)) - (cl-incf i)))) - -(defun company-search-printing-char () - (interactive) - (company-search-assert-enabled) - (let* ((ss (concat company-search-string (string last-command-event))) - (pos (company-search ss (nthcdr company-selection company-candidates)))) - (if (null pos) - (ding) - (setq company-search-string ss - company-search-lighter (concat " Search: \"" ss "\"")) - (company-set-selection (+ company-selection pos) t)))) - -(defun company-search-repeat-forward () - "Repeat the incremental search in completion candidates forward." - (interactive) - (company-search-assert-enabled) - (let ((pos (company-search company-search-string - (cdr (nthcdr company-selection - company-candidates))))) - (if (null pos) - (ding) - (company-set-selection (+ company-selection pos 1) t)))) - -(defun company-search-repeat-backward () - "Repeat the incremental search in completion candidates backwards." - (interactive) - (company-search-assert-enabled) - (let ((pos (company-search company-search-string - (nthcdr (- company-candidates-length - company-selection) - (reverse company-candidates))))) - (if (null pos) - (ding) - (company-set-selection (- company-selection pos 1) t)))) - -(defun company-create-match-predicate () - (let ((ss company-search-string)) - (setq company-candidates-predicate - (when ss (lambda (candidate) (string-match ss candidate))))) - (company-update-candidates - (company-apply-predicate company-candidates company-candidates-predicate)) - ;; Invalidate cache. - (setq company-candidates-cache (cons company-prefix company-candidates))) - -(defun company-filter-printing-char () - (interactive) - (company-search-assert-enabled) - (company-search-printing-char) - (company-create-match-predicate) - (company-call-frontends 'update)) - -(defun company-search-kill-others () - "Limit the completion candidates to the ones matching the search string." - (interactive) - (company-search-assert-enabled) - (company-create-match-predicate) - (company-search-mode 0) - (company-call-frontends 'update)) - -(defun company-search-abort () - "Abort searching the completion candidates." - (interactive) - (company-search-assert-enabled) - (company-set-selection company-search-old-selection t) - (company-search-mode 0)) - -(defun company-search-other-char () - (interactive) - (company-search-assert-enabled) - (company-search-mode 0) - (company--unread-last-input)) - -(defvar company-search-map - (let ((i 0) - (keymap (make-keymap))) - (if (fboundp 'max-char) - (set-char-table-range (nth 1 keymap) (cons #x100 (max-char)) - 'company-search-printing-char) - (with-no-warnings - ;; obsolete in Emacs 23 - (let ((l (generic-character-list)) - (table (nth 1 keymap))) - (while l - (set-char-table-default table (car l) 'company-search-printing-char) - (setq l (cdr l)))))) - (define-key keymap [t] 'company-search-other-char) - (while (< i ?\s) - (define-key keymap (make-string 1 i) 'company-search-other-char) - (cl-incf i)) - (while (< i 256) - (define-key keymap (vector i) 'company-search-printing-char) - (cl-incf i)) - (let ((meta-map (make-sparse-keymap))) - (define-key keymap (char-to-string meta-prefix-char) meta-map) - (define-key keymap [escape] meta-map)) - (define-key keymap (vector meta-prefix-char t) 'company-search-other-char) - (define-key keymap "\e\e\e" 'company-search-other-char) - (define-key keymap [escape escape escape] 'company-search-other-char) - (define-key keymap (kbd "DEL") 'company-search-other-char) - - (define-key keymap "\C-g" 'company-search-abort) - (define-key keymap "\C-s" 'company-search-repeat-forward) - (define-key keymap "\C-r" 'company-search-repeat-backward) - (define-key keymap "\C-o" 'company-search-kill-others) - keymap) - "Keymap used for incrementally searching the completion candidates.") - -(define-minor-mode company-search-mode - "Search mode for completion candidates. -Don't start this directly, use `company-search-candidates' or -`company-filter-candidates'." - nil company-search-lighter nil - (if company-search-mode - (if (company-manual-begin) - (progn - (setq company-search-old-selection company-selection) - (company-call-frontends 'update)) - (setq company-search-mode nil)) - (kill-local-variable 'company-search-string) - (kill-local-variable 'company-search-lighter) - (kill-local-variable 'company-search-old-selection) - (company-enable-overriding-keymap company-active-map))) - -(defun company-search-assert-enabled () - (company-assert-enabled) - (unless company-search-mode - (company-uninstall-map) - (error "Company not in search mode"))) - -(defun company-search-candidates () - "Start searching the completion candidates incrementally. - -\\Search can be controlled with the commands: -- `company-search-repeat-forward' (\\[company-search-repeat-forward]) -- `company-search-repeat-backward' (\\[company-search-repeat-backward]) -- `company-search-abort' (\\[company-search-abort]) - -Regular characters are appended to the search string. - -The command `company-search-kill-others' (\\[company-search-kill-others]) -uses the search string to limit the completion candidates." - (interactive) - (company-search-mode 1) - (company-enable-overriding-keymap company-search-map)) - -(defvar company-filter-map - (let ((keymap (make-keymap))) - (define-key keymap [remap company-search-printing-char] - 'company-filter-printing-char) - (set-keymap-parent keymap company-search-map) - keymap) - "Keymap used for incrementally searching the completion candidates.") - -(defun company-filter-candidates () - "Start filtering the completion candidates incrementally. -This works the same way as `company-search-candidates' immediately -followed by `company-search-kill-others' after each input." - (interactive) - (company-search-mode 1) - (company-enable-overriding-keymap company-filter-map)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun company-select-next () - "Select the next candidate in the list." - (interactive) - (when (company-manual-begin) - (company-set-selection (1+ company-selection)))) - -(defun company-select-previous () - "Select the previous candidate in the list." - (interactive) - (when (company-manual-begin) - (company-set-selection (1- company-selection)))) - -(defun company-select-next-or-abort () - "Select the next candidate if more than one, else abort -and invoke the normal binding." - (interactive) - (if (> company-candidates-length 1) - (company-select-next) - (company-abort) - (company--unread-last-input))) - -(defun company-select-previous-or-abort () - "Select the previous candidate if more than one, else abort -and invoke the normal binding." - (interactive) - (if (> company-candidates-length 1) - (company-select-previous) - (company-abort) - (company--unread-last-input))) - -(defvar company-pseudo-tooltip-overlay) - -(defvar company-tooltip-offset) - -(defun company--inside-tooltip-p (event-col-row row height) - (let* ((ovl company-pseudo-tooltip-overlay) - (column (overlay-get ovl 'company-column)) - (width (overlay-get ovl 'company-width)) - (evt-col (car event-col-row)) - (evt-row (cdr event-col-row))) - (and (>= evt-col column) - (< evt-col (+ column width)) - (if (> height 0) - (and (> evt-row row) - (<= evt-row (+ row height) )) - (and (< evt-row row) - (>= evt-row (+ row height))))))) - -(defun company--event-col-row (event) - (company--posn-col-row (event-start event))) - -(defun company-select-mouse (event) - "Select the candidate picked by the mouse." - (interactive "e") - (let ((event-col-row (company--event-col-row event)) - (ovl-row (company--row)) - (ovl-height (and company-pseudo-tooltip-overlay - (min (overlay-get company-pseudo-tooltip-overlay - 'company-height) - company-candidates-length)))) - (if (and ovl-height - (company--inside-tooltip-p event-col-row ovl-row ovl-height)) - (progn - (company-set-selection (+ (cdr event-col-row) - (1- company-tooltip-offset) - (if (and (eq company-tooltip-offset-display 'lines) - (not (zerop company-tooltip-offset))) - -1 0) - (- ovl-row) - (if (< ovl-height 0) - (- 1 ovl-height) - 0))) - t) - (company-abort) - (company--unread-last-input) - nil))) - -(defun company-complete-mouse (event) - "Insert the candidate picked by the mouse." - (interactive "e") - (when (company-select-mouse event) - (company-complete-selection))) - -(defun company-complete-selection () - "Insert the selected candidate." - (interactive) - (when (company-manual-begin) - (let ((result (nth company-selection company-candidates))) - (company-finish result)))) - -(defun company-complete-common () - "Insert the common part of all candidates." - (interactive) - (when (company-manual-begin) - (if (and (not (cdr company-candidates)) - (equal company-common (car company-candidates))) - (company-complete-selection) - (when company-common - (company--insert-candidate company-common))))) - -(defun company-complete () - "Insert the common part of all candidates or the current selection. -The first time this is called, the common part is inserted, the second -time, or when the selection has been changed, the selected candidate is -inserted." - (interactive) - (when (company-manual-begin) - (if (or company-selection-changed - (eq last-command 'company-complete-common)) - (call-interactively 'company-complete-selection) - (call-interactively 'company-complete-common) - (setq this-command 'company-complete-common)))) - -(defun company-complete-number (n) - "Insert the Nth candidate. -To show the number next to the candidates in some back-ends, enable -`company-show-numbers'. When called interactively, uses the last typed -character, stripping the modifiers. That character must be a digit." - (interactive - (list (let ((n (- (event-basic-type last-command-event) ?0))) - (if (zerop n) 10 n)))) - (when (company-manual-begin) - (and (or (< n 1) (> n company-candidates-length)) - (error "No candidate number %d" n)) - (cl-decf n) - (company-finish (nth n company-candidates)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defconst company-space-strings-limit 100) - -(defconst company-space-strings - (let (lst) - (dotimes (i company-space-strings-limit) - (push (make-string (- company-space-strings-limit 1 i) ?\ ) lst)) - (apply 'vector lst))) - -(defun company-space-string (len) - (if (< len company-space-strings-limit) - (aref company-space-strings len) - (make-string len ?\ ))) - -(defun company-safe-substring (str from &optional to) - (if (> from (string-width str)) - "" - (with-temp-buffer - (insert str) - (move-to-column from) - (let ((beg (point))) - (if to - (progn - (move-to-column to) - (concat (buffer-substring beg (point)) - (let ((padding (- to (current-column)))) - (when (> padding 0) - (company-space-string padding))))) - (buffer-substring beg (point-max))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-last-metadata nil) - -(defun company-fetch-metadata () - (let ((selected (nth company-selection company-candidates))) - (unless (eq selected (car company-last-metadata)) - (setq company-last-metadata - (cons selected (company-call-backend 'meta selected)))) - (cdr company-last-metadata))) - -(defun company-doc-buffer (&optional string) - (with-current-buffer (get-buffer-create "*company-documentation*") - (erase-buffer) - (when string - (save-excursion - (insert string))) - (current-buffer))) - -(defvar company--electric-commands - '(scroll-other-window scroll-other-window-down) - "List of Commands that won't break out of electric commands.") - -(defmacro company--electric-do (&rest body) - (declare (indent 0) (debug t)) - `(when (company-manual-begin) - (save-window-excursion - (let ((height (window-height)) - (row (company--row)) - cmd) - ,@body - (and (< (window-height) height) - (< (- (window-height) row 2) company-tooltip-limit) - (recenter (- (window-height) row 2))) - (while (memq (setq cmd (key-binding (vector (list (read-event))))) - company--electric-commands) - (call-interactively cmd)) - (company--unread-last-input))))) - -(defun company--unread-last-input () - (when last-input-event - (clear-this-command-keys t) - (setq unread-command-events (list last-input-event)))) - -(defun company-show-doc-buffer () - "Temporarily show the documentation buffer for the selection." - (interactive) - (company--electric-do - (let* ((selected (nth company-selection company-candidates)) - (doc-buffer (or (company-call-backend 'doc-buffer selected) - (error "No documentation available")))) - (with-current-buffer doc-buffer - (goto-char (point-min))) - (display-buffer doc-buffer t)))) -(put 'company-show-doc-buffer 'company-keep t) - -(defun company-show-location () - "Temporarily display a buffer showing the selected candidate in context." - (interactive) - (company--electric-do - (let* ((selected (nth company-selection company-candidates)) - (location (company-call-backend 'location selected)) - (pos (or (cdr location) (error "No location available"))) - (buffer (or (and (bufferp (car location)) (car location)) - (find-file-noselect (car location) t)))) - (with-selected-window (display-buffer buffer t) - (save-restriction - (widen) - (if (bufferp (car location)) - (goto-char pos) - (goto-char (point-min)) - (forward-line (1- pos)))) - (set-window-start nil (point)))))) -(put 'company-show-location 'company-keep t) - -;;; package functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-callback nil) - -(defun company-remove-callback (&optional ignored) - (remove-hook 'company-completion-finished-hook company-callback t) - (remove-hook 'company-completion-cancelled-hook 'company-remove-callback t) - (remove-hook 'company-completion-finished-hook 'company-remove-callback t)) - -(defun company-begin-backend (backend &optional callback) - "Start a completion at point using BACKEND." - (interactive (let ((val (completing-read "Company back-end: " - obarray - 'functionp nil "company-"))) - (when val - (list (intern val))))) - (when (setq company-callback callback) - (add-hook 'company-completion-finished-hook company-callback nil t)) - (add-hook 'company-completion-cancelled-hook 'company-remove-callback nil t) - (add-hook 'company-completion-finished-hook 'company-remove-callback nil t) - (setq company-backend backend) - ;; Return non-nil if active. - (or (company-manual-begin) - (error "Cannot complete at point"))) - -(defun company-begin-with (candidates - &optional prefix-length require-match callback) - "Start a completion at point. -CANDIDATES is the list of candidates to use and PREFIX-LENGTH is the length -of the prefix that already is in the buffer before point. -It defaults to 0. - -CALLBACK is a function called with the selected result if the user -successfully completes the input. - -Example: \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)" - (let ((begin-marker (copy-marker (point) t))) - (company-begin-backend - (lambda (command &optional arg &rest ignored) - (pcase command - (`prefix - (when (equal (point) (marker-position begin-marker)) - (buffer-substring (- (point) (or prefix-length 0)) (point)))) - (`candidates - (all-completions arg candidates)) - (`require-match - require-match))) - callback))) - -(defun company-version (&optional show-version) - "Get the Company version as string. - -If SHOW-VERSION is non-nil, show the version in the echo area." - (interactive (list t)) - (with-temp-buffer - (insert-file-contents (find-library-name "company")) - (require 'lisp-mnt) - (if show-version - (message "Company version: %s" (lm-version)) - (lm-version)))) - -;;; pseudo-tooltip ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-pseudo-tooltip-overlay nil) - -(defvar-local company-tooltip-offset 0) - -(defun company-tooltip--lines-update-offset (selection num-lines limit) - (cl-decf limit 2) - (setq company-tooltip-offset - (max (min selection company-tooltip-offset) - (- selection -1 limit))) - - (when (<= company-tooltip-offset 1) - (cl-incf limit) - (setq company-tooltip-offset 0)) - - (when (>= company-tooltip-offset (- num-lines limit 1)) - (cl-incf limit) - (when (= selection (1- num-lines)) - (cl-decf company-tooltip-offset) - (when (<= company-tooltip-offset 1) - (setq company-tooltip-offset 0) - (cl-incf limit)))) - - limit) - -(defun company-tooltip--simple-update-offset (selection _num-lines limit) - (setq company-tooltip-offset - (if (< selection company-tooltip-offset) - selection - (max company-tooltip-offset - (- selection limit -1))))) - -;;; propertize - -(defsubst company-round-tab (arg) - (* (/ (+ arg tab-width) tab-width) tab-width)) - -(defun company-plainify (str) - (let ((prefix (get-text-property 0 'line-prefix str))) - (when prefix ; Keep the original value unmodified, for no special reason. - (setq str (concat prefix str)) - (remove-text-properties 0 (length str) '(line-prefix) str))) - (let* ((pieces (split-string str "\t")) - (copy pieces)) - (while (cdr copy) - (setcar copy (company-safe-substring - (car copy) 0 (company-round-tab (string-width (car copy))))) - (pop copy)) - (apply 'concat pieces))) - -(defun company-fill-propertize (value annotation width selected left right) - (let* ((margin (length left)) - (common (or (company-call-backend 'match value) - (if company-common - (string-width company-common) - 0))) - (ann-ralign company-tooltip-align-annotations) - (value (company--clean-string value)) - (ann-truncate (< width - (+ (length value) (length annotation) - (if ann-ralign 1 0)))) - (ann-start (+ margin - (if ann-ralign - (if ann-truncate - (1+ (length value)) - (- width (length annotation))) - (length value)))) - (ann-end (min (+ ann-start (length annotation)) (+ margin width))) - (line (concat left - (if (or ann-truncate (not ann-ralign)) - (company-safe-substring - (concat value - (when (and annotation ann-ralign) " ") - annotation) - 0 width) - (concat - (company-safe-substring value 0 - (- width (length annotation))) - annotation)) - right))) - (setq common (+ (min common width) margin)) - (setq width (+ width margin (length right))) - - (add-text-properties 0 width '(face company-tooltip - mouse-face company-tooltip-mouse) - line) - (add-text-properties margin common - '(face company-tooltip-common - mouse-face company-tooltip-mouse) - line) - (when (< ann-start ann-end) - (add-text-properties ann-start ann-end - '(face company-tooltip-annotation - mouse-face company-tooltip-mouse) - line)) - (when selected - (if (and company-search-string - (string-match (regexp-quote company-search-string) value - (length company-prefix))) - (let ((beg (+ margin (match-beginning 0))) - (end (+ margin (match-end 0)))) - (add-text-properties beg end '(face company-tooltip-search) - line) - (when (< beg common) - (add-text-properties beg common - '(face company-tooltip-common-selection) - line))) - (add-text-properties 0 width '(face company-tooltip-selection - mouse-face company-tooltip-selection) - line) - (add-text-properties margin common - '(face company-tooltip-common-selection - mouse-face company-tooltip-selection) - line))) - line)) - -(defun company--clean-string (str) - (replace-regexp-in-string - "\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]" - (lambda (match) - (cond - ((match-beginning 1) - ;; FIXME: Better char for 'non-printable'? - ;; We shouldn't get any of these, but sometimes we might. - "\u2017") - ((match-beginning 2) - ;; Zero-width non-breakable space. - "") - ((> (string-width match) 1) - (concat - (make-string (1- (string-width match)) ?\ufeff) - match)) - (t match))) - str)) - -;;; replace - -(defun company-buffer-lines (beg end) - (goto-char beg) - (let (lines lines-moved) - (while (and (> (setq lines-moved (vertical-motion 1)) 0) - (<= (point) end)) - (let ((bound (min end (1- (point))))) - ;; A visual line can contain several physical lines (e.g. with outline's - ;; folding overlay). Take only the first one. - (push (buffer-substring beg - (save-excursion - (goto-char beg) - (re-search-forward "$" bound 'move) - (point))) - lines)) - ;; One physical line can be displayed as several visual ones as well: - ;; add empty strings to the list, to even the count. - (dotimes (_ (1- lines-moved)) - (push "" lines)) - (setq beg (point))) - (unless (eq beg end) - (push (buffer-substring beg end) lines)) - (nreverse lines))) - -(defun company-modify-line (old new offset) - (concat (company-safe-substring old 0 offset) - new - (company-safe-substring old (+ offset (length new))))) - -(defsubst company--length-limit (lst limit) - (if (nthcdr limit lst) - limit - (length lst))) - -(defun company--replacement-string (lines old column nl &optional align-top) - (cl-decf column company-tooltip-margin) - - (when (and align-top company-tooltip-flip-when-above) - (setq lines (reverse lines))) - - (let ((width (length (car lines))) - (remaining-cols (- (+ (company--window-width) (window-hscroll)) - column))) - (when (> width remaining-cols) - (cl-decf column (- width remaining-cols)))) - - (let ((offset (and (< column 0) (- column))) - new) - (when offset - (setq column 0)) - (when align-top - ;; untouched lines first - (dotimes (_ (- (length old) (length lines))) - (push (pop old) new))) - ;; length into old lines. - (while old - (push (company-modify-line (pop old) - (company--offset-line (pop lines) offset) - column) new)) - ;; Append whole new lines. - (while lines - (push (concat (company-space-string column) - (company--offset-line (pop lines) offset)) - new)) - - (let ((str (concat (when nl " ") - "\n" - (mapconcat 'identity (nreverse new) "\n") - "\n"))) - (font-lock-append-text-property 0 (length str) 'face 'default str) - (when nl (put-text-property 0 1 'cursor t str)) - str))) - -(defun company--offset-line (line offset) - (if (and offset line) - (substring line offset) - line)) - -(defun company--create-lines (selection limit) - (let ((len company-candidates-length) - (numbered 99999) - (window-width (company--window-width)) - lines - width - lines-copy - items - previous - remainder - scrollbar-bounds) - - ;; Maybe clear old offset. - (when (< len (+ company-tooltip-offset limit)) - (setq company-tooltip-offset 0)) - - ;; Scroll to offset. - (if (eq company-tooltip-offset-display 'lines) - (setq limit (company-tooltip--lines-update-offset selection len limit)) - (company-tooltip--simple-update-offset selection len limit)) - - (cond - ((eq company-tooltip-offset-display 'scrollbar) - (setq scrollbar-bounds (company--scrollbar-bounds company-tooltip-offset - limit len))) - ((eq company-tooltip-offset-display 'lines) - (when (> company-tooltip-offset 0) - (setq previous (format "...(%d)" company-tooltip-offset))) - (setq remainder (- len limit company-tooltip-offset) - remainder (when (> remainder 0) - (setq remainder (format "...(%d)" remainder)))))) - - (cl-decf selection company-tooltip-offset) - (setq width (max (length previous) (length remainder)) - lines (nthcdr company-tooltip-offset company-candidates) - len (min limit len) - lines-copy lines) - - (cl-decf window-width (* 2 company-tooltip-margin)) - (when scrollbar-bounds (cl-decf window-width)) - - (dotimes (_ len) - (let* ((value (pop lines-copy)) - (annotation (company-call-backend 'annotation value))) - (when (and annotation company-tooltip-align-annotations) - ;; `lisp-completion-at-point' adds a space. - (setq annotation (comment-string-strip annotation t nil))) - (push (cons value annotation) items) - (setq width (max (+ (string-width value) - (if (and annotation company-tooltip-align-annotations) - (1+ (length annotation)) - (length annotation))) - width)))) - - (setq width (min window-width - (max company-tooltip-minimum-width - (if (and company-show-numbers - (< company-tooltip-offset 10)) - (+ 2 width) - width)))) - - ;; number can make tooltip too long - (when company-show-numbers - (setq numbered company-tooltip-offset)) - - (let ((items (nreverse items)) new) - (when previous - (push (company--scrollpos-line previous width) new)) - - (dotimes (i len) - (let* ((item (pop items)) - (str (company-reformat (car item))) - (annotation (cdr item)) - (right (company-space-string company-tooltip-margin)) - (width width)) - (when (< numbered 10) - (cl-decf width 2) - (cl-incf numbered) - (setq right (concat (format " %d" (mod numbered 10)) right))) - (push (concat - (company-fill-propertize str annotation - width (equal i selection) - (company-space-string - company-tooltip-margin) - right) - (when scrollbar-bounds - (company--scrollbar i scrollbar-bounds))) - new))) - - (when remainder - (push (company--scrollpos-line remainder width) new)) - - (nreverse new)))) - -(defun company--scrollbar-bounds (offset limit length) - (when (> length limit) - (let* ((size (ceiling (* limit (float limit)) length)) - (lower (floor (* limit (float offset)) length)) - (upper (+ lower size -1))) - (cons lower upper)))) - -(defun company--scrollbar (i bounds) - (propertize " " 'face - (if (and (>= i (car bounds)) (<= i (cdr bounds))) - 'company-scrollbar-fg - 'company-scrollbar-bg))) - -(defun company--scrollpos-line (text width) - (propertize (concat (company-space-string company-tooltip-margin) - (company-safe-substring text 0 width) - (company-space-string company-tooltip-margin)) - 'face 'company-tooltip)) - -;; show - -(defsubst company--window-height () - (if (fboundp 'window-screen-lines) - (floor (window-screen-lines)) - (window-body-height))) - -(defsubst company--window-width () - (let ((ww (window-body-width))) - ;; Account for the line continuation column. - (when (zerop (cadr (window-fringes))) - (cl-decf ww)) - (unless (or (display-graphic-p) - (version< "24.3.1" emacs-version)) - ;; Emacs 24.3 and earlier included margins - ;; in window-width when in TTY. - (cl-decf ww - (let ((margins (window-margins))) - (+ (or (car margins) 0) - (or (cdr margins) 0))))) - ww)) - -(defun company--pseudo-tooltip-height () - "Calculate the appropriate tooltip height. -Returns a negative number if the tooltip should be displayed above point." - (let* ((lines (company--row)) - (below (- (company--window-height) 1 lines))) - (if (and (< below (min company-tooltip-minimum company-candidates-length)) - (> lines below)) - (- (max 3 (min company-tooltip-limit lines))) - (max 3 (min company-tooltip-limit below))))) - -(defun company-pseudo-tooltip-show (row column selection) - (company-pseudo-tooltip-hide) - (save-excursion - - (let* ((height (company--pseudo-tooltip-height)) - above) - - (when (< height 0) - (setq row (+ row height -1) - above t)) - - (let* ((nl (< (move-to-window-line row) row)) - (beg (point)) - (end (save-excursion - (move-to-window-line (+ row (abs height))) - (point))) - (ov (make-overlay (if nl beg (1- beg)) end nil t t)) - (args (list (mapcar 'company-plainify - (company-buffer-lines beg end)) - column nl above))) - - (setq company-pseudo-tooltip-overlay ov) - (overlay-put ov 'company-replacement-args args) - - (let ((lines (company--create-lines selection (abs height)))) - (overlay-put ov 'company-display - (apply 'company--replacement-string lines args)) - (overlay-put ov 'company-width (string-width (car lines)))) - - (overlay-put ov 'company-column column) - (overlay-put ov 'company-height height))))) - -(defun company-pseudo-tooltip-show-at-point (pos column-offset) - (let* ((col-row (company--col-row pos)) - (col (- (car col-row) column-offset))) - (when (< col 0) (setq col 0)) - (company-pseudo-tooltip-show (1+ (cdr col-row)) col company-selection))) - -(defun company-pseudo-tooltip-edit (selection) - (let* ((height (overlay-get company-pseudo-tooltip-overlay 'company-height)) - (lines (company--create-lines selection (abs height)))) - (overlay-put company-pseudo-tooltip-overlay 'company-width - (string-width (car lines))) - (overlay-put company-pseudo-tooltip-overlay 'company-display - (apply 'company--replacement-string - lines - (overlay-get company-pseudo-tooltip-overlay - 'company-replacement-args))))) - -(defun company-pseudo-tooltip-hide () - (when company-pseudo-tooltip-overlay - (delete-overlay company-pseudo-tooltip-overlay) - (setq company-pseudo-tooltip-overlay nil))) - -(defun company-pseudo-tooltip-hide-temporarily () - (when (overlayp company-pseudo-tooltip-overlay) - (overlay-put company-pseudo-tooltip-overlay 'invisible nil) - (overlay-put company-pseudo-tooltip-overlay 'after-string nil))) - -(defun company-pseudo-tooltip-unhide () - (when company-pseudo-tooltip-overlay - (let* ((ov company-pseudo-tooltip-overlay) - (disp (overlay-get ov 'company-display))) - ;; Beat outline's folding overlays, at least. - (overlay-put ov 'priority 1) - ;; `display' could be better (http://debbugs.gnu.org/18285), but it - ;; doesn't work when the overlay is empty, which is what happens at eob. - ;; It also seems to interact badly with `cursor'. - ;; We deal with priorities by having the overlay start before the newline. - (overlay-put ov 'after-string disp) - (overlay-put ov 'invisible t) - (overlay-put ov 'window (selected-window))))) - -(defun company-pseudo-tooltip-guard () - (cons - (save-excursion (beginning-of-visual-line)) - (let ((ov company-pseudo-tooltip-overlay) - (overhang (save-excursion (end-of-visual-line) - (- (line-end-position) (point))))) - (when (>= (overlay-get ov 'company-height) 0) - (cons - (buffer-substring-no-properties (point) (overlay-start ov)) - (when (>= overhang 0) overhang)))))) - -(defun company-pseudo-tooltip-frontend (command) - "`company-mode' front-end similar to a tooltip but based on overlays." - (cl-case command - (pre-command (company-pseudo-tooltip-hide-temporarily)) - (post-command - (unless (when (overlayp company-pseudo-tooltip-overlay) - (let* ((ov company-pseudo-tooltip-overlay) - (old-height (overlay-get ov 'company-height)) - (new-height (company--pseudo-tooltip-height))) - (and - (>= (* old-height new-height) 0) - (>= (abs old-height) (abs new-height)) - (equal (company-pseudo-tooltip-guard) - (overlay-get ov 'company-guard))))) - ;; Redraw needed. - (company-pseudo-tooltip-show-at-point (point) (length company-prefix)) - (overlay-put company-pseudo-tooltip-overlay - 'company-guard (company-pseudo-tooltip-guard))) - (company-pseudo-tooltip-unhide)) - (hide (company-pseudo-tooltip-hide) - (setq company-tooltip-offset 0)) - (update (when (overlayp company-pseudo-tooltip-overlay) - (company-pseudo-tooltip-edit company-selection))))) - -(defun company-pseudo-tooltip-unless-just-one-frontend (command) - "`company-pseudo-tooltip-frontend', but not shown for single candidates." - (unless (and (eq command 'post-command) - (company--show-inline-p)) - (company-pseudo-tooltip-frontend command))) - -;;; overlay ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-preview-overlay nil) - -(defun company-preview-show-at-point (pos) - (company-preview-hide) - - (setq company-preview-overlay (make-overlay pos pos)) - - (let ((completion (nth company-selection company-candidates))) - (setq completion (propertize completion 'face 'company-preview)) - (add-text-properties 0 (length company-common) - '(face company-preview-common) completion) - - ;; Add search string - (and company-search-string - (string-match (regexp-quote company-search-string) completion) - (add-text-properties (match-beginning 0) - (match-end 0) - '(face company-preview-search) - completion)) - - (setq completion (company-strip-prefix completion)) - - (and (equal pos (point)) - (not (equal completion "")) - (add-text-properties 0 1 '(cursor t) completion)) - - (let ((ov company-preview-overlay)) - (overlay-put ov 'after-string completion) - (overlay-put ov 'window (selected-window))))) - -(defun company-preview-hide () - (when company-preview-overlay - (delete-overlay company-preview-overlay) - (setq company-preview-overlay nil))) - -(defun company-preview-frontend (command) - "`company-mode' front-end showing the selection as if it had been inserted." - (pcase command - (`pre-command (company-preview-hide)) - (`post-command (company-preview-show-at-point (point))) - (`hide (company-preview-hide)))) - -(defun company-preview-if-just-one-frontend (command) - "`company-preview-frontend', but only shown for single candidates." - (when (or (not (eq command 'post-command)) - (company--show-inline-p)) - (company-preview-frontend command))) - -(defun company--show-inline-p () - (and (not (cdr company-candidates)) - company-common - (or (eq (company-call-backend 'ignore-case) 'keep-prefix) - (string-prefix-p company-prefix company-common)))) - -;;; echo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar-local company-echo-last-msg nil) - -(defvar company-echo-timer nil) - -(defvar company-echo-delay .01) - -(defun company-echo-show (&optional getter) - (when getter - (setq company-echo-last-msg (funcall getter))) - (let ((message-log-max nil)) - (if company-echo-last-msg - (message "%s" company-echo-last-msg) - (message "")))) - -(defun company-echo-show-soon (&optional getter) - (when company-echo-timer - (cancel-timer company-echo-timer)) - (setq company-echo-timer (run-with-timer 0 nil 'company-echo-show getter))) - -(defsubst company-echo-show-when-idle (&optional getter) - (when (sit-for company-echo-delay) - (company-echo-show getter))) - -(defun company-echo-format () - - (let ((limit (window-body-width (minibuffer-window))) - (len -1) - ;; Roll to selection. - (candidates (nthcdr company-selection company-candidates)) - (i (if company-show-numbers company-selection 99999)) - comp msg) - - (while candidates - (setq comp (company-reformat (pop candidates)) - len (+ len 1 (length comp))) - (if (< i 10) - ;; Add number. - (progn - (setq comp (propertize (format "%d: %s" i comp) - 'face 'company-echo)) - (cl-incf len 3) - (cl-incf i) - (add-text-properties 3 (+ 3 (length company-common)) - '(face company-echo-common) comp)) - (setq comp (propertize comp 'face 'company-echo)) - (add-text-properties 0 (length company-common) - '(face company-echo-common) comp)) - (if (>= len limit) - (setq candidates nil) - (push comp msg))) - - (mapconcat 'identity (nreverse msg) " "))) - -(defun company-echo-strip-common-format () - - (let ((limit (window-body-width (minibuffer-window))) - (len (+ (length company-prefix) 2)) - ;; Roll to selection. - (candidates (nthcdr company-selection company-candidates)) - (i (if company-show-numbers company-selection 99999)) - msg comp) - - (while candidates - (setq comp (company-strip-prefix (pop candidates)) - len (+ len 2 (length comp))) - (when (< i 10) - ;; Add number. - (setq comp (format "%s (%d)" comp i)) - (cl-incf len 4) - (cl-incf i)) - (if (>= len limit) - (setq candidates nil) - (push (propertize comp 'face 'company-echo) msg))) - - (concat (propertize company-prefix 'face 'company-echo-common) "{" - (mapconcat 'identity (nreverse msg) ", ") - "}"))) - -(defun company-echo-hide () - (unless (equal company-echo-last-msg "") - (setq company-echo-last-msg "") - (company-echo-show))) - -(defun company-echo-frontend (command) - "`company-mode' front-end showing the candidates in the echo area." - (pcase command - (`post-command (company-echo-show-soon 'company-echo-format)) - (`hide (company-echo-hide)))) - -(defun company-echo-strip-common-frontend (command) - "`company-mode' front-end showing the candidates in the echo area." - (pcase command - (`post-command (company-echo-show-soon 'company-echo-strip-common-format)) - (`hide (company-echo-hide)))) - -(defun company-echo-metadata-frontend (command) - "`company-mode' front-end showing the documentation in the echo area." - (pcase command - (`post-command (company-echo-show-when-idle 'company-fetch-metadata)) - (`hide (company-echo-hide)))) - -(provide 'company) -;;; company.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-abbrev.el b/emacs.d/elpa/company-20150503.1854/company-abbrev.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-abbrev.el rename to emacs.d/elpa/company-20150503.1854/company-abbrev.el diff --git a/emacs.d/elpa/company-20150503.1854/company-autoloads.el b/emacs.d/elpa/company-20150503.1854/company-autoloads.el new file mode 100644 index 0000000..cbdab52 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-autoloads.el @@ -0,0 +1,281 @@ +;;; company-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "company" "company.el" (21837 24216 0 0)) +;;; Generated autoloads from company.el + +(autoload 'company-mode "company" "\ +\"complete anything\"; is an in-buffer completion framework. +Completion starts automatically, depending on the values +`company-idle-delay' and `company-minimum-prefix-length'. + +Completion can be controlled with the commands: +`company-complete-common', `company-complete-selection', `company-complete', +`company-select-next', `company-select-previous'. If these commands are +called before `company-idle-delay', completion will also start. + +Completions can be searched with `company-search-candidates' or +`company-filter-candidates'. These can be used while completion is +inactive, as well. + +The completion data is retrieved using `company-backends' and displayed +using `company-frontends'. If you want to start a specific back-end, call +it interactively or use `company-begin-backend'. + +regular keymap (`company-mode-map'): + +\\{company-mode-map} +keymap during active completions (`company-active-map'): + +\\{company-active-map} + +\(fn &optional ARG)" t nil) + +(defvar global-company-mode nil "\ +Non-nil if Global-Company mode is enabled. +See the command `global-company-mode' for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `global-company-mode'.") + +(custom-autoload 'global-company-mode "company" nil) + +(autoload 'global-company-mode "company" "\ +Toggle Company mode in all buffers. +With prefix ARG, enable Global-Company mode if ARG is positive; +otherwise, disable it. If called from Lisp, enable the mode if +ARG is omitted or nil. + +Company mode is enabled in all buffers where +`company-mode-on' would do it. +See `company-mode' for more information on Company mode. + +\(fn &optional ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "company-abbrev" "company-abbrev.el" (21837 +;;;;;; 24216 0 0)) +;;; Generated autoloads from company-abbrev.el + +(autoload 'company-abbrev "company-abbrev" "\ +`company-mode' completion back-end for abbrev. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-bbdb" "company-bbdb.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-bbdb.el + +(autoload 'company-bbdb "company-bbdb" "\ +`company-mode' completion back-end for BBDB. + +\(fn COMMAND &optional ARG &rest IGNORE)" t nil) + +;;;*** + +;;;### (autoloads nil "company-css" "company-css.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-css.el + +(autoload 'company-css "company-css" "\ +`company-mode' completion back-end for `css-mode'. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-dabbrev" "company-dabbrev.el" (21837 +;;;;;; 24216 0 0)) +;;; Generated autoloads from company-dabbrev.el + +(autoload 'company-dabbrev "company-dabbrev" "\ +dabbrev-like `company-mode' completion back-end. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-dabbrev-code" "company-dabbrev-code.el" +;;;;;; (21837 24216 0 0)) +;;; Generated autoloads from company-dabbrev-code.el + +(autoload 'company-dabbrev-code "company-dabbrev-code" "\ +dabbrev-like `company-mode' back-end for code. +The back-end looks for all symbols in the current buffer that aren't in +comments or strings. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-elisp" "company-elisp.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-elisp.el + +(autoload 'company-elisp "company-elisp" "\ +`company-mode' completion back-end for Emacs Lisp. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-etags" "company-etags.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-etags.el + +(autoload 'company-etags "company-etags" "\ +`company-mode' completion back-end for etags. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-files" "company-files.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-files.el + +(autoload 'company-files "company-files" "\ +`company-mode' completion back-end existing file names. +Completions works for proper absolute and relative files paths. +File paths with spaces are only supported inside strings. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-gtags" "company-gtags.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-gtags.el + +(autoload 'company-gtags "company-gtags" "\ +`company-mode' completion back-end for GNU Global. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-ispell" "company-ispell.el" (21837 +;;;;;; 24216 0 0)) +;;; Generated autoloads from company-ispell.el + +(autoload 'company-ispell "company-ispell" "\ +`company-mode' completion back-end using Ispell. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-keywords" "company-keywords.el" (21837 +;;;;;; 24216 0 0)) +;;; Generated autoloads from company-keywords.el + +(autoload 'company-keywords "company-keywords" "\ +`company-mode' back-end for programming language keywords. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-nxml" "company-nxml.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-nxml.el + +(autoload 'company-nxml "company-nxml" "\ +`company-mode' completion back-end for `nxml-mode'. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-oddmuse" "company-oddmuse.el" (21837 +;;;;;; 24216 0 0)) +;;; Generated autoloads from company-oddmuse.el + +(autoload 'company-oddmuse "company-oddmuse" "\ +`company-mode' completion back-end for `oddmuse-mode'. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-semantic" "company-semantic.el" (21837 +;;;;;; 24216 0 0)) +;;; Generated autoloads from company-semantic.el + +(autoload 'company-semantic "company-semantic" "\ +`company-mode' completion back-end using CEDET Semantic. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-tempo" "company-tempo.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-tempo.el + +(autoload 'company-tempo "company-tempo" "\ +`company-mode' completion back-end for tempo. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-xcode" "company-xcode.el" (21837 24216 +;;;;;; 0 0)) +;;; Generated autoloads from company-xcode.el + +(autoload 'company-xcode "company-xcode" "\ +`company-mode' completion back-end for Xcode projects. + +\(fn COMMAND &optional ARG &rest IGNORED)" t nil) + +;;;*** + +;;;### (autoloads nil "company-yasnippet" "company-yasnippet.el" +;;;;;; (21837 24216 0 0)) +;;; Generated autoloads from company-yasnippet.el + +(autoload 'company-yasnippet "company-yasnippet" "\ +`company-mode' back-end for `yasnippet'. + +This back-end should be used with care, because as long as there are +snippets defined for the current major mode, this back-end will always +shadow back-ends that come after it. Recommended usages: + +* In a buffer-local value of `company-backends', grouped with a back-end or + several that provide actual text completions. + + (add-hook 'js-mode-hook + (lambda () + (set (make-local-variable 'company-backends) + '((company-dabbrev-code company-yasnippet))))) + +* After keyword `:with', grouped with other back-ends. + + (push '(company-semantic :with company-yasnippet) company-backends) + +* Not in `company-backends', just bound to a key. + + (global-set-key (kbd \"C-c y\") 'company-yasnippet) + +\(fn COMMAND &optional ARG &rest IGNORE)" t nil) + +;;;*** + +;;;### (autoloads nil nil ("company-capf.el" "company-clang.el" "company-cmake.el" +;;;;;; "company-eclim.el" "company-pkg.el" "company-template.el") +;;;;;; (21837 24216 843840 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; company-autoloads.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-bbdb.el b/emacs.d/elpa/company-20150503.1854/company-bbdb.el new file mode 100644 index 0000000..58be84c --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-bbdb.el @@ -0,0 +1,61 @@ +;;; company-bbdb.el --- company-mode completion back-end for BBDB in message-mode + +;; Copyright (C) 2013-2014 Free Software Foundation, Inc. + +;; Author: Jan Tatarik + +;; 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 . + +(require 'company) +(require 'cl-lib) + +(declare-function bbdb-record-get-field "bbdb") +(declare-function bbdb-records "bbdb") +(declare-function bbdb-dwim-mail "bbdb-com") +(declare-function bbdb-search "bbdb-com") + +(defgroup company-bbdb nil + "Completion back-end for BBDB." + :group 'company) + +(defcustom company-bbdb-modes '(message-mode) + "Major modes in which `company-bbdb' may complete." + :type '(repeat (symbol :tag "Major mode")) + :package-version '(company . "0.8.8")) + +(defun company-bbdb--candidates (arg) + (cl-mapcan (lambda (record) + (mapcar (lambda (mail) (bbdb-dwim-mail record mail)) + (bbdb-record-get-field record 'mail))) + (eval '(bbdb-search (bbdb-records) arg nil arg)))) + +;;;###autoload +(defun company-bbdb (command &optional arg &rest ignore) + "`company-mode' completion back-end for BBDB." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-bbdb)) + (prefix (and (memq major-mode company-bbdb-modes) + (featurep 'bbdb-com) + (looking-back "^\\(To\\|Cc\\|Bcc\\): *\\(.*\\)" + (line-beginning-position)) + (match-string-no-properties 2))) + (candidates (company-bbdb--candidates arg)) + (sorted t) + (no-cache t))) + +(provide 'company-bbdb) +;;; company-bbdb.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-capf.el b/emacs.d/elpa/company-20150503.1854/company-capf.el new file mode 100644 index 0000000..17b739b --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-capf.el @@ -0,0 +1,153 @@ +;;; company-capf.el --- company-mode completion-at-point-functions back-end -*- lexical-binding: t -*- + +;; Copyright (C) 2013-2015 Free Software Foundation, Inc. + +;; Author: Stefan Monnier + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) + +(defvar company--capf-cache nil) + +(defun company--capf-data () + (let ((cache company--capf-cache)) + (if (and (equal (current-buffer) (car cache)) + (equal (point) (car (setq cache (cdr cache)))) + (equal (buffer-chars-modified-tick) (car (setq cache (cdr cache))))) + (cadr cache) + (let ((data (company--capf-data-real))) + (setq company--capf-cache + (list (current-buffer) (point) (buffer-chars-modified-tick) data)) + data)))) + +(defun company--capf-data-real () + (cl-letf* (((default-value 'completion-at-point-functions) + ;; Ignore tags-completion-at-point-function because it subverts + ;; company-etags in the default value of company-backends, where + ;; the latter comes later. + (remove 'tags-completion-at-point-function + (default-value 'completion-at-point-functions))) + (data (run-hook-wrapped 'completion-at-point-functions + ;; Ignore misbehaving functions. + #'completion--capf-wrapper 'optimist))) + (when (and (consp (cdr data)) (integer-or-marker-p (nth 1 data))) data))) + +(defun company-capf (command &optional arg &rest _args) + "`company-mode' back-end using `completion-at-point-functions'." + (interactive (list 'interactive)) + (pcase command + (`interactive (company-begin-backend 'company-capf)) + (`prefix + (let ((res (company--capf-data))) + (when res + (if (> (nth 2 res) (point)) + 'stop + (buffer-substring-no-properties (nth 1 res) (point)))))) + (`candidates + (let ((res (company--capf-data))) + (when res + (let* ((table (nth 3 res)) + (pred (plist-get (nthcdr 4 res) :predicate)) + (meta (completion-metadata + (buffer-substring (nth 1 res) (nth 2 res)) + table pred)) + (sortfun (cdr (assq 'display-sort-function meta))) + (candidates (completion-all-completions arg table pred (length arg))) + (last (last candidates)) + (base-size (and (numberp (cdr last)) (cdr last)))) + (when base-size + (setcdr last nil)) + (when sortfun + (setq candidates (funcall sortfun candidates))) + (if (not (zerop (or base-size 0))) + (let ((before (substring arg 0 base-size))) + (mapcar (lambda (candidate) + (concat before candidate)) + candidates)) + candidates))))) + (`sorted + (let ((res (company--capf-data))) + (when res + (let ((meta (completion-metadata + (buffer-substring (nth 1 res) (nth 2 res)) + (nth 3 res) (plist-get (nthcdr 4 res) :predicate)))) + (cdr (assq 'display-sort-function meta)))))) + (`match + ;; Can't just use 0 when base-size (see above) is non-zero. + (let ((start (if (get-text-property 0 'font-lock-face arg) + 0 + (next-single-property-change 0 'font-lock-face arg)))) + (when start + ;; completions-common-part comes first, but we can't just look for this + ;; value because it can be in a list. + (or + (let ((value (get-text-property start 'font-lock-face arg))) + (text-property-not-all start (length arg) + 'font-lock-face value arg)) + (length arg))))) + (`duplicates t) + (`no-cache t) ;Not much can be done here, as long as we handle + ;non-prefix matches. + (`meta + (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-docsig))) + (when f (funcall f arg)))) + (`doc-buffer + (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-doc-buffer))) + (when f (funcall f arg)))) + (`location + (let ((f (plist-get (nthcdr 4 (company--capf-data)) :company-location))) + (when f (funcall f arg)))) + (`annotation + (save-excursion + ;; FIXME: `company-begin' sets `company-point' after calling + ;; `company--begin-new'. We shouldn't rely on `company-point' here, + ;; better to cache the capf-data value instead. However: we can't just + ;; save the last capf-data value in `prefix', because that command can + ;; get called more often than `candidates', and at any point in the + ;; buffer (https://github.com/company-mode/company-mode/issues/153). + ;; We could try propertizing the returned prefix string, but it's not + ;; passed to `annotation', and `company-prefix' is set only after + ;; `company--strip-duplicates' is called. + (when company-point + (goto-char company-point)) + (let ((f (plist-get (nthcdr 4 (company--capf-data)) :annotation-function))) + (when f (funcall f arg))))) + (`require-match + (plist-get (nthcdr 4 (company--capf-data)) :company-require-match)) + (`init nil) ;Don't bother: plenty of other ways to initialize the code. + (`post-completion + (let* ((res (company--capf-data)) + (exit-function (plist-get (nthcdr 4 res) :exit-function)) + (table (nth 3 res)) + (pred (plist-get (nthcdr 4 res) :predicate))) + (if exit-function + ;; Follow the example of `completion--done'. + (funcall exit-function arg + (if (eq (try-completion arg table pred) t) + 'finished 'sole))))) + )) + +(provide 'company-capf) + +;;; company-capf.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-clang.el b/emacs.d/elpa/company-20150503.1854/company-clang.el new file mode 100644 index 0000000..d0e2b84 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-clang.el @@ -0,0 +1,331 @@ +;;; company-clang.el --- company-mode completion back-end for Clang -*- lexical-binding: t -*- + +;; Copyright (C) 2009, 2011, 2013-2015 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'company-template) +(require 'cl-lib) + +(defgroup company-clang nil + "Completion back-end for Clang." + :group 'company) + +(defcustom company-clang-executable + (executable-find "clang") + "Location of clang executable." + :type 'file) + +(defcustom company-clang-begin-after-member-access t + "When non-nil, automatic completion will start whenever the current +symbol is preceded by \".\", \"->\" or \"::\", ignoring +`company-minimum-prefix-length'. + +If `company-begin-commands' is a list, it should include `c-electric-lt-gt' +and `c-electric-colon', for automatic completion right after \">\" and +\":\".") + +(defcustom company-clang-arguments nil + "Additional arguments to pass to clang when completing. +Prefix files (-include ...) can be selected with `company-clang-set-prefix' +or automatically through a custom `company-clang-prefix-guesser'." + :type '(repeat (string :tag "Argument"))) + +(defcustom company-clang-prefix-guesser 'company-clang-guess-prefix + "A function to determine the prefix file for the current buffer." + :type '(function :tag "Guesser function" nil)) + +(defvar company-clang-modes '(c-mode c++-mode objc-mode) + "Major modes which clang may complete.") + +(defcustom company-clang-insert-arguments t + "When non-nil, insert function arguments as a template after completion." + :type 'boolean + :package-version '(company . "0.8.0")) + +;; prefix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar company-clang--prefix nil) + +(defsubst company-clang--guess-pch-file (file) + (let ((dir (directory-file-name (file-name-directory file)))) + (when (equal (file-name-nondirectory dir) "Classes") + (setq dir (file-name-directory dir))) + (car (directory-files dir t "\\([^.]h\\|[^h]\\).pch\\'" t)))) + +(defsubst company-clang--file-substring (file beg end) + (with-temp-buffer + (insert-file-contents-literally file nil beg end) + (buffer-string))) + +(defun company-clang-guess-prefix () + "Try to guess the prefix file for the current buffer." + ;; Prefixes seem to be called .pch. Pre-compiled headers do, too. + ;; So we look at the magic number to rule them out. + (let* ((file (company-clang--guess-pch-file buffer-file-name)) + (magic-number (and file (company-clang--file-substring file 0 4)))) + (unless (member magic-number '("CPCH" "gpch")) + file))) + +(defun company-clang-set-prefix (&optional prefix) + "Use PREFIX as a prefix (-include ...) file for clang completion." + (interactive (let ((def (funcall company-clang-prefix-guesser))) + (unless (stringp def) + (setq def default-directory)) + (list (read-file-name "Prefix file: " + (when def (file-name-directory def)) + def t (when def (file-name-nondirectory def)))))) + ;; TODO: pre-compile? + (setq company-clang--prefix (and (stringp prefix) + (file-regular-p prefix) + prefix))) + +;; Clean-up on exit. +(add-hook 'kill-emacs-hook 'company-clang-set-prefix) + +;; parsing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; TODO: Handle Pattern (syntactic hints would be neat). +;; Do we ever see OVERLOAD (or OVERRIDE)? +(defconst company-clang--completion-pattern + "^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:]*\\)\\(?: : \\(.*\\)$\\)?$") + +(defconst company-clang--error-buffer-name "*clang-error*") + +(defun company-clang--lang-option () + (if (eq major-mode 'objc-mode) + (if (string= "m" (file-name-extension buffer-file-name)) + "objective-c" "objective-c++") + (substring (symbol-name major-mode) 0 -5))) + +(defun company-clang--parse-output (prefix _objc) + (goto-char (point-min)) + (let ((pattern (format company-clang--completion-pattern + (regexp-quote prefix))) + (case-fold-search nil) + lines match) + (while (re-search-forward pattern nil t) + (setq match (match-string-no-properties 1)) + (unless (equal match "Pattern") + (save-match-data + (when (string-match ":" match) + (setq match (substring match 0 (match-beginning 0))))) + (let ((meta (match-string-no-properties 2))) + (when (and meta (not (string= match meta))) + (put-text-property 0 1 'meta + (company-clang--strip-formatting meta) + match))) + (push match lines))) + lines)) + +(defun company-clang--meta (candidate) + (get-text-property 0 'meta candidate)) + +(defun company-clang--annotation (candidate) + (let ((ann (company-clang--annotation-1 candidate))) + (if (not (and ann (string-prefix-p "(*)" ann))) + ann + (with-temp-buffer + (insert ann) + (search-backward ")") + (let ((pt (1+ (point)))) + (re-search-forward ".\\_>" nil t) + (delete-region pt (point))) + (buffer-string))))) + +(defun company-clang--annotation-1 (candidate) + (let ((meta (company-clang--meta candidate))) + (cond + ((null meta) nil) + ((string-match "[^:]:[^:]" meta) + (substring meta (1+ (match-beginning 0)))) + ((string-match "\\((.*)[ a-z]*\\'\\)" meta) + (let ((paren (match-beginning 1))) + (if (not (eq (aref meta (1- paren)) ?>)) + (match-string 1 meta) + (with-temp-buffer + (insert meta) + (goto-char paren) + (substring meta (1- (search-backward "<")))))))))) + +(defun company-clang--strip-formatting (text) + (replace-regexp-in-string + "#]" " " + (replace-regexp-in-string "[<{[]#\\|#[>}]" "" text t) + t)) + +(defun company-clang--handle-error (res args) + (goto-char (point-min)) + (let* ((buf (get-buffer-create company-clang--error-buffer-name)) + (cmd (concat company-clang-executable " " (mapconcat 'identity args " "))) + (pattern (format company-clang--completion-pattern "")) + (err (if (re-search-forward pattern nil t) + (buffer-substring-no-properties (point-min) + (1- (match-beginning 0))) + ;; Warn the user more aggressively if no match was found. + (message "clang failed with error %d:\n%s" res cmd) + (buffer-string)))) + + (with-current-buffer buf + (let ((inhibit-read-only t)) + (erase-buffer) + (insert (current-time-string) + (format "\nclang failed with error %d:\n" res) + cmd "\n\n") + (insert err) + (setq buffer-read-only t) + (goto-char (point-min)))))) + +(defun company-clang--start-process (prefix callback &rest args) + (let ((objc (derived-mode-p 'objc-mode)) + (buf (get-buffer-create "*clang-output*")) + ;; Looks unnecessary in Emacs 25.1 and later. + (process-adaptive-read-buffering nil)) + (with-current-buffer buf + (erase-buffer) + (setq buffer-undo-list t)) + (if (get-buffer-process buf) + (funcall callback nil) + (let ((process (apply #'start-process "company-clang" buf + company-clang-executable args))) + (set-process-sentinel + process + (lambda (proc status) + (unless (string-match-p "hangup" status) + (funcall + callback + (let ((res (process-exit-status proc))) + (with-current-buffer buf + (unless (eq 0 res) + (company-clang--handle-error res args)) + ;; Still try to get any useful input. + (company-clang--parse-output prefix objc))))))) + (unless (company-clang--auto-save-p) + (send-region process (point-min) (point-max)) + (send-string process "\n") + (process-send-eof process)))))) + +(defsubst company-clang--build-location (pos) + (save-excursion + (goto-char pos) + (format "%s:%d:%d" + (if (company-clang--auto-save-p) buffer-file-name "-") + (line-number-at-pos) + (1+ (length + (encode-coding-region + (line-beginning-position) + (point) + 'utf-8 + t)))))) + +(defsubst company-clang--build-complete-args (pos) + (append '("-fsyntax-only" "-Xclang" "-code-completion-macros") + (unless (company-clang--auto-save-p) + (list "-x" (company-clang--lang-option))) + company-clang-arguments + (when (stringp company-clang--prefix) + (list "-include" (expand-file-name company-clang--prefix))) + (list "-Xclang" (format "-code-completion-at=%s" + (company-clang--build-location pos))) + (list (if (company-clang--auto-save-p) buffer-file-name "-")))) + +(defun company-clang--candidates (prefix callback) + (and (company-clang--auto-save-p) + (buffer-modified-p) + (basic-save-buffer)) + (when (null company-clang--prefix) + (company-clang-set-prefix (or (funcall company-clang-prefix-guesser) + 'none))) + (apply 'company-clang--start-process + prefix + callback + (company-clang--build-complete-args (- (point) (length prefix))))) + +(defun company-clang--prefix () + (if company-clang-begin-after-member-access + (company-grab-symbol-cons "\\.\\|->\\|::" 2) + (company-grab-symbol))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defconst company-clang-required-version 1.1) + +(defvar company-clang--version nil) + +(defun company-clang--auto-save-p () + (< company-clang--version 2.9)) + +(defsubst company-clang-version () + "Return the version of `company-clang-executable'." + (with-temp-buffer + (call-process company-clang-executable nil t nil "--version") + (goto-char (point-min)) + (if (re-search-forward "clang\\(?: version \\|-\\)\\([0-9.]+\\)" nil t) + (let ((ver (string-to-number (match-string-no-properties 1)))) + (if (> ver 100) + (/ ver 100) + ver)) + 0))) + +(defun company-clang (command &optional arg &rest ignored) + "`company-mode' completion back-end for Clang. +Clang is a parser for C and ObjC. Clang version 1.1 or newer is required. + +Additional command line arguments can be specified in +`company-clang-arguments'. Prefix files (-include ...) can be selected +with `company-clang-set-prefix' or automatically through a custom +`company-clang-prefix-guesser'. + +With Clang versions before 2.9, we have to save the buffer before +performing completion. With Clang 2.9 and later, buffer contents are +passed via standard input." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-clang)) + (init (when (memq major-mode company-clang-modes) + (unless company-clang-executable + (error "Company found no clang executable")) + (setq company-clang--version (company-clang-version)) + (when (< company-clang--version company-clang-required-version) + (error "Company requires clang version 1.1")))) + (prefix (and (memq major-mode company-clang-modes) + buffer-file-name + company-clang-executable + (not (company-in-string-or-comment)) + (or (company-clang--prefix) 'stop))) + (candidates (cons :async + (lambda (cb) (company-clang--candidates arg cb)))) + (meta (company-clang--meta arg)) + (annotation (company-clang--annotation arg)) + (post-completion (let ((anno (company-clang--annotation arg))) + (when (and company-clang-insert-arguments anno) + (insert anno) + (if (string-match "\\`:[^:]" anno) + (company-clang-objc-templatify anno) + (company-template-c-like-templatify + (concat arg anno)))))))) + +(provide 'company-clang) +;;; company-clang.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-cmake.el b/emacs.d/elpa/company-20150503.1854/company-cmake.el new file mode 100644 index 0000000..e2962f5 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-cmake.el @@ -0,0 +1,198 @@ +;;; company-cmake.el --- company-mode completion back-end for CMake + +;; Copyright (C) 2013-2014 Free Software Foundation, Inc. + +;; Author: Chen Bin +;; Version: 0.2 + +;; 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: +;; +;; company-cmake offers completions for module names, variable names and +;; commands used by CMake. And their descriptions. + +;;; Code: + +(require 'company) +(require 'cl-lib) + +(defgroup company-cmake nil + "Completion back-end for CMake." + :group 'company) + +(defcustom company-cmake-executable + (executable-find "cmake") + "Location of cmake executable." + :type 'file) + +(defvar company-cmake-executable-arguments + '("--help-command-list" + "--help-module-list" + "--help-variable-list") + "The arguments we pass to cmake, separately. +They affect which types of symbols we get completion candidates for.") + +(defvar company-cmake--completion-pattern + "^\\(%s[a-zA-Z0-9_<>]%s\\)$" + "Regexp to match the candidates.") + +(defvar company-cmake-modes '(cmake-mode) + "Major modes in which cmake may complete.") + +(defvar company-cmake--candidates-cache nil + "Cache for the raw candidates.") + +(defvar company-cmake--meta-command-cache nil + "Cache for command arguments to retrieve descriptions for the candidates.") + +(defun company-cmake--replace-tags (rlt) + (setq rlt (replace-regexp-in-string + "\\(.*?\\(IS_GNU\\)?\\)\\(.*\\)" + (lambda (_match) + (mapconcat 'identity + (if (match-beginning 2) + '("\\1CXX\\3" "\\1C\\3" "\\1G77\\3") + '("\\1CXX\\3" "\\1C\\3" "\\1Fortran\\3")) + "\n")) + rlt t)) + (setq rlt (replace-regexp-in-string + "\\(.*\\)\\(.*\\)" + (mapconcat 'identity '("\\1DEBUG\\2" "\\1RELEASE\\2" + "\\1RELWITHDEBINFO\\2" "\\1MINSIZEREL\\2") + "\n") + rlt)) + rlt) + +(defun company-cmake--fill-candidates-cache (arg) + "Fill candidates cache if needed." + (let (rlt) + (unless company-cmake--candidates-cache + (setq company-cmake--candidates-cache (make-hash-table :test 'equal))) + + ;; If hash is empty, fill it. + (unless (gethash arg company-cmake--candidates-cache) + (with-temp-buffer + (let ((res (call-process company-cmake-executable nil t nil arg))) + (unless (zerop res) + (message "cmake executable exited with error=%d" res))) + (setq rlt (buffer-string))) + (setq rlt (company-cmake--replace-tags rlt)) + (puthash arg rlt company-cmake--candidates-cache)) + )) + +(defun company-cmake--parse (prefix content cmd) + (let ((start 0) + (pattern (format company-cmake--completion-pattern + (regexp-quote prefix) + (if (zerop (length prefix)) "+" "*"))) + (lines (split-string content "\n")) + match + rlt) + (dolist (line lines) + (when (string-match pattern line) + (let ((match (match-string 1 line))) + (when match + (puthash match cmd company-cmake--meta-command-cache) + (push match rlt))))) + rlt)) + +(defun company-cmake--candidates (prefix) + (let (results + cmd-opts + str) + + (unless company-cmake--meta-command-cache + (setq company-cmake--meta-command-cache (make-hash-table :test 'equal))) + + (dolist (arg company-cmake-executable-arguments) + (company-cmake--fill-candidates-cache arg) + (setq cmd-opts (replace-regexp-in-string "-list$" "" arg) ) + + (setq str (gethash arg company-cmake--candidates-cache)) + (when str + (setq results (nconc results + (company-cmake--parse prefix str cmd-opts))))) + results)) + +(defun company-cmake--unexpand-candidate (candidate) + (cond + ((string-match "^CMAKE_\\(C\\|CXX\\|Fortran\\)\\(_.*\\)$" candidate) + (setq candidate (concat "CMAKE_" (match-string 2 candidate)))) + + ;; C flags + ((string-match "^\\(.*_\\)IS_GNU\\(C\\|CXX\\|G77\\)$" candidate) + (setq candidate (concat (match-string 1 candidate) "IS_GNU"))) + + ;; C flags + ((string-match "^\\(.*_\\)OVERRIDE_\\(C\\|CXX\\|Fortran\\)$" candidate) + (setq candidate (concat (match-string 1 candidate) "OVERRIDE_"))) + + ((string-match "^\\(.*\\)\\(_DEBUG\\|_RELEASE\\|_RELWITHDEBINFO\\|_MINSIZEREL\\)\\(.*\\)$" candidate) + (setq candidate (concat (match-string 1 candidate) + "_" + (match-string 3 candidate))))) + candidate) + +(defun company-cmake--meta (candidate) + (let ((cmd-opts (gethash candidate company-cmake--meta-command-cache)) + result) + (setq candidate (company-cmake--unexpand-candidate candidate)) + + ;; Don't cache the documentation of every candidate (command) + ;; Cache in this case will cost too much memory. + (with-temp-buffer + (call-process company-cmake-executable nil t nil cmd-opts candidate) + ;; Go to the third line, trim it and return the result. + ;; Tested with cmake 2.8.9. + (goto-char (point-min)) + (forward-line 2) + (setq result (buffer-substring-no-properties (line-beginning-position) + (line-end-position))) + (setq result (replace-regexp-in-string "^[ \t\n\r]+" "" result)) + result))) + +(defun company-cmake--doc-buffer (candidate) + (let ((cmd-opts (gethash candidate company-cmake--meta-command-cache))) + + (setq candidate (company-cmake--unexpand-candidate candidate)) + (with-temp-buffer + (call-process company-cmake-executable nil t nil cmd-opts candidate) + ;; Go to the third line, trim it and return the doc buffer. + ;; Tested with cmake 2.8.9. + (goto-char (point-min)) + (forward-line 2) + (company-doc-buffer + (buffer-substring-no-properties (line-beginning-position) + (point-max)))))) + +(defun company-cmake (command &optional arg &rest ignored) + "`company-mode' completion back-end for CMake. +CMake is a cross-platform, open-source make system." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-cmake)) + (init (when (memq major-mode company-cmake-modes) + (unless company-cmake-executable + (error "Company found no cmake executable")))) + (prefix (and (memq major-mode company-cmake-modes) + (not (company-in-string-or-comment)) + (company-grab-symbol))) + (candidates (company-cmake--candidates arg)) + (meta (company-cmake--meta arg)) + (doc-buffer (company-cmake--doc-buffer arg)) + )) + +(provide 'company-cmake) +;;; company-cmake.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-css.el b/emacs.d/elpa/company-20150503.1854/company-css.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-css.el rename to emacs.d/elpa/company-20150503.1854/company-css.el diff --git a/emacs.d/elpa/company-20141014.1517/company-dabbrev-code.el b/emacs.d/elpa/company-20150503.1854/company-dabbrev-code.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-dabbrev-code.el rename to emacs.d/elpa/company-20150503.1854/company-dabbrev-code.el diff --git a/emacs.d/elpa/company-20150503.1854/company-dabbrev.el b/emacs.d/elpa/company-20150503.1854/company-dabbrev.el new file mode 100644 index 0000000..2ab4303 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-dabbrev.el @@ -0,0 +1,170 @@ +;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end -*- lexical-binding: t -*- + +;; Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) + +(defgroup company-dabbrev nil + "dabbrev-like completion back-end." + :group 'company) + +(defcustom company-dabbrev-other-buffers 'all + "Determines whether `company-dabbrev' should search other buffers. +If `all', search all other buffers, except the ignored ones. If t, search +buffers with the same major mode. See also `company-dabbrev-time-limit'." + :type '(choice (const :tag "Off" nil) + (const :tag "Same major mode" t) + (const :tag "All" all))) + +(defcustom company-dabbrev-ignore-buffers "\\`[ *]" + "Regexp matching the names of buffers to ignore." + :type 'regexp) + +(defcustom company-dabbrev-time-limit .1 + "Determines how many seconds `company-dabbrev' should look for matches." + :type '(choice (const :tag "Off" nil) + (number :tag "Seconds"))) + +(defcustom company-dabbrev-char-regexp "\\sw" + "A regular expression matching the characters `company-dabbrev' looks for." + :type 'regexp) + +(defcustom company-dabbrev-ignore-case 'keep-prefix + "Non-nil to ignore case when collecting completion candidates. +When it's `keep-prefix', the text before point will remain unchanged after +candidate is inserted, even some of its characters have different case.") + +(defcustom company-dabbrev-downcase 'case-replace + "Whether to downcase the returned candidates. + +The value of nil means keep them as-is. +`case-replace' means use the value of `case-replace'. +Any other value means downcase. + +If you set this value to nil, you may also want to set +`company-dabbrev-ignore-case' to any value other than `keep-prefix'.") + +(defcustom company-dabbrev-minimum-length 4 + "The minimum length for the completion candidate to be included. +This variable affects both `company-dabbrev' and `company-dabbrev-code'." + :type 'integer + :package-version '(company . "0.8.3")) + +(defcustom company-dabbrev-ignore-invisible nil + "Non-nil to skip invisible text." + :type 'boolean + :package-version '(company . "0.9.0")) + +(defmacro company-dabrev--time-limit-while (test start limit &rest body) + (declare (indent 3) (debug t)) + `(let ((company-time-limit-while-counter 0)) + (catch 'done + (while ,test + ,@body + (and ,limit + (eq (cl-incf company-time-limit-while-counter) 25) + (setq company-time-limit-while-counter 0) + (> (float-time (time-since ,start)) ,limit) + (throw 'done 'company-time-out)))))) + +(defsubst company-dabbrev--make-regexp (prefix) + (concat "\\<" (if (equal prefix "") + company-dabbrev-char-regexp + (regexp-quote prefix)) + "\\(" company-dabbrev-char-regexp "\\)*\\>")) + +(defun company-dabbrev--search-buffer (regexp pos symbols start limit + ignore-comments) + (save-excursion + (cl-flet ((maybe-collect-match + () + (let ((match (match-string-no-properties 0))) + (when (and (>= (length match) company-dabbrev-minimum-length) + (not (and company-dabbrev-ignore-invisible + (invisible-p (match-beginning 0))))) + (push match symbols))))) + (goto-char (if pos (1- pos) (point-min))) + ;; search before pos + (company-dabrev--time-limit-while (re-search-backward regexp nil t) + start limit + (if (and ignore-comments (save-match-data (company-in-string-or-comment))) + (goto-char (nth 8 (syntax-ppss))) + (maybe-collect-match))) + (goto-char (or pos (point-min))) + ;; search after pos + (company-dabrev--time-limit-while (re-search-forward regexp nil t) + start limit + (if (and ignore-comments (save-match-data (company-in-string-or-comment))) + (re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t) + (maybe-collect-match))) + symbols))) + +(defun company-dabbrev--search (regexp &optional limit other-buffer-modes + ignore-comments) + (let* ((start (current-time)) + (symbols (company-dabbrev--search-buffer regexp (point) nil start limit + ignore-comments))) + (when other-buffer-modes + (cl-dolist (buffer (delq (current-buffer) (buffer-list))) + (with-current-buffer buffer + (when (if (eq other-buffer-modes 'all) + (not (string-match-p company-dabbrev-ignore-buffers + (buffer-name))) + (apply #'derived-mode-p other-buffer-modes)) + (setq symbols + (company-dabbrev--search-buffer regexp nil symbols start + limit ignore-comments)))) + (and limit + (> (float-time (time-since start)) limit) + (cl-return)))) + symbols)) + +;;;###autoload +(defun company-dabbrev (command &optional arg &rest ignored) + "dabbrev-like `company-mode' completion back-end." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-dabbrev)) + (prefix (company-grab-word)) + (candidates + (let* ((case-fold-search company-dabbrev-ignore-case) + (words (company-dabbrev--search (company-dabbrev--make-regexp arg) + company-dabbrev-time-limit + (pcase company-dabbrev-other-buffers + (`t (list major-mode)) + (`all `all)))) + (downcase-p (if (eq company-dabbrev-downcase 'case-replace) + case-replace + company-dabbrev-downcase))) + (if downcase-p + (mapcar 'downcase words) + words))) + (ignore-case company-dabbrev-ignore-case) + (duplicates t))) + +(provide 'company-dabbrev) +;;; company-dabbrev.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-eclim.el b/emacs.d/elpa/company-20150503.1854/company-eclim.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-eclim.el rename to emacs.d/elpa/company-20150503.1854/company-eclim.el diff --git a/emacs.d/elpa/company-20141014.1517/company-elisp.el b/emacs.d/elpa/company-20150503.1854/company-elisp.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-elisp.el rename to emacs.d/elpa/company-20150503.1854/company-elisp.el diff --git a/emacs.d/elpa/company-20150503.1854/company-etags.el b/emacs.d/elpa/company-20150503.1854/company-etags.el new file mode 100644 index 0000000..1c01c91 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-etags.el @@ -0,0 +1,94 @@ +;;; company-etags.el --- company-mode completion back-end for etags + +;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) +(require 'etags) + +(defgroup company-etags nil + "Completion back-end for etags." + :group 'company) + +(defcustom company-etags-use-main-table-list t + "Always search `tags-table-list' if set. +If this is disabled, `company-etags' will try to find the one table for each +buffer automatically." + :type '(choice (const :tag "off" nil) + (const :tag "on" t))) + +(defcustom company-etags-ignore-case nil + "Non-nil to ignore case in completion candidates." + :type 'boolean + :package-version '(company . "0.7.3")) + +(defvar company-etags-modes '(prog-mode c-mode objc-mode c++-mode java-mode + jde-mode pascal-mode perl-mode python-mode)) + +(defvar-local company-etags-buffer-table 'unknown) + +(defun company-etags-find-table () + (let ((file (locate-dominating-file (or buffer-file-name + default-directory) + "TAGS"))) + (when (and file (file-regular-p file)) + (list (expand-file-name file))))) + +(defun company-etags-buffer-table () + (or (and company-etags-use-main-table-list tags-table-list) + (if (eq company-etags-buffer-table 'unknown) + (setq company-etags-buffer-table (company-etags-find-table)) + company-etags-buffer-table))) + +(defun company-etags--candidates (prefix) + (let ((tags-table-list (company-etags-buffer-table)) + (completion-ignore-case company-etags-ignore-case)) + (and (or tags-file-name tags-table-list) + (fboundp 'tags-completion-table) + (save-excursion + (visit-tags-table-buffer) + (all-completions prefix (tags-completion-table)))))) + +;;;###autoload +(defun company-etags (command &optional arg &rest ignored) + "`company-mode' completion back-end for etags." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-etags)) + (prefix (and (apply 'derived-mode-p company-etags-modes) + (not (company-in-string-or-comment)) + (company-etags-buffer-table) + (or (company-grab-symbol) 'stop))) + (candidates (company-etags--candidates arg)) + (location (let ((tags-table-list (company-etags-buffer-table))) + (when (fboundp 'find-tag-noselect) + (save-excursion + (let ((buffer (find-tag-noselect arg))) + (cons buffer (with-current-buffer buffer (point)))))))) + (ignore-case company-etags-ignore-case))) + +(provide 'company-etags) +;;; company-etags.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-files.el b/emacs.d/elpa/company-20150503.1854/company-files.el new file mode 100644 index 0000000..200f9cf --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-files.el @@ -0,0 +1,111 @@ +;;; company-files.el --- company-mode completion back-end for file paths + +;; Copyright (C) 2009-2011, 2014-2015 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) + +(defun company-files--directory-files (dir prefix) + (ignore-errors + (if (equal prefix "") + (directory-files dir nil "\\`[^.]\\|\\`.[^.]") + (file-name-all-completions prefix dir)))) + +(defvar company-files--regexps + (let* ((root (if (eq system-type 'windows-nt) + "[a-zA-Z]:/" + "/")) + (begin (concat "\\(?:\\.\\{1,2\\}/\\|~/\\|" root "\\)"))) + (list (concat "\"\\(" begin "[^\"\n]*\\)") + (concat "\'\\(" begin "[^\'\n]*\\)") + (concat "\\(?:[ \t]\\|^\\)\\(" begin "[^ \t\n]*\\)")))) + +(defun company-files--grab-existing-name () + ;; Grab the file name. + ;; When surrounded with quotes, it can include spaces. + (let (file dir) + (and (cl-dolist (regexp company-files--regexps) + (when (setq file (company-grab-line regexp 1)) + (cl-return file))) + (company-files--connected-p file) + (setq dir (file-name-directory file)) + (not (string-match "//" dir)) + (file-exists-p dir) + (file-name-all-completions (file-name-nondirectory file) dir) + file))) + +(defun company-files--connected-p (file) + (or (not (file-remote-p file)) + (file-remote-p file nil t))) + +(defvar company-files--completion-cache nil) + +(defun company-files--complete (prefix) + (let* ((dir (file-name-directory prefix)) + (key (list (file-name-nondirectory prefix) + (expand-file-name dir) + (nth 5 (file-attributes dir)))) + (file (file-name-nondirectory prefix)) + (completion-ignore-case read-file-name-completion-ignore-case) + candidates directories) + (unless (company-file--keys-match-p key (car company-files--completion-cache)) + (dolist (file (company-files--directory-files dir file)) + (setq file (concat dir file)) + (when (company-files--connected-p file) + (push file candidates) + (when (file-directory-p file) + (push file directories)))) + (dolist (directory (reverse directories)) + ;; Add one level of children. + (dolist (child (company-files--directory-files directory "")) + (push (concat directory + (unless (eq (aref directory (1- (length directory))) ?/) "/") + child) candidates))) + (setq company-files--completion-cache (cons key (nreverse candidates)))) + (all-completions prefix + (cdr company-files--completion-cache)))) + +(defun company-file--keys-match-p (new old) + (and (equal (cdr old) (cdr new)) + (string-prefix-p (car old) (car new)))) + +;;;###autoload +(defun company-files (command &optional arg &rest ignored) + "`company-mode' completion back-end existing file names. +Completions works for proper absolute and relative files paths. +File paths with spaces are only supported inside strings." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-files)) + (prefix (company-files--grab-existing-name)) + (candidates (company-files--complete arg)) + (location (cons (dired-noselect + (file-name-directory (directory-file-name arg))) 1)) + (sorted t) + (no-cache t))) + +(provide 'company-files) +;;; company-files.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-gtags.el b/emacs.d/elpa/company-20150503.1854/company-gtags.el new file mode 100644 index 0000000..e214db7 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-gtags.el @@ -0,0 +1,116 @@ +;;; company-gtags.el --- company-mode completion back-end for GNU Global + +;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'company-template) +(require 'cl-lib) + +(defgroup company-gtags nil + "Completion back-end for GNU Global." + :group 'company) + +(defcustom company-gtags-executable + (executable-find "global") + "Location of GNU global executable." + :type 'string) + +(define-obsolete-variable-alias + 'company-gtags-gnu-global-program-name + 'company-gtags-executable "earlier") + +(defcustom company-gtags-insert-arguments t + "When non-nil, insert function arguments as a template after completion." + :type 'boolean + :package-version '(company . "0.8.1")) + +(defvar-local company-gtags--tags-available-p 'unknown) + +(defcustom company-gtags-modes '(prog-mode jde-mode) + "Modes that use `company-gtags'. +In all these modes (and their derivatives) `company-gtags' will perform +completion." + :type '(repeat (symbol :tag "Major mode")) + :package-version '(company . "0.8.4")) + +(defun company-gtags--tags-available-p () + (if (eq company-gtags--tags-available-p 'unknown) + (setq company-gtags--tags-available-p + (locate-dominating-file buffer-file-name "GTAGS")) + company-gtags--tags-available-p)) + +(defun company-gtags--fetch-tags (prefix) + (with-temp-buffer + (let (tags) + (when (= 0 (call-process company-gtags-executable nil + (list (current-buffer) nil) nil "-xGq" (concat "^" prefix))) + (goto-char (point-min)) + (cl-loop while + (re-search-forward (concat + "^" + "\\([^ ]*\\)" ;; completion + "[ \t]+\\([[:digit:]]+\\)" ;; linum + "[ \t]+\\([^ \t]+\\)" ;; file + "[ \t]+\\(.*\\)" ;; definition + "$" + ) nil t) + collect + (propertize (match-string 1) + 'meta (match-string 4) + 'location (cons (expand-file-name (match-string 3)) + (string-to-number (match-string 2))) + )))))) + +(defun company-gtags--annotation (arg) + (let ((meta (get-text-property 0 'meta arg))) + (when (string-match (concat arg "\\((.*)\\).*") meta) + (match-string 1 meta)))) + +;;;###autoload +(defun company-gtags (command &optional arg &rest ignored) + "`company-mode' completion back-end for GNU Global." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-gtags)) + (prefix (and company-gtags-executable + buffer-file-name + (apply #'derived-mode-p company-gtags-modes) + (not (company-in-string-or-comment)) + (company-gtags--tags-available-p) + (or (company-grab-symbol) 'stop))) + (candidates (company-gtags--fetch-tags arg)) + (sorted t) + (duplicates t) + (annotation (company-gtags--annotation arg)) + (meta (get-text-property 0 'meta arg)) + (location (get-text-property 0 'location arg)) + (post-completion (let ((anno (company-gtags--annotation arg))) + (when (and company-gtags-insert-arguments anno) + (insert anno) + (company-template-c-like-templatify anno)))))) + +(provide 'company-gtags) +;;; company-gtags.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-ispell.el b/emacs.d/elpa/company-20150503.1854/company-ispell.el new file mode 100644 index 0000000..4ce8dfc --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-ispell.el @@ -0,0 +1,76 @@ +;;; company-ispell.el --- company-mode completion back-end using Ispell + +;; Copyright (C) 2009-2011, 2013-2015 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) +(require 'ispell) + +(defgroup company-ispell nil + "Completion back-end using Ispell." + :group 'company) + +(defcustom company-ispell-dictionary nil + "Dictionary to use for `company-ispell'. +If nil, use `ispell-complete-word-dict'." + :type '(choice (const :tag "default (nil)" nil) + (file :tag "dictionary" t))) + +(defvar company-ispell-available 'unknown) + +(defun company-ispell-available () + (when (eq company-ispell-available 'unknown) + (condition-case err + (progn + (lookup-words "WHATEVER") + (setq company-ispell-available t)) + (error + (message "Company: ispell-look-command not found") + (setq company-ispell-available nil)))) + company-ispell-available) + +;;;###autoload +(defun company-ispell (command &optional arg &rest ignored) + "`company-mode' completion back-end using Ispell." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-ispell)) + (prefix (when (company-ispell-available) + (company-grab-word))) + (candidates + (let ((words (lookup-words arg (or company-ispell-dictionary + ispell-complete-word-dict))) + (completion-ignore-case t)) + (if (string= arg "") + ;; Small optimization. + words + ;; Work around issue #284. + (all-completions arg words)))) + (sorted t) + (ignore-case 'keep-prefix))) + +(provide 'company-ispell) +;;; company-ispell.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-keywords.el b/emacs.d/elpa/company-20150503.1854/company-keywords.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-keywords.el rename to emacs.d/elpa/company-20150503.1854/company-keywords.el diff --git a/emacs.d/elpa/company-20141014.1517/company-nxml.el b/emacs.d/elpa/company-20150503.1854/company-nxml.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-nxml.el rename to emacs.d/elpa/company-20150503.1854/company-nxml.el diff --git a/emacs.d/elpa/company-20141014.1517/company-oddmuse.el b/emacs.d/elpa/company-20150503.1854/company-oddmuse.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-oddmuse.el rename to emacs.d/elpa/company-20150503.1854/company-oddmuse.el diff --git a/emacs.d/elpa/company-20150503.1854/company-pkg.el b/emacs.d/elpa/company-20150503.1854/company-pkg.el new file mode 100644 index 0000000..0bc9773 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-pkg.el @@ -0,0 +1,8 @@ +(define-package "company" "20150503.1854" "Modular text completion framework" + '((emacs "24.1") + (cl-lib "0.5")) + :url "http://company-mode.github.io/" :keywords + '("abbrev" "convenience" "matching")) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/company-20150503.1854/company-semantic.el b/emacs.d/elpa/company-20150503.1854/company-semantic.el new file mode 100644 index 0000000..a1c7d16 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-semantic.el @@ -0,0 +1,156 @@ +;;; company-semantic.el --- company-mode completion back-end using Semantic + +;; Copyright (C) 2009-2011, 2013 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) + +(defvar semantic-idle-summary-function) +(declare-function semantic-documentation-for-tag "semantic/doc" ) +(declare-function semantic-analyze-current-context "semantic/analyze") +(declare-function semantic-analyze-possible-completions "semantic/complete") +(declare-function semantic-analyze-find-tags-by-prefix "semantic/analyze/fcn") +(declare-function semantic-tag-class "semantic/tag") +(declare-function semantic-tag-name "semantic/tag") +(declare-function semantic-tag-start "semantic/tag") +(declare-function semantic-tag-buffer "semantic/tag") +(declare-function semantic-active-p "semantic") + +(defgroup company-semantic nil + "Completion back-end using Semantic." + :group 'company) + +(defcustom company-semantic-metadata-function 'company-semantic-summary-and-doc + "The function turning a semantic tag into doc information." + :type 'function) + +(defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode)) + +(defvar-local company-semantic--current-tags nil + "Tags for the current context.") + +(defun company-semantic-documentation-for-tag (tag) + (when (semantic-tag-buffer tag) + ;; When TAG's buffer is unknown, the function below raises an error. + (semantic-documentation-for-tag tag))) + +(defun company-semantic-doc-or-summary (tag) + (or (company-semantic-documentation-for-tag tag) + (and (require 'semantic-idle nil t) + (require 'semantic/idle nil t) + (funcall semantic-idle-summary-function tag nil t)))) + +(defun company-semantic-summary-and-doc (tag) + (let ((doc (company-semantic-documentation-for-tag tag)) + (summary (funcall semantic-idle-summary-function tag nil t))) + (and (stringp doc) + (string-match "\n*\\(.*\\)$" doc) + (setq doc (match-string 1 doc))) + (concat summary + (when doc + (if (< (+ (length doc) (length summary) 4) (window-width)) + " -- " + "\n")) + doc))) + +(defun company-semantic-doc-buffer (tag) + (let ((doc (company-semantic-documentation-for-tag tag))) + (when doc + (company-doc-buffer + (concat (funcall semantic-idle-summary-function tag nil t) + "\n" + doc))))) + +(defsubst company-semantic-completions (prefix) + (ignore-errors + (let ((completion-ignore-case nil) + (context (semantic-analyze-current-context))) + (setq company-semantic--current-tags + (semantic-analyze-possible-completions context)) + (all-completions prefix company-semantic--current-tags)))) + +(defun company-semantic-completions-raw (prefix) + (setq company-semantic--current-tags nil) + (dolist (tag (semantic-analyze-find-tags-by-prefix prefix)) + (unless (eq (semantic-tag-class tag) 'include) + (push tag company-semantic--current-tags))) + (delete "" (mapcar 'semantic-tag-name company-semantic--current-tags))) + +(defun company-semantic-annotation (argument tags) + (let* ((tag (assoc argument tags)) + (kind (when tag (elt tag 1)))) + (cl-case kind + (function (let* ((prototype (semantic-format-tag-prototype tag nil nil)) + (par-pos (string-match "(" prototype))) + (when par-pos (substring prototype par-pos))))))) + +(defun company-semantic--pre-prefix-length (prefix-length) + "Sum up the length of all chained symbols before POS. +Symbols are chained by \".\" or \"->\"." + (save-excursion + (let ((pos (point))) + (goto-char (- (point) prefix-length)) + (while (looking-back "->\\|\\.") + (goto-char (match-beginning 0)) + (skip-syntax-backward "w_")) + (- pos (point))))) + +(defun company-semantic--grab () + "Grab the semantic prefix, but return everything before -> or . as length." + (let ((symbol (company-grab-symbol))) + (when symbol + (cons symbol (company-semantic--pre-prefix-length (length symbol)))))) + +;;;###autoload +(defun company-semantic (command &optional arg &rest ignored) + "`company-mode' completion back-end using CEDET Semantic." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-semantic)) + (prefix (and (featurep 'semantic) + (semantic-active-p) + (memq major-mode company-semantic-modes) + (not (company-in-string-or-comment)) + (or (company-semantic--grab) 'stop))) + (candidates (if (and (equal arg "") + (not (looking-back "->\\|\\."))) + (company-semantic-completions-raw arg) + (company-semantic-completions arg))) + (meta (funcall company-semantic-metadata-function + (assoc arg company-semantic--current-tags))) + (annotation (company-semantic-annotation arg + company-semantic--current-tags)) + (doc-buffer (company-semantic-doc-buffer + (assoc arg company-semantic--current-tags))) + ;; Because "" is an empty context and doesn't return local variables. + (no-cache (equal arg "")) + (location (let ((tag (assoc arg company-semantic--current-tags))) + (when (buffer-live-p (semantic-tag-buffer tag)) + (cons (semantic-tag-buffer tag) + (semantic-tag-start tag))))))) + +(provide 'company-semantic) +;;; company-semantic.el ends here diff --git a/emacs.d/elpa/company-20150503.1854/company-template.el b/emacs.d/elpa/company-20150503.1854/company-template.el new file mode 100644 index 0000000..d90458c --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-template.el @@ -0,0 +1,214 @@ +;;; company-template.el + +;; Copyright (C) 2009, 2010, 2014-2015 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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 . + +;;; Code: + +(require 'cl-lib) + +(defface company-template-field + '((((background dark)) (:background "yellow" :foreground "black")) + (((background light)) (:background "orange" :foreground "black"))) + "Face used for editable text in template fields." + :group 'company) + +(defvar company-template-nav-map + (let ((keymap (make-sparse-keymap))) + (define-key keymap [tab] 'company-template-forward-field) + (define-key keymap (kbd "TAB") 'company-template-forward-field) + keymap)) + +(defvar-local company-template--buffer-templates nil) + +;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-template-templates-at (pos) + (let (os) + (dolist (o (overlays-at pos)) + ;; FIXME: Always return the whole list of templates? + ;; We remove templates not at point after every command. + (when (memq o company-template--buffer-templates) + (push o os))) + os)) + +(defun company-template-move-to-first (templ) + (interactive) + (goto-char (overlay-start templ)) + (company-template-forward-field)) + +(defun company-template-forward-field () + (interactive) + (let* ((start (point)) + (templates (company-template-templates-at (point))) + (minimum (apply 'max (mapcar 'overlay-end templates))) + (fields (cl-loop for templ in templates + append (overlay-get templ 'company-template-fields)))) + (dolist (pos (mapcar 'overlay-start fields)) + (and pos + (> pos (point)) + (< pos minimum) + (setq minimum pos))) + (push-mark) + (goto-char minimum) + (company-template-remove-field (company-template-field-at start)))) + +(defun company-template-field-at (&optional point) + (cl-loop for ovl in (overlays-at (or point (point))) + when (overlay-get ovl 'company-template-parent) + return ovl)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-template-declare-template (beg end) + (let ((ov (make-overlay beg end))) + ;; (overlay-put ov 'face 'highlight) + (overlay-put ov 'keymap company-template-nav-map) + (overlay-put ov 'priority 101) + (overlay-put ov 'evaporate t) + (push ov company-template--buffer-templates) + (add-hook 'post-command-hook 'company-template-post-command nil t) + ov)) + +(defun company-template-remove-template (templ) + (mapc 'company-template-remove-field + (overlay-get templ 'company-template-fields)) + (setq company-template--buffer-templates + (delq templ company-template--buffer-templates)) + (delete-overlay templ)) + +(defun company-template-add-field (templ beg end &optional display) + "Add new field to template TEMPL spanning from BEG to END. +When DISPLAY is non-nil, set the respective property on the overlay. +Leave point at the end of the field." + (cl-assert templ) + (when (> end (overlay-end templ)) + (move-overlay templ (overlay-start templ) end)) + (let ((ov (make-overlay beg end)) + (siblings (overlay-get templ 'company-template-fields))) + ;; (overlay-put ov 'evaporate t) + (overlay-put ov 'intangible t) + (overlay-put ov 'face 'company-template-field) + (when display + (overlay-put ov 'display display)) + (overlay-put ov 'company-template-parent templ) + (overlay-put ov 'insert-in-front-hooks '(company-template-insert-hook)) + (push ov siblings) + (overlay-put templ 'company-template-fields siblings))) + +(defun company-template-remove-field (ovl &optional clear) + (when (overlayp ovl) + (when (overlay-buffer ovl) + (when clear + (delete-region (overlay-start ovl) (overlay-end ovl))) + (delete-overlay ovl)) + (let* ((templ (overlay-get ovl 'company-template-parent)) + (siblings (overlay-get templ 'company-template-fields))) + (setq siblings (delq ovl siblings)) + (overlay-put templ 'company-template-fields siblings)))) + +(defun company-template-clean-up (&optional pos) + "Clean up all templates that don't contain POS." + (let ((local-ovs (overlays-at (or pos (point))))) + (dolist (templ company-template--buffer-templates) + (unless (memq templ local-ovs) + (company-template-remove-template templ))))) + +;; hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-template-insert-hook (ovl after-p &rest _ignore) + "Called when a snippet input prompt is modified." + (unless after-p + (company-template-remove-field ovl t))) + +(defun company-template-post-command () + (company-template-clean-up) + (unless company-template--buffer-templates + (remove-hook 'post-command-hook 'company-template-post-command t))) + +;; common ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-template-c-like-templatify (call) + (let* ((end (point-marker)) + (beg (- (point) (length call))) + (templ (company-template-declare-template beg end)) + paren-open paren-close) + (with-syntax-table (make-syntax-table (syntax-table)) + (modify-syntax-entry ?< "(") + (modify-syntax-entry ?> ")") + (when (search-backward ")" beg t) + (setq paren-close (point-marker)) + (forward-char 1) + (delete-region (point) end) + (backward-sexp) + (forward-char 1) + (setq paren-open (point-marker))) + (when (search-backward ">" beg t) + (let ((angle-close (point-marker))) + (forward-char 1) + (backward-sexp) + (forward-char) + (company-template--c-like-args templ angle-close))) + (when (looking-back "\\((\\*)\\)(" (line-beginning-position)) + (delete-region (match-beginning 1) (match-end 1))) + (when paren-open + (goto-char paren-open) + (company-template--c-like-args templ paren-close))) + (if (overlay-get templ 'company-template-fields) + (company-template-move-to-first templ) + (company-template-remove-template templ) + (goto-char end)))) + +(defun company-template--c-like-args (templ end) + (let ((last-pos (point))) + (while (re-search-forward "\\([^,]+\\),?" end 'move) + (when (zerop (car (parse-partial-sexp last-pos (point)))) + (company-template-add-field templ last-pos (match-end 1)) + (skip-chars-forward " ") + (setq last-pos (point)))))) + +;; objc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-clang-objc-templatify (selector) + (let* ((end (point-marker)) + (beg (- (point) (length selector) 1)) + (templ (company-template-declare-template beg end)) + (cnt 0)) + (save-excursion + (goto-char beg) + (catch 'stop + (while (search-forward ":" end t) + (if (looking-at "\\(([^)]*)\\) ?") + (company-template-add-field templ (point) (match-end 1)) + ;; Not sure which conditions this case manifests under, but + ;; apparently it did before, when I wrote the first test for this + ;; function. FIXME: Revisit it. + (company-template-add-field templ (point) + (progn + (insert (format "arg%d" cnt)) + (point))) + (when (< (point) end) + (insert " ")) + (cl-incf cnt)) + (when (>= (point) end) + (throw 'stop t))))) + (company-template-move-to-first templ))) + +(provide 'company-template) +;;; company-template.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-tempo.el b/emacs.d/elpa/company-20150503.1854/company-tempo.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-tempo.el rename to emacs.d/elpa/company-20150503.1854/company-tempo.el diff --git a/emacs.d/elpa/company-20150503.1854/company-xcode.el b/emacs.d/elpa/company-20150503.1854/company-xcode.el new file mode 100644 index 0000000..c7a6f80 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company-xcode.el @@ -0,0 +1,123 @@ +;;; company-xcode.el --- company-mode completion back-end for Xcode projects + +;; Copyright (C) 2009-2011, 2014 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher + +;; 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: +;; + +;;; Code: + +(require 'company) +(require 'cl-lib) + +(defgroup company-xcode nil + "Completion back-end for Xcode projects." + :group 'company) + +(defcustom company-xcode-xcodeindex-executable (executable-find "xcodeindex") + "Location of xcodeindex executable." + :type 'file) + +(defvar company-xcode-tags nil) + +(defun company-xcode-reset () + "Reset the cached tags." + (interactive) + (setq company-xcode-tags nil)) + +(defcustom company-xcode-types + '("Class" "Constant" "Enum" "Macro" "Modeled Class" "Structure" + "Type" "Union" "Function") + "The types of symbols offered by `company-xcode'. +No context-enabled completion is available. Types like methods will be +offered regardless of whether the class supports them. The defaults should be +valid in most contexts." + :set (lambda (variable value) + (set variable value) + (company-xcode-reset)) + :type '(set (const "Category") (const "Class") (const "Class Method") + (const "Class Variable") (const "Constant") (const "Enum") + (const "Field") (const "Instance Method") + (const "Instance Variable") (const "Macro") + (const "Modeled Class") (const "Modeled Method") + (const "Modeled Property") (const "Property") (const "Protocol") + (const "Structure") (const "Type") (const "Union") + (const "Variable") (const "Function"))) + +(defvar-local company-xcode-project 'unknown) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-xcode-fetch (project-bundle) + (setq project-bundle (directory-file-name project-bundle)) + (message "Retrieving dump from %s..." project-bundle) + (with-temp-buffer + (let ((default-directory (file-name-directory project-bundle))) + (call-process company-xcode-xcodeindex-executable nil (current-buffer) + nil "dump" "-project" + (file-name-nondirectory project-bundle) "-quiet") + (goto-char (point-min)) + (let ((regexp (concat "^\\([^\t\n]*\\)\t[^\t\n]*\t" + (regexp-opt company-xcode-types) + "\t[^\t\n]*\t[^\t\n]*")) + candidates) + (while (re-search-forward regexp nil t) + (cl-pushnew (match-string 1) candidates :test #'equal)) + (message "Retrieving dump from %s...done" project-bundle) + candidates)))) + +(defun company-xcode-find-project () + (let ((dir (if buffer-file-name + (file-name-directory buffer-file-name) + (expand-file-name default-directory))) + (prev-dir nil) + file) + (while (not (or file (equal dir prev-dir))) + (setq file (car (directory-files dir t ".xcodeproj\\'" t)) + prev-dir dir + dir (file-name-directory (directory-file-name dir)))) + file)) + +(defun company-xcode-tags () + (when (eq company-xcode-project 'unknown) + (setq company-xcode-project (company-xcode-find-project))) + (when company-xcode-project + (cdr (or (assoc company-xcode-project company-xcode-tags) + (car (push (cons company-xcode-project + (company-xcode-fetch company-xcode-project)) + company-xcode-tags)))))) +;;;###autoload +(defun company-xcode (command &optional arg &rest ignored) + "`company-mode' completion back-end for Xcode projects." + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'company-xcode)) + (prefix (and company-xcode-xcodeindex-executable + (company-xcode-tags) + (not (company-in-string-or-comment)) + (or (company-grab-symbol) 'stop))) + (candidates (let ((completion-ignore-case nil)) + (company-xcode-tags) + (all-completions arg (company-xcode-tags)))))) + + +(provide 'company-xcode) +;;; company-xcode.el ends here diff --git a/emacs.d/elpa/company-20141014.1517/company-yasnippet.el b/emacs.d/elpa/company-20150503.1854/company-yasnippet.el similarity index 100% rename from emacs.d/elpa/company-20141014.1517/company-yasnippet.el rename to emacs.d/elpa/company-20150503.1854/company-yasnippet.el diff --git a/emacs.d/elpa/company-20150503.1854/company.el b/emacs.d/elpa/company-20150503.1854/company.el new file mode 100644 index 0000000..9163749 --- /dev/null +++ b/emacs.d/elpa/company-20150503.1854/company.el @@ -0,0 +1,2841 @@ +;;; company.el --- Modular text completion framework -*- lexical-binding: t -*- + +;; Copyright (C) 2009-2015 Free Software Foundation, Inc. + +;; Author: Nikolaj Schumacher +;; Maintainer: Dmitry Gutov +;; URL: http://company-mode.github.io/ +;; Version: 0.9.0-cvs +;; Keywords: abbrev, convenience, matching +;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) + +;; 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: +;; +;; Company is a modular completion mechanism. Modules for retrieving completion +;; candidates are called back-ends, modules for displaying them are front-ends. +;; +;; Company comes with many back-ends, e.g. `company-elisp'. These are +;; distributed in separate files and can be used individually. +;; +;; Place company.el and the back-ends you want to use in a directory and add the +;; following to your .emacs: +;; (add-to-list 'load-path "/path/to/company") +;; (autoload 'company-mode "company" nil t) +;; +;; Enable company-mode with M-x company-mode. For further information look at +;; the documentation for `company-mode' (C-h f company-mode RET) +;; +;; If you want to start a specific back-end, call it interactively or use +;; `company-begin-backend'. For example: +;; M-x company-abbrev will prompt for and insert an abbrev. +;; +;; To write your own back-end, look at the documentation for `company-backends'. +;; Here is a simple example completing "foo": +;; +;; (defun company-my-backend (command &optional arg &rest ignored) +;; (pcase command +;; (`prefix (when (looking-back "foo\\>") +;; (match-string 0))) +;; (`candidates (list "foobar" "foobaz" "foobarbaz")) +;; (`meta (format "This value is named %s" arg)))) +;; +;; Sometimes it is a good idea to mix several back-ends together, for example to +;; enrich gtags with dabbrev-code results (to emulate local variables). +;; To do this, add a list with both back-ends as an element in company-backends. +;; +;;; Change Log: +;; +;; See NEWS.md in the repository. + +;;; Code: + +(require 'cl-lib) +(require 'newcomment) + +;; FIXME: Use `user-error'. +(add-to-list 'debug-ignored-errors "^.* frontend cannot be used twice$") +(add-to-list 'debug-ignored-errors "^Echo area cannot be used twice$") +(add-to-list 'debug-ignored-errors "^No \\(document\\|loc\\)ation available$") +(add-to-list 'debug-ignored-errors "^Company not ") +(add-to-list 'debug-ignored-errors "^No candidate number ") +(add-to-list 'debug-ignored-errors "^Cannot complete at point$") +(add-to-list 'debug-ignored-errors "^No other back-end$") + +;;; Compatibility +(eval-and-compile + ;; `defvar-local' for Emacs 24.2 and below + (unless (fboundp 'defvar-local) + (defmacro defvar-local (var val &optional docstring) + "Define VAR as a buffer-local variable with default value VAL. +Like `defvar' but additionally marks the variable as being automatically +buffer-local wherever it is set." + (declare (debug defvar) (doc-string 3)) + `(progn + (defvar ,var ,val ,docstring) + (make-variable-buffer-local ',var))))) + +(defgroup company nil + "Extensible inline text completion mechanism" + :group 'abbrev + :group 'convenience + :group 'matching) + +(defface company-tooltip + '((default :foreground "black") + (((class color) (min-colors 88) (background light)) + (:background "cornsilk")) + (((class color) (min-colors 88) (background dark)) + (:background "yellow"))) + "Face used for the tooltip.") + +(defface company-tooltip-selection + '((default :inherit company-tooltip) + (((class color) (min-colors 88) (background light)) + (:background "light blue")) + (((class color) (min-colors 88) (background dark)) + (:background "orange1")) + (t (:background "green"))) + "Face used for the selection in the tooltip.") + +(defface company-tooltip-search + '((default :inherit company-tooltip-selection)) + "Face used for the search string in the tooltip.") + +(defface company-tooltip-mouse + '((default :inherit highlight)) + "Face used for the tooltip item under the mouse.") + +(defface company-tooltip-common + '((default :inherit company-tooltip) + (((background light)) + :foreground "darkred") + (((background dark)) + :foreground "red")) + "Face used for the common completion in the tooltip.") + +(defface company-tooltip-common-selection + '((default :inherit company-tooltip-selection) + (((background light)) + :foreground "darkred") + (((background dark)) + :foreground "red")) + "Face used for the selected common completion in the tooltip.") + +(defface company-tooltip-annotation + '((default :inherit company-tooltip) + (((background light)) + :foreground "firebrick4") + (((background dark)) + :foreground "red4")) + "Face used for the annotation in the tooltip.") + +(defface company-scrollbar-fg + '((((background light)) + :background "darkred") + (((background dark)) + :background "red")) + "Face used for the tooltip scrollbar thumb.") + +(defface company-scrollbar-bg + '((default :inherit company-tooltip) + (((background light)) + :background "wheat") + (((background dark)) + :background "gold")) + "Face used for the tooltip scrollbar background.") + +(defface company-preview + '((((background light)) + :inherit company-tooltip-selection) + (((background dark)) + :background "blue4" + :foreground "wheat")) + "Face used for the completion preview.") + +(defface company-preview-common + '((((background light)) + :inherit company-tooltip-selection) + (((background dark)) + :inherit company-preview + :foreground "red")) + "Face used for the common part of the completion preview.") + +(defface company-preview-search + '((((background light)) + :inherit company-tooltip-common-selection) + (((background dark)) + :inherit company-preview + :background "blue1")) + "Face used for the search string in the completion preview.") + +(defface company-echo nil + "Face used for completions in the echo area.") + +(defface company-echo-common + '((((background dark)) (:foreground "firebrick1")) + (((background light)) (:background "firebrick4"))) + "Face used for the common part of completions in the echo area.") + +(defun company-frontends-set (variable value) + ;; Uniquify. + (let ((value (delete-dups (copy-sequence value)))) + (and (memq 'company-pseudo-tooltip-unless-just-one-frontend value) + (memq 'company-pseudo-tooltip-frontend value) + (error "Pseudo tooltip frontend cannot be used twice")) + (and (memq 'company-preview-if-just-one-frontend value) + (memq 'company-preview-frontend value) + (error "Preview frontend cannot be used twice")) + (and (memq 'company-echo value) + (memq 'company-echo-metadata-frontend value) + (error "Echo area cannot be used twice")) + ;; Preview must come last. + (dolist (f '(company-preview-if-just-one-frontend company-preview-frontend)) + (when (cdr (memq f value)) + (setq value (append (delq f value) (list f))))) + (set variable value))) + +(defcustom company-frontends '(company-pseudo-tooltip-unless-just-one-frontend + company-preview-if-just-one-frontend + company-echo-metadata-frontend) + "The list of active front-ends (visualizations). +Each front-end is a function that takes one argument. It is called with +one of the following arguments: + +`show': When the visualization should start. + +`hide': When the visualization should end. + +`update': When the data has been updated. + +`pre-command': Before every command that is executed while the +visualization is active. + +`post-command': After every command that is executed while the +visualization is active. + +The visualized data is stored in `company-prefix', `company-candidates', +`company-common', `company-selection', `company-point' and +`company-search-string'." + :set 'company-frontends-set + :type '(repeat (choice (const :tag "echo" company-echo-frontend) + (const :tag "echo, strip common" + company-echo-strip-common-frontend) + (const :tag "show echo meta-data in echo" + company-echo-metadata-frontend) + (const :tag "pseudo tooltip" + company-pseudo-tooltip-frontend) + (const :tag "pseudo tooltip, multiple only" + company-pseudo-tooltip-unless-just-one-frontend) + (const :tag "preview" company-preview-frontend) + (const :tag "preview, unique only" + company-preview-if-just-one-frontend) + (function :tag "custom function" nil)))) + +(defcustom company-tooltip-limit 10 + "The maximum number of candidates in the tooltip." + :type 'integer) + +(defcustom company-tooltip-minimum 6 + "The minimum height of the tooltip. +If this many lines are not available, prefer to display the tooltip above." + :type 'integer) + +(defcustom company-tooltip-minimum-width 0 + "The minimum width of the tooltip's inner area. +This doesn't include the margins and the scroll bar." + :type 'integer + :package-version '(company . "0.8.0")) + +(defcustom company-tooltip-margin 1 + "Width of margin columns to show around the toolip." + :type 'integer) + +(defcustom company-tooltip-offset-display 'scrollbar + "Method using which the tooltip displays scrolling position. +`scrollbar' means draw a scrollbar to the right of the items. +`lines' means wrap items in lines with \"before\" and \"after\" counters." + :type '(choice (const :tag "Scrollbar" scrollbar) + (const :tag "Two lines" lines))) + +(defcustom company-tooltip-align-annotations nil + "When non-nil, align annotations to the right tooltip border." + :type 'boolean + :package-version '(company . "0.7.1")) + +(defcustom company-tooltip-flip-when-above nil + "Whether to flip the tooltip when it's above the current line." + :type 'boolean + :package-version '(company . "0.8.1")) + +(defvar company-safe-backends + '((company-abbrev . "Abbrev") + (company-bbdb . "BBDB") + (company-capf . "completion-at-point-functions") + (company-clang . "Clang") + (company-cmake . "CMake") + (company-css . "CSS") + (company-dabbrev . "dabbrev for plain text") + (company-dabbrev-code . "dabbrev for code") + (company-eclim . "Eclim (an Eclipse interface)") + (company-elisp . "Emacs Lisp") + (company-etags . "etags") + (company-files . "Files") + (company-gtags . "GNU Global") + (company-ispell . "Ispell") + (company-keywords . "Programming language keywords") + (company-nxml . "nxml") + (company-oddmuse . "Oddmuse") + (company-semantic . "Semantic") + (company-tempo . "Tempo templates") + (company-xcode . "Xcode"))) +(put 'company-safe-backends 'risky-local-variable t) + +(defun company-safe-backends-p (backends) + (and (consp backends) + (not (cl-dolist (backend backends) + (unless (if (consp backend) + (company-safe-backends-p backend) + (assq backend company-safe-backends)) + (cl-return t)))))) + +(defcustom company-backends `(,@(unless (version< "24.3.51" emacs-version) + (list 'company-elisp)) + company-bbdb + company-nxml company-css + company-eclim company-semantic company-clang + company-xcode company-cmake + company-capf + (company-dabbrev-code company-gtags company-etags + company-keywords) + company-oddmuse company-files company-dabbrev) + "The list of active back-ends (completion engines). + +Only one back-end is used at a time. The choice depends on the order of +the items in this list, and on the values they return in response to the +`prefix' command (see below). But a back-end can also be a \"grouped\" +one (see below). + +`company-begin-backend' can be used to start a specific back-end, +`company-other-backend' will skip to the next matching back-end in the list. + +Each back-end is a function that takes a variable number of arguments. +The first argument is the command requested from the back-end. It is one +of the following: + +`prefix': The back-end should return the text to be completed. It must be +text immediately before point. Returning nil from this command passes +control to the next back-end. The function should return `stop' if it +should complete but cannot (e.g. if it is in the middle of a string). +Instead of a string, the back-end may return a cons where car is the prefix +and cdr is used instead of the actual prefix length in the comparison +against `company-minimum-prefix-length'. It must be either number or t, +and in the latter case the test automatically succeeds. + +`candidates': The second argument is the prefix to be completed. The +return value should be a list of candidates that match the prefix. + +Non-prefix matches are also supported (candidates that don't start with the +prefix, but match it in some backend-defined way). Backends that use this +feature must disable cache (return t to `no-cache') and might also want to +respond to `match'. + +Optional commands: + +`sorted': Return t here to indicate that the candidates are sorted and will +not need to be sorted again. + +`duplicates': If non-nil, company will take care of removing duplicates +from the list. + +`no-cache': Usually company doesn't ask for candidates again as completion +progresses, unless the back-end returns t for this command. The second +argument is the latest prefix. + +`meta': The second argument is a completion candidate. Return a (short) +documentation string for it. + +`doc-buffer': The second argument is a completion candidate. Return a +buffer with documentation for it. Preferably use `company-doc-buffer', + +`location': The second argument is a completion candidate. Return the cons +of buffer and buffer location, or of file and line number where the +completion candidate was defined. + +`annotation': The second argument is a completion candidate. Return a +string to be displayed inline with the candidate in the popup. If +duplicates are removed by company, candidates with equal string values will +be kept if they have different annotations. For that to work properly, +backends should store the related information on candidates using text +properties. + +`match': The second argument is a completion candidate. Return the index +after the end of text matching `prefix' within the candidate string. It +will be used when rendering the popup. This command only makes sense for +backends that provide non-prefix completion. + +`require-match': If this returns t, the user is not allowed to enter +anything not offered as a candidate. Use with care! The default value nil +gives the user that choice with `company-require-match'. Return value +`never' overrides that option the other way around. + +`init': Called once for each buffer. The back-end can check for external +programs and files and load any required libraries. Raising an error here +will show up in message log once, and the back-end will not be used for +completion. + +`post-completion': Called after a completion candidate has been inserted +into the buffer. The second argument is the candidate. Can be used to +modify it, e.g. to expand a snippet. + +The back-end should return nil for all commands it does not support or +does not know about. It should also be callable interactively and use +`company-begin-backend' to start itself in that case. + +Grouped back-ends: + +An element of `company-backends' can also itself be a list of back-ends, +then it's considered to be a \"grouped\" back-end. + +When possible, commands taking a candidate as an argument are dispatched to +the back-end it came from. In other cases, the first non-nil value among +all the back-ends is returned. + +The latter is the case for the `prefix' command. But if the group contains +the keyword `:with', the back-ends after it are ignored for this command. + +The completions from back-ends in a group are merged (but only from those +that return the same `prefix'). + +Asynchronous back-ends: + +The return value of each command can also be a cons (:async . FETCHER) +where FETCHER is a function of one argument, CALLBACK. When the data +arrives, FETCHER must call CALLBACK and pass it the appropriate return +value, as described above. + +True asynchronous operation is only supported for command `candidates', and +only during idle completion. Other commands will block the user interface, +even if the back-end uses the asynchronous calling convention." + :type `(repeat + (choice + :tag "Back-end" + ,@(mapcar (lambda (b) `(const :tag ,(cdr b) ,(car b))) + company-safe-backends) + (symbol :tag "User defined") + (repeat :tag "Merged Back-ends" + (choice :tag "Back-end" + ,@(mapcar (lambda (b) + `(const :tag ,(cdr b) ,(car b))) + company-safe-backends) + (const :tag "With" :with) + (symbol :tag "User defined")))))) + +(put 'company-backends 'safe-local-variable 'company-safe-backends-p) + +(defcustom company-transformers nil + "Functions to change the list of candidates received from backends. + +Each function gets called with the return value of the previous one. +The first one gets passed the list of candidates, already sorted and +without duplicates." + :type '(choice + (const :tag "None" nil) + (const :tag "Sort by occurrence" (company-sort-by-occurrence)) + (const :tag "Sort by back-end importance" + (company-sort-by-backend-importance)) + (repeat :tag "User defined" (function)))) + +(defcustom company-completion-started-hook nil + "Hook run when company starts completing. +The hook is called with one argument that is non-nil if the completion was +started manually." + :type 'hook) + +(defcustom company-completion-cancelled-hook nil + "Hook run when company cancels completing. +The hook is called with one argument that is non-nil if the completion was +aborted manually." + :type 'hook) + +(defcustom company-completion-finished-hook nil + "Hook run when company successfully completes. +The hook is called with the selected candidate as an argument. + +If you indend to use it to post-process candidates from a specific +back-end, consider using the `post-completion' command instead." + :type 'hook) + +(defcustom company-minimum-prefix-length 3 + "The minimum prefix length for idle completion." + :type '(integer :tag "prefix length")) + +(defcustom company-abort-manual-when-too-short nil + "If enabled, cancel a manually started completion when the prefix gets +shorter than both `company-minimum-prefix-length' and the length of the +prefix it was started from." + :type 'boolean + :package-version '(company . "0.8.0")) + +(defcustom company-require-match 'company-explicit-action-p + "If enabled, disallow non-matching input. +This can be a function do determine if a match is required. + +This can be overridden by the back-end, if it returns t or `never' to +`require-match'. `company-auto-complete' also takes precedence over this." + :type '(choice (const :tag "Off" nil) + (function :tag "Predicate function") + (const :tag "On, if user interaction took place" + 'company-explicit-action-p) + (const :tag "On" t))) + +(defcustom company-auto-complete nil + "Determines when to auto-complete. +If this is enabled, all characters from `company-auto-complete-chars' +trigger insertion of the selected completion candidate. +This can also be a function." + :type '(choice (const :tag "Off" nil) + (function :tag "Predicate function") + (const :tag "On, if user interaction took place" + 'company-explicit-action-p) + (const :tag "On" t))) + +(defcustom company-auto-complete-chars '(?\ ?\) ?.) + "Determines which characters trigger auto-completion. +See `company-auto-complete'. If this is a string, each string character +tiggers auto-completion. If it is a list of syntax description characters (see +`modify-syntax-entry'), all characters with that syntax auto-complete. + +This can also be a function, which is called with the new input and should +return non-nil if company should auto-complete. + +A character that is part of a valid candidate never triggers auto-completion." + :type '(choice (string :tag "Characters") + (set :tag "Syntax" + (const :tag "Whitespace" ?\ ) + (const :tag "Symbol" ?_) + (const :tag "Opening parentheses" ?\() + (const :tag "Closing parentheses" ?\)) + (const :tag "Word constituent" ?w) + (const :tag "Punctuation." ?.) + (const :tag "String quote." ?\") + (const :tag "Paired delimiter." ?$) + (const :tag "Expression quote or prefix operator." ?\') + (const :tag "Comment starter." ?<) + (const :tag "Comment ender." ?>) + (const :tag "Character-quote." ?/) + (const :tag "Generic string fence." ?|) + (const :tag "Generic comment fence." ?!)) + (function :tag "Predicate function"))) + +(defcustom company-idle-delay .5 + "The idle delay in seconds until completion starts automatically. +The prefix still has to satisfy `company-minimum-prefix-length' before that +happens. The value of nil means no idle completion." + :type '(choice (const :tag "never (nil)" nil) + (const :tag "immediate (0)" 0) + (number :tag "seconds"))) + +(defcustom company-begin-commands '(self-insert-command + org-self-insert-command + orgtbl-self-insert-command + c-scope-operator + c-electric-colon + c-electric-lt-gt + c-electric-slash) + "A list of commands after which idle completion is allowed. +If this is t, it can show completions after any command except a few from a +pre-defined list. See `company-idle-delay'. + +Alternatively, any command with a non-nil `company-begin' property is +treated as if it was on this list." + :type '(choice (const :tag "Any command" t) + (const :tag "Self insert command" '(self-insert-command)) + (repeat :tag "Commands" function)) + :package-version '(company . "0.8.4")) + +(defcustom company-continue-commands '(not save-buffer save-some-buffers + save-buffers-kill-terminal + save-buffers-kill-emacs) + "A list of commands that are allowed during completion. +If this is t, or if `company-begin-commands' is t, any command is allowed. +Otherwise, the value must be a list of symbols. If it starts with `not', +the cdr is the list of commands that abort completion. Otherwise, all +commands except those in that list, or in `company-begin-commands', or +commands in the `company-' namespace, abort completion." + :type '(choice (const :tag "Any command" t) + (cons :tag "Any except" + (const not) + (repeat :tag "Commands" function)) + (repeat :tag "Commands" function))) + +(defcustom company-show-numbers nil + "If enabled, show quick-access numbers for the first ten candidates." + :type '(choice (const :tag "off" nil) + (const :tag "on" t))) + +(defcustom company-selection-wrap-around nil + "If enabled, selecting item before first or after last wraps around." + :type '(choice (const :tag "off" nil) + (const :tag "on" t))) + +(defvar company-async-wait 0.03 + "Pause between checks to see if the value's been set when turning an +asynchronous call into synchronous.") + +(defvar company-async-timeout 2 + "Maximum wait time for a value to be set during asynchronous call.") + +;;; mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar company-mode-map (make-sparse-keymap) + "Keymap used by `company-mode'.") + +(defvar company-active-map + (let ((keymap (make-sparse-keymap))) + (define-key keymap "\e\e\e" 'company-abort) + (define-key keymap "\C-g" 'company-abort) + (define-key keymap (kbd "M-n") 'company-select-next) + (define-key keymap (kbd "M-p") 'company-select-previous) + (define-key keymap (kbd "") 'company-select-next-or-abort) + (define-key keymap (kbd "") 'company-select-previous-or-abort) + (define-key keymap [remap scroll-up-command] 'company-next-page) + (define-key keymap [remap scroll-down-command] 'company-previous-page) + (define-key keymap [down-mouse-1] 'ignore) + (define-key keymap [down-mouse-3] 'ignore) + (define-key keymap [mouse-1] 'company-complete-mouse) + (define-key keymap [mouse-3] 'company-select-mouse) + (define-key keymap [up-mouse-1] 'ignore) + (define-key keymap [up-mouse-3] 'ignore) + (define-key keymap [return] 'company-complete-selection) + (define-key keymap (kbd "RET") 'company-complete-selection) + (define-key keymap [tab] 'company-complete-common) + (define-key keymap (kbd "TAB") 'company-complete-common) + (define-key keymap (kbd "") 'company-show-doc-buffer) + (define-key keymap (kbd "C-h") 'company-show-doc-buffer) + (define-key keymap "\C-w" 'company-show-location) + (define-key keymap "\C-s" 'company-search-candidates) + (define-key keymap "\C-\M-s" 'company-filter-candidates) + (dotimes (i 10) + (define-key keymap (read-kbd-macro (format "M-%d" i)) 'company-complete-number)) + keymap) + "Keymap that is enabled during an active completion.") + +(defvar company--disabled-backends nil) + +(defun company-init-backend (backend) + (and (symbolp backend) + (not (fboundp backend)) + (ignore-errors (require backend nil t))) + (cond + ((symbolp backend) + (condition-case err + (progn + (funcall backend 'init) + (put backend 'company-init t)) + (error + (put backend 'company-init 'failed) + (unless (memq backend company--disabled-backends) + (message "Company back-end '%s' could not be initialized:\n%s" + backend (error-message-string err))) + (cl-pushnew backend company--disabled-backends) + nil))) + ;; No initialization for lambdas. + ((functionp backend) t) + (t ;; Must be a list. + (cl-dolist (b backend) + (unless (keywordp b) + (company-init-backend b)))))) + +(defcustom company-lighter-base "company" + "Base string to use for the `company-mode' lighter." + :type 'string + :package-version '(company . "0.8.10")) + +(defvar company-lighter '(" " + (company-candidates + (:eval + (if (consp company-backend) + (company--group-lighter (nth company-selection + company-candidates) + company-lighter-base) + (symbol-name company-backend))) + company-lighter-base)) + "Mode line lighter for Company. + +The value of this variable is a mode line template as in +`mode-line-format'.") + +(put 'company-lighter 'risky-local-variable t) + +;;;###autoload +(define-minor-mode company-mode + "\"complete anything\"; is an in-buffer completion framework. +Completion starts automatically, depending on the values +`company-idle-delay' and `company-minimum-prefix-length'. + +Completion can be controlled with the commands: +`company-complete-common', `company-complete-selection', `company-complete', +`company-select-next', `company-select-previous'. If these commands are +called before `company-idle-delay', completion will also start. + +Completions can be searched with `company-search-candidates' or +`company-filter-candidates'. These can be used while completion is +inactive, as well. + +The completion data is retrieved using `company-backends' and displayed +using `company-frontends'. If you want to start a specific back-end, call +it interactively or use `company-begin-backend'. + +regular keymap (`company-mode-map'): + +\\{company-mode-map} +keymap during active completions (`company-active-map'): + +\\{company-active-map}" + nil company-lighter company-mode-map + (if company-mode + (progn + (when (eq company-idle-delay t) + (setq company-idle-delay 0) + (warn "Setting `company-idle-delay' to t is deprecated. Set it to 0 instead.")) + (add-hook 'pre-command-hook 'company-pre-command nil t) + (add-hook 'post-command-hook 'company-post-command nil t) + (mapc 'company-init-backend company-backends)) + (remove-hook 'pre-command-hook 'company-pre-command t) + (remove-hook 'post-command-hook 'company-post-command t) + (company-cancel) + (kill-local-variable 'company-point))) + +(defcustom company-global-modes t + "Modes for which `company-mode' mode is turned on by `global-company-mode'. +If nil, means no modes. If t, then all major modes have it turned on. +If a list, it should be a list of `major-mode' symbol names for which +`company-mode' should be automatically turned on. The sense of the list is +negated if it begins with `not'. For example: + (c-mode c++-mode) +means that `company-mode' is turned on for buffers in C and C++ modes only. + (not message-mode) +means that `company-mode' is always turned on except in `message-mode' buffers." + :type '(choice (const :tag "none" nil) + (const :tag "all" t) + (set :menu-tag "mode specific" :tag "modes" + :value (not) + (const :tag "Except" not) + (repeat :inline t (symbol :tag "mode"))))) + +;;;###autoload +(define-globalized-minor-mode global-company-mode company-mode company-mode-on) + +(defun company-mode-on () + (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s))) + (cond ((eq company-global-modes t) + t) + ((eq (car-safe company-global-modes) 'not) + (not (memq major-mode (cdr company-global-modes)))) + (t (memq major-mode company-global-modes)))) + (company-mode 1))) + +(defsubst company-assert-enabled () + (unless company-mode + (company-uninstall-map) + (error "Company not enabled"))) + +;;; keymaps ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-my-keymap nil) + +(defvar company-emulation-alist '((t . nil))) + +(defsubst company-enable-overriding-keymap (keymap) + (company-uninstall-map) + (setq company-my-keymap keymap)) + +(defun company-ensure-emulation-alist () + (unless (eq 'company-emulation-alist (car emulation-mode-map-alists)) + (setq emulation-mode-map-alists + (cons 'company-emulation-alist + (delq 'company-emulation-alist emulation-mode-map-alists))))) + +(defun company-install-map () + (unless (or (cdar company-emulation-alist) + (null company-my-keymap)) + (setf (cdar company-emulation-alist) company-my-keymap))) + +(defun company-uninstall-map () + (setf (cdar company-emulation-alist) nil)) + +;; Hack: +;; Emacs calculates the active keymaps before reading the event. That means we +;; cannot change the keymap from a timer. So we send a bogus command. +;; XXX: Even in Emacs 24.4, seems to be needed in the terminal. +(defun company-ignore () + (interactive) + (setq this-command last-command)) + +(global-set-key '[company-dummy-event] 'company-ignore) + +(defun company-input-noop () + (push 'company-dummy-event unread-command-events)) + +(defun company--posn-col-row (posn) + (let ((col (car (posn-col-row posn))) + ;; `posn-col-row' doesn't work well with lines of different height. + ;; `posn-actual-col-row' doesn't handle multiple-width characters. + (row (cdr (posn-actual-col-row posn)))) + (when (and header-line-format (version< emacs-version "24.3.93.3")) + ;; http://debbugs.gnu.org/18384 + (cl-decf row)) + (cons (+ col (window-hscroll)) row))) + +(defun company--col-row (&optional pos) + (company--posn-col-row (posn-at-point pos))) + +(defun company--row (&optional pos) + (cdr (company--col-row pos))) + +;;; backends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-backend nil) + +(defun company-grab (regexp &optional expression limit) + (when (looking-back regexp limit) + (or (match-string-no-properties (or expression 0)) ""))) + +(defun company-grab-line (regexp &optional expression) + (company-grab regexp expression (point-at-bol))) + +(defun company-grab-symbol () + (if (looking-at "\\_>") + (buffer-substring (point) (save-excursion (skip-syntax-backward "w_") + (point))) + (unless (and (char-after) (memq (char-syntax (char-after)) '(?w ?_))) + ""))) + +(defun company-grab-word () + (if (looking-at "\\>") + (buffer-substring (point) (save-excursion (skip-syntax-backward "w") + (point))) + (unless (and (char-after) (eq (char-syntax (char-after)) ?w)) + ""))) + +(defun company-grab-symbol-cons (idle-begin-after-re &optional max-len) + (let ((symbol (company-grab-symbol))) + (when symbol + (save-excursion + (forward-char (- (length symbol))) + (if (looking-back idle-begin-after-re (if max-len + (- (point) max-len) + (line-beginning-position))) + (cons symbol t) + symbol))))) + +(defun company-in-string-or-comment () + (let ((ppss (syntax-ppss))) + (or (car (setq ppss (nthcdr 3 ppss))) + (car (setq ppss (cdr ppss))) + (nth 3 ppss)))) + +(defun company-call-backend (&rest args) + (company--force-sync #'company-call-backend-raw args company-backend)) + +(defun company--force-sync (fun args backend) + (let ((value (apply fun args))) + (if (not (eq (car-safe value) :async)) + value + (let ((res 'trash) + (start (time-to-seconds))) + (funcall (cdr value) + (lambda (result) (setq res result))) + (while (eq res 'trash) + (if (> (- (time-to-seconds) start) company-async-timeout) + (error "Company: Back-end %s async timeout with args %s" + backend args) + (sleep-for company-async-wait))) + res)))) + +(defun company-call-backend-raw (&rest args) + (condition-case-unless-debug err + (if (functionp company-backend) + (apply company-backend args) + (apply #'company--multi-backend-adapter company-backend args)) + (error (error "Company: Back-end %s error \"%s\" with args %s" + company-backend (error-message-string err) args)))) + +(defun company--multi-backend-adapter (backends command &rest args) + (let ((backends (cl-loop for b in backends + when (not (and (symbolp b) + (eq 'failed (get b 'company-init)))) + collect b))) + (setq backends + (if (eq command 'prefix) + (butlast backends (length (member :with backends))) + (delq :with backends))) + (pcase command + (`candidates + (company--multi-backend-adapter-candidates backends (car args))) + (`sorted nil) + (`duplicates t) + ((or `prefix `ignore-case `no-cache `require-match) + (let (value) + (cl-dolist (backend backends) + (when (setq value (company--force-sync + backend (cons command args) backend)) + (cl-return value))))) + (_ + (let ((arg (car args))) + (when (> (length arg) 0) + (let ((backend (or (get-text-property 0 'company-backend arg) + (car backends)))) + (apply backend command args)))))))) + +(defun company--multi-backend-adapter-candidates (backends prefix) + (let ((pairs (cl-loop for backend in (cdr backends) + when (equal (company--prefix-str + (funcall backend 'prefix)) + prefix) + collect (cons (funcall backend 'candidates prefix) + (let ((b backend)) + (lambda (candidates) + (mapcar + (lambda (str) + (propertize str 'company-backend b)) + candidates))))))) + (when (equal (company--prefix-str (funcall (car backends) 'prefix)) prefix) + ;; Small perf optimization: don't tag the candidates received + ;; from the first backend in the group. + (push (cons (funcall (car backends) 'candidates prefix) + 'identity) + pairs)) + (company--merge-async pairs (lambda (values) (apply #'append values))))) + +(defun company--merge-async (pairs merger) + (let ((async (cl-loop for pair in pairs + thereis + (eq :async (car-safe (car pair)))))) + (if (not async) + (funcall merger (cl-loop for (val . mapper) in pairs + collect (funcall mapper val))) + (cons + :async + (lambda (callback) + (let* (lst + (pending (mapcar #'car pairs)) + (finisher (lambda () + (unless pending + (funcall callback + (funcall merger + (nreverse lst))))))) + (dolist (pair pairs) + (push nil lst) + (let* ((cell lst) + (val (car pair)) + (mapper (cdr pair)) + (this-finisher (lambda (res) + (setq pending (delq val pending)) + (setcar cell (funcall mapper res)) + (funcall finisher)))) + (if (not (eq :async (car-safe val))) + (funcall this-finisher val) + (let ((fetcher (cdr val))) + (funcall fetcher this-finisher))))))))))) + +(defun company--prefix-str (prefix) + (or (car-safe prefix) prefix)) + +;;; completion mechanism ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-prefix nil) + +(defvar-local company-candidates nil) + +(defvar-local company-candidates-length nil) + +(defvar-local company-candidates-cache nil) + +(defvar-local company-candidates-predicate nil) + +(defvar-local company-common nil) + +(defvar-local company-selection 0) + +(defvar-local company-selection-changed nil) + +(defvar-local company--manual-action nil + "Non-nil, if manual completion took place.") + +(defvar-local company--manual-prefix nil) + +(defvar company--auto-completion nil + "Non-nil when current candidate is being inserted automatically. +Controlled by `company-auto-complete'.") + +(defvar-local company--point-max nil) + +(defvar-local company-point nil) + +(defvar company-timer nil) + +(defsubst company-strip-prefix (str) + (substring str (length company-prefix))) + +(defun company--insert-candidate (candidate) + (when (> (length candidate) 0) + (setq candidate (substring-no-properties candidate)) + ;; XXX: Return value we check here is subject to change. + (if (eq (company-call-backend 'ignore-case) 'keep-prefix) + (insert (company-strip-prefix candidate)) + (unless (equal company-prefix candidate) + (delete-region (- (point) (length company-prefix)) (point)) + (insert candidate))))) + +(defmacro company-with-candidate-inserted (candidate &rest body) + "Evaluate BODY with CANDIDATE temporarily inserted. +This is a tool for back-ends that need candidates inserted before they +can retrieve meta-data for them." + (declare (indent 1)) + `(let ((inhibit-modification-hooks t) + (inhibit-point-motion-hooks t) + (modified-p (buffer-modified-p))) + (company--insert-candidate ,candidate) + (unwind-protect + (progn ,@body) + (delete-region company-point (point)) + (set-buffer-modified-p modified-p)))) + +(defun company-explicit-action-p () + "Return whether explicit completion action was taken by the user." + (or company--manual-action + company-selection-changed)) + +(defun company-reformat (candidate) + ;; company-ispell needs this, because the results are always lower-case + ;; It's mory efficient to fix it only when they are displayed. + ;; FIXME: Adopt the current text's capitalization instead? + (if (eq (company-call-backend 'ignore-case) 'keep-prefix) + (concat company-prefix (substring candidate (length company-prefix))) + candidate)) + +(defun company--should-complete () + (and (eq company-idle-delay 'now) + (not (or buffer-read-only overriding-terminal-local-map + overriding-local-map)) + ;; Check if in the middle of entering a key combination. + (or (equal (this-command-keys-vector) []) + (not (keymapp (key-binding (this-command-keys-vector))))) + (not (and transient-mark-mode mark-active)))) + +(defun company--should-continue () + (or (eq t company-begin-commands) + (eq t company-continue-commands) + (if (eq 'not (car company-continue-commands)) + (not (memq this-command (cdr company-continue-commands))) + (or (memq this-command company-begin-commands) + (memq this-command company-continue-commands) + (and (symbolp this-command) + (string-match-p "\\`company-" (symbol-name this-command))))))) + +(defun company-call-frontends (command) + (dolist (frontend company-frontends) + (condition-case-unless-debug err + (funcall frontend command) + (error (error "Company: Front-end %s error \"%s\" on command %s" + frontend (error-message-string err) command))))) + +(defun company-set-selection (selection &optional force-update) + (setq selection + (if company-selection-wrap-around + (mod selection company-candidates-length) + (max 0 (min (1- company-candidates-length) selection)))) + (when (or force-update (not (equal selection company-selection))) + (setq company-selection selection + company-selection-changed t) + (company-call-frontends 'update))) + +(defun company--group-lighter (candidate base) + (let ((backend (or (get-text-property 0 'company-backend candidate) + (car company-backend)))) + (when (and backend (symbolp backend)) + (let ((name (replace-regexp-in-string "company-\\|-company" "" + (symbol-name backend)))) + (format "%s-<%s>" base name))))) + +(defun company-update-candidates (candidates) + (setq company-candidates-length (length candidates)) + (if company-selection-changed + ;; Try to restore the selection + (let ((selected (nth company-selection company-candidates))) + (setq company-selection 0 + company-candidates candidates) + (when selected + (catch 'found + (while candidates + (let ((candidate (pop candidates))) + (when (and (string= candidate selected) + (equal (company-call-backend 'annotation candidate) + (company-call-backend 'annotation selected))) + (throw 'found t))) + (cl-incf company-selection)) + (setq company-selection 0 + company-selection-changed nil)))) + (setq company-selection 0 + company-candidates candidates)) + ;; Calculate common. + (let ((completion-ignore-case (company-call-backend 'ignore-case))) + ;; We want to support non-prefix completion, so filtering is the + ;; responsibility of each respective backend, not ours. + ;; On the other hand, we don't want to replace non-prefix input in + ;; `company-complete-common', unless there's only one candidate. + (setq company-common + (if (cdr company-candidates) + (let ((common (try-completion "" company-candidates))) + (when (string-prefix-p company-prefix common + completion-ignore-case) + common)) + (car company-candidates))))) + +(defun company-calculate-candidates (prefix) + (let ((candidates (cdr (assoc prefix company-candidates-cache))) + (ignore-case (company-call-backend 'ignore-case))) + (or candidates + (when company-candidates-cache + (let ((len (length prefix)) + (completion-ignore-case ignore-case) + prev) + (cl-dotimes (i (1+ len)) + (when (setq prev (cdr (assoc (substring prefix 0 (- len i)) + company-candidates-cache))) + (setq candidates (all-completions prefix prev)) + (cl-return t))))) + (progn + ;; No cache match, call the backend. + (setq candidates (company--preprocess-candidates + (company--fetch-candidates prefix))) + ;; Save in cache. + (push (cons prefix candidates) company-candidates-cache))) + ;; Only now apply the predicate and transformers. + (setq candidates (company--postprocess-candidates candidates)) + (when candidates + (if (or (cdr candidates) + (not (eq t (compare-strings (car candidates) nil nil + prefix nil nil ignore-case)))) + candidates + ;; Already completed and unique; don't start. + t)))) + +(defun company--fetch-candidates (prefix) + (let ((c (if company--manual-action + (company-call-backend 'candidates prefix) + (company-call-backend-raw 'candidates prefix))) + res) + (if (not (eq (car c) :async)) + c + (let ((buf (current-buffer)) + (win (selected-window)) + (tick (buffer-chars-modified-tick)) + (pt (point)) + (backend company-backend)) + (funcall + (cdr c) + (lambda (candidates) + (if (not (and candidates (eq res 'done))) + ;; There's no completions to display, + ;; or the fetcher called us back right away. + (setq res candidates) + (setq company-backend backend + company-candidates-cache + (list (cons prefix + (company--preprocess-candidates candidates)))) + (company-idle-begin buf win tick pt))))) + ;; FIXME: Relying on the fact that the callers + ;; will interpret nil as "do nothing" is shaky. + ;; A throw-catch would be one possible improvement. + (or res + (progn (setq res 'done) nil))))) + +(defun company--preprocess-candidates (candidates) + (unless (company-call-backend 'sorted) + (setq candidates (sort candidates 'string<))) + (when (company-call-backend 'duplicates) + (company--strip-duplicates candidates)) + candidates) + +(defun company--postprocess-candidates (candidates) + (when (or company-candidates-predicate company-transformers) + (setq candidates (copy-sequence candidates))) + (when company-candidates-predicate + (setq candidates (cl-delete-if-not company-candidates-predicate candidates))) + (company--transform-candidates candidates)) + +(defun company--strip-duplicates (candidates) + (let ((c2 candidates) + (annos 'unk)) + (while c2 + (setcdr c2 + (let ((str (pop c2))) + (while (let ((str2 (car c2))) + (if (not (equal str str2)) + (progn + (setq annos 'unk) + nil) + (when (eq annos 'unk) + (setq annos (list (company-call-backend + 'annotation str)))) + (let ((anno2 (company-call-backend + 'annotation str2))) + (if (member anno2 annos) + t + (push anno2 annos) + nil)))) + (pop c2)) + c2))))) + +(defun company--transform-candidates (candidates) + (let ((c candidates)) + (dolist (tr company-transformers) + (setq c (funcall tr c))) + c)) + +(defcustom company-occurrence-weight-function + #'company-occurrence-prefer-closest-above + "Function to weigh matches in `company-sort-by-occurrence'. +It's called with three arguments: cursor position, the beginning and the +end of the match." + :type '(choice + (const :tag "First above point, then below point" + company-occurrence-prefer-closest-above) + (const :tag "Prefer closest in any direction" + company-occurrence-prefer-any-closest))) + +(defun company-occurrence-prefer-closest-above (pos match-beg match-end) + "Give priority to the matches above point, then those below point." + (if (< match-beg pos) + (- pos match-end) + (- match-beg (window-start)))) + +(defun company-occurrence-prefer-any-closest (pos _match-beg match-end) + "Give priority to the matches closest to the point." + (abs (- pos match-end))) + +(defun company-sort-by-occurrence (candidates) + "Sort CANDIDATES according to their occurrences. +Searches for each in the currently visible part of the current buffer and +prioritizes the matches according to `company-occurrence-weight-function'. +The rest of the list is appended unchanged. +Keywords and function definition names are ignored." + (let* ((w-start (window-start)) + (w-end (window-end)) + (start-point (point)) + occurs + (noccurs + (save-excursion + (cl-delete-if + (lambda (candidate) + (when (catch 'done + (goto-char w-start) + (while (search-forward candidate w-end t) + (when (and (not (eq (point) start-point)) + (save-match-data + (company--occurrence-predicate))) + (throw 'done t)))) + (push + (cons candidate + (funcall company-occurrence-weight-function + start-point + (match-beginning 0) + (match-end 0))) + occurs) + t)) + candidates)))) + (nconc + (mapcar #'car (sort occurs (lambda (e1 e2) (<= (cdr e1) (cdr e2))))) + noccurs))) + +(defun company--occurrence-predicate () + (let ((beg (match-beginning 0)) + (end (match-end 0))) + (save-excursion + (goto-char end) + (and (not (memq (get-text-property (1- (point)) 'face) + '(font-lock-function-name-face + font-lock-keyword-face))) + (let ((prefix (company--prefix-str + (company-call-backend 'prefix)))) + (and (stringp prefix) + (= (length prefix) (- end beg)))))))) + +(defun company-sort-by-backend-importance (candidates) + "Sort CANDIDATES as two priority groups. +If `company-backend' is a function, do nothing. If it's a list, move +candidates from back-ends before keyword `:with' to the front. Candidates +from the rest of the back-ends in the group, if any, will be left at the end." + (if (functionp company-backend) + candidates + (let ((low-priority (cdr (memq :with company-backend)))) + (if (null low-priority) + candidates + (sort candidates + (lambda (c1 c2) + (and + (let ((b2 (get-text-property 0 'company-backend c2))) + (and b2 (memq b2 low-priority))) + (let ((b1 (get-text-property 0 'company-backend c1))) + (or (not b1) (not (memq b1 low-priority))))))))))) + +(defun company-idle-begin (buf win tick pos) + (and (eq buf (current-buffer)) + (eq win (selected-window)) + (eq tick (buffer-chars-modified-tick)) + (eq pos (point)) + (when (company-auto-begin) + (company-input-noop) + (let ((this-command 'company-idle-begin)) + (company-post-command))))) + +(defun company-auto-begin () + (and company-mode + (not company-candidates) + (let ((company-idle-delay 'now)) + (condition-case-unless-debug err + (progn + (company--perform) + ;; Return non-nil if active. + company-candidates) + (error (message "Company: An error occurred in auto-begin") + (message "%s" (error-message-string err)) + (company-cancel)) + (quit (company-cancel)))))) + +(defun company-manual-begin () + (interactive) + (company-assert-enabled) + (setq company--manual-action t) + (unwind-protect + (let ((company-minimum-prefix-length 0)) + (or company-candidates + (company-auto-begin))) + (unless company-candidates + (setq company--manual-action nil)))) + +(defun company-other-backend (&optional backward) + (interactive (list current-prefix-arg)) + (company-assert-enabled) + (let* ((after (if company-backend + (cdr (member company-backend company-backends)) + company-backends)) + (before (cdr (member company-backend (reverse company-backends)))) + (next (if backward + (append before (reverse after)) + (append after (reverse before))))) + (company-cancel) + (cl-dolist (backend next) + (when (ignore-errors (company-begin-backend backend)) + (cl-return t)))) + (unless company-candidates + (error "No other back-end"))) + +(defun company-require-match-p () + (let ((backend-value (company-call-backend 'require-match))) + (or (eq backend-value t) + (and (not (eq backend-value 'never)) + (if (functionp company-require-match) + (funcall company-require-match) + (eq company-require-match t)))))) + +(defun company-auto-complete-p (input) + "Return non-nil, if input starts with punctuation or parentheses." + (and (if (functionp company-auto-complete) + (funcall company-auto-complete) + company-auto-complete) + (if (functionp company-auto-complete-chars) + (funcall company-auto-complete-chars input) + (if (consp company-auto-complete-chars) + (memq (char-syntax (string-to-char input)) + company-auto-complete-chars) + (string-match (substring input 0 1) company-auto-complete-chars))))) + +(defun company--incremental-p () + (and (> (point) company-point) + (> (point-max) company--point-max) + (not (eq this-command 'backward-delete-char-untabify)) + (equal (buffer-substring (- company-point (length company-prefix)) + company-point) + company-prefix))) + +(defun company--continue-failed (new-prefix) + (let ((input (buffer-substring-no-properties (point) company-point))) + (cond + ((company-auto-complete-p input) + ;; auto-complete + (save-excursion + (goto-char company-point) + (let ((company--auto-completion t)) + (company-complete-selection)) + nil)) + ((and (or (not (company-require-match-p)) + ;; Don't require match if the new prefix + ;; doesn't continue the old one, and the latter was a match. + (not (stringp new-prefix)) + (<= (length new-prefix) (length company-prefix))) + (member company-prefix company-candidates)) + ;; Last input was a success, + ;; but we're treating it as an abort + input anyway, + ;; like the `unique' case below. + (company-cancel 'non-unique)) + ((company-require-match-p) + ;; Wrong incremental input, but required match. + (delete-char (- (length input))) + (ding) + (message "Matching input is required") + company-candidates) + (t (company-cancel))))) + +(defun company--good-prefix-p (prefix) + (and (stringp (company--prefix-str prefix)) ;excludes 'stop + (or (eq (cdr-safe prefix) t) + (let ((len (or (cdr-safe prefix) (length prefix)))) + (if company--manual-prefix + (or (not company-abort-manual-when-too-short) + ;; Must not be less than minimum or initial length. + (>= len (min company-minimum-prefix-length + (length company--manual-prefix)))) + (>= len company-minimum-prefix-length)))))) + +(defun company--continue () + (when (company-call-backend 'no-cache company-prefix) + ;; Don't complete existing candidates, fetch new ones. + (setq company-candidates-cache nil)) + (let* ((new-prefix (company-call-backend 'prefix)) + (c (when (and (company--good-prefix-p new-prefix) + (setq new-prefix (company--prefix-str new-prefix)) + (= (- (point) (length new-prefix)) + (- company-point (length company-prefix)))) + (company-calculate-candidates new-prefix)))) + (cond + ((eq c t) + ;; t means complete/unique. + ;; Handle it like completion was aborted, to differentiate from user + ;; calling one of Company's commands to insert the candidate, + ;; not to trigger template expansion, etc. + (company-cancel 'unique)) + ((consp c) + ;; incremental match + (setq company-prefix new-prefix) + (company-update-candidates c) + c) + ((not (company--incremental-p)) + (company-cancel)) + (t (company--continue-failed new-prefix))))) + +(defun company--begin-new () + (let (prefix c) + (cl-dolist (backend (if company-backend + ;; prefer manual override + (list company-backend) + company-backends)) + (setq prefix + (if (or (symbolp backend) + (functionp backend)) + (when (or (not (symbolp backend)) + (eq t (get backend 'company-init)) + (unless (get backend 'company-init) + (company-init-backend backend))) + (funcall backend 'prefix)) + (company--multi-backend-adapter backend 'prefix))) + (when prefix + (when (company--good-prefix-p prefix) + (setq company-prefix (company--prefix-str prefix) + company-backend backend + c (company-calculate-candidates company-prefix)) + ;; t means complete/unique. We don't start, so no hooks. + (if (not (consp c)) + (when company--manual-action + (message "No completion found")) + (when company--manual-action + (setq company--manual-prefix prefix)) + (company-update-candidates c) + (run-hook-with-args 'company-completion-started-hook + (company-explicit-action-p)) + (company-call-frontends 'show))) + (cl-return c))))) + +(defun company--perform () + (or (and company-candidates (company--continue)) + (and (company--should-complete) (company--begin-new))) + (if (not company-candidates) + (setq company-backend nil) + (setq company-point (point) + company--point-max (point-max)) + (company-ensure-emulation-alist) + (company-enable-overriding-keymap company-active-map) + (company-call-frontends 'update))) + +(defun company-cancel (&optional result) + (unwind-protect + (when company-prefix + (if (stringp result) + (progn + (company-call-backend 'pre-completion result) + (run-hook-with-args 'company-completion-finished-hook result) + (company-call-backend 'post-completion result)) + (run-hook-with-args 'company-completion-cancelled-hook result))) + (setq company-backend nil + company-prefix nil + company-candidates nil + company-candidates-length nil + company-candidates-cache nil + company-candidates-predicate nil + company-common nil + company-selection 0 + company-selection-changed nil + company--manual-action nil + company--manual-prefix nil + company--point-max nil + company-point nil) + (when company-timer + (cancel-timer company-timer)) + (company-search-mode 0) + (company-call-frontends 'hide) + (company-enable-overriding-keymap nil)) + ;; Make return value explicit. + nil) + +(defun company-abort () + (interactive) + (company-cancel 'abort)) + +(defun company-finish (result) + (company--insert-candidate result) + (company-cancel result)) + +(defsubst company-keep (command) + (and (symbolp command) (get command 'company-keep))) + +(defun company-pre-command () + (unless (company-keep this-command) + (condition-case-unless-debug err + (when company-candidates + (company-call-frontends 'pre-command) + (unless (company--should-continue) + (company-abort))) + (error (message "Company: An error occurred in pre-command") + (message "%s" (error-message-string err)) + (company-cancel)))) + (when company-timer + (cancel-timer company-timer) + (setq company-timer nil)) + (company-uninstall-map)) + +(defun company-post-command () + (when (null this-command) + ;; Happens when the user presses `C-g' while inside + ;; `flyspell-post-command-hook', for example. + ;; Or any other `post-command-hook' function that can call `sit-for', + ;; or any quittable timer function. + (company-abort) + (setq this-command 'company-abort)) + (unless (company-keep this-command) + (condition-case-unless-debug err + (progn + (unless (equal (point) company-point) + (let (company-idle-delay) ; Against misbehavior while debugging. + (company--perform))) + (if company-candidates + (company-call-frontends 'post-command) + (and (numberp company-idle-delay) + (company--should-begin) + (setq company-timer + (run-with-timer company-idle-delay nil + 'company-idle-begin + (current-buffer) (selected-window) + (buffer-chars-modified-tick) (point)))))) + (error (message "Company: An error occurred in post-command") + (message "%s" (error-message-string err)) + (company-cancel)))) + (company-install-map)) + +(defvar company--begin-inhibit-commands '(company-abort + company-complete-mouse + company-complete + company-complete-common + company-complete-selection + company-complete-number) + "List of commands after which idle completion is (still) disabled when +`company-begin-commands' is t.") + +(defun company--should-begin () + (if (eq t company-begin-commands) + (not (memq this-command company--begin-inhibit-commands)) + (or + (memq this-command company-begin-commands) + (and (symbolp this-command) (get this-command 'company-begin))))) + +;;; search ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-search-string "") + +(defvar company-search-lighter '(" " + (company-search-filtering "Filter" "Search") + ": \"" + company-search-string + "\"")) + +(defvar-local company-search-filtering nil + "Non-nil to filter the completion candidates by the search string") + +(defvar-local company--search-old-selection 0) + +(defvar-local company--search-old-changed nil) + +(defun company--search (text lines) + (let ((quoted (regexp-quote text)) + (i 0)) + (cl-dolist (line lines) + (when (string-match quoted line (length company-prefix)) + (cl-return i)) + (cl-incf i)))) + +(defun company-search-keypad () + (interactive) + (let* ((name (symbol-name last-command-event)) + (last-command-event (aref name (1- (length name))))) + (company-search-printing-char))) + +(defun company-search-printing-char () + (interactive) + (company--search-assert-enabled) + (let ((ss (concat company-search-string (string last-command-event)))) + (when company-search-filtering + (company--search-update-predicate ss)) + (company--search-update-string ss))) + +(defun company--search-update-predicate (&optional ss) + (let* ((company-candidates-predicate + (and (not (string= ss "")) + company-search-filtering + (lambda (candidate) (string-match ss candidate)))) + (cc (company-calculate-candidates company-prefix))) + (unless cc (error "No match")) + (company-update-candidates cc))) + +(defun company--search-update-string (new) + (let* ((pos (company--search new (nthcdr company-selection company-candidates)))) + (if (null pos) + (ding) + (setq company-search-string new) + (company-set-selection (+ company-selection pos) t)))) + +(defun company--search-assert-input () + (company--search-assert-enabled) + (when (string= company-search-string "") + (error "Empty search string"))) + +(defun company-search-repeat-forward () + "Repeat the incremental search in completion candidates forward." + (interactive) + (company--search-assert-input) + (let ((pos (company--search company-search-string + (cdr (nthcdr company-selection + company-candidates))))) + (if (null pos) + (ding) + (company-set-selection (+ company-selection pos 1) t)))) + +(defun company-search-repeat-backward () + "Repeat the incremental search in completion candidates backwards." + (interactive) + (company--search-assert-input) + (let ((pos (company--search company-search-string + (nthcdr (- company-candidates-length + company-selection) + (reverse company-candidates))))) + (if (null pos) + (ding) + (company-set-selection (- company-selection pos 1) t)))) + +(defun company-search-toggle-filtering () + "Toggle `company-search-filtering'." + (interactive) + (company--search-assert-enabled) + (setq company-search-filtering (not company-search-filtering)) + (let ((ss company-search-string)) + (company--search-update-predicate ss) + (company--search-update-string ss))) + +(defun company-search-abort () + "Abort searching the completion candidates." + (interactive) + (company--search-assert-enabled) + (company-search-mode 0) + (company-set-selection company--search-old-selection t) + (setq company-selection-changed company--search-old-changed)) + +(defun company-search-other-char () + (interactive) + (company--search-assert-enabled) + (company-search-mode 0) + (company--unread-last-input)) + +(defun company-search-delete-char () + (interactive) + (company--search-assert-enabled) + (if (string= company-search-string "") + (ding) + (let ((ss (substring company-search-string 0 -1))) + (when company-search-filtering + (company--search-update-predicate ss)) + (company--search-update-string ss)))) + +(defvar company-search-map + (let ((i 0) + (keymap (make-keymap))) + (if (fboundp 'max-char) + (set-char-table-range (nth 1 keymap) (cons #x100 (max-char)) + 'company-search-printing-char) + (with-no-warnings + ;; obsolete in Emacs 23 + (let ((l (generic-character-list)) + (table (nth 1 keymap))) + (while l + (set-char-table-default table (car l) 'company-search-printing-char) + (setq l (cdr l)))))) + (define-key keymap [t] 'company-search-other-char) + (while (< i ?\s) + (define-key keymap (make-string 1 i) 'company-search-other-char) + (cl-incf i)) + (while (< i 256) + (define-key keymap (vector i) 'company-search-printing-char) + (cl-incf i)) + (dotimes (i 10) + (define-key keymap (read (format "[kp-%s]" i)) 'company-search-keypad)) + (let ((meta-map (make-sparse-keymap))) + (define-key keymap (char-to-string meta-prefix-char) meta-map) + (define-key keymap [escape] meta-map)) + (define-key keymap (vector meta-prefix-char t) 'company-search-other-char) + (define-key keymap (kbd "M-n") 'company-select-next) + (define-key keymap (kbd "M-p") 'company-select-previous) + (define-key keymap (kbd "") 'company-select-next-or-abort) + (define-key keymap (kbd "") 'company-select-previous-or-abort) + (define-key keymap "\e\e\e" 'company-search-other-char) + (define-key keymap [escape escape escape] 'company-search-other-char) + (define-key keymap (kbd "DEL") 'company-search-delete-char) + (define-key keymap [backspace] 'company-search-delete-char) + (define-key keymap "\C-g" 'company-search-abort) + (define-key keymap "\C-s" 'company-search-repeat-forward) + (define-key keymap "\C-r" 'company-search-repeat-backward) + (define-key keymap "\C-o" 'company-search-toggle-filtering) + (dotimes (i 10) + (define-key keymap (read-kbd-macro (format "M-%d" i)) 'company-complete-number)) + keymap) + "Keymap used for incrementally searching the completion candidates.") + +(define-minor-mode company-search-mode + "Search mode for completion candidates. +Don't start this directly, use `company-search-candidates' or +`company-filter-candidates'." + nil company-search-lighter nil + (if company-search-mode + (if (company-manual-begin) + (progn + (setq company--search-old-selection company-selection + company--search-old-changed company-selection-changed) + (company-call-frontends 'update) + (company-enable-overriding-keymap company-search-map)) + (setq company-search-mode nil)) + (kill-local-variable 'company-search-string) + (kill-local-variable 'company-search-filtering) + (kill-local-variable 'company--search-old-selection) + (kill-local-variable 'company--search-old-changed) + (when company-backend + (company--search-update-predicate "") + (company-call-frontends 'update)) + (company-enable-overriding-keymap company-active-map))) + +(defun company--search-assert-enabled () + (company-assert-enabled) + (unless company-search-mode + (company-uninstall-map) + (error "Company not in search mode"))) + +(defun company-search-candidates () + "Start searching the completion candidates incrementally. + +\\Search can be controlled with the commands: +- `company-search-repeat-forward' (\\[company-search-repeat-forward]) +- `company-search-repeat-backward' (\\[company-search-repeat-backward]) +- `company-search-abort' (\\[company-search-abort]) +- `company-search-delete-char' (\\[company-search-delete-char]) + +Regular characters are appended to the search string. + +The command `company-search-toggle-filtering' (\\[company-search-toggle-filtering]) +uses the search string to filter the completion candidates." + (interactive) + (company-search-mode 1)) + +(defvar company-filter-map + (let ((keymap (make-keymap))) + (define-key keymap [remap company-search-printing-char] + 'company-filter-printing-char) + (set-keymap-parent keymap company-search-map) + keymap) + "Keymap used for incrementally searching the completion candidates.") + +(defun company-filter-candidates () + "Start filtering the completion candidates incrementally. +This works the same way as `company-search-candidates' immediately +followed by `company-search-toggle-filtering'." + (interactive) + (company-search-mode 1) + (setq company-search-filtering t)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-select-next (&optional arg) + "Select the next candidate in the list. + +With ARG, move by that many elements." + (interactive "p") + (when (company-manual-begin) + (company-set-selection (+ (or arg 1) company-selection)))) + +(defun company-select-previous (&optional arg) + "Select the previous candidate in the list. + +With ARG, move by that many elements." + (interactive "p") + (company-select-next (if arg (- arg) -1))) + +(defun company-select-next-or-abort (&optional arg) + "Select the next candidate if more than one, else abort +and invoke the normal binding. + +With ARG, move by that many elements." + (interactive "p") + (if (> company-candidates-length 1) + (company-select-next arg) + (company-abort) + (company--unread-last-input))) + +(defun company-select-previous-or-abort (&optional arg) + "Select the previous candidate if more than one, else abort +and invoke the normal binding. + +With ARG, move by that many elements." + (interactive "p") + (if (> company-candidates-length 1) + (company-select-previous arg) + (company-abort) + (company--unread-last-input))) + +(defun company-next-page () + "Select the candidate one page further." + (interactive) + (when (company-manual-begin) + (company-set-selection (+ company-selection + company-tooltip-limit)))) + +(defun company-previous-page () + "Select the candidate one page earlier." + (interactive) + (when (company-manual-begin) + (company-set-selection (- company-selection + company-tooltip-limit)))) + +(defvar company-pseudo-tooltip-overlay) + +(defvar company-tooltip-offset) + +(defun company--inside-tooltip-p (event-col-row row height) + (let* ((ovl company-pseudo-tooltip-overlay) + (column (overlay-get ovl 'company-column)) + (width (overlay-get ovl 'company-width)) + (evt-col (car event-col-row)) + (evt-row (cdr event-col-row))) + (and (>= evt-col column) + (< evt-col (+ column width)) + (if (> height 0) + (and (> evt-row row) + (<= evt-row (+ row height) )) + (and (< evt-row row) + (>= evt-row (+ row height))))))) + +(defun company--event-col-row (event) + (company--posn-col-row (event-start event))) + +(defun company-select-mouse (event) + "Select the candidate picked by the mouse." + (interactive "e") + (let ((event-col-row (company--event-col-row event)) + (ovl-row (company--row)) + (ovl-height (and company-pseudo-tooltip-overlay + (min (overlay-get company-pseudo-tooltip-overlay + 'company-height) + company-candidates-length)))) + (if (and ovl-height + (company--inside-tooltip-p event-col-row ovl-row ovl-height)) + (progn + (company-set-selection (+ (cdr event-col-row) + (1- company-tooltip-offset) + (if (and (eq company-tooltip-offset-display 'lines) + (not (zerop company-tooltip-offset))) + -1 0) + (- ovl-row) + (if (< ovl-height 0) + (- 1 ovl-height) + 0))) + t) + (company-abort) + (company--unread-last-input) + nil))) + +(defun company-complete-mouse (event) + "Insert the candidate picked by the mouse." + (interactive "e") + (when (company-select-mouse event) + (company-complete-selection))) + +(defun company-complete-selection () + "Insert the selected candidate." + (interactive) + (when (company-manual-begin) + (let ((result (nth company-selection company-candidates))) + (company-finish result)))) + +(defun company-complete-common () + "Insert the common part of all candidates." + (interactive) + (when (company-manual-begin) + (if (and (not (cdr company-candidates)) + (equal company-common (car company-candidates))) + (company-complete-selection) + (company--insert-candidate company-common)))) + +(defun company-complete-common-or-cycle (&optional arg) + "Insert the common part of all candidates, or select the next one. + +With ARG, move by that many elements." + (interactive "p") + (when (company-manual-begin) + (let ((tick (buffer-chars-modified-tick))) + (call-interactively 'company-complete-common) + (when (eq tick (buffer-chars-modified-tick)) + (let ((company-selection-wrap-around t) + (current-prefix-arg arg)) + (call-interactively 'company-select-next)))))) + +(defun company-complete () + "Insert the common part of all candidates or the current selection. +The first time this is called, the common part is inserted, the second +time, or when the selection has been changed, the selected candidate is +inserted." + (interactive) + (when (company-manual-begin) + (if (or company-selection-changed + (eq last-command 'company-complete-common)) + (call-interactively 'company-complete-selection) + (call-interactively 'company-complete-common) + (setq this-command 'company-complete-common)))) + +(defun company-complete-number (n) + "Insert the Nth candidate visible in the tooltip. +To show the number next to the candidates in some back-ends, enable +`company-show-numbers'. When called interactively, uses the last typed +character, stripping the modifiers. That character must be a digit." + (interactive + (list (let* ((type (event-basic-type last-command-event)) + (char (if (characterp type) + ;; Number on the main row. + type + ;; Keypad number, if bound directly. + (car (last (string-to-list (symbol-name type)))))) + (n (- char ?0))) + (if (zerop n) 10 n)))) + (when (company-manual-begin) + (and (or (< n 1) (> n (- company-candidates-length + company-tooltip-offset))) + (error "No candidate number %d" n)) + (cl-decf n) + (company-finish (nth (+ n company-tooltip-offset) + company-candidates)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defconst company-space-strings-limit 100) + +(defconst company-space-strings + (let (lst) + (dotimes (i company-space-strings-limit) + (push (make-string (- company-space-strings-limit 1 i) ?\ ) lst)) + (apply 'vector lst))) + +(defun company-space-string (len) + (if (< len company-space-strings-limit) + (aref company-space-strings len) + (make-string len ?\ ))) + +(defun company-safe-substring (str from &optional to) + (if (> from (string-width str)) + "" + (with-temp-buffer + (insert str) + (move-to-column from) + (let ((beg (point))) + (if to + (progn + (move-to-column to) + (concat (buffer-substring beg (point)) + (let ((padding (- to (current-column)))) + (when (> padding 0) + (company-space-string padding))))) + (buffer-substring beg (point-max))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-last-metadata nil) + +(defun company-fetch-metadata () + (let ((selected (nth company-selection company-candidates))) + (unless (eq selected (car company-last-metadata)) + (setq company-last-metadata + (cons selected (company-call-backend 'meta selected)))) + (cdr company-last-metadata))) + +(defun company-doc-buffer (&optional string) + (with-current-buffer (get-buffer-create "*company-documentation*") + (erase-buffer) + (when string + (save-excursion + (insert string))) + (current-buffer))) + +(defvar company--electric-commands + '(scroll-other-window scroll-other-window-down mwheel-scroll) + "List of Commands that won't break out of electric commands.") + +(defmacro company--electric-do (&rest body) + (declare (indent 0) (debug t)) + `(when (company-manual-begin) + (save-window-excursion + (let ((height (window-height)) + (row (company--row)) + cmd) + ,@body + (and (< (window-height) height) + (< (- (window-height) row 2) company-tooltip-limit) + (recenter (- (window-height) row 2))) + (while (memq (setq cmd (key-binding (read-key-sequence-vector nil))) + company--electric-commands) + (condition-case err + (call-interactively cmd) + ((beginning-of-buffer end-of-buffer) + (message (error-message-string err))))) + (company--unread-last-input))))) + +(defun company--unread-last-input () + (when last-input-event + (clear-this-command-keys t) + (setq unread-command-events (list last-input-event)))) + +(defun company-show-doc-buffer () + "Temporarily show the documentation buffer for the selection." + (interactive) + (let (other-window-scroll-buffer) + (company--electric-do + (let* ((selected (nth company-selection company-candidates)) + (doc-buffer (or (company-call-backend 'doc-buffer selected) + (error "No documentation available")))) + (setq other-window-scroll-buffer (get-buffer doc-buffer)) + (with-current-buffer doc-buffer + (goto-char (point-min))) + (display-buffer doc-buffer t))))) +(put 'company-show-doc-buffer 'company-keep t) + +(defun company-show-location () + "Temporarily display a buffer showing the selected candidate in context." + (interactive) + (let (other-window-scroll-buffer) + (company--electric-do + (let* ((selected (nth company-selection company-candidates)) + (location (company-call-backend 'location selected)) + (pos (or (cdr location) (error "No location available"))) + (buffer (or (and (bufferp (car location)) (car location)) + (find-file-noselect (car location) t)))) + (setq other-window-scroll-buffer (get-buffer buffer)) + (with-selected-window (display-buffer buffer t) + (save-restriction + (widen) + (if (bufferp (car location)) + (goto-char pos) + (goto-char (point-min)) + (forward-line (1- pos)))) + (set-window-start nil (point))))))) +(put 'company-show-location 'company-keep t) + +;;; package functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-callback nil) + +(defun company-remove-callback (&optional ignored) + (remove-hook 'company-completion-finished-hook company-callback t) + (remove-hook 'company-completion-cancelled-hook 'company-remove-callback t) + (remove-hook 'company-completion-finished-hook 'company-remove-callback t)) + +(defun company-begin-backend (backend &optional callback) + "Start a completion at point using BACKEND." + (interactive (let ((val (completing-read "Company back-end: " + obarray + 'functionp nil "company-"))) + (when val + (list (intern val))))) + (when (setq company-callback callback) + (add-hook 'company-completion-finished-hook company-callback nil t)) + (add-hook 'company-completion-cancelled-hook 'company-remove-callback nil t) + (add-hook 'company-completion-finished-hook 'company-remove-callback nil t) + (setq company-backend backend) + ;; Return non-nil if active. + (or (company-manual-begin) + (error "Cannot complete at point"))) + +(defun company-begin-with (candidates + &optional prefix-length require-match callback) + "Start a completion at point. +CANDIDATES is the list of candidates to use and PREFIX-LENGTH is the length +of the prefix that already is in the buffer before point. +It defaults to 0. + +CALLBACK is a function called with the selected result if the user +successfully completes the input. + +Example: \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)" + (let ((begin-marker (copy-marker (point) t))) + (company-begin-backend + (lambda (command &optional arg &rest ignored) + (pcase command + (`prefix + (when (equal (point) (marker-position begin-marker)) + (buffer-substring (- (point) (or prefix-length 0)) (point)))) + (`candidates + (all-completions arg candidates)) + (`require-match + require-match))) + callback))) + +(defun company-version (&optional show-version) + "Get the Company version as string. + +If SHOW-VERSION is non-nil, show the version in the echo area." + (interactive (list t)) + (with-temp-buffer + (require 'find-func) + (insert-file-contents (find-library-name "company")) + (require 'lisp-mnt) + (if show-version + (message "Company version: %s" (lm-version)) + (lm-version)))) + +(defun company-diag () + "Pop a buffer with information about completions at point." + (interactive) + (let* ((bb company-backends) + backend + (prefix (cl-loop for b in bb + thereis (let ((company-backend b)) + (setq backend b) + (company-call-backend 'prefix)))) + cc annotations) + (when (stringp prefix) + (let ((company-backend backend)) + (setq cc (company-call-backend 'candidates prefix) + annotations + (mapcar + (lambda (c) (cons c (company-call-backend 'annotation c))) + cc)))) + (pop-to-buffer (get-buffer-create "*company-diag*")) + (setq buffer-read-only nil) + (erase-buffer) + (insert (format "Emacs %s (%s) of %s on %s" + emacs-version system-configuration + (format-time-string "%Y-%m-%d" emacs-build-time) + emacs-build-system)) + (insert "\nCompany " (company-version) "\n\n") + (insert "company-backends: " (pp-to-string bb)) + (insert "\n") + (insert "Used backend: " (pp-to-string backend)) + (insert "\n") + (insert "Prefix: " (pp-to-string prefix)) + (insert "\n") + (insert (message "Completions:")) + (unless cc (insert " none")) + (save-excursion + (dolist (c annotations) + (insert "\n " (prin1-to-string (car c))) + (when (cdr c) + (insert " " (prin1-to-string (cdr c)))))) + (special-mode))) + +;;; pseudo-tooltip ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-pseudo-tooltip-overlay nil) + +(defvar-local company-tooltip-offset 0) + +(defun company-tooltip--lines-update-offset (selection num-lines limit) + (cl-decf limit 2) + (setq company-tooltip-offset + (max (min selection company-tooltip-offset) + (- selection -1 limit))) + + (when (<= company-tooltip-offset 1) + (cl-incf limit) + (setq company-tooltip-offset 0)) + + (when (>= company-tooltip-offset (- num-lines limit 1)) + (cl-incf limit) + (when (= selection (1- num-lines)) + (cl-decf company-tooltip-offset) + (when (<= company-tooltip-offset 1) + (setq company-tooltip-offset 0) + (cl-incf limit)))) + + limit) + +(defun company-tooltip--simple-update-offset (selection _num-lines limit) + (setq company-tooltip-offset + (if (< selection company-tooltip-offset) + selection + (max company-tooltip-offset + (- selection limit -1))))) + +;;; propertize + +(defsubst company-round-tab (arg) + (* (/ (+ arg tab-width) tab-width) tab-width)) + +(defun company-plainify (str) + (let ((prefix (get-text-property 0 'line-prefix str))) + (when prefix ; Keep the original value unmodified, for no special reason. + (setq str (concat prefix str)) + (remove-text-properties 0 (length str) '(line-prefix) str))) + (let* ((pieces (split-string str "\t")) + (copy pieces)) + (while (cdr copy) + (setcar copy (company-safe-substring + (car copy) 0 (company-round-tab (string-width (car copy))))) + (pop copy)) + (apply 'concat pieces))) + +(defun company-fill-propertize (value annotation width selected left right) + (let* ((margin (length left)) + (common (or (company-call-backend 'match value) + (if company-common + (string-width company-common) + 0))) + (ann-ralign company-tooltip-align-annotations) + (ann-truncate (< width + (+ (length value) (length annotation) + (if ann-ralign 1 0)))) + (ann-start (+ margin + (if ann-ralign + (if ann-truncate + (1+ (length value)) + (- width (length annotation))) + (length value)))) + (ann-end (min (+ ann-start (length annotation)) (+ margin width))) + (line (concat left + (if (or ann-truncate (not ann-ralign)) + (company-safe-substring + (concat value + (when (and annotation ann-ralign) " ") + annotation) + 0 width) + (concat + (company-safe-substring value 0 + (- width (length annotation))) + annotation)) + right))) + (setq common (+ (min common width) margin)) + (setq width (+ width margin (length right))) + + (add-text-properties 0 width '(face company-tooltip + mouse-face company-tooltip-mouse) + line) + (add-text-properties margin common + '(face company-tooltip-common + mouse-face company-tooltip-mouse) + line) + (when (< ann-start ann-end) + (add-text-properties ann-start ann-end + '(face company-tooltip-annotation + mouse-face company-tooltip-mouse) + line)) + (when selected + (if (and (not (string= company-search-string "")) + (string-match (regexp-quote company-search-string) value + (length company-prefix))) + (let ((beg (+ margin (match-beginning 0))) + (end (+ margin (match-end 0))) + (width (- width (length right)))) + (when (< beg width) + (add-text-properties beg (min end width) + '(face company-tooltip-search) + line))) + (add-text-properties 0 width '(face company-tooltip-selection + mouse-face company-tooltip-selection) + line) + (add-text-properties margin common + '(face company-tooltip-common-selection + mouse-face company-tooltip-selection) + line))) + line)) + +(defun company--clean-string (str) + (replace-regexp-in-string + "\\([^[:graph:] ]\\)\\|\\(\ufeff\\)\\|[[:multibyte:]]" + (lambda (match) + (cond + ((match-beginning 1) + ;; FIXME: Better char for 'non-printable'? + ;; We shouldn't get any of these, but sometimes we might. + "\u2017") + ((match-beginning 2) + ;; Zero-width non-breakable space. + "") + ((> (string-width match) 1) + (concat + (make-string (1- (string-width match)) ?\ufeff) + match)) + (t match))) + str)) + +;;; replace + +(defun company-buffer-lines (beg end) + (goto-char beg) + (let (lines lines-moved) + (while (and (not (eobp)) ; http://debbugs.gnu.org/19553 + (> (setq lines-moved (vertical-motion 1)) 0) + (<= (point) end)) + (let ((bound (min end (1- (point))))) + ;; A visual line can contain several physical lines (e.g. with outline's + ;; folding overlay). Take only the first one. + (push (buffer-substring beg + (save-excursion + (goto-char beg) + (re-search-forward "$" bound 'move) + (point))) + lines)) + ;; One physical line can be displayed as several visual ones as well: + ;; add empty strings to the list, to even the count. + (dotimes (_ (1- lines-moved)) + (push "" lines)) + (setq beg (point))) + (unless (eq beg end) + (push (buffer-substring beg end) lines)) + (nreverse lines))) + +(defun company-modify-line (old new offset) + (concat (company-safe-substring old 0 offset) + new + (company-safe-substring old (+ offset (length new))))) + +(defsubst company--length-limit (lst limit) + (if (nthcdr limit lst) + limit + (length lst))) + +(defsubst company--window-height () + (if (fboundp 'window-screen-lines) + (floor (window-screen-lines)) + (window-body-height))) + +(defun company--window-width () + (let ((ww (window-body-width))) + ;; Account for the line continuation column. + (when (zerop (cadr (window-fringes))) + (cl-decf ww)) + (unless (or (display-graphic-p) + (version< "24.3.1" emacs-version)) + ;; Emacs 24.3 and earlier included margins + ;; in window-width when in TTY. + (cl-decf ww + (let ((margins (window-margins))) + (+ (or (car margins) 0) + (or (cdr margins) 0))))) + (when (and word-wrap + (version< emacs-version "24.4.51.5")) + ;; http://debbugs.gnu.org/18384 + (cl-decf ww)) + ww)) + +(defun company--replacement-string (lines old column nl &optional align-top) + (cl-decf column company-tooltip-margin) + + (when (and align-top company-tooltip-flip-when-above) + (setq lines (reverse lines))) + + (let ((width (length (car lines))) + (remaining-cols (- (+ (company--window-width) (window-hscroll)) + column))) + (when (> width remaining-cols) + (cl-decf column (- width remaining-cols)))) + + (let ((offset (and (< column 0) (- column))) + new) + (when offset + (setq column 0)) + (when align-top + ;; untouched lines first + (dotimes (_ (- (length old) (length lines))) + (push (pop old) new))) + ;; length into old lines. + (while old + (push (company-modify-line (pop old) + (company--offset-line (pop lines) offset) + column) + new)) + ;; Append whole new lines. + (while lines + (push (concat (company-space-string column) + (company--offset-line (pop lines) offset)) + new)) + + (let ((str (concat (when nl " ") + "\n" + (mapconcat 'identity (nreverse new) "\n") + "\n"))) + (font-lock-append-text-property 0 (length str) 'face 'default str) + (when nl (put-text-property 0 1 'cursor t str)) + str))) + +(defun company--offset-line (line offset) + (if (and offset line) + (substring line offset) + line)) + +(defun company--create-lines (selection limit) + (let ((len company-candidates-length) + (window-width (company--window-width)) + lines + width + lines-copy + items + previous + remainder + scrollbar-bounds) + + ;; Maybe clear old offset. + (when (< len (+ company-tooltip-offset limit)) + (setq company-tooltip-offset 0)) + + ;; Scroll to offset. + (if (eq company-tooltip-offset-display 'lines) + (setq limit (company-tooltip--lines-update-offset selection len limit)) + (company-tooltip--simple-update-offset selection len limit)) + + (cond + ((eq company-tooltip-offset-display 'scrollbar) + (setq scrollbar-bounds (company--scrollbar-bounds company-tooltip-offset + limit len))) + ((eq company-tooltip-offset-display 'lines) + (when (> company-tooltip-offset 0) + (setq previous (format "...(%d)" company-tooltip-offset))) + (setq remainder (- len limit company-tooltip-offset) + remainder (when (> remainder 0) + (setq remainder (format "...(%d)" remainder)))))) + + (cl-decf selection company-tooltip-offset) + (setq width (max (length previous) (length remainder)) + lines (nthcdr company-tooltip-offset company-candidates) + len (min limit len) + lines-copy lines) + + (cl-decf window-width (* 2 company-tooltip-margin)) + (when scrollbar-bounds (cl-decf window-width)) + + (dotimes (_ len) + (let* ((value (pop lines-copy)) + (annotation (company-call-backend 'annotation value))) + (setq value (company--clean-string (company-reformat value))) + (when annotation + (when company-tooltip-align-annotations + ;; `lisp-completion-at-point' adds a space. + (setq annotation (comment-string-strip annotation t nil))) + (setq annotation (company--clean-string annotation))) + (push (cons value annotation) items) + (setq width (max (+ (length value) + (if (and annotation company-tooltip-align-annotations) + (1+ (length annotation)) + (length annotation))) + width)))) + + (setq width (min window-width + (max company-tooltip-minimum-width + (if company-show-numbers + (+ 2 width) + width)))) + + (let ((items (nreverse items)) + (numbered (if company-show-numbers 0 99999)) + new) + (when previous + (push (company--scrollpos-line previous width) new)) + + (dotimes (i len) + (let* ((item (pop items)) + (str (car item)) + (annotation (cdr item)) + (right (company-space-string company-tooltip-margin)) + (width width)) + (when (< numbered 10) + (cl-decf width 2) + (cl-incf numbered) + (setq right (concat (format " %d" (mod numbered 10)) right))) + (push (concat + (company-fill-propertize str annotation + width (equal i selection) + (company-space-string + company-tooltip-margin) + right) + (when scrollbar-bounds + (company--scrollbar i scrollbar-bounds))) + new))) + + (when remainder + (push (company--scrollpos-line remainder width) new)) + + (nreverse new)))) + +(defun company--scrollbar-bounds (offset limit length) + (when (> length limit) + (let* ((size (ceiling (* limit (float limit)) length)) + (lower (floor (* limit (float offset)) length)) + (upper (+ lower size -1))) + (cons lower upper)))) + +(defun company--scrollbar (i bounds) + (propertize " " 'face + (if (and (>= i (car bounds)) (<= i (cdr bounds))) + 'company-scrollbar-fg + 'company-scrollbar-bg))) + +(defun company--scrollpos-line (text width) + (propertize (concat (company-space-string company-tooltip-margin) + (company-safe-substring text 0 width) + (company-space-string company-tooltip-margin)) + 'face 'company-tooltip)) + +;; show + +(defun company--pseudo-tooltip-height () + "Calculate the appropriate tooltip height. +Returns a negative number if the tooltip should be displayed above point." + (let* ((lines (company--row)) + (below (- (company--window-height) 1 lines))) + (if (and (< below (min company-tooltip-minimum company-candidates-length)) + (> lines below)) + (- (max 3 (min company-tooltip-limit lines))) + (max 3 (min company-tooltip-limit below))))) + +(defun company-pseudo-tooltip-show (row column selection) + (company-pseudo-tooltip-hide) + (save-excursion + + (let* ((height (company--pseudo-tooltip-height)) + above) + + (when (< height 0) + (setq row (+ row height -1) + above t)) + + (let* ((nl (< (move-to-window-line row) row)) + (beg (point)) + (end (save-excursion + (move-to-window-line (+ row (abs height))) + (point))) + (ov (make-overlay (if nl beg (1- beg)) end nil t)) + (args (list (mapcar 'company-plainify + (company-buffer-lines beg end)) + column nl above))) + + (setq company-pseudo-tooltip-overlay ov) + (overlay-put ov 'company-replacement-args args) + + (let ((lines (company--create-lines selection (abs height)))) + (overlay-put ov 'company-display + (apply 'company--replacement-string lines args)) + (overlay-put ov 'company-width (string-width (car lines)))) + + (overlay-put ov 'company-column column) + (overlay-put ov 'company-height height))))) + +(defun company-pseudo-tooltip-show-at-point (pos column-offset) + (let* ((col-row (company--col-row pos)) + (col (- (car col-row) column-offset))) + (when (< col 0) (setq col 0)) + (company-pseudo-tooltip-show (1+ (cdr col-row)) col company-selection))) + +(defun company-pseudo-tooltip-edit (selection) + (let* ((height (overlay-get company-pseudo-tooltip-overlay 'company-height)) + (lines (company--create-lines selection (abs height)))) + (overlay-put company-pseudo-tooltip-overlay 'company-width + (string-width (car lines))) + (overlay-put company-pseudo-tooltip-overlay 'company-display + (apply 'company--replacement-string + lines + (overlay-get company-pseudo-tooltip-overlay + 'company-replacement-args))))) + +(defun company-pseudo-tooltip-hide () + (when company-pseudo-tooltip-overlay + (delete-overlay company-pseudo-tooltip-overlay) + (setq company-pseudo-tooltip-overlay nil))) + +(defun company-pseudo-tooltip-hide-temporarily () + (when (overlayp company-pseudo-tooltip-overlay) + (overlay-put company-pseudo-tooltip-overlay 'invisible nil) + (overlay-put company-pseudo-tooltip-overlay 'after-string nil))) + +(defun company-pseudo-tooltip-unhide () + (when company-pseudo-tooltip-overlay + (let* ((ov company-pseudo-tooltip-overlay) + (disp (overlay-get ov 'company-display))) + ;; Beat outline's folding overlays, at least. + (overlay-put ov 'priority 1) + ;; `display' could be better (http://debbugs.gnu.org/18285), but it + ;; doesn't work when the overlay is empty, which is what happens at eob. + ;; It also seems to interact badly with `cursor'. + ;; We deal with priorities by having the overlay start before the newline. + (overlay-put ov 'after-string disp) + (overlay-put ov 'invisible t) + (overlay-put ov 'window (selected-window))))) + +(defun company-pseudo-tooltip-guard () + (cons + (save-excursion (beginning-of-visual-line)) + (let ((ov company-pseudo-tooltip-overlay) + (overhang (save-excursion (end-of-visual-line) + (- (line-end-position) (point))))) + (when (>= (overlay-get ov 'company-height) 0) + (cons + (buffer-substring-no-properties (point) (overlay-start ov)) + (when (>= overhang 0) overhang)))))) + +(defun company-pseudo-tooltip-frontend (command) + "`company-mode' front-end similar to a tooltip but based on overlays." + (cl-case command + (pre-command (company-pseudo-tooltip-hide-temporarily)) + (post-command + (unless (when (overlayp company-pseudo-tooltip-overlay) + (let* ((ov company-pseudo-tooltip-overlay) + (old-height (overlay-get ov 'company-height)) + (new-height (company--pseudo-tooltip-height))) + (and + (>= (* old-height new-height) 0) + (>= (abs old-height) (abs new-height)) + (equal (company-pseudo-tooltip-guard) + (overlay-get ov 'company-guard))))) + ;; Redraw needed. + (company-pseudo-tooltip-show-at-point (point) (length company-prefix)) + (overlay-put company-pseudo-tooltip-overlay + 'company-guard (company-pseudo-tooltip-guard))) + (company-pseudo-tooltip-unhide)) + (hide (company-pseudo-tooltip-hide) + (setq company-tooltip-offset 0)) + (update (when (overlayp company-pseudo-tooltip-overlay) + (company-pseudo-tooltip-edit company-selection))))) + +(defun company-pseudo-tooltip-unless-just-one-frontend (command) + "`company-pseudo-tooltip-frontend', but not shown for single candidates." + (unless (and (eq command 'post-command) + (company--show-inline-p)) + (company-pseudo-tooltip-frontend command))) + +;;; overlay ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-preview-overlay nil) + +(defun company-preview-show-at-point (pos) + (company-preview-hide) + + (let ((completion (nth company-selection company-candidates))) + (setq completion (propertize completion 'face 'company-preview)) + (add-text-properties 0 (length company-common) + '(face company-preview-common) completion) + + ;; Add search string + (and company-search-string + (string-match (regexp-quote company-search-string) completion) + (add-text-properties (match-beginning 0) + (match-end 0) + '(face company-preview-search) + completion)) + + (setq completion (company-strip-prefix completion)) + + (and (equal pos (point)) + (not (equal completion "")) + (add-text-properties 0 1 '(cursor 1) completion)) + + (let* ((beg pos) + (pto company-pseudo-tooltip-overlay) + (ptf-workaround (and + pto + (char-before pos) + (eq pos (overlay-start pto))))) + ;; Try to accomodate for the pseudo-tooltip overlay, + ;; which may start at the same position if it's at eol. + (when ptf-workaround + (cl-decf beg) + (setq completion (concat (buffer-substring beg pos) completion))) + + (setq company-preview-overlay (make-overlay beg pos)) + + (let ((ov company-preview-overlay)) + (overlay-put ov (if ptf-workaround 'display 'after-string) + completion) + (overlay-put ov 'window (selected-window)))))) + +(defun company-preview-hide () + (when company-preview-overlay + (delete-overlay company-preview-overlay) + (setq company-preview-overlay nil))) + +(defun company-preview-frontend (command) + "`company-mode' front-end showing the selection as if it had been inserted." + (pcase command + (`pre-command (company-preview-hide)) + (`post-command (company-preview-show-at-point (point))) + (`hide (company-preview-hide)))) + +(defun company-preview-if-just-one-frontend (command) + "`company-preview-frontend', but only shown for single candidates." + (when (or (not (eq command 'post-command)) + (company--show-inline-p)) + (company-preview-frontend command))) + +(defun company--show-inline-p () + (and (not (cdr company-candidates)) + company-common + (or (eq (company-call-backend 'ignore-case) 'keep-prefix) + (string-prefix-p company-prefix company-common)))) + +;;; echo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar-local company-echo-last-msg nil) + +(defvar company-echo-timer nil) + +(defvar company-echo-delay .01) + +(defun company-echo-show (&optional getter) + (when getter + (setq company-echo-last-msg (funcall getter))) + (let ((message-log-max nil)) + (if company-echo-last-msg + (message "%s" company-echo-last-msg) + (message "")))) + +(defun company-echo-show-soon (&optional getter) + (when company-echo-timer + (cancel-timer company-echo-timer)) + (setq company-echo-timer (run-with-timer 0 nil 'company-echo-show getter))) + +(defsubst company-echo-show-when-idle (&optional getter) + (when (sit-for company-echo-delay) + (company-echo-show getter))) + +(defun company-echo-format () + + (let ((limit (window-body-width (minibuffer-window))) + (len -1) + ;; Roll to selection. + (candidates (nthcdr company-selection company-candidates)) + (i (if company-show-numbers company-selection 99999)) + comp msg) + + (while candidates + (setq comp (company-reformat (pop candidates)) + len (+ len 1 (length comp))) + (if (< i 10) + ;; Add number. + (progn + (setq comp (propertize (format "%d: %s" i comp) + 'face 'company-echo)) + (cl-incf len 3) + (cl-incf i) + (add-text-properties 3 (+ 3 (length company-common)) + '(face company-echo-common) comp)) + (setq comp (propertize comp 'face 'company-echo)) + (add-text-properties 0 (length company-common) + '(face company-echo-common) comp)) + (if (>= len limit) + (setq candidates nil) + (push comp msg))) + + (mapconcat 'identity (nreverse msg) " "))) + +(defun company-echo-strip-common-format () + + (let ((limit (window-body-width (minibuffer-window))) + (len (+ (length company-prefix) 2)) + ;; Roll to selection. + (candidates (nthcdr company-selection company-candidates)) + (i (if company-show-numbers company-selection 99999)) + msg comp) + + (while candidates + (setq comp (company-strip-prefix (pop candidates)) + len (+ len 2 (length comp))) + (when (< i 10) + ;; Add number. + (setq comp (format "%s (%d)" comp i)) + (cl-incf len 4) + (cl-incf i)) + (if (>= len limit) + (setq candidates nil) + (push (propertize comp 'face 'company-echo) msg))) + + (concat (propertize company-prefix 'face 'company-echo-common) "{" + (mapconcat 'identity (nreverse msg) ", ") + "}"))) + +(defun company-echo-hide () + (unless (equal company-echo-last-msg "") + (setq company-echo-last-msg "") + (company-echo-show))) + +(defun company-echo-frontend (command) + "`company-mode' front-end showing the candidates in the echo area." + (pcase command + (`post-command (company-echo-show-soon 'company-echo-format)) + (`hide (company-echo-hide)))) + +(defun company-echo-strip-common-frontend (command) + "`company-mode' front-end showing the candidates in the echo area." + (pcase command + (`post-command (company-echo-show-soon 'company-echo-strip-common-format)) + (`hide (company-echo-hide)))) + +(defun company-echo-metadata-frontend (command) + "`company-mode' front-end showing the documentation in the echo area." + (pcase command + (`post-command (company-echo-show-when-idle 'company-fetch-metadata)) + (`hide (company-echo-hide)))) + +(provide 'company) +;;; company.el ends here diff --git a/emacs.d/elpa/concurrent-20140609.1940/concurrent-autoloads.el b/emacs.d/elpa/concurrent-20140609.1940/concurrent-autoloads.el deleted file mode 100644 index 946bcfc..0000000 --- a/emacs.d/elpa/concurrent-20140609.1940/concurrent-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; concurrent-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("concurrent.el") (21571 44956 836134 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; concurrent-autoloads.el ends here diff --git a/emacs.d/elpa/concurrent-20140609.1940/concurrent-pkg.el b/emacs.d/elpa/concurrent-20140609.1940/concurrent-pkg.el deleted file mode 100644 index 951091f..0000000 --- a/emacs.d/elpa/concurrent-20140609.1940/concurrent-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "concurrent" "20140609.1940" "Concurrent utility functions for emacs lisp" '((deferred "0.3.1")) :url "https://github.com/kiwanami/emacs-deferred/blob/master/README-concurrent.markdown" :keywords '("deferred" "async" "concurrent")) diff --git a/emacs.d/elpa/concurrent-20140609.1940/concurrent.el b/emacs.d/elpa/concurrent-20140609.1940/concurrent.el deleted file mode 100644 index 7f827a4..0000000 --- a/emacs.d/elpa/concurrent-20140609.1940/concurrent.el +++ /dev/null @@ -1,509 +0,0 @@ -;;; concurrent.el --- Concurrent utility functions for emacs lisp - -;; Copyright (C) 2010, 2011, 2012 SAKURAI Masashi - -;; Author: SAKURAI Masashi -;; Version: 20140609.1940 -;; X-Original-Version: 0.3.1 -;; Keywords: deferred, async, concurrent -;; Package-Requires: ((deferred "0.3.1")) -;; URL: https://github.com/kiwanami/emacs-deferred/blob/master/README-concurrent.markdown - -;; 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: - -;; 'concurrent.el' is a higher level library for concurrent tasks -;; based on 'deferred.el'. This library has following features: -;; -;; - Generator -;; - Green thread -;; - Semaphore -;; - Dataflow -;; - Signal/Channel - -(require 'cl) - -(require 'deferred) - -(defvar cc:version nil "version number") -(setq cc:version "0.3") - -;;; Code: - - - -(defmacro cc:aif (test-form then-form &rest else-forms) - (declare (debug (form form &rest form))) - `(let ((it ,test-form)) - (if it ,then-form ,@else-forms))) -(put 'cc:aif 'lisp-indent-function 2) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Generator - -(defun cc:generator-replace-yield (tree) - "[internal] Replace `yield' symbols to calling a function in TREE." - (let (ret) - (loop for i in tree - do (cond - ((eq i 'yield) - (push 'funcall ret) - (push i ret)) - ((listp i) - (push (cc:generator-replace-yield i) ret)) - (t - (push i ret)))) - (nreverse ret))) - -(defun cc:generator-line (chain line) - "[internal] Return a macro expansion to execute the sexp LINE -asynchronously." - (cond - ;; function object - ((functionp line) - `(setq ,chain (deferred:nextc ,chain ,line))) - ;; while loop form - ((eq 'while (car line)) - (let ((condition (cadr line)) - (body (cddr line))) - `(setq ,chain - (deferred:nextc ,chain - (deferred:lambda (x) - (if ,condition - (deferred:nextc - (progn - ,@(cc:generator-replace-yield body)) self))))))) - ;; statement - (t - `(setq ,chain - (deferred:nextc ,chain - (deferred:lambda (x) ,(cc:generator-replace-yield line))))))) - -(defmacro cc:generator (callback &rest body) - "Create a generator object. If BODY has `yield' symbols, it -means calling callback function CALLBACK." - (let ((chain (gensym)) - (cc (gensym)) - (waiter (gensym))) - `(lexical-let* - (,chain - (,cc ,callback) - (,waiter (deferred:new)) - (yield (lambda (x) (funcall ,cc x) ,waiter))) - (setq ,chain ,waiter) - ,@(loop for i in body - collect - (cc:generator-line chain i)) - (lambda () (deferred:callback ,waiter))))) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Thread - -(defun cc:thread-line (wait-time chain line) - "[internal] Return a macro expansion to execute the sexp LINE asynchronously. -WAIT-TIME is an interval time between tasks. -CHAIN is the previous deferred task." - (cond - ;; function object - ((functionp line) - `(setq ,chain (deferred:nextc ,chain ,line))) - ;; while loop form - ((eq 'while (car line)) - (let ((condition (cadr line)) - (body (cddr line)) - (retsym (gensym))) - `(setq ,chain - (deferred:nextc ,chain - (deferred:lambda (x) - (if ,condition - (deferred:nextc - (let ((,retsym (progn ,@body))) - (if (deferred-p ,retsym) ,retsym - (deferred:wait ,wait-time))) - self))))))) - ;; statement - (t - `(setq ,chain - (deferred:nextc ,chain - (lambda (x) ,line)))))) - -(defmacro cc:thread (wait-time-msec &rest body) - "Return a thread object." - (let ((chain (gensym)) - (dstart (gensym))) - `(lexical-let* - (,chain - (,dstart (deferred:new))) - (setq ,chain ,dstart) - ,@(loop for i in body - collect - (cc:thread-line wait-time-msec chain i)) - (deferred:callback ,dstart)))) -(put 'cc:thread 'lisp-indent-function 1) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Semaphore - -(defstruct cc:semaphore max-permits permits waiting-deferreds) - -(defun cc:semaphore-create(permits-num) - "Return a semaphore object with PERMITS-NUM permissions." - (make-cc:semaphore :max-permits permits-num :permits permits-num)) - -(defun cc:semaphore-acquire(semaphore) - "Acquire an execution permission and return deferred object to chain. -If this semaphore object has permissions, the subsequent deferred -task is executed immediately. If this semaphore object has no -permissions, the subsequent deferred task is blocked. After the -permission is returned, the task is executed." - (cond - ((< 0 (cc:semaphore-permits semaphore)) - (decf (cc:semaphore-permits semaphore)) - (deferred:succeed)) - (t - (let ((d (deferred:new))) - (push d (cc:semaphore-waiting-deferreds semaphore)) - d)))) - -(defun cc:semaphore-release(semaphore) - "Release an execution permission. The programmer is responsible to return the permissions." - (when (<= (cc:semaphore-max-permits semaphore) - (cc:semaphore-permits semaphore)) - (error "Too many calling semaphore-release. [max:%s <= permits:%s]" - (cc:semaphore-max-permits semaphore) - (cc:semaphore-permits semaphore))) - (let ((waiting-deferreds - (cc:semaphore-waiting-deferreds semaphore))) - (cond - (waiting-deferreds - (let* ((d (car (last waiting-deferreds)))) - (setf (cc:semaphore-waiting-deferreds semaphore) - (nbutlast waiting-deferreds)) - (deferred:callback-post d))) - (t - (incf (cc:semaphore-permits semaphore))))) - semaphore) - -(defun cc:semaphore-with (semaphore body-func &optional error-func) - "Execute the task BODY-FUNC asynchronously with the semaphore block." - (lexical-let ((semaphore semaphore)) - (deferred:try - (deferred:nextc (cc:semaphore-acquire semaphore) body-func) - :catch - error-func - :finally - (lambda (x) (cc:semaphore-release semaphore))))) -(put 'cc:semaphore-with 'lisp-indent-function 1) - -(defun cc:semaphore-release-all (semaphore) - "Release all permissions for resetting the semaphore object. -If the semaphore object has some blocked tasks, this function -return a list of the tasks and clear the list of the blocked -tasks in the semaphore object." - (setf (cc:semaphore-permits semaphore) - (cc:semaphore-max-permits semaphore)) - (let ((ds (cc:semaphore-waiting-deferreds semaphore))) - (when ds - (setf (cc:semaphore-waiting-deferreds semaphore) nil)) - ds)) - -(defun cc:semaphore-interrupt-all (semaphore) - "Clear the list of the blocked tasks in the semaphore and return a deferred object to chain. -This function is used for the interruption cases." - (when (cc:semaphore-waiting-deferreds semaphore) - (setf (cc:semaphore-waiting-deferreds semaphore) nil) - (setf (cc:semaphore-permits semaphore) 0)) - (cc:semaphore-acquire semaphore)) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Signal / Channel - -(defun cc:signal-channel (&optional name parent-channel) - "Create a channel. -NAME is a channel name for debug. -PARENT-CHANNEL is an upstream channel. The observers of this channel can receive the upstream signals. -In the case of using the function `cc:signal-send', the observers of the upstream channel can not receive the signals of this channel. The function `cc:signal-send-global' can send a signal to the upstream channels from the downstream channels." - (lexical-let - ((ch (cons - (or name (format "signal%s" (deferred:uid))) ; name for debug - (cons - parent-channel ; parent-channel - nil)))) ; observers - (when parent-channel - (cc:signal-connect - parent-channel - t (lambda (event) - (destructuring-bind - (event-name event-args) event - (apply 'cc:signal-send - ch event-name event-args))))) - ch)) - -(defmacro cc:signal-name (ch) - "[internal] Return signal name." - `(car ,ch)) - -(defmacro cc:signal-parent-channel (ch) - "[internal] Return parent channel object." - `(cadr ,ch)) - -(defmacro cc:signal-observers (ch) - "[internal] Return observers." - `(cddr ,ch)) - -(defun cc:signal-connect (channel event-sym &optional callback) - "Append an observer for EVENT-SYM of CHANNEL and return a deferred object. -If EVENT-SYM is `t', the observer receives all signals of the channel. -If CALLBACK function is given, the deferred object executes the -CALLBACK function asynchronously. One can connect subsequent -tasks to the returned deferred object." - (let ((d (if callback - (deferred:new callback) - (deferred:new)))) - (push (cons event-sym d) - (cc:signal-observers channel)) - d)) - -(defun cc:signal-send (channel event-sym &rest args) - "Send a signal to CHANNEL. If ARGS values are given, observers can get the values by following code: (lambda (event) (destructuring-bind (event-sym (args)) event ... )). " - (let ((observers (cc:signal-observers channel)) - (event (list event-sym args))) - (loop for i in observers - for name = (car i) - for d = (cdr i) - if (or (eq event-sym name) (eq t name)) - do (deferred:callback-post d event)))) - -(defun cc:signal-send-global (channel event-sym &rest args) - "Send a signal to the most upstream channel. " - (cc:aif (cc:signal-parent-channel channel) - (apply 'cc:signal-send-global it event-sym args) - (apply 'cc:signal-send channel event-sym args))) - - -(defun cc:signal-disconnect (channel deferred) - "Remove the observer object DEFERRED from CHANNEL and return -the removed deferred object. " - (let ((observers (cc:signal-observers channel)) deleted) - (setf - (cc:signal-observers channel) ; place - (loop for i in observers - for d = (cdr i) - unless (eq d deferred) - collect i - else - do (push i deleted))) - deleted)) - -(defun cc:signal-disconnect-all (channel) - "Remove all observers." - (setf - (cc:signal-observers channel) ; place - nil)) - - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Dataflow - -;; Dataflow variable entry -(defstruct cc:dataflow key (value 'cc:dataflow-undefine) deferred-list) - -(defun cc:dataflow-undefine-p (obj) - "[internal] If the variable entry is not bound, return `t'." - (eq 'cc:dataflow-undefine (cc:dataflow-value obj))) - -(defmacro cc:dataflow-parent-environment (df) - "[internal] Return the parent environment." - `(car ,df)) - -(defmacro cc:dataflow-test (df) - "[internal] Return the test function." - `(cadr ,df)) - -(defmacro cc:dataflow-channel (df) - "[internal] Return the channel object." - `(caddr ,df)) - -(defmacro cc:dataflow-list (df) - "[internal] Return the list of deferred object which are waiting for value binding." - `(cdddr ,df)) - -(defun cc:dataflow-environment (&optional parent-env test-func channel) - "Create a dataflow environment. -PARENT-ENV is the default environment. If this environment doesn't have the entry A and the parent one has the entry A, this environment can return the entry A. One can override the entry, setting another entry A to this environment. -TEST-FUNC is a test function that compares the entry keys. The default function is `equal'. -CHANNEL is a channel object that sends signals of variable events. Observers can receive following signals: --get-first : the fist referrer is waiting for binding, --get-waiting : another referrer is waiting for binding, --set : a value is bound, --get : returned a bound value, --clear : cleared one entry, --clear-all : cleared all entries. -" - (let ((this (list parent-env - (or test-func 'equal) - (or channel - (cc:signal-channel - 'dataflow - (and parent-env - (cc:dataflow-channel parent-env))))))) - (cc:dataflow-init-connect this) - this)) - -(defun cc:dataflow-init-connect (df) - "[internal] Initialize the channel object." - (lexical-let ((df df)) - (cc:dataflow-connect - df 'set - (lambda (args) - (destructuring-bind (event (key)) args - (let* ((obj (cc:dataflow-get-object-for-value df key)) - (value (and obj (cc:dataflow-value obj)))) - (when obj - (loop for i in (cc:aif (cc:dataflow-get-object-for-deferreds df key) - (cc:dataflow-deferred-list it) nil) - do (deferred:callback-post i value)) - (setf (cc:dataflow-deferred-list obj) nil)))))))) - -(defun cc:dataflow-get-object-for-value (df key) - "[internal] Return an entry object that is indicated by KEY. -If the environment DF doesn't have the entry and the parent one has the entry, this function returns the entry of the parent environment. This function doesn't affect the waiting list." - (or - (loop for i in (cc:dataflow-list df) - with test = (cc:dataflow-test df) - if (and (funcall test key (cc:dataflow-key i)) - (not (cc:dataflow-undefine-p i))) - return i) - (deferred:aand - (cc:dataflow-parent-environment df) - (cc:dataflow-get-object-for-value it key)))) - -(defun cc:dataflow-get-object-for-deferreds (df key) - "[internal] Return a list of the deferred objects those are waiting for value binding. -This function doesn't affect the waiting list and doesn't refer the parent environment." - (loop for i in (cc:dataflow-list df) - with test = (cc:dataflow-test df) - if (funcall test key (cc:dataflow-key i)) - return i)) - -(defun cc:dataflow-connect (df event-sym &optional callback) - "Append an observer for EVENT-SYM of the channel of DF and return a deferred object. -See the docstring of `cc:dataflow-environment' for details." - (cc:signal-connect (cc:dataflow-channel df) event-sym callback)) - -(defun cc:dataflow-signal (df event &optional arg) - "[internal] Send a signal to the channel of DF." - (cc:signal-send (cc:dataflow-channel df) event arg)) - -(defun cc:dataflow-get (df key) - "Return a deferred object that can refer the value which is indicated by KEY. -If DF has the entry that bound value, the subsequent deferred task is executed immediately. -If not, the task is deferred till a value is bound." - (let ((obj (cc:dataflow-get-object-for-value df key))) - (cond - ((and obj (cc:dataflow-value obj)) - (cc:dataflow-signal df 'get key) - (deferred:succeed (cc:dataflow-value obj))) - (t - (setq obj (cc:dataflow-get-object-for-deferreds df key)) - (unless obj - (setq obj (make-cc:dataflow :key key)) - (push obj (cc:dataflow-list df)) - (cc:dataflow-signal df 'get-first key)) - (let ((d (deferred:new))) - (push d (cc:dataflow-deferred-list obj)) - (cc:dataflow-signal df 'get-waiting key) - d))))) - -(defun cc:dataflow-get-sync (df key) - "Return the value which is indicated by KEY synchronously. -If the environment DF doesn't have an entry of KEY, this function returns nil." - (let ((obj (cc:dataflow-get-object-for-value df key))) - (and obj (cc:dataflow-value obj)))) - -(defun cc:dataflow-set (df key value) - "Bind the VALUE to KEY in the environment DF. -If DF already has the bound entry of KEY, this function throws an error signal. -VALUE can be nil as a value." - (let ((obj (cc:dataflow-get-object-for-deferreds df key))) - (cond - ((and obj (not (cc:dataflow-undefine-p obj))) - ;; overwrite! - (error "Can not set a dataflow value. The key [%s] has already had a value. NEW:[%s] OLD:[%s]" key value (cc:dataflow-value obj))) - (obj - (setf (cc:dataflow-value obj) value)) - (t - ;; just value arrived - (push (make-cc:dataflow :key key :value value) - (cc:dataflow-list df)))) - ;; value arrived and start deferred objects - (cc:dataflow-signal df 'set key) - value)) - -(defun cc:dataflow-clear (df key) - "Clear the entry which is indicated by KEY. -This function does nothing for the waiting deferred objects." - (cc:dataflow-signal df 'clear key) - (setf (cc:dataflow-list df) - (loop for i in (cc:dataflow-list df) - with test = (cc:dataflow-test df) - unless (funcall test key (cc:dataflow-key i)) - collect i))) - -(defun cc:dataflow-get-avalable-pairs (df) - "Return an available key-value alist in the environment DF and the parent ones." - (append - (loop for i in (cc:dataflow-list df) - for key = (cc:dataflow-key i) - for val = (cc:dataflow-value i) - unless (cc:dataflow-undefine-p i) collect (cons key val)) - (deferred:aand - (cc:dataflow-parent-environment df) - (cc:dataflow-get-avalable-pairs it)))) - -(defun cc:dataflow-get-waiting-keys (df) - "Return a list of keys which have waiting deferred objects in the environment DF and the parent ones." - (append - (loop for i in (cc:dataflow-list df) - for key = (cc:dataflow-key i) - for val = (cc:dataflow-value i) - if (cc:dataflow-undefine-p i) collect key) - (deferred:aand - (cc:dataflow-parent-environment df) - (cc:dataflow-get-waiting-keys it)))) - -(defun cc:dataflow-clear-all (df) - "Clear all entries in the environment DF. -This function does nothing for the waiting deferred objects." - (cc:dataflow-signal df 'clear-all) - (setf (cc:dataflow-list df) nil)) - - -(provide 'concurrent) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions) -;; End: - -;;; concurrent.el ends here - diff --git a/emacs.d/elpa/concurrent-20150309.2052/concurrent-autoloads.el b/emacs.d/elpa/concurrent-20150309.2052/concurrent-autoloads.el new file mode 100644 index 0000000..38b735e --- /dev/null +++ b/emacs.d/elpa/concurrent-20150309.2052/concurrent-autoloads.el @@ -0,0 +1,15 @@ +;;; concurrent-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil nil ("concurrent.el") (21837 24216 635114 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; concurrent-autoloads.el ends here diff --git a/emacs.d/elpa/concurrent-20150309.2052/concurrent-pkg.el b/emacs.d/elpa/concurrent-20150309.2052/concurrent-pkg.el new file mode 100644 index 0000000..2aacdcb --- /dev/null +++ b/emacs.d/elpa/concurrent-20150309.2052/concurrent-pkg.el @@ -0,0 +1 @@ +(define-package "concurrent" "20150309.2052" "Concurrent utility functions for emacs lisp" '((deferred "0.3.1")) :url "https://github.com/kiwanami/emacs-deferred/blob/master/README-concurrent.markdown" :keywords '("deferred" "async" "concurrent")) diff --git a/emacs.d/elpa/concurrent-20150309.2052/concurrent.el b/emacs.d/elpa/concurrent-20150309.2052/concurrent.el new file mode 100644 index 0000000..a6beacb --- /dev/null +++ b/emacs.d/elpa/concurrent-20150309.2052/concurrent.el @@ -0,0 +1,507 @@ +;;; concurrent.el --- Concurrent utility functions for emacs lisp + +;; Copyright (C) 2010, 2011, 2012 SAKURAI Masashi + +;; Author: SAKURAI Masashi +;; Version: 0.3.1 +;; Package-Version: 20150309.2052 +;; Keywords: deferred, async, concurrent +;; Package-Requires: ((deferred "0.3.1")) +;; URL: https://github.com/kiwanami/emacs-deferred/blob/master/README-concurrent.markdown + +;; 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: + +;; 'concurrent.el' is a higher level library for concurrent tasks +;; based on 'deferred.el'. This library has following features: +;; +;; - Generator +;; - Green thread +;; - Semaphore +;; - Dataflow +;; - Signal/Channel + +(require 'cl) + +(require 'deferred) + +(defvar cc:version nil "version number") +(setq cc:version "0.3") + +;;; Code: + + + +(defmacro cc:aif (test-form then-form &rest else-forms) + (declare (debug (form form &rest form))) + `(let ((it ,test-form)) + (if it ,then-form ,@else-forms))) +(put 'cc:aif 'lisp-indent-function 2) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Generator + +(defun cc:generator-replace-yield (tree) + "[internal] Replace `yield' symbols to calling a function in TREE." + (let (ret) + (loop for i in tree + do (cond + ((eq i 'yield) + (push 'funcall ret) + (push i ret)) + ((listp i) + (push (cc:generator-replace-yield i) ret)) + (t + (push i ret)))) + (nreverse ret))) + +(defun cc:generator-line (chain line) + "[internal] Return a macro expansion to execute the sexp LINE +asynchronously." + (cond + ;; function object + ((functionp line) + `(setq ,chain (deferred:nextc ,chain ,line))) + ;; while loop form + ((eq 'while (car line)) + (let ((condition (cadr line)) + (body (cddr line))) + `(setq ,chain + (deferred:nextc ,chain + (deferred:lambda (x) + (if ,condition + (deferred:nextc + (progn + ,@(cc:generator-replace-yield body)) self))))))) + ;; statement + (t + `(setq ,chain + (deferred:nextc ,chain + (deferred:lambda (x) ,(cc:generator-replace-yield line))))))) + +(defmacro cc:generator (callback &rest body) + "Create a generator object. If BODY has `yield' symbols, it +means calling callback function CALLBACK." + (let ((chain (gensym)) + (cc (gensym)) + (waiter (gensym))) + `(lexical-let* + (,chain + (,cc ,callback) + (,waiter (deferred:new)) + (yield (lambda (x) (funcall ,cc x) ,waiter))) + (setq ,chain ,waiter) + ,@(loop for i in body + collect + (cc:generator-line chain i)) + (lambda () (deferred:callback ,waiter))))) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Thread + +(defun cc:thread-line (wait-time chain line) + "[internal] Return a macro expansion to execute the sexp LINE asynchronously. +WAIT-TIME is an interval time between tasks. +CHAIN is the previous deferred task." + (cond + ;; function object + ((functionp line) + `(setq ,chain (deferred:nextc ,chain ,line))) + ;; while loop form + ((eq 'while (car line)) + (let ((condition (cadr line)) + (body (cddr line)) + (retsym (gensym))) + `(setq ,chain + (deferred:nextc ,chain + (deferred:lambda (x) + (if ,condition + (deferred:nextc + (let ((,retsym (progn ,@body))) + (if (deferred-p ,retsym) ,retsym + (deferred:wait ,wait-time))) + self))))))) + ;; statement + (t + `(setq ,chain + (deferred:nextc ,chain + (lambda (x) ,line)))))) + +(defmacro cc:thread (wait-time-msec &rest body) + "Return a thread object." + (let ((chain (gensym)) + (dstart (gensym))) + `(lexical-let* + (,chain + (,dstart (deferred:new))) + (setq ,chain ,dstart) + ,@(loop for i in body + collect + (cc:thread-line wait-time-msec chain i)) + (deferred:callback ,dstart)))) +(put 'cc:thread 'lisp-indent-function 1) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Semaphore + +(defstruct cc:semaphore max-permits permits waiting-deferreds) + +(defun cc:semaphore-create(permits-num) + "Return a semaphore object with PERMITS-NUM permissions." + (make-cc:semaphore :max-permits permits-num :permits permits-num)) + +(defun cc:semaphore-acquire(semaphore) + "Acquire an execution permission and return deferred object to chain. +If this semaphore object has permissions, the subsequent deferred +task is executed immediately. If this semaphore object has no +permissions, the subsequent deferred task is blocked. After the +permission is returned, the task is executed." + (cond + ((< 0 (cc:semaphore-permits semaphore)) + (decf (cc:semaphore-permits semaphore)) + (deferred:succeed)) + (t + (let ((d (deferred:new))) + (push d (cc:semaphore-waiting-deferreds semaphore)) + d)))) + +(defun cc:semaphore-release(semaphore) + "Release an execution permission. The programmer is responsible to return the permissions." + (when (<= (cc:semaphore-max-permits semaphore) + (cc:semaphore-permits semaphore)) + (error "Too many calling semaphore-release. [max:%s <= permits:%s]" + (cc:semaphore-max-permits semaphore) + (cc:semaphore-permits semaphore))) + (let ((waiting-deferreds + (cc:semaphore-waiting-deferreds semaphore))) + (cond + (waiting-deferreds + (let* ((d (car (last waiting-deferreds)))) + (setf (cc:semaphore-waiting-deferreds semaphore) + (nbutlast waiting-deferreds)) + (deferred:callback-post d))) + (t + (incf (cc:semaphore-permits semaphore))))) + semaphore) + +(defun cc:semaphore-with (semaphore body-func &optional error-func) + "Execute the task BODY-FUNC asynchronously with the semaphore block." + (lexical-let ((semaphore semaphore)) + (deferred:try + (deferred:nextc (cc:semaphore-acquire semaphore) body-func) + :catch + error-func + :finally + (lambda (_x) (cc:semaphore-release semaphore))))) +(put 'cc:semaphore-with 'lisp-indent-function 1) + +(defun cc:semaphore-release-all (semaphore) + "Release all permissions for resetting the semaphore object. +If the semaphore object has some blocked tasks, this function +return a list of the tasks and clear the list of the blocked +tasks in the semaphore object." + (setf (cc:semaphore-permits semaphore) + (cc:semaphore-max-permits semaphore)) + (let ((ds (cc:semaphore-waiting-deferreds semaphore))) + (when ds + (setf (cc:semaphore-waiting-deferreds semaphore) nil)) + ds)) + +(defun cc:semaphore-interrupt-all (semaphore) + "Clear the list of the blocked tasks in the semaphore and return a deferred object to chain. +This function is used for the interruption cases." + (when (cc:semaphore-waiting-deferreds semaphore) + (setf (cc:semaphore-waiting-deferreds semaphore) nil) + (setf (cc:semaphore-permits semaphore) 0)) + (cc:semaphore-acquire semaphore)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Signal / Channel + +(defun cc:signal-channel (&optional name parent-channel) + "Create a channel. +NAME is a channel name for debug. +PARENT-CHANNEL is an upstream channel. The observers of this channel can receive the upstream signals. +In the case of using the function `cc:signal-send', the observers of the upstream channel can not receive the signals of this channel. The function `cc:signal-send-global' can send a signal to the upstream channels from the downstream channels." + (lexical-let + ((ch (cons + (or name (format "signal%s" (deferred:uid))) ; name for debug + (cons + parent-channel ; parent-channel + nil)))) ; observers + (when parent-channel + (cc:signal-connect + parent-channel + t (lambda (event) + (destructuring-bind + (event-name event-args) event + (apply 'cc:signal-send + ch event-name event-args))))) + ch)) + +(defmacro cc:signal-name (ch) + "[internal] Return signal name." + `(car ,ch)) + +(defmacro cc:signal-parent-channel (ch) + "[internal] Return parent channel object." + `(cadr ,ch)) + +(defmacro cc:signal-observers (ch) + "[internal] Return observers." + `(cddr ,ch)) + +(defun cc:signal-connect (channel event-sym &optional callback) + "Append an observer for EVENT-SYM of CHANNEL and return a deferred object. +If EVENT-SYM is `t', the observer receives all signals of the channel. +If CALLBACK function is given, the deferred object executes the +CALLBACK function asynchronously. One can connect subsequent +tasks to the returned deferred object." + (let ((d (if callback + (deferred:new callback) + (deferred:new)))) + (push (cons event-sym d) + (cc:signal-observers channel)) + d)) + +(defun cc:signal-send (channel event-sym &rest args) + "Send a signal to CHANNEL. If ARGS values are given, observers can get the values by following code: (lambda (event) (destructuring-bind (event-sym (args)) event ... )). " + (let ((observers (cc:signal-observers channel)) + (event (list event-sym args))) + (loop for i in observers + for name = (car i) + for d = (cdr i) + if (or (eq event-sym name) (eq t name)) + do (deferred:callback-post d event)))) + +(defun cc:signal-send-global (channel event-sym &rest args) + "Send a signal to the most upstream channel. " + (cc:aif (cc:signal-parent-channel channel) + (apply 'cc:signal-send-global it event-sym args) + (apply 'cc:signal-send channel event-sym args))) + + +(defun cc:signal-disconnect (channel deferred) + "Remove the observer object DEFERRED from CHANNEL and return +the removed deferred object. " + (let ((observers (cc:signal-observers channel)) deleted) + (setf + (cc:signal-observers channel) ; place + (loop for i in observers + for d = (cdr i) + unless (eq d deferred) + collect i + else + do (push i deleted))) + deleted)) + +(defun cc:signal-disconnect-all (channel) + "Remove all observers." + (setf + (cc:signal-observers channel) ; place + nil)) + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Dataflow + +;; Dataflow variable entry +(defstruct cc:dataflow key (value 'cc:dataflow-undefine) deferred-list) + +(defun cc:dataflow-undefine-p (obj) + "[internal] If the variable entry is not bound, return `t'." + (eq 'cc:dataflow-undefine (cc:dataflow-value obj))) + +(defmacro cc:dataflow-parent-environment (df) + "[internal] Return the parent environment." + `(car ,df)) + +(defmacro cc:dataflow-test (df) + "[internal] Return the test function." + `(cadr ,df)) + +(defmacro cc:dataflow-channel (df) + "[internal] Return the channel object." + `(caddr ,df)) + +(defmacro cc:dataflow-list (df) + "[internal] Return the list of deferred object which are waiting for value binding." + `(cdddr ,df)) + +(defun cc:dataflow-environment (&optional parent-env test-func channel) + "Create a dataflow environment. +PARENT-ENV is the default environment. If this environment doesn't have the entry A and the parent one has the entry A, this environment can return the entry A. One can override the entry, setting another entry A to this environment. +TEST-FUNC is a test function that compares the entry keys. The default function is `equal'. +CHANNEL is a channel object that sends signals of variable events. Observers can receive following signals: +-get-first : the fist referrer is waiting for binding, +-get-waiting : another referrer is waiting for binding, +-set : a value is bound, +-get : returned a bound value, +-clear : cleared one entry, +-clear-all : cleared all entries. +" + (let ((this (list parent-env + (or test-func 'equal) + (or channel + (cc:signal-channel + 'dataflow + (and parent-env + (cc:dataflow-channel parent-env))))))) + (cc:dataflow-init-connect this) + this)) + +(defun cc:dataflow-init-connect (df) + "[internal] Initialize the channel object." + (lexical-let ((df df)) + (cc:dataflow-connect + df 'set + (lambda (args) + (destructuring-bind (_event (key)) args + (let* ((obj (cc:dataflow-get-object-for-value df key)) + (value (and obj (cc:dataflow-value obj)))) + (when obj + (loop for i in (cc:aif (cc:dataflow-get-object-for-deferreds df key) + (cc:dataflow-deferred-list it) nil) + do (deferred:callback-post i value)) + (setf (cc:dataflow-deferred-list obj) nil)))))))) + +(defun cc:dataflow-get-object-for-value (df key) + "[internal] Return an entry object that is indicated by KEY. +If the environment DF doesn't have the entry and the parent one has the entry, this function returns the entry of the parent environment. This function doesn't affect the waiting list." + (or + (loop for i in (cc:dataflow-list df) + with test = (cc:dataflow-test df) + if (and (funcall test key (cc:dataflow-key i)) + (not (cc:dataflow-undefine-p i))) + return i) + (deferred:aand + (cc:dataflow-parent-environment df) + (cc:dataflow-get-object-for-value it key)))) + +(defun cc:dataflow-get-object-for-deferreds (df key) + "[internal] Return a list of the deferred objects those are waiting for value binding. +This function doesn't affect the waiting list and doesn't refer the parent environment." + (loop for i in (cc:dataflow-list df) + with test = (cc:dataflow-test df) + if (funcall test key (cc:dataflow-key i)) + return i)) + +(defun cc:dataflow-connect (df event-sym &optional callback) + "Append an observer for EVENT-SYM of the channel of DF and return a deferred object. +See the docstring of `cc:dataflow-environment' for details." + (cc:signal-connect (cc:dataflow-channel df) event-sym callback)) + +(defun cc:dataflow-signal (df event &optional arg) + "[internal] Send a signal to the channel of DF." + (cc:signal-send (cc:dataflow-channel df) event arg)) + +(defun cc:dataflow-get (df key) + "Return a deferred object that can refer the value which is indicated by KEY. +If DF has the entry that bound value, the subsequent deferred task is executed immediately. +If not, the task is deferred till a value is bound." + (let ((obj (cc:dataflow-get-object-for-value df key))) + (cond + ((and obj (cc:dataflow-value obj)) + (cc:dataflow-signal df 'get key) + (deferred:succeed (cc:dataflow-value obj))) + (t + (setq obj (cc:dataflow-get-object-for-deferreds df key)) + (unless obj + (setq obj (make-cc:dataflow :key key)) + (push obj (cc:dataflow-list df)) + (cc:dataflow-signal df 'get-first key)) + (let ((d (deferred:new))) + (push d (cc:dataflow-deferred-list obj)) + (cc:dataflow-signal df 'get-waiting key) + d))))) + +(defun cc:dataflow-get-sync (df key) + "Return the value which is indicated by KEY synchronously. +If the environment DF doesn't have an entry of KEY, this function returns nil." + (let ((obj (cc:dataflow-get-object-for-value df key))) + (and obj (cc:dataflow-value obj)))) + +(defun cc:dataflow-set (df key value) + "Bind the VALUE to KEY in the environment DF. +If DF already has the bound entry of KEY, this function throws an error signal. +VALUE can be nil as a value." + (let ((obj (cc:dataflow-get-object-for-deferreds df key))) + (cond + ((and obj (not (cc:dataflow-undefine-p obj))) + ;; overwrite! + (error "Can not set a dataflow value. The key [%s] has already had a value. NEW:[%s] OLD:[%s]" key value (cc:dataflow-value obj))) + (obj + (setf (cc:dataflow-value obj) value)) + (t + ;; just value arrived + (push (make-cc:dataflow :key key :value value) + (cc:dataflow-list df)))) + ;; value arrived and start deferred objects + (cc:dataflow-signal df 'set key) + value)) + +(defun cc:dataflow-clear (df key) + "Clear the entry which is indicated by KEY. +This function does nothing for the waiting deferred objects." + (cc:dataflow-signal df 'clear key) + (setf (cc:dataflow-list df) + (loop for i in (cc:dataflow-list df) + with test = (cc:dataflow-test df) + unless (funcall test key (cc:dataflow-key i)) + collect i))) + +(defun cc:dataflow-get-avalable-pairs (df) + "Return an available key-value alist in the environment DF and the parent ones." + (append + (loop for i in (cc:dataflow-list df) + for key = (cc:dataflow-key i) + for val = (cc:dataflow-value i) + unless (cc:dataflow-undefine-p i) collect (cons key val)) + (deferred:aand + (cc:dataflow-parent-environment df) + (cc:dataflow-get-avalable-pairs it)))) + +(defun cc:dataflow-get-waiting-keys (df) + "Return a list of keys which have waiting deferred objects in the environment DF and the parent ones." + (append + (loop for i in (cc:dataflow-list df) + for key = (cc:dataflow-key i) + if (cc:dataflow-undefine-p i) collect key) + (deferred:aand + (cc:dataflow-parent-environment df) + (cc:dataflow-get-waiting-keys it)))) + +(defun cc:dataflow-clear-all (df) + "Clear all entries in the environment DF. +This function does nothing for the waiting deferred objects." + (cc:dataflow-signal df 'clear-all) + (setf (cc:dataflow-list df) nil)) + + +(provide 'concurrent) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions) +;; End: + +;;; concurrent.el ends here diff --git a/emacs.d/elpa/dash-20141008.712/dash-autoloads.el b/emacs.d/elpa/dash-20141008.712/dash-autoloads.el deleted file mode 100644 index 5ca9f9f..0000000 --- a/emacs.d/elpa/dash-20141008.712/dash-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; dash-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("dash.el") (21570 23223 488064 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; dash-autoloads.el ends here diff --git a/emacs.d/elpa/dash-20141008.712/dash-pkg.el b/emacs.d/elpa/dash-20141008.712/dash-pkg.el deleted file mode 100644 index ee8197d..0000000 --- a/emacs.d/elpa/dash-20141008.712/dash-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "dash" "20141008.712" "A modern list library for Emacs" 'nil :keywords '("lists")) diff --git a/emacs.d/elpa/dash-20141008.712/dash.el b/emacs.d/elpa/dash-20141008.712/dash.el deleted file mode 100644 index 61c701d..0000000 --- a/emacs.d/elpa/dash-20141008.712/dash.el +++ /dev/null @@ -1,2180 +0,0 @@ -;;; dash.el --- A modern list library for Emacs - -;; Copyright (C) 2012-2014 Magnar Sveen - -;; Author: Magnar Sveen -;; Version: 20141008.712 -;; X-Original-Version: 2.9.0 -;; Keywords: lists - -;; 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 modern list api for Emacs. -;; -;; See documentation on https://github.com/magnars/dash.el#functions - -;;; Code: - -(defgroup dash () - "Customize group for dash.el" - :group 'lisp - :prefix "dash-") - -(defun dash--enable-fontlock (symbol value) - (when value - (dash-enable-font-lock)) - (set-default symbol value)) - -(defcustom dash-enable-fontlock nil - "If non-nil, enable fontification of dash functions, macros and -special values." - :type 'boolean - :set 'dash--enable-fontlock - :group 'dash) - -(defmacro !cons (car cdr) - "Destructive: Set CDR to the cons of CAR and CDR." - `(setq ,cdr (cons ,car ,cdr))) - -(defmacro !cdr (list) - "Destructive: Set LIST to the cdr of LIST." - `(setq ,list (cdr ,list))) - -(defmacro --each (list &rest body) - "Anaphoric form of `-each'." - (declare (debug (form body)) - (indent 1)) - (let ((l (make-symbol "list"))) - `(let ((,l ,list) - (it-index 0)) - (while ,l - (let ((it (car ,l))) - ,@body) - (setq it-index (1+ it-index)) - (!cdr ,l))))) - -(defun -each (list fn) - "Call FN with every item in LIST. Return nil, used for side-effects only." - (--each list (funcall fn it))) - -(put '-each 'lisp-indent-function 1) - -(defmacro --each-while (list pred &rest body) - "Anaphoric form of `-each-while'." - (declare (debug (form form body)) - (indent 2)) - (let ((l (make-symbol "list")) - (c (make-symbol "continue"))) - `(let ((,l ,list) - (,c t) - (it-index 0)) - (while (and ,l ,c) - (let ((it (car ,l))) - (if (not ,pred) (setq ,c nil) ,@body)) - (setq it-index (1+ it-index)) - (!cdr ,l))))) - -(defun -each-while (list pred fn) - "Call FN with every item in LIST while (PRED item) is non-nil. -Return nil, used for side-effects only." - (--each-while list (funcall pred it) (funcall fn it))) - -(put '-each-while 'lisp-indent-function 2) - -(defmacro --dotimes (num &rest body) - "Repeatedly executes BODY (presumably for side-effects) with `it` bound to integers from 0 through NUM-1." - (declare (debug (form body)) - (indent 1)) - (let ((n (make-symbol "num"))) - `(let ((,n ,num) - (it 0)) - (while (< it ,n) - ,@body - (setq it (1+ it)))))) - -(defun -dotimes (num fn) - "Repeatedly calls FN (presumably for side-effects) passing in integers from 0 through NUM-1." - (--dotimes num (funcall fn it))) - -(put '-dotimes 'lisp-indent-function 1) - -(defun -map (fn list) - "Return a new list consisting of the result of applying FN to the items in LIST." - (mapcar fn list)) - -(defmacro --map (form list) - "Anaphoric form of `-map'." - (declare (debug (form form))) - `(mapcar (lambda (it) ,form) ,list)) - -(defmacro --reduce-from (form initial-value list) - "Anaphoric form of `-reduce-from'." - (declare (debug (form form form))) - `(let ((acc ,initial-value)) - (--each ,list (setq acc ,form)) - acc)) - -(defun -reduce-from (fn initial-value list) - "Return the result of applying FN to INITIAL-VALUE and the -first item in LIST, then applying FN to that result and the 2nd -item, etc. If LIST contains no items, return INITIAL-VALUE and -FN is not called. - -In the anaphoric form `--reduce-from', the accumulated value is -exposed as `acc`." - (--reduce-from (funcall fn acc it) initial-value list)) - -(defmacro --reduce (form list) - "Anaphoric form of `-reduce'." - (declare (debug (form form))) - (let ((lv (make-symbol "list-value"))) - `(let ((,lv ,list)) - (if ,lv - (--reduce-from ,form (car ,lv) (cdr ,lv)) - (let (acc it) ,form))))) - -(defun -reduce (fn list) - "Return the result of applying FN to the first 2 items in LIST, -then applying FN to that result and the 3rd item, etc. If LIST -contains no items, FN must accept no arguments as well, and -reduce return the result of calling FN with no arguments. If -LIST has only 1 item, it is returned and FN is not called. - -In the anaphoric form `--reduce', the accumulated value is -exposed as `acc`." - (if list - (-reduce-from fn (car list) (cdr list)) - (funcall fn))) - -(defun -reduce-r-from (fn initial-value list) - "Replace conses with FN, nil with INITIAL-VALUE and evaluate -the resulting expression. If LIST is empty, INITIAL-VALUE is -returned and FN is not called. - -Note: this function works the same as `-reduce-from' but the -operation associates from right instead of from left." - (if (not list) initial-value - (funcall fn (car list) (-reduce-r-from fn initial-value (cdr list))))) - -(defmacro --reduce-r-from (form initial-value list) - "Anaphoric version of `-reduce-r-from'." - (declare (debug (form form form))) - `(-reduce-r-from (lambda (&optional it acc) ,form) ,initial-value ,list)) - -(defun -reduce-r (fn list) - "Replace conses with FN and evaluate the resulting expression. -The final nil is ignored. If LIST contains no items, FN must -accept no arguments as well, and reduce return the result of -calling FN with no arguments. If LIST has only 1 item, it is -returned and FN is not called. - -The first argument of FN is the new item, the second is the -accumulated value. - -Note: this function works the same as `-reduce' but the operation -associates from right instead of from left." - (cond - ((not list) (funcall fn)) - ((not (cdr list)) (car list)) - (t (funcall fn (car list) (-reduce-r fn (cdr list)))))) - -(defmacro --reduce-r (form list) - "Anaphoric version of `-reduce-r'." - (declare (debug (form form))) - `(-reduce-r (lambda (&optional it acc) ,form) ,list)) - -(defmacro --filter (form list) - "Anaphoric form of `-filter'." - (declare (debug (form form))) - (let ((r (make-symbol "result"))) - `(let (,r) - (--each ,list (when ,form (!cons it ,r))) - (nreverse ,r)))) - -(defun -filter (pred list) - "Return a new list of the items in LIST for which PRED returns a non-nil value. - -Alias: `-select'" - (--filter (funcall pred it) list)) - -(defalias '-select '-filter) -(defalias '--select '--filter) - -(defmacro --remove (form list) - "Anaphoric form of `-remove'." - (declare (debug (form form))) - `(--filter (not ,form) ,list)) - -(defun -remove (pred list) - "Return a new list of the items in LIST for which PRED returns nil. - -Alias: `-reject'" - (--remove (funcall pred it) list)) - -(defalias '-reject '-remove) -(defalias '--reject '--remove) - -(defmacro --keep (form list) - "Anaphoric form of `-keep'." - (declare (debug (form form))) - (let ((r (make-symbol "result")) - (m (make-symbol "mapped"))) - `(let (,r) - (--each ,list (let ((,m ,form)) (when ,m (!cons ,m ,r)))) - (nreverse ,r)))) - -(defun -keep (fn list) - "Return a new list of the non-nil results of applying FN to the items in LIST." - (--keep (funcall fn it) list)) - -(defun -non-nil (list) - "Return all non-nil elements of LIST." - (-remove 'null list)) - -(defmacro --map-indexed (form list) - "Anaphoric form of `-map-indexed'." - (declare (debug (form form))) - (let ((r (make-symbol "result"))) - `(let (,r) - (--each ,list - (!cons ,form ,r)) - (nreverse ,r)))) - -(defun -map-indexed (fn list) - "Return a new list consisting of the result of (FN index item) for each item in LIST. - -In the anaphoric form `--map-indexed', the index is exposed as `it-index`." - (--map-indexed (funcall fn it-index it) list)) - -(defmacro --map-when (pred rep list) - "Anaphoric form of `-map-when'." - (declare (debug (form form form))) - (let ((r (make-symbol "result"))) - `(let (,r) - (--each ,list (!cons (if ,pred ,rep it) ,r)) - (nreverse ,r)))) - -(defun -map-when (pred rep list) - "Return a new list where the elements in LIST that does not match the PRED function -are unchanged, and where the elements in LIST that do match the PRED function are mapped -through the REP function. - -Alias: `-replace-where' - -See also: `-update-at'" - (--map-when (funcall pred it) (funcall rep it) list)) - -(defalias '-replace-where '-map-when) -(defalias '--replace-where '--map-when) - -(defun -replace (old new list) - "Replace all OLD items in LIST with NEW. - -Elements are compared using `equal'. - -See also: `-replace-at'" - (--map-when (equal it old) new list)) - -(defun -flatten (l) - "Take a nested list L and return its contents as a single, flat list. - -See also: `-flatten-n'" - (if (and (listp l) (listp (cdr l))) - (-mapcat '-flatten l) - (list l))) - -(defun -flatten-n (num list) - "Flatten NUM levels of a nested LIST. - -See also: `-flatten'" - (-last-item (--iterate (--mapcat (-list it) it) list (1+ num)))) - -(defun -concat (&rest lists) - "Return a new list with the concatenation of the elements in the supplied LISTS." - (apply 'append lists)) - -(defmacro --mapcat (form list) - "Anaphoric form of `-mapcat'." - (declare (debug (form form))) - `(apply 'append (--map ,form ,list))) - -(defun -mapcat (fn list) - "Return the concatenation of the result of mapping FN over LIST. -Thus function FN should return a list." - (--mapcat (funcall fn it) list)) - -(defalias '-copy 'copy-sequence - "Create a shallow copy of LIST.") - -(defun -splice (pred fun list) - "Splice lists generated by FUN in place of elements matching PRED in LIST. - -FUN takes the element matching PRED as input. - -This function can be used as replacement for `,@' in case you -need to splice several lists at marked positions (for example -with keywords). - -See also: `-splice-list', `-insert-at'" - (let (r) - (--each list - (if (funcall pred it) - (let ((new (funcall fun it))) - (--each new (!cons it r))) - (!cons it r))) - (nreverse r))) - -(defmacro --splice (pred form list) - "Anaphoric form of `-splice'." - `(-splice (lambda (it) ,pred) (lambda (it) ,form) ,list)) - -(defun -splice-list (pred new-list list) - "Splice NEW-LIST in place of elements matching PRED in LIST. - -See also: `-splice', `-insert-at'" - (-splice pred (lambda (_) new-list) list)) - -(defun --splice-list (pred new-list list) - "Anaphoric form of `-splice-list'." - `(-splice-list (lambda (it) ,pred) ,new-list ,list)) - -(defun -cons* (&rest args) - "Make a new list from the elements of ARGS. - -The last 2 members of ARGS are used as the final cons of the -result so if the final member of ARGS is not a list the result is -a dotted list." - (-reduce-r 'cons args)) - -(defun -snoc (list elem &rest elements) - "Append ELEM to the end of the list. - -This is like `cons', but operates on the end of list. - -If ELEMENTS is non nil, append these to the list as well." - (-concat list (list elem) elements)) - -(defmacro --first (form list) - "Anaphoric form of `-first'." - (declare (debug (form form))) - (let ((n (make-symbol "needle"))) - `(let (,n) - (--each-while ,list (not ,n) - (when ,form (setq ,n it))) - ,n))) - -(defun -first (pred list) - "Return the first x in LIST where (PRED x) is non-nil, else nil. - -To get the first item in the list no questions asked, use `car'. - -Alias: `-find'" - (--first (funcall pred it) list)) - -(defalias '-find '-first) -(defalias '--find '--first) - -(defmacro --last (form list) - "Anaphoric form of `-last'." - (declare (debug (form form))) - (let ((n (make-symbol "needle"))) - `(let (,n) - (--each ,list - (when ,form (setq ,n it))) - ,n))) - -(defun -last (pred list) - "Return the last x in LIST where (PRED x) is non-nil, else nil." - (--last (funcall pred it) list)) - -(defalias '-first-item 'car - "Return the first item of LIST, or nil on an empty list.") - -(defun -last-item (list) - "Return the last item of LIST, or nil on an empty list." - (car (last list))) - -(defun -butlast (list) - "Return a list of all items in list except for the last." - (let (result) - (while (cdr list) - (!cons (car list) result) - (!cdr list)) - (nreverse result))) - -(defmacro --count (pred list) - "Anaphoric form of `-count'." - (declare (debug (form form))) - (let ((r (make-symbol "result"))) - `(let ((,r 0)) - (--each ,list (when ,pred (setq ,r (1+ ,r)))) - ,r))) - -(defun -count (pred list) - "Counts the number of items in LIST where (PRED item) is non-nil." - (--count (funcall pred it) list)) - -(defun ---truthy? (val) - (not (null val))) - -(defmacro --any? (form list) - "Anaphoric form of `-any?'." - (declare (debug (form form))) - `(---truthy? (--first ,form ,list))) - -(defun -any? (pred list) - "Return t if (PRED x) is non-nil for any x in LIST, else nil. - -Alias: `-any-p', `-some?', `-some-p'" - (--any? (funcall pred it) list)) - -(defalias '-some? '-any?) -(defalias '--some? '--any?) -(defalias '-any-p '-any?) -(defalias '--any-p '--any?) -(defalias '-some-p '-any?) -(defalias '--some-p '--any?) - -(defmacro --all? (form list) - "Anaphoric form of `-all?'." - (declare (debug (form form))) - (let ((a (make-symbol "all"))) - `(let ((,a t)) - (--each-while ,list ,a (setq ,a ,form)) - (---truthy? ,a)))) - -(defun -all? (pred list) - "Return t if (PRED x) is non-nil for all x in LIST, else nil. - -Alias: `-all-p', `-every?', `-every-p'" - (--all? (funcall pred it) list)) - -(defalias '-every? '-all?) -(defalias '--every? '--all?) -(defalias '-all-p '-all?) -(defalias '--all-p '--all?) -(defalias '-every-p '-all?) -(defalias '--every-p '--all?) - -(defmacro --none? (form list) - "Anaphoric form of `-none?'." - (declare (debug (form form))) - `(--all? (not ,form) ,list)) - -(defun -none? (pred list) - "Return t if (PRED x) is nil for all x in LIST, else nil. - -Alias: `-none-p'" - (--none? (funcall pred it) list)) - -(defalias '-none-p '-none?) -(defalias '--none-p '--none?) - -(defmacro --only-some? (form list) - "Anaphoric form of `-only-some?'." - (declare (debug (form form))) - (let ((y (make-symbol "yes")) - (n (make-symbol "no"))) - `(let (,y ,n) - (--each-while ,list (not (and ,y ,n)) - (if ,form (setq ,y t) (setq ,n t))) - (---truthy? (and ,y ,n))))) - -(defun -only-some? (pred list) - "Return `t` if at least one item of LIST matches PRED and at least one item of LIST does not match PRED. -Return `nil` both if all items match the predicate or if none of the items match the predicate. - -Alias: `-only-some-p'" - (--only-some? (funcall pred it) list)) - -(defalias '-only-some-p '-only-some?) -(defalias '--only-some-p '--only-some?) - -(defun -slice (list from &optional to step) - "Return copy of LIST, starting from index FROM to index TO. - -FROM or TO may be negative. These values are then interpreted -modulo the length of the list. - -If STEP is a number, only each STEPth item in the resulting -section is returned. Defaults to 1." - (let ((length (length list)) - (new-list nil)) - ;; to defaults to the end of the list - (setq to (or to length)) - (setq step (or step 1)) - ;; handle negative indices - (when (< from 0) - (setq from (mod from length))) - (when (< to 0) - (setq to (mod to length))) - - ;; iterate through the list, keeping the elements we want - (--each-while list (< it-index to) - (when (and (>= it-index from) - (= (mod (- from it-index) step) 0)) - (push it new-list))) - (nreverse new-list))) - -(defun -take (n list) - "Return a new list of the first N items in LIST, or all items if there are fewer than N." - (let (result) - (--dotimes n - (when list - (!cons (car list) result) - (!cdr list))) - (nreverse result))) - -(defalias '-drop 'nthcdr "Return the tail of LIST without the first N items.") - -(defmacro --take-while (form list) - "Anaphoric form of `-take-while'." - (declare (debug (form form))) - (let ((r (make-symbol "result"))) - `(let (,r) - (--each-while ,list ,form (!cons it ,r)) - (nreverse ,r)))) - -(defun -take-while (pred list) - "Return a new list of successive items from LIST while (PRED item) returns a non-nil value." - (--take-while (funcall pred it) list)) - -(defmacro --drop-while (form list) - "Anaphoric form of `-drop-while'." - (declare (debug (form form))) - (let ((l (make-symbol "list"))) - `(let ((,l ,list)) - (while (and ,l (let ((it (car ,l))) ,form)) - (!cdr ,l)) - ,l))) - -(defun -drop-while (pred list) - "Return the tail of LIST starting from the first item for which (PRED item) returns nil." - (--drop-while (funcall pred it) list)) - -(defun -split-at (n list) - "Return a list of ((-take N LIST) (-drop N LIST)), in no more than one pass through the list." - (let (result) - (--dotimes n - (when list - (!cons (car list) result) - (!cdr list))) - (list (nreverse result) list))) - -(defun -rotate (n list) - "Rotate LIST N places to the right. With N negative, rotate to the left. -The time complexity is O(n)." - (if (> n 0) - (append (last list n) (butlast list n)) - (append (-drop (- n) list) (-take (- n) list)))) - -(defun -insert-at (n x list) - "Return a list with X inserted into LIST at position N. - -See also: `-splice', `-splice-list'" - (let ((split-list (-split-at n list))) - (nconc (car split-list) (cons x (cadr split-list))))) - -(defun -replace-at (n x list) - "Return a list with element at Nth position in LIST replaced with X. - -See also: `-replace'" - (let ((split-list (-split-at n list))) - (nconc (car split-list) (cons x (cdr (cadr split-list)))))) - -(defun -update-at (n func list) - "Return a list with element at Nth position in LIST replaced with `(func (nth n list))`. - -See also: `-map-when'" - (let ((split-list (-split-at n list))) - (nconc (car split-list) (cons (funcall func (car (cadr split-list))) (cdr (cadr split-list)))))) - -(defmacro --update-at (n form list) - "Anaphoric version of `-update-at'." - (declare (debug (form form form))) - `(-update-at ,n (lambda (it) ,form) ,list)) - -(defun -remove-at (n list) - "Return a list with element at Nth position in LIST removed. - -See also: `-remove-at-indices', `-remove'" - (-remove-at-indices (list n) list)) - -(defun -remove-at-indices (indices list) - "Return a list whose elements are elements from LIST without -elements selected as `(nth i list)` for all i -from INDICES. - -See also: `-remove-at', `-remove'" - (let* ((indices (-sort '< indices)) - (diffs (cons (car indices) (-map '1- (-zip-with '- (cdr indices) indices)))) - r) - (--each diffs - (let ((split (-split-at it list))) - (!cons (car split) r) - (setq list (cdr (cadr split))))) - (!cons list r) - (apply '-concat (nreverse r)))) - -(defmacro --split-with (pred list) - "Anaphoric form of `-split-with'." - (declare (debug (form form))) - (let ((l (make-symbol "list")) - (r (make-symbol "result")) - (c (make-symbol "continue"))) - `(let ((,l ,list) - (,r nil) - (,c t)) - (while (and ,l ,c) - (let ((it (car ,l))) - (if (not ,pred) - (setq ,c nil) - (!cons it ,r) - (!cdr ,l)))) - (list (nreverse ,r) ,l)))) - -(defun -split-with (pred list) - "Return a list of ((-take-while PRED LIST) (-drop-while PRED LIST)), in no more than one pass through the list." - (--split-with (funcall pred it) list)) - -(defmacro -split-on (item list) - "Split the LIST each time ITEM is found. - -Unlike `-partition-by', the ITEM is discarded from the results. -Empty lists are also removed from the result. - -Comparison is done by `equal'. - -See also `-split-when'" - (declare (debug (form form))) - `(-split-when (lambda (it) (equal it ,item)) ,list)) - -(defmacro --split-when (form list) - "Anaphoric version of `-split-when'." - (declare (debug (form form))) - `(-split-when (lambda (it) ,form) ,list)) - -(defun -split-when (fn list) - "Split the LIST on each element where FN returns non-nil. - -Unlike `-partition-by', the \"matched\" element is discarded from -the results. Empty lists are also removed from the result. - -This function can be thought of as a generalization of -`split-string'." - (let (r s) - (while list - (if (not (funcall fn (car list))) - (push (car list) s) - (when s (push (nreverse s) r)) - (setq s nil)) - (!cdr list)) - (when s (push (nreverse s) r)) - (nreverse r))) - -(defmacro --separate (form list) - "Anaphoric form of `-separate'." - (declare (debug (form form))) - (let ((y (make-symbol "yes")) - (n (make-symbol "no"))) - `(let (,y ,n) - (--each ,list (if ,form (!cons it ,y) (!cons it ,n))) - (list (nreverse ,y) (nreverse ,n))))) - -(defun -separate (pred list) - "Return a list of ((-filter PRED LIST) (-remove PRED LIST)), in one pass through the list." - (--separate (funcall pred it) list)) - -(defun ---partition-all-in-steps-reversed (n step list) - "Private: Used by -partition-all-in-steps and -partition-in-steps." - (when (< step 1) - (error "Step must be a positive number, or you're looking at some juicy infinite loops.")) - (let ((result nil) - (len 0)) - (while list - (!cons (-take n list) result) - (setq list (-drop step list))) - result)) - -(defun -partition-all-in-steps (n step list) - "Return a new list with the items in LIST grouped into N-sized sublists at offsets STEP apart. -The last groups may contain less than N items." - (nreverse (---partition-all-in-steps-reversed n step list))) - -(defun -partition-in-steps (n step list) - "Return a new list with the items in LIST grouped into N-sized sublists at offsets STEP apart. -If there are not enough items to make the last group N-sized, -those items are discarded." - (let ((result (---partition-all-in-steps-reversed n step list))) - (while (and result (< (length (car result)) n)) - (!cdr result)) - (nreverse result))) - -(defun -partition-all (n list) - "Return a new list with the items in LIST grouped into N-sized sublists. -The last group may contain less than N items." - (-partition-all-in-steps n n list)) - -(defun -partition (n list) - "Return a new list with the items in LIST grouped into N-sized sublists. -If there are not enough items to make the last group N-sized, -those items are discarded." - (-partition-in-steps n n list)) - -(defmacro --partition-by (form list) - "Anaphoric form of `-partition-by'." - (declare (debug (form form))) - (let ((r (make-symbol "result")) - (s (make-symbol "sublist")) - (v (make-symbol "value")) - (n (make-symbol "new-value")) - (l (make-symbol "list"))) - `(let ((,l ,list)) - (when ,l - (let* ((,r nil) - (it (car ,l)) - (,s (list it)) - (,v ,form) - (,l (cdr ,l))) - (while ,l - (let* ((it (car ,l)) - (,n ,form)) - (unless (equal ,v ,n) - (!cons (nreverse ,s) ,r) - (setq ,s nil) - (setq ,v ,n)) - (!cons it ,s) - (!cdr ,l))) - (!cons (nreverse ,s) ,r) - (nreverse ,r)))))) - -(defun -partition-by (fn list) - "Apply FN to each item in LIST, splitting it each time FN returns a new value." - (--partition-by (funcall fn it) list)) - -(defmacro --partition-by-header (form list) - "Anaphoric form of `-partition-by-header'." - (declare (debug (form form))) - (let ((r (make-symbol "result")) - (s (make-symbol "sublist")) - (h (make-symbol "header-value")) - (b (make-symbol "seen-body?")) - (n (make-symbol "new-value")) - (l (make-symbol "list"))) - `(let ((,l ,list)) - (when ,l - (let* ((,r nil) - (it (car ,l)) - (,s (list it)) - (,h ,form) - (,b nil) - (,l (cdr ,l))) - (while ,l - (let* ((it (car ,l)) - (,n ,form)) - (if (equal ,h ,n) - (when ,b - (!cons (nreverse ,s) ,r) - (setq ,s nil) - (setq ,b nil)) - (setq ,b t)) - (!cons it ,s) - (!cdr ,l))) - (!cons (nreverse ,s) ,r) - (nreverse ,r)))))) - -(defun -partition-by-header (fn list) - "Apply FN to the first item in LIST. That is the header -value. Apply FN to each item in LIST, splitting it each time FN -returns the header value, but only after seeing at least one -other value (the body)." - (--partition-by-header (funcall fn it) list)) - -(defmacro --group-by (form list) - "Anaphoric form of `-group-by'." - (declare (debug (form form))) - (let ((l (make-symbol "list")) - (v (make-symbol "value")) - (k (make-symbol "key")) - (r (make-symbol "result"))) - `(let ((,l ,list) - ,r) - ;; Convert `list' to an alist and store it in `r'. - (while ,l - (let* ((,v (car ,l)) - (it ,v) - (,k ,form) - (kv (assoc ,k ,r))) - (if kv - (setcdr kv (cons ,v (cdr kv))) - (push (list ,k ,v) ,r)) - (setq ,l (cdr ,l)))) - ;; Reverse lists in each group. - (let ((rest ,r)) - (while rest - (let ((kv (car rest))) - (setcdr kv (nreverse (cdr kv)))) - (setq rest (cdr rest)))) - ;; Reverse order of keys. - (nreverse ,r)))) - -(defun -group-by (fn list) - "Separate LIST into an alist whose keys are FN applied to the -elements of LIST. Keys are compared by `equal'." - (--group-by (funcall fn it) list)) - -(defun -interpose (sep list) - "Return a new list of all elements in LIST separated by SEP." - (let (result) - (when list - (!cons (car list) result) - (!cdr list)) - (while list - (setq result (cons (car list) (cons sep result))) - (!cdr list)) - (nreverse result))) - -(defun -interleave (&rest lists) - "Return a new list of the first item in each list, then the second etc." - (let (result) - (while (-none? 'null lists) - (--each lists (!cons (car it) result)) - (setq lists (-map 'cdr lists))) - (nreverse result))) - -(defmacro --zip-with (form list1 list2) - "Anaphoric form of `-zip-with'. - -The elements in list1 is bound as `it`, the elements in list2 as `other`." - (declare (debug (form form form))) - (let ((r (make-symbol "result")) - (l1 (make-symbol "list1")) - (l2 (make-symbol "list2"))) - `(let ((,r nil) - (,l1 ,list1) - (,l2 ,list2)) - (while (and ,l1 ,l2) - (let ((it (car ,l1)) - (other (car ,l2))) - (!cons ,form ,r) - (!cdr ,l1) - (!cdr ,l2))) - (nreverse ,r)))) - -(defun -zip-with (fn list1 list2) - "Zip the two lists LIST1 and LIST2 using a function FN. This -function is applied pairwise taking as first argument element of -LIST1 and as second argument element of LIST2 at corresponding -position. - -The anaphoric form `--zip-with' binds the elements from LIST1 as `it`, -and the elements from LIST2 as `other`." - (--zip-with (funcall fn it other) list1 list2)) - -(defun -zip (&rest lists) - "Zip LISTS together. Group the head of each list, followed by the -second elements of each list, and so on. The lengths of the returned -groupings are equal to the length of the shortest input list. - -If two lists are provided as arguments, return the groupings as a list -of cons cells. Otherwise, return the groupings as a list of lists. " - (let (results) - (while (-none? 'null lists) - (setq results (cons (mapcar 'car lists) results)) - (setq lists (mapcar 'cdr lists))) - (setq results (nreverse results)) - (if (= (length lists) 2) - ; to support backward compatability, return - ; a cons cell if two lists were provided - (--map (cons (car it) (cadr it)) results) - results))) - -(defun -zip-fill (fill-value &rest lists) - "Zip LISTS, with FILL-VALUE padded onto the shorter lists. The -lengths of the returned groupings are equal to the length of the -longest input list." - (apply '-zip (apply '-pad (cons fill-value lists)))) - -(defun -cycle (list) - "Return an infinite copy of LIST that will cycle through the -elements and repeat from the beginning." - (let ((newlist (-map 'identity list))) - (nconc newlist newlist))) - -(defun -pad (fill-value &rest lists) - "Appends FILL-VALUE to the end of each list in LISTS such that they -will all have the same length." - (let* ((annotations (-annotate 'length lists)) - (n (-max (-map 'car annotations)))) - (--map (append (cdr it) (-repeat (- n (car it)) fill-value)) annotations))) - -(defun -annotate (fn list) - "Return a list of cons cells where each cell is FN applied to each -element of LIST paired with the unmodified element of LIST." - (-zip (-map fn list) list)) - -(defmacro --annotate (form list) - "Anaphoric version of `-annotate'." - (declare (debug (form form))) - `(-annotate (lambda (it) ,form) ,list)) - -(defun dash--table-carry (lists restore-lists &optional re) - "Helper for `-table' and `-table-flat'. - -If a list overflows, carry to the right and reset the list. - -Return how many lists were re-seted." - (while (and (not (car lists)) - (not (equal lists '(nil)))) - (setcar lists (car restore-lists)) - (pop (cadr lists)) - (!cdr lists) - (!cdr restore-lists) - (when re - (push (nreverse (car re)) (cadr re)) - (setcar re nil) - (!cdr re)))) - -(defun -table (fn &rest lists) - "Compute outer product of LISTS using function FN. - -The function FN should have the same arity as the number of -supplied lists. - -The outer product is computed by applying fn to all possible -combinations created by taking one element from each list in -order. The dimension of the result is (length lists). - -See also: `-table-flat'" - (let ((restore-lists (copy-sequence lists)) - (last-list (last lists)) - (re (--map nil (number-sequence 1 (length lists))))) - (while (car last-list) - (let ((item (apply fn (-map 'car lists)))) - (push item (car re)) - (pop (car lists)) - (dash--table-carry lists restore-lists re))) - (nreverse (car (last re))))) - -(defun -table-flat (fn &rest lists) - "Compute flat outer product of LISTS using function FN. - -The function FN should have the same arity as the number of -supplied lists. - -The outer product is computed by applying fn to all possible -combinations created by taking one element from each list in -order. The results are flattened, ignoring the tensor structure -of the result. This is equivalent to calling: - - (-flatten-n (1- (length lists)) (-table fn lists)) - -but the implementation here is much more efficient. - -See also: `-flatten-n', `-table'" - (let ((restore-lists (copy-sequence lists)) - (last-list (last lists)) - re) - (while (car last-list) - (push (apply fn (-map 'car lists)) re) - (pop (car lists)) - (dash--table-carry lists restore-lists)) - (nreverse re))) - -(defun -partial (fn &rest args) - "Take a function FN and fewer than the normal arguments to FN, -and return a fn that takes a variable number of additional ARGS. -When called, the returned function calls FN with ARGS first and -then additional args." - (apply 'apply-partially fn args)) - -(defun -elem-index (elem list) - "Return the index of the first element in the given LIST which -is equal to the query element ELEM, or nil if there is no -such element." - (car (-elem-indices elem list))) - -(defun -elem-indices (elem list) - "Return the indices of all elements in LIST equal to the query -element ELEM, in ascending order." - (-find-indices (-partial 'equal elem) list)) - -(defun -find-indices (pred list) - "Return the indices of all elements in LIST satisfying the -predicate PRED, in ascending order." - (let ((i 0)) - (apply 'append (--map-indexed (when (funcall pred it) (list it-index)) list)))) - -(defmacro --find-indices (form list) - "Anaphoric version of `-find-indices'." - (declare (debug (form form))) - `(-find-indices (lambda (it) ,form) ,list)) - -(defun -find-index (pred list) - "Take a predicate PRED and a LIST and return the index of the -first element in the list satisfying the predicate, or nil if -there is no such element." - (car (-find-indices pred list))) - -(defmacro --find-index (form list) - "Anaphoric version of `-find-index'." - (declare (debug (form form))) - `(-find-index (lambda (it) ,form) ,list)) - -(defun -find-last-index (pred list) - "Take a predicate PRED and a LIST and return the index of the -last element in the list satisfying the predicate, or nil if -there is no such element." - (-last-item (-find-indices pred list))) - -(defmacro --find-last-index (form list) - "Anaphoric version of `-find-last-index'." - `(-find-last-index (lambda (it) ,form) ,list)) - -(defun -select-by-indices (indices list) - "Return a list whose elements are elements from LIST selected -as `(nth i list)` for all i from INDICES." - (let (r) - (--each indices - (!cons (nth it list) r)) - (nreverse r))) - -(defmacro -> (x &optional form &rest more) - "Thread the expr through the forms. Insert X as the second item -in the first form, making a list of it if it is not a list -already. If there are more forms, insert the first form as the -second item in second form, etc." - (cond - ((null form) x) - ((null more) (if (listp form) - `(,(car form) ,x ,@(cdr form)) - (list form x))) - (:else `(-> (-> ,x ,form) ,@more)))) - -(defmacro ->> (x form &rest more) - "Thread the expr through the forms. Insert X as the last item -in the first form, making a list of it if it is not a list -already. If there are more forms, insert the first form as the -last item in second form, etc." - (if (null more) - (if (listp form) - `(,(car form) ,@(cdr form) ,x) - (list form x)) - `(->> (->> ,x ,form) ,@more))) - -(defmacro --> (x form &rest more) - "Thread the expr through the forms. Insert X at the position -signified by the token `it' in the first form. If there are more -forms, insert the first form at the position signified by `it' in -in second form, etc." - (if (null more) - (if (listp form) - (--map-when (eq it 'it) x form) - (list form x)) - `(--> (--> ,x ,form) ,@more))) - -(put '-> 'lisp-indent-function 1) -(put '->> 'lisp-indent-function 1) -(put '--> 'lisp-indent-function 1) - -(defun -grade-up (comparator list) - "Grade elements of LIST using COMPARATOR relation, yielding a -permutation vector such that applying this permutation to LIST -sorts it in ascending order." - ;; ugly hack to "fix" lack of lexical scope - (let ((comp `(lambda (it other) (funcall ',comparator (car it) (car other))))) - (->> (--map-indexed (cons it it-index) list) - (-sort comp) - (-map 'cdr)))) - -(defun -grade-down (comparator list) - "Grade elements of LIST using COMPARATOR relation, yielding a -permutation vector such that applying this permutation to LIST -sorts it in descending order." - ;; ugly hack to "fix" lack of lexical scope - (let ((comp `(lambda (it other) (funcall ',comparator (car other) (car it))))) - (->> (--map-indexed (cons it it-index) list) - (-sort comp) - (-map 'cdr)))) - -(defmacro -when-let (var-val &rest body) - "If VAL evaluates to non-nil, bind it to VAR and execute body. -VAR-VAL should be a (VAR VAL) pair." - (declare (debug ((symbolp form) body)) - (indent 1)) - (let ((var (car var-val)) - (val (cadr var-val))) - `(let ((,var ,val)) - (when ,var - ,@body)))) - -(defmacro -when-let* (vars-vals &rest body) - "If all VALS evaluate to true, bind them to their corresponding -VARS and execute body. VARS-VALS should be a list of (VAR VAL) -pairs (corresponding to bindings of `let*')." - (declare (debug ((&rest (symbolp form)) body)) - (indent 1)) - (if (= (length vars-vals) 1) - `(-when-let ,(car vars-vals) - ,@body) - `(-when-let ,(car vars-vals) - (-when-let* ,(cdr vars-vals) - ,@body)))) - -(defmacro --when-let (val &rest body) - "If VAL evaluates to non-nil, bind it to `it' and execute -body." - (declare (debug (form body)) - (indent 1)) - `(let ((it ,val)) - (when it - ,@body))) - -(defmacro -if-let (var-val then &rest else) - "If VAL evaluates to non-nil, bind it to VAR and do THEN, -otherwise do ELSE. VAR-VAL should be a (VAR VAL) pair." - (declare (debug ((symbolp form) form body)) - (indent 2)) - (let ((var (car var-val)) - (val (cadr var-val))) - `(let ((,var ,val)) - (if ,var ,then ,@else)))) - -(defmacro -if-let* (vars-vals then &rest else) - "If all VALS evaluate to true, bind them to their corresponding -VARS and do THEN, otherwise do ELSE. VARS-VALS should be a list -of (VAR VAL) pairs (corresponding to the bindings of `let*')." - (declare (debug ((&rest (symbolp form)) form body)) - (indent 2)) - (let ((first-pair (car vars-vals)) - (rest (cdr vars-vals))) - (if (= (length vars-vals) 1) - `(-if-let ,first-pair ,then ,@else) - `(-if-let ,first-pair - (-if-let* ,rest ,then ,@else) - ,@else)))) - -(defmacro --if-let (val then &rest else) - "If VAL evaluates to non-nil, bind it to `it' and do THEN, -otherwise do ELSE." - (declare (debug (form form body)) - (indent 2)) - `(let ((it ,val)) - (if it ,then ,@else))) - -(defun dash--match-ignore-place-p (symbol) - "Return non-nil if SYMBOL is a symbol and starts with _." - (and (symbolp symbol) - (eq (aref (symbol-name symbol) 0) ?_))) - -(defun dash--match-cons-skip-cdr (skip-cdr source) - "Helper function generating idiomatic shifting code." - (cond - ((= skip-cdr 0) - `(pop ,source)) - (t - `(progn - (setq ,s (nthcdr ,skip-cdr ,s)) - (pop ,s))))) - -(defun dash--match-cons-get-car (skip-cdr source) - "Helper function generating idiomatic code to get nth car." - (cond - ((= skip-cdr 0) - `(car ,source)) - ((= skip-cdr 1) - `(cadr ,source)) - (t - `(nth ,skip-cdr ,source)))) - -(defun dash--match-cons-get-cdr (skip-cdr source) - "Helper function generating idiomatic code to get nth cdr." - (cond - ((= skip-cdr 0) - source) - ((= skip-cdr 1) - `(cdr ,source)) - (t - `(nthcdr ,skip-cdr ,source)))) - -(defun dash--match-cons (match-form source) - "Setup a cons matching environment and call the real matcher." - (let ((s (make-symbol "--dash-source--")) - (n 0) - (m match-form)) - (while (and (consp m) - (symbolp (car m)) - (eq (aref (symbol-name (car m)) 0) ?_)) - (setq n (1+ n)) (!cdr m)) - (cond - ;; handle improper lists - ((and (consp m) - (not (cdr m))) - (dash--match (car m) (dash--match-cons-get-car n source))) - ;; handle other special types - ((> n 0) - (dash--match m (dash--match-cons-get-cdr n source))) - ;; this is the only entry-point for dash--match-cons-1, that's - ;; why we can't simply use the above branch, it would produce - ;; infinite recursion - (t - (cons (list s source) (dash--match-cons-1 match-form s)))))) - -(defun dash--match-cons-1 (match-form source &optional props) - "Match MATCH-FORM against SOURCE. - -MATCH-FORM is a proper or improper list. Each element of -MATCH-FORM is either a symbol, which gets bound to the respective -value in source or another match form which gets destructured -recursively. - -If the cdr of last cons cell in the list is `nil', matching stops -there. - -SOURCE is a proper or improper list." - (let ((skip-cdr (or (plist-get props :skip-cdr) 0))) - (cond - ((consp match-form) - (cond - ((cdr match-form) - (cond - ((and (symbolp (car match-form)) - (eq (car match-form) '&keys)) - (dash--match-kv (cons '&plist (cdr match-form)) (dash--match-cons-get-cdr skip-cdr source))) - ((dash--match-ignore-place-p (car match-form)) - (dash--match-cons-1 (cdr match-form) source - (plist-put props :skip-cdr (1+ skip-cdr)))) - (t - (-concat (dash--match (car match-form) (dash--match-cons-skip-cdr skip-cdr source)) - (dash--match-cons-1 (cdr match-form) source))))) - (t ;; Last matching place, no need for shift - (dash--match (car match-form) (dash--match-cons-get-car skip-cdr source))))) - ((eq match-form nil) - nil) - (t ;; Handle improper lists. Last matching place, no need for shift - (dash--match match-form (dash--match-cons-get-cdr skip-cdr source)))))) - -(defun dash--vector-tail (seq start) - "Return the tail of SEQ starting at START." - (cond - ((vectorp seq) - (let* ((re-length (- (length seq) start)) - (re (make-vector re-length 0))) - (--dotimes re-length (aset re it (aref seq (+ it start)))) - re)) - ((stringp seq) - (substring seq start)))) - -(defun dash--match-vector (match-form source) - "Setup a vector matching environment and call the real matcher." - (let ((s (make-symbol "--dash-source--"))) - (cond - ;; don't bind `s' if we only have one sub-pattern - ((= (length match-form) 1) - (dash--match (aref match-form 0) `(aref ,source 0))) - ;; don't bind `s' if we only have one sub-pattern which is not ignored - ((let* ((ignored-places (mapcar 'dash--match-ignore-place-p match-form)) - (ignored-places-n (length (-remove 'null ignored-places)))) - (when (= ignored-places-n (1- (length match-form))) - (let ((n (-find-index 'null ignored-places))) - (dash--match (aref match-form n) `(aref ,source ,n)))))) - (t - (cons (list s source) (dash--match-vector-1 match-form s)))))) - -(defun dash--match-vector-1 (match-form source) - "Match MATCH-FORM against SOURCE. - -MATCH-FORM is a vector. Each element of MATCH-FORM is either a -symbol, which gets bound to the respective value in source or -another match form which gets destructured recursively. - -If second-from-last place in MATCH-FORM is the symbol &rest, the -next element of the MATCH-FORM is matched against the tail of -SOURCE, starting at index of the &rest symbol. This is -conceptually the same as the (head . tail) match for improper -lists, where dot plays the role of &rest. - -SOURCE is a vector. - -If the MATCH-FORM vector is shorter than SOURCE vector, only -the (length MATCH-FORM) places are bound, the rest of the SOURCE -is discarded." - (let ((i 0) - (l (length match-form)) - (re)) - (while (< i l) - (let ((m (aref match-form i))) - (push (cond - ((and (symbolp m) - (eq m '&rest)) - (prog1 (dash--match - (aref match-form (1+ i)) - `(dash--vector-tail ,source ,i)) - (setq i l))) - ((and (symbolp m) - ;; do not match symbols starting with _ - (not (eq (aref (symbol-name m) 0) ?_))) - (list (list m `(aref ,source ,i)))) - ((not (symbolp m)) - (dash--match m `(aref ,source ,i)))) - re) - (setq i (1+ i)))) - (-flatten-n 1 (nreverse re)))) - -(defun dash--match-kv (match-form source) - "Setup a kv matching environment and call the real matcher. - -kv can be any key-value store, such as plist, alist or hash-table." - (let ((s (make-symbol "--dash-source--"))) - (cond - ;; don't bind `s' if we only have one sub-pattern (&type key val) - ((= (length match-form) 3) - (dash--match-kv-1 (cdr match-form) source (car match-form))) - (t - (cons (list s source) (dash--match-kv-1 (cdr match-form) s (car match-form))))))) - -(defun dash--match-kv-1 (match-form source type) - "Match MATCH-FORM against SOURCE of type TYPE. - -MATCH-FORM is a proper list of the form (key1 place1 ... keyN -placeN). Each placeK is either a symbol, which gets bound to the -value of keyK retrieved from the key-value store, or another -match form which gets destructured recursively. - -SOURCE is a key-value store of type TYPE, which can be a plist, -an alist or a hash table. - -TYPE is a token specifying the type of the key-value store. -Valid values are &plist, &alist and &hash." - (-flatten-n 1 (-map - (lambda (kv) - (let* ((k (car kv)) - (v (cadr kv)) - (getter (cond - ((eq type '&plist) - `(plist-get ,source ,k)) - ((eq type '&alist) - `(cdr (assoc ,k ,source))) - ((eq type '&hash) - `(gethash ,k ,source))))) - (cond - ((symbolp v) - (list (list v getter))) - (t (dash--match v getter))))) - (-partition 2 match-form)))) - -(defun dash--match-symbol (match-form source) - "Bind a symbol. - -This works just like `let', there is no destructuring." - (list (list match-form source))) - -(defun dash--match (match-form source) - "Match MATCH-FORM against SOURCE. - -This function tests the MATCH-FORM and dispatches to specific -matchers based on the type of the expression. - -Key-value stores are disambiguated by placing a token &plist, -&alist or &hash as a first item in the MATCH-FORM." - (cond - ((symbolp match-form) - (dash--match-symbol match-form source)) - ((consp match-form) - (cond - ((memq (car match-form) '(&plist &alist &hash)) - (dash--match-kv match-form source)) - ((eq (car match-form) '&keys) - (dash--match-kv (cons '&plist (cdr match-form)) source)) - (t (dash--match-cons match-form source)))) - ((vectorp match-form) - (dash--match-vector match-form source)))) - -(defmacro -let* (varlist &rest body) - "Bind variables according to VARLIST then eval BODY. - -VARLIST is a list of lists of the form (PATTERN SOURCE). Each -PATTERN is matched against the SOURCE structurally. SOURCE is -only evaluated once for each PATTERN. - -Each SOURCE can refer to the symbols already bound by this -VARLIST. This is useful if you want to destructure SOURCE -recursively but also want to name the intermediate structures. - -See `-let' for the list of all possible patterns." - (declare (debug ((&rest (sexp form)) body)) - (indent 1)) - (let ((bindings (--mapcat (dash--match (car it) (cadr it)) varlist))) - `(let* ,bindings - ,@body))) - -(defmacro -let (varlist &rest body) - "Bind variables according to VARLIST then eval BODY. - -VARLIST is a list of lists of the form (PATTERN SOURCE). Each -PATTERN is matched against the SOURCE \"structurally\". SOURCE -is only evaluated once for each PATTERN. Each PATTERN is matched -recursively, and can therefore contain sub-patterns which are -matched against corresponding sub-expressions of SOURCE. - -All the SOURCEs are evalled before any symbols are -bound (i.e. \"in parallel\"). - -If VARLIST only contains one (PATTERN SOURCE) element, you can -optionally specify it using a vector and discarding the -outer-most parens. Thus - - (-let ((PATTERN SOURCE)) ..) - -becomes - - (-let [PATTERN SOURCE] ..). - -`-let' uses a convention of not binding places (symbols) starting -with _ whenever it's possible. You can use this to skip over -entries you don't care about. However, this is not *always* -possible (as a result of implementation) and these symbols might -get bound to undefined values. - -Following is the overview of supported patterns. Remember that -patterns can be matched recursively, so every a, b, aK in the -following can be a matching construct and not necessarily a -symbol/variable. - -Symbol: - - a - bind the SOURCE to A. This is just like regular `let'. - -Conses and lists: - - (a) - bind `car' of cons/list to A - - (a . b) - bind car of cons to A and `cdr' to B - - (a b) - bind car of list to A and `cadr' to B - - (a1 a2 a3 ...) - bind 0th car of list to A1, 1st to A2, 2nd to A3 ... - - (a1 a2 a3 ... aN . rest) - as above, but bind the Nth cdr to REST. - -Vectors: - - [a] - bind 0th element of a non-list sequence to A (works with - vectors, strings, bit arrays...) - - [a1 a2 a3 ...] - bind 0th element of non-list sequence to A0, 1st to - A1, 2nd to A2, ... - If the PATTERN is shorter than SOURCE, the values at - places not in PATTERN are ignored. - If the PATTERN is longer than SOURCE, an `error' is - thrown. - - [a1 a2 a3 ... &rest rest] ) - as above, but bind the rest of - the sequence to REST. This is - conceptually the same as improper list - matching (a1 a2 ... aN . rest) - -Key/value stores: - - (&plist key0 a0 ... keyN aN) - bind value mapped by keyK in the - SOURCE plist to aK. If the - value is not found, aK is nil. - - (&alist key0 a0 ... keyN aN) - bind value mapped by keyK in the - SOURCE alist to aK. If the - value is not found, aK is nil. - - (&hash key0 a0 ... keyN aN) - bind value mapped by keyK in the - SOURCE hash table to aK. If the - value is not found, aK is nil. - -Further, special keyword &keys supports \"inline\" matching of -plist-like key-value pairs, similarly to &keys keyword of -`cl-defun'. - - (a1 a2 ... aN &keys key1 b1 ... keyN bK) - -This binds N values from the list to a1 ... aN, then interprets -the cdr as a plist (see key/value matching above)." - (declare (debug ((&rest (sexp form)) body)) - (indent 1)) - (if (vectorp varlist) - `(let* ,(dash--match (aref varlist 0) (aref varlist 1)) - ,@body) - (let* ((inputs (--map-indexed (list (make-symbol (format "input%d" it-index)) (cadr it)) varlist)) - (new-varlist (--map (list (caar it) (cadr it)) (-zip varlist inputs)))) - `(let ,inputs - (-let* ,new-varlist ,@body))))) - -(defmacro -lambda (match-form &rest body) - "Return a lambda which destructures its input as MATCH-FORM and executes BODY. - -Note that you have to enclose the MATCH-FORM in a pair of parens, -such that: - - (-lambda (x) body) - (-lambda (x y ...) body) - -has the usual semantics of `lambda'. Furthermore, these get -translated into normal lambda, so there is no performance -penalty. - -See `-let' for the description of destructuring mechanism." - (cond - ((not (consp match-form)) - (signal 'wrong-type-argument "match-form must be a list")) - ;; no destructuring, so just return regular lambda to make things faster - ((-all? 'symbolp match-form) - `(lambda ,match-form ,@body)) - (t - (let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form))) - ;; TODO: because inputs to the lambda are evaluated only once, - ;; -let* need not to create the extra bindings to ensure that. - ;; We should find a way to optimize that. Not critical however. - `(lambda ,(--map (cadr it) inputs) - (-let* ,inputs ,@body)))))) - -(defun -distinct (list) - "Return a new list with all duplicates removed. -The test for equality is done with `equal', -or with `-compare-fn' if that's non-nil. - -Alias: `-uniq'" - (let (result) - (--each list (unless (-contains? result it) (!cons it result))) - (nreverse result))) - -(defalias '-uniq '-distinct) - -(defun -union (list list2) - "Return a new list containing the elements of LIST1 and elements of LIST2 that are not in LIST1. -The test for equality is done with `equal', -or with `-compare-fn' if that's non-nil." - (let (result) - (--each list (!cons it result)) - (--each list2 (unless (-contains? result it) (!cons it result))) - (nreverse result))) - -(defun -intersection (list list2) - "Return a new list containing only the elements that are members of both LIST and LIST2. -The test for equality is done with `equal', -or with `-compare-fn' if that's non-nil." - (--filter (-contains? list2 it) list)) - -(defun -difference (list list2) - "Return a new list with only the members of LIST that are not in LIST2. -The test for equality is done with `equal', -or with `-compare-fn' if that's non-nil." - (--filter (not (-contains? list2 it)) list)) - -(defvar -compare-fn nil - "Tests for equality use this function or `equal' if this is nil. -It should only be set using dynamic scope with a let, like: - - (let ((-compare-fn =)) (-union numbers1 numbers2 numbers3)") - -(defun -contains? (list element) - "Return non-nil if LIST contains ELEMENT. - -The test for equality is done with `equal', or with `-compare-fn' -if that's non-nil. - -Alias: `-contains-p'" - (not - (null - (cond - ((null -compare-fn) (member element list)) - ((eq -compare-fn 'eq) (memq element list)) - ((eq -compare-fn 'eql) (memql element list)) - (t - (let ((lst list)) - (while (and lst - (not (funcall -compare-fn element (car lst)))) - (setq lst (cdr lst))) - lst)))))) - -(defalias '-contains-p '-contains?) - -(defun -same-items? (list list2) - "Return true if LIST and LIST2 has the same items. - -The order of the elements in the lists does not matter. - -Alias: `-same-items-p'" - (let ((length-a (length list)) - (length-b (length list2))) - (and - (= length-a length-b) - (= length-a (length (-intersection list list2)))))) - -(defalias '-same-items-p '-same-items?) - -(defun -is-prefix? (prefix list) - "Return non-nil if PREFIX is prefix of LIST. - -Alias: `-is-prefix-p'" - (--each-while list (equal (car prefix) it) - (!cdr prefix)) - (not prefix)) - -(defun -is-suffix? (suffix list) - "Return non-nil if SUFFIX is suffix of LIST. - -Alias: `-is-suffix-p'" - (-is-prefix? (nreverse suffix) (nreverse list))) - -(defun -is-infix? (infix list) - "Return non-nil if INFIX is infix of LIST. - -This operation runs in O(n^2) time - -Alias: `-is-infix-p'" - (let (done) - (while (and (not done) list) - (setq done (-is-prefix? infix list)) - (!cdr list)) - done)) - -(defalias '-is-prefix-p '-is-prefix?) -(defalias '-is-suffix-p '-is-suffix?) -(defalias '-is-infix-p '-is-infix?) - -(defun -sort (comparator list) - "Sort LIST, stably, comparing elements using COMPARATOR. -Return the sorted list. LIST is NOT modified by side effects. -COMPARATOR is called with two elements of LIST, and should return non-nil -if the first element should sort before the second." - (sort (copy-sequence list) comparator)) - -(defmacro --sort (form list) - "Anaphoric form of `-sort'." - (declare (debug (form form))) - `(-sort (lambda (it other) ,form) ,list)) - -(defun -list (&rest args) - "Return a list with ARGS. - -If first item of ARGS is already a list, simply return ARGS. If -not, return a list with ARGS as elements." - (let ((arg (car args))) - (if (listp arg) arg args))) - -(defun -repeat (n x) - "Return a list with X repeated N times. -Return nil if N is less than 1." - (let (ret) - (--dotimes n (!cons x ret)) - ret)) - -(defun -sum (list) - "Return the sum of LIST." - (apply '+ list)) - -(defun -product (list) - "Return the product of LIST." - (apply '* list)) - -(defun -max (list) - "Return the largest value from LIST of numbers or markers." - (apply 'max list)) - -(defun -min (list) - "Return the smallest value from LIST of numbers or markers." - (apply 'min list)) - -(defun -max-by (comparator list) - "Take a comparison function COMPARATOR and a LIST and return -the greatest element of the list by the comparison function. - -See also combinator `-on' which can transform the values before -comparing them." - (--reduce (if (funcall comparator it acc) it acc) list)) - -(defun -min-by (comparator list) - "Take a comparison function COMPARATOR and a LIST and return -the least element of the list by the comparison function. - -See also combinator `-on' which can transform the values before -comparing them." - (--reduce (if (funcall comparator it acc) acc it) list)) - -(defmacro --max-by (form list) - "Anaphoric version of `-max-by'. - -The items for the comparator form are exposed as \"it\" and \"other\"." - (declare (debug (form form))) - `(-max-by (lambda (it other) ,form) ,list)) - -(defmacro --min-by (form list) - "Anaphoric version of `-min-by'. - -The items for the comparator form are exposed as \"it\" and \"other\"." - (declare (debug (form form))) - `(-min-by (lambda (it other) ,form) ,list)) - -(defun -iterate (fun init n) - "Return a list of iterated applications of FUN to INIT. - -This means a list of form: - - (init (fun init) (fun (fun init)) ...) - -N is the length of the returned list." - (if (= n 0) nil - (let ((r (list init))) - (--dotimes (1- n) - (push (funcall fun (car r)) r)) - (nreverse r)))) - -(defmacro --iterate (form init n) - "Anaphoric version of `-iterate'." - (declare (debug (form form form))) - `(-iterate (lambda (it) ,form) ,init ,n)) - -(defun -fix (fn list) - "Compute the (least) fixpoint of FN with initial input LIST. - -FN is called at least once, results are compared with `equal'." - (let ((re (funcall fn list))) - (while (not (equal list re)) - (setq list re) - (setq re (funcall fn re))) - re)) - -(defmacro --fix (form list) - "Anaphoric form of `-fix'." - `(-fix (lambda (it) ,form) ,list)) - -(defun -unfold (fun seed) - "Build a list from SEED using FUN. - -This is \"dual\" operation to `-reduce-r': while -reduce-r -consumes a list to produce a single value, `-unfold' takes a -seed value and builds a (potentially infinite!) list. - -FUN should return `nil' to stop the generating process, or a -cons (A . B), where A will be prepended to the result and B is -the new seed." - (let ((last (funcall fun seed)) r) - (while last - (push (car last) r) - (setq last (funcall fun (cdr last)))) - (nreverse r))) - -(defmacro --unfold (form seed) - "Anaphoric version of `-unfold'." - (declare (debug (form form))) - `(-unfold (lambda (it) ,form) ,seed)) - -(defun -cons-pair? (con) - "Return non-nil if CON is true cons pair. -That is (A . B) where B is not a list." - (and (listp con) - (not (listp (cdr con))))) - -(defun -cons-to-list (con) - "Convert a cons pair to a list with `car' and `cdr' of the pair respectively." - (list (car con) (cdr con))) - -(defun -value-to-list (val) - "Convert a value to a list. - -If the value is a cons pair, make a list with two elements, `car' -and `cdr' of the pair respectively. - -If the value is anything else, wrap it in a list." - (cond - ((-cons-pair? val) (-cons-to-list val)) - (t (list val)))) - -(defun -tree-mapreduce-from (fn folder init-value tree) - "Apply FN to each element of TREE, and make a list of the results. -If elements of TREE are lists themselves, apply FN recursively to -elements of these nested lists. - -Then reduce the resulting lists using FOLDER and initial value -INIT-VALUE. See `-reduce-r-from'. - -This is the same as calling `-tree-reduce-from' after `-tree-map' -but is twice as fast as it only traverse the structure once." - (cond - ((not tree) nil) - ((-cons-pair? tree) (funcall fn tree)) - ((listp tree) - (-reduce-r-from folder init-value (mapcar (lambda (x) (-tree-mapreduce-from fn folder init-value x)) tree))) - (t (funcall fn tree)))) - -(defmacro --tree-mapreduce-from (form folder init-value tree) - "Anaphoric form of `-tree-mapreduce-from'." - (declare (debug (form form form form))) - `(-tree-mapreduce-from (lambda (it) ,form) (lambda (it acc) ,folder) ,init-value ,tree)) - -(defun -tree-mapreduce (fn folder tree) - "Apply FN to each element of TREE, and make a list of the results. -If elements of TREE are lists themselves, apply FN recursively to -elements of these nested lists. - -Then reduce the resulting lists using FOLDER and initial value -INIT-VALUE. See `-reduce-r-from'. - -This is the same as calling `-tree-reduce' after `-tree-map' -but is twice as fast as it only traverse the structure once." - (cond - ((not tree) nil) - ((-cons-pair? tree) (funcall fn tree)) - ((listp tree) - (-reduce-r folder (mapcar (lambda (x) (-tree-mapreduce fn folder x)) tree))) - (t (funcall fn tree)))) - -(defmacro --tree-mapreduce (form folder tree) - "Anaphoric form of `-tree-mapreduce'." - (declare (debug (form form form))) - `(-tree-mapreduce (lambda (it) ,form) (lambda (it acc) ,folder) ,tree)) - -(defun -tree-map (fn tree) - "Apply FN to each element of TREE while preserving the tree structure." - (cond - ((not tree) nil) - ((-cons-pair? tree) (funcall fn tree)) - ((listp tree) - (mapcar (lambda (x) (-tree-map fn x)) tree)) - (t (funcall fn tree)))) - -(defmacro --tree-map (form tree) - "Anaphoric form of `-tree-map'." - (declare (debug (form form))) - `(-tree-map (lambda (it) ,form) ,tree)) - -(defun -tree-reduce-from (fn init-value tree) - "Use FN to reduce elements of list TREE. -If elements of TREE are lists themselves, apply the reduction recursively. - -FN is first applied to INIT-VALUE and first element of the list, -then on this result and second element from the list etc. - -The initial value is ignored on cons pairs as they always contain -two elements." - (cond - ((not tree) nil) - ((-cons-pair? tree) tree) - ((listp tree) - (-reduce-r-from fn init-value (mapcar (lambda (x) (-tree-reduce-from fn init-value x)) tree))) - (t tree))) - -(defmacro --tree-reduce-from (form init-value tree) - "Anaphoric form of `-tree-reduce-from'." - (declare (debug (form form form))) - `(-tree-reduce-from (lambda (it acc) ,form) ,init-value ,tree)) - -(defun -tree-reduce (fn tree) - "Use FN to reduce elements of list TREE. -If elements of TREE are lists themselves, apply the reduction recursively. - -FN is first applied to first element of the list and second -element, then on this result and third element from the list etc. - -See `-reduce-r' for how exactly are lists of zero or one element handled." - (cond - ((not tree) nil) - ((-cons-pair? tree) tree) - ((listp tree) - (-reduce-r fn (mapcar (lambda (x) (-tree-reduce fn x)) tree))) - (t tree))) - -(defmacro --tree-reduce (form tree) - "Anaphoric form of `-tree-reduce'." - (declare (debug (form form))) - `(-tree-reduce (lambda (it acc) ,form) ,tree)) - -(defun -tree-map-nodes (pred fun tree) - "Call FUN on each node of TREE that satisfies PRED. - -If PRED returns nil, continue descending down this node. If PRED -returns non-nil, apply FUN to this node and do not descend -further." - (if (funcall pred tree) - (funcall fun tree) - (if (listp tree) - (-map (lambda (x) (-tree-map-nodes pred fun x)) tree) - tree))) - -(defmacro --tree-map-nodes (pred form tree) - "Anaphoric form of `-tree-map-nodes'." - `(-tree-map-nodes (lambda (it) ,pred) (lambda (it) ,form) ,tree)) - -(defun -tree-seq (branch children tree) - "Return a sequence of the nodes in TREE, in depth-first search order. - -BRANCH is a predicate of one argument that returns non-nil if the -passed argument is a branch, that is, a node that can have children. - -CHILDREN is a function of one argument that returns the children -of the passed branch node. - -Non-branch nodes are simply copied." - (cons tree - (when (funcall branch tree) - (-mapcat (lambda (x) (-tree-seq branch children x)) - (funcall children tree))))) - -(defmacro --tree-seq (branch children tree) - "Anaphoric form of `-tree-seq'." - `(-tree-seq (lambda (it) ,branch) (lambda (it) ,children) ,tree)) - -(defun -clone (list) - "Create a deep copy of LIST. -The new list has the same elements and structure but all cons are -replaced with new ones. This is useful when you need to clone a -structure such as plist or alist." - (-tree-map 'identity list)) - -(defun dash-enable-font-lock () - "Add syntax highlighting to dash functions, macros and magic values." - (eval-after-load "lisp-mode" - '(progn - (let ((new-keywords '( - "-each" - "--each" - "-each-while" - "--each-while" - "-dotimes" - "--dotimes" - "-map" - "--map" - "-reduce-from" - "--reduce-from" - "-reduce" - "--reduce" - "-reduce-r-from" - "--reduce-r-from" - "-reduce-r" - "--reduce-r" - "-filter" - "--filter" - "-select" - "--select" - "-remove" - "--remove" - "-reject" - "--reject" - "-non-nil" - "-keep" - "--keep" - "-map-indexed" - "--map-indexed" - "-splice" - "--splice" - "-splice-list" - "--splice-list" - "-map-when" - "--map-when" - "-replace-where" - "--replace-where" - "-replace" - "-flatten" - "-flatten-n" - "-concat" - "-mapcat" - "--mapcat" - "-copy" - "-cons*" - "-snoc" - "-first" - "--first" - "-find" - "--find" - "-last" - "--last" - "-first-item" - "-last-item" - "-butlast" - "-count" - "--count" - "-any?" - "--any?" - "-some?" - "--some?" - "-any-p" - "--any-p" - "-some-p" - "--some-p" - "-all?" - "--all?" - "-every?" - "--every?" - "-all-p" - "--all-p" - "-every-p" - "--every-p" - "-none?" - "--none?" - "-none-p" - "--none-p" - "-only-some?" - "--only-some?" - "-only-some-p" - "--only-some-p" - "-slice" - "-take" - "-drop" - "-take-while" - "--take-while" - "-drop-while" - "--drop-while" - "-split-at" - "-rotate" - "-insert-at" - "-replace-at" - "-update-at" - "--update-at" - "-remove-at" - "-remove-at-indices" - "-split-with" - "--split-with" - "-split-on" - "-split-when" - "--split-when" - "-separate" - "--separate" - "-partition-all-in-steps" - "-partition-in-steps" - "-partition-all" - "-partition" - "-partition-by" - "--partition-by" - "-partition-by-header" - "--partition-by-header" - "-group-by" - "--group-by" - "-interpose" - "-interleave" - "-zip-with" - "--zip-with" - "-zip" - "-zip-fill" - "-cycle" - "-pad" - "-annotate" - "--annotate" - "-table" - "-table-flat" - "-partial" - "-elem-index" - "-elem-indices" - "-find-indices" - "--find-indices" - "-find-index" - "--find-index" - "-find-last-index" - "--find-last-index" - "-select-by-indices" - "-grade-up" - "-grade-down" - "->" - "->>" - "-->" - "-when-let" - "-when-let*" - "--when-let" - "-if-let" - "-if-let*" - "--if-let" - "-let*" - "-let" - "-lambda" - "-distinct" - "-uniq" - "-union" - "-intersection" - "-difference" - "-contains?" - "-contains-p" - "-same-items?" - "-same-items-p" - "-is-prefix-p" - "-is-prefix?" - "-is-suffix-p" - "-is-suffix?" - "-is-infix-p" - "-is-infix?" - "-sort" - "--sort" - "-list" - "-repeat" - "-sum" - "-product" - "-max" - "-min" - "-max-by" - "--max-by" - "-min-by" - "--min-by" - "-iterate" - "--iterate" - "-fix" - "--fix" - "-unfold" - "--unfold" - "-cons-pair?" - "-cons-to-list" - "-value-to-list" - "-tree-mapreduce-from" - "--tree-mapreduce-from" - "-tree-mapreduce" - "--tree-mapreduce" - "-tree-map" - "--tree-map" - "-tree-reduce-from" - "--tree-reduce-from" - "-tree-reduce" - "--tree-reduce" - "-tree-seq" - "--tree-seq" - "-tree-map-nodes" - "--tree-map-nodes" - "-clone" - "-rpartial" - "-juxt" - "-applify" - "-on" - "-flip" - "-const" - "-cut" - "-orfn" - "-andfn" - "-iteratefn" - "-fixfn" - "-prodfn" - )) - (special-variables '( - "it" - "it-index" - "acc" - "other" - ))) - (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "\\_<" (regexp-opt special-variables 'paren) "\\_>") - 1 font-lock-variable-name-face)) 'append) - (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "(\\s-*" (regexp-opt new-keywords 'paren) "\\_>") - 1 font-lock-keyword-face)) 'append)) - (--each (buffer-list) - (with-current-buffer it - (when (and (eq major-mode 'emacs-lisp-mode) - (boundp 'font-lock-mode) - font-lock-mode) - (font-lock-refresh-defaults))))))) - -(provide 'dash) -;;; dash.el ends here diff --git a/emacs.d/elpa/dash-20150503.1343/dash-autoloads.el b/emacs.d/elpa/dash-20150503.1343/dash-autoloads.el new file mode 100644 index 0000000..9ec0c9c --- /dev/null +++ b/emacs.d/elpa/dash-20150503.1343/dash-autoloads.el @@ -0,0 +1,15 @@ +;;; dash-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil nil ("dash.el") (21837 24216 457071 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; dash-autoloads.el ends here diff --git a/emacs.d/elpa/dash-20150503.1343/dash-pkg.el b/emacs.d/elpa/dash-20150503.1343/dash-pkg.el new file mode 100644 index 0000000..ec88d1a --- /dev/null +++ b/emacs.d/elpa/dash-20150503.1343/dash-pkg.el @@ -0,0 +1 @@ +(define-package "dash" "20150503.1343" "A modern list library for Emacs" 'nil :keywords '("lists")) diff --git a/emacs.d/elpa/dash-20150503.1343/dash.el b/emacs.d/elpa/dash-20150503.1343/dash.el new file mode 100644 index 0000000..357d0df --- /dev/null +++ b/emacs.d/elpa/dash-20150503.1343/dash.el @@ -0,0 +1,2374 @@ +;;; dash.el --- A modern list library for Emacs + +;; Copyright (C) 2012-2014 Magnar Sveen + +;; Author: Magnar Sveen +;; Version: 2.10.0 +;; Package-Version: 20150503.1343 +;; Keywords: lists + +;; 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 modern list api for Emacs. +;; +;; See documentation on https://github.com/magnars/dash.el#functions + +;;; Code: + +(defgroup dash () + "Customize group for dash.el" + :group 'lisp + :prefix "dash-") + +(defun dash--enable-fontlock (symbol value) + (when value + (dash-enable-font-lock)) + (set-default symbol value)) + +(defcustom dash-enable-fontlock nil + "If non-nil, enable fontification of dash functions, macros and +special values." + :type 'boolean + :set 'dash--enable-fontlock + :group 'dash) + +(defmacro !cons (car cdr) + "Destructive: Set CDR to the cons of CAR and CDR." + `(setq ,cdr (cons ,car ,cdr))) + +(defmacro !cdr (list) + "Destructive: Set LIST to the cdr of LIST." + `(setq ,list (cdr ,list))) + +(defmacro --each (list &rest body) + "Anaphoric form of `-each'." + (declare (debug (form body)) + (indent 1)) + (let ((l (make-symbol "list"))) + `(let ((,l ,list) + (it-index 0)) + (while ,l + (let ((it (car ,l))) + ,@body) + (setq it-index (1+ it-index)) + (!cdr ,l))))) + +(defun -each (list fn) + "Call FN with every item in LIST. Return nil, used for side-effects only." + (--each list (funcall fn it))) + +(put '-each 'lisp-indent-function 1) + +(defmacro --each-while (list pred &rest body) + "Anaphoric form of `-each-while'." + (declare (debug (form form body)) + (indent 2)) + (let ((l (make-symbol "list")) + (c (make-symbol "continue"))) + `(let ((,l ,list) + (,c t) + (it-index 0)) + (while (and ,l ,c) + (let ((it (car ,l))) + (if (not ,pred) (setq ,c nil) ,@body)) + (setq it-index (1+ it-index)) + (!cdr ,l))))) + +(defun -each-while (list pred fn) + "Call FN with every item in LIST while (PRED item) is non-nil. +Return nil, used for side-effects only." + (--each-while list (funcall pred it) (funcall fn it))) + +(put '-each-while 'lisp-indent-function 2) + +(defmacro --dotimes (num &rest body) + "Repeatedly executes BODY (presumably for side-effects) with `it` bound to integers from 0 through NUM-1." + (declare (debug (form body)) + (indent 1)) + (let ((n (make-symbol "num"))) + `(let ((,n ,num) + (it 0)) + (while (< it ,n) + ,@body + (setq it (1+ it)))))) + +(defun -dotimes (num fn) + "Repeatedly calls FN (presumably for side-effects) passing in integers from 0 through NUM-1." + (--dotimes num (funcall fn it))) + +(put '-dotimes 'lisp-indent-function 1) + +(defun -map (fn list) + "Return a new list consisting of the result of applying FN to the items in LIST." + (mapcar fn list)) + +(defmacro --map (form list) + "Anaphoric form of `-map'." + (declare (debug (form form))) + `(mapcar (lambda (it) ,form) ,list)) + +(defmacro --reduce-from (form initial-value list) + "Anaphoric form of `-reduce-from'." + (declare (debug (form form form))) + `(let ((acc ,initial-value)) + (--each ,list (setq acc ,form)) + acc)) + +(defun -reduce-from (fn initial-value list) + "Return the result of applying FN to INITIAL-VALUE and the +first item in LIST, then applying FN to that result and the 2nd +item, etc. If LIST contains no items, return INITIAL-VALUE and +FN is not called. + +In the anaphoric form `--reduce-from', the accumulated value is +exposed as `acc`." + (--reduce-from (funcall fn acc it) initial-value list)) + +(defmacro --reduce (form list) + "Anaphoric form of `-reduce'." + (declare (debug (form form))) + (let ((lv (make-symbol "list-value"))) + `(let ((,lv ,list)) + (if ,lv + (--reduce-from ,form (car ,lv) (cdr ,lv)) + (let (acc it) ,form))))) + +(defun -reduce (fn list) + "Return the result of applying FN to the first 2 items in LIST, +then applying FN to that result and the 3rd item, etc. If LIST +contains no items, FN must accept no arguments as well, and +reduce return the result of calling FN with no arguments. If +LIST has only 1 item, it is returned and FN is not called. + +In the anaphoric form `--reduce', the accumulated value is +exposed as `acc`." + (if list + (-reduce-from fn (car list) (cdr list)) + (funcall fn))) + +(defun -reduce-r-from (fn initial-value list) + "Replace conses with FN, nil with INITIAL-VALUE and evaluate +the resulting expression. If LIST is empty, INITIAL-VALUE is +returned and FN is not called. + +Note: this function works the same as `-reduce-from' but the +operation associates from right instead of from left." + (if (not list) initial-value + (funcall fn (car list) (-reduce-r-from fn initial-value (cdr list))))) + +(defmacro --reduce-r-from (form initial-value list) + "Anaphoric version of `-reduce-r-from'." + (declare (debug (form form form))) + `(-reduce-r-from (lambda (&optional it acc) ,form) ,initial-value ,list)) + +(defun -reduce-r (fn list) + "Replace conses with FN and evaluate the resulting expression. +The final nil is ignored. If LIST contains no items, FN must +accept no arguments as well, and reduce return the result of +calling FN with no arguments. If LIST has only 1 item, it is +returned and FN is not called. + +The first argument of FN is the new item, the second is the +accumulated value. + +Note: this function works the same as `-reduce' but the operation +associates from right instead of from left." + (cond + ((not list) (funcall fn)) + ((not (cdr list)) (car list)) + (t (funcall fn (car list) (-reduce-r fn (cdr list)))))) + +(defmacro --reduce-r (form list) + "Anaphoric version of `-reduce-r'." + (declare (debug (form form))) + `(-reduce-r (lambda (&optional it acc) ,form) ,list)) + +(defmacro --filter (form list) + "Anaphoric form of `-filter'." + (declare (debug (form form))) + (let ((r (make-symbol "result"))) + `(let (,r) + (--each ,list (when ,form (!cons it ,r))) + (nreverse ,r)))) + +(defun -filter (pred list) + "Return a new list of the items in LIST for which PRED returns a non-nil value. + +Alias: `-select'" + (--filter (funcall pred it) list)) + +(defalias '-select '-filter) +(defalias '--select '--filter) + +(defmacro --remove (form list) + "Anaphoric form of `-remove'." + (declare (debug (form form))) + `(--filter (not ,form) ,list)) + +(defun -remove (pred list) + "Return a new list of the items in LIST for which PRED returns nil. + +Alias: `-reject'" + (--remove (funcall pred it) list)) + +(defalias '-reject '-remove) +(defalias '--reject '--remove) + +(defun -remove-first (pred list) + "Return a new list with the first item matching PRED removed. + +Alias: `-reject-first' + +See also: `-remove', `-map-first'" + (let (front) + (while (and list (not (funcall pred (car list)))) + (push (car list) front) + (!cdr list)) + (if list + (-concat (nreverse front) (cdr list)) + (nreverse front)))) + +(defmacro --remove-first (form list) + "Anaphoric form of `-remove-first'." + (declare (debug (form form))) + `(-remove-first (lambda (it) ,form) ,list)) + +(defalias '-reject-first '-remove-first) +(defalias '--reject-first '--remove-first) + +(defun -remove-last (pred list) + "Return a new list with the last item matching PRED removed. + +Alias: `-reject-last' + +See also: `-remove', `-map-last'" + (nreverse (-remove-first pred (nreverse list)))) + +(defmacro --remove-last (form list) + "Anaphoric form of `-remove-last'." + (declare (debug (form form))) + `(-remove-last (lambda (it) ,form) ,list)) + +(defalias '-reject-last '-remove-last) +(defalias '--reject-last '--remove-last) + +(defun -remove-item (item list) + "Remove all occurences of ITEM from LIST. + +Comparison is done with `equal'." + (--remove (equal it item) list)) + +(defmacro --keep (form list) + "Anaphoric form of `-keep'." + (declare (debug (form form))) + (let ((r (make-symbol "result")) + (m (make-symbol "mapped"))) + `(let (,r) + (--each ,list (let ((,m ,form)) (when ,m (!cons ,m ,r)))) + (nreverse ,r)))) + +(defun -keep (fn list) + "Return a new list of the non-nil results of applying FN to the items in LIST. + +If you want to select the original items satisfying a predicate use `-filter'." + (--keep (funcall fn it) list)) + +(defun -non-nil (list) + "Return all non-nil elements of LIST." + (-remove 'null list)) + +(defmacro --map-indexed (form list) + "Anaphoric form of `-map-indexed'." + (declare (debug (form form))) + (let ((r (make-symbol "result"))) + `(let (,r) + (--each ,list + (!cons ,form ,r)) + (nreverse ,r)))) + +(defun -map-indexed (fn list) + "Return a new list consisting of the result of (FN index item) for each item in LIST. + +In the anaphoric form `--map-indexed', the index is exposed as `it-index`." + (--map-indexed (funcall fn it-index it) list)) + +(defmacro --map-when (pred rep list) + "Anaphoric form of `-map-when'." + (declare (debug (form form form))) + (let ((r (make-symbol "result"))) + `(let (,r) + (--each ,list (!cons (if ,pred ,rep it) ,r)) + (nreverse ,r)))) + +(defun -map-when (pred rep list) + "Return a new list where the elements in LIST that does not match the PRED function +are unchanged, and where the elements in LIST that do match the PRED function are mapped +through the REP function. + +Alias: `-replace-where' + +See also: `-update-at'" + (--map-when (funcall pred it) (funcall rep it) list)) + +(defalias '-replace-where '-map-when) +(defalias '--replace-where '--map-when) + +(defun -map-first (pred rep list) + "Replace first item in LIST satisfying PRED with result of REP called on this item. + +See also: `-map-when', `-replace-first'" + (let (front) + (while (and list (not (funcall pred (car list)))) + (push (car list) front) + (!cdr list)) + (if list + (-concat (nreverse front) (cons (funcall rep (car list)) (cdr list))) + (nreverse front)))) + +(defmacro --map-first (pred rep list) + "Anaphoric form of `-map-first'." + `(-map-first (lambda (it) ,pred) (lambda (it) ,rep) ,list)) + +(defun -map-last (pred rep list) + "Replace first item in LIST satisfying PRED with result of REP called on this item. + +See also: `-map-when', `-replace-last'" + (nreverse (-map-first pred rep (nreverse list)))) + +(defmacro --map-last (pred rep list) + "Anaphoric form of `-map-last'." + `(-map-last (lambda (it) ,pred) (lambda (it) ,rep) ,list)) + +(defun -replace (old new list) + "Replace all OLD items in LIST with NEW. + +Elements are compared using `equal'. + +See also: `-replace-at'" + (--map-when (equal it old) new list)) + +(defun -replace-first (old new list) + "Replace the first occurence of OLD with NEW in LIST. + +Elements are compared using `equal'. + +See also: `-map-first'" + (--map-first (equal old it) new list)) + +(defun -replace-last (old new list) + "Replace the last occurence of OLD with NEW in LIST. + +Elements are compared using `equal'. + +See also: `-map-last'" + (--map-last (equal old it) new list)) + +(defmacro --mapcat (form list) + "Anaphoric form of `-mapcat'." + (declare (debug (form form))) + `(apply 'append (--map ,form ,list))) + +(defun -mapcat (fn list) + "Return the concatenation of the result of mapping FN over LIST. +Thus function FN should return a list." + (--mapcat (funcall fn it) list)) + +(defun -flatten (l) + "Take a nested list L and return its contents as a single, flat list. + +See also: `-flatten-n'" + (if (and (listp l) (listp (cdr l))) + (-mapcat '-flatten l) + (list l))) + +(defmacro --iterate (form init n) + "Anaphoric version of `-iterate'." + (declare (debug (form form form))) + `(-iterate (lambda (it) ,form) ,init ,n)) + +(defun -flatten-n (num list) + "Flatten NUM levels of a nested LIST. + +See also: `-flatten'" + (-last-item (--iterate (--mapcat (-list it) it) list (1+ num)))) + +(defun -concat (&rest lists) + "Return a new list with the concatenation of the elements in the supplied LISTS." + (apply 'append lists)) + +(defalias '-copy 'copy-sequence + "Create a shallow copy of LIST.") + +(defun -splice (pred fun list) + "Splice lists generated by FUN in place of elements matching PRED in LIST. + +FUN takes the element matching PRED as input. + +This function can be used as replacement for `,@' in case you +need to splice several lists at marked positions (for example +with keywords). + +See also: `-splice-list', `-insert-at'" + (let (r) + (--each list + (if (funcall pred it) + (let ((new (funcall fun it))) + (--each new (!cons it r))) + (!cons it r))) + (nreverse r))) + +(defmacro --splice (pred form list) + "Anaphoric form of `-splice'." + `(-splice (lambda (it) ,pred) (lambda (it) ,form) ,list)) + +(defun -splice-list (pred new-list list) + "Splice NEW-LIST in place of elements matching PRED in LIST. + +See also: `-splice', `-insert-at'" + (-splice pred (lambda (_) new-list) list)) + +(defmacro --splice-list (pred new-list list) + "Anaphoric form of `-splice-list'." + `(-splice-list (lambda (it) ,pred) ,new-list ,list)) + +(defun -cons* (&rest args) + "Make a new list from the elements of ARGS. + +The last 2 members of ARGS are used as the final cons of the +result so if the final member of ARGS is not a list the result is +a dotted list." + (-reduce-r 'cons args)) + +(defun -snoc (list elem &rest elements) + "Append ELEM to the end of the list. + +This is like `cons', but operates on the end of list. + +If ELEMENTS is non nil, append these to the list as well." + (-concat list (list elem) elements)) + +(defmacro --first (form list) + "Anaphoric form of `-first'." + (declare (debug (form form))) + (let ((n (make-symbol "needle"))) + `(let (,n) + (--each-while ,list (not ,n) + (when ,form (setq ,n it))) + ,n))) + +(defun -first (pred list) + "Return the first x in LIST where (PRED x) is non-nil, else nil. + +To get the first item in the list no questions asked, use `car'. + +Alias: `-find'" + (--first (funcall pred it) list)) + +(defalias '-find '-first) +(defalias '--find '--first) + +(defmacro --some (form list) + "Anaphoric form of `-some'." + (declare (debug (form form))) + (let ((n (make-symbol "needle"))) + `(let (,n) + (--each-while ,list (not ,n) + (setq ,n ,form)) + ,n))) + +(defun -some (pred list) + "Return (PRED x) for the first LIST item where (PRED x) is non-nil, else nil. + +Alias: `-any'" + (--some (funcall pred it) list)) + +(defalias '-any '-some) +(defalias '--any '--some) + +(defmacro --last (form list) + "Anaphoric form of `-last'." + (declare (debug (form form))) + (let ((n (make-symbol "needle"))) + `(let (,n) + (--each ,list + (when ,form (setq ,n it))) + ,n))) + +(defun -last (pred list) + "Return the last x in LIST where (PRED x) is non-nil, else nil." + (--last (funcall pred it) list)) + +(defalias '-first-item 'car + "Return the first item of LIST, or nil on an empty list.") + +(defun -last-item (list) + "Return the last item of LIST, or nil on an empty list." + (car (last list))) + +(defun -butlast (list) + "Return a list of all items in list except for the last." + (let (result) + (while (cdr list) + (!cons (car list) result) + (!cdr list)) + (nreverse result))) + +(defmacro --count (pred list) + "Anaphoric form of `-count'." + (declare (debug (form form))) + (let ((r (make-symbol "result"))) + `(let ((,r 0)) + (--each ,list (when ,pred (setq ,r (1+ ,r)))) + ,r))) + +(defun -count (pred list) + "Counts the number of items in LIST where (PRED item) is non-nil." + (--count (funcall pred it) list)) + +(defun ---truthy? (val) + (not (null val))) + +(defmacro --any? (form list) + "Anaphoric form of `-any?'." + (declare (debug (form form))) + `(---truthy? (--first ,form ,list))) + +(defun -any? (pred list) + "Return t if (PRED x) is non-nil for any x in LIST, else nil. + +Alias: `-any-p', `-some?', `-some-p'" + (--any? (funcall pred it) list)) + +(defalias '-some? '-any?) +(defalias '--some? '--any?) +(defalias '-any-p '-any?) +(defalias '--any-p '--any?) +(defalias '-some-p '-any?) +(defalias '--some-p '--any?) + +(defmacro --all? (form list) + "Anaphoric form of `-all?'." + (declare (debug (form form))) + (let ((a (make-symbol "all"))) + `(let ((,a t)) + (--each-while ,list ,a (setq ,a ,form)) + (---truthy? ,a)))) + +(defun -all? (pred list) + "Return t if (PRED x) is non-nil for all x in LIST, else nil. + +Alias: `-all-p', `-every?', `-every-p'" + (--all? (funcall pred it) list)) + +(defalias '-every? '-all?) +(defalias '--every? '--all?) +(defalias '-all-p '-all?) +(defalias '--all-p '--all?) +(defalias '-every-p '-all?) +(defalias '--every-p '--all?) + +(defmacro --none? (form list) + "Anaphoric form of `-none?'." + (declare (debug (form form))) + `(--all? (not ,form) ,list)) + +(defun -none? (pred list) + "Return t if (PRED x) is nil for all x in LIST, else nil. + +Alias: `-none-p'" + (--none? (funcall pred it) list)) + +(defalias '-none-p '-none?) +(defalias '--none-p '--none?) + +(defmacro --only-some? (form list) + "Anaphoric form of `-only-some?'." + (declare (debug (form form))) + (let ((y (make-symbol "yes")) + (n (make-symbol "no"))) + `(let (,y ,n) + (--each-while ,list (not (and ,y ,n)) + (if ,form (setq ,y t) (setq ,n t))) + (---truthy? (and ,y ,n))))) + +(defun -only-some? (pred list) + "Return `t` if at least one item of LIST matches PRED and at least one item of LIST does not match PRED. +Return `nil` both if all items match the predicate or if none of the items match the predicate. + +Alias: `-only-some-p'" + (--only-some? (funcall pred it) list)) + +(defalias '-only-some-p '-only-some?) +(defalias '--only-some-p '--only-some?) + +(defun -slice (list from &optional to step) + "Return copy of LIST, starting from index FROM to index TO. + +FROM or TO may be negative. These values are then interpreted +modulo the length of the list. + +If STEP is a number, only each STEPth item in the resulting +section is returned. Defaults to 1." + (let ((length (length list)) + (new-list nil)) + ;; to defaults to the end of the list + (setq to (or to length)) + (setq step (or step 1)) + ;; handle negative indices + (when (< from 0) + (setq from (mod from length))) + (when (< to 0) + (setq to (mod to length))) + + ;; iterate through the list, keeping the elements we want + (--each-while list (< it-index to) + (when (and (>= it-index from) + (= (mod (- from it-index) step) 0)) + (push it new-list))) + (nreverse new-list))) + +(defun -take (n list) + "Return a new list of the first N items in LIST, or all items if there are fewer than N." + (let (result) + (--dotimes n + (when list + (!cons (car list) result) + (!cdr list))) + (nreverse result))) + +(defalias '-drop 'nthcdr "Return the tail of LIST without the first N items.") + +(defmacro --take-while (form list) + "Anaphoric form of `-take-while'." + (declare (debug (form form))) + (let ((r (make-symbol "result"))) + `(let (,r) + (--each-while ,list ,form (!cons it ,r)) + (nreverse ,r)))) + +(defun -take-while (pred list) + "Return a new list of successive items from LIST while (PRED item) returns a non-nil value." + (--take-while (funcall pred it) list)) + +(defmacro --drop-while (form list) + "Anaphoric form of `-drop-while'." + (declare (debug (form form))) + (let ((l (make-symbol "list"))) + `(let ((,l ,list)) + (while (and ,l (let ((it (car ,l))) ,form)) + (!cdr ,l)) + ,l))) + +(defun -drop-while (pred list) + "Return the tail of LIST starting from the first item for which (PRED item) returns nil." + (--drop-while (funcall pred it) list)) + +(defun -split-at (n list) + "Return a list of ((-take N LIST) (-drop N LIST)), in no more than one pass through the list." + (let (result) + (--dotimes n + (when list + (!cons (car list) result) + (!cdr list))) + (list (nreverse result) list))) + +(defun -rotate (n list) + "Rotate LIST N places to the right. With N negative, rotate to the left. +The time complexity is O(n)." + (if (> n 0) + (append (last list n) (butlast list n)) + (append (-drop (- n) list) (-take (- n) list)))) + +(defun -insert-at (n x list) + "Return a list with X inserted into LIST at position N. + +See also: `-splice', `-splice-list'" + (let ((split-list (-split-at n list))) + (nconc (car split-list) (cons x (cadr split-list))))) + +(defun -replace-at (n x list) + "Return a list with element at Nth position in LIST replaced with X. + +See also: `-replace'" + (let ((split-list (-split-at n list))) + (nconc (car split-list) (cons x (cdr (cadr split-list)))))) + +(defun -update-at (n func list) + "Return a list with element at Nth position in LIST replaced with `(func (nth n list))`. + +See also: `-map-when'" + (let ((split-list (-split-at n list))) + (nconc (car split-list) (cons (funcall func (car (cadr split-list))) (cdr (cadr split-list)))))) + +(defmacro --update-at (n form list) + "Anaphoric version of `-update-at'." + (declare (debug (form form form))) + `(-update-at ,n (lambda (it) ,form) ,list)) + +(defun -remove-at (n list) + "Return a list with element at Nth position in LIST removed. + +See also: `-remove-at-indices', `-remove'" + (-remove-at-indices (list n) list)) + +(defun -remove-at-indices (indices list) + "Return a list whose elements are elements from LIST without +elements selected as `(nth i list)` for all i +from INDICES. + +See also: `-remove-at', `-remove'" + (let* ((indices (-sort '< indices)) + (diffs (cons (car indices) (-map '1- (-zip-with '- (cdr indices) indices)))) + r) + (--each diffs + (let ((split (-split-at it list))) + (!cons (car split) r) + (setq list (cdr (cadr split))))) + (!cons list r) + (apply '-concat (nreverse r)))) + +(defmacro --split-with (pred list) + "Anaphoric form of `-split-with'." + (declare (debug (form form))) + (let ((l (make-symbol "list")) + (r (make-symbol "result")) + (c (make-symbol "continue"))) + `(let ((,l ,list) + (,r nil) + (,c t)) + (while (and ,l ,c) + (let ((it (car ,l))) + (if (not ,pred) + (setq ,c nil) + (!cons it ,r) + (!cdr ,l)))) + (list (nreverse ,r) ,l)))) + +(defun -split-with (pred list) + "Return a list of ((-take-while PRED LIST) (-drop-while PRED LIST)), in no more than one pass through the list." + (--split-with (funcall pred it) list)) + +(defmacro -split-on (item list) + "Split the LIST each time ITEM is found. + +Unlike `-partition-by', the ITEM is discarded from the results. +Empty lists are also removed from the result. + +Comparison is done by `equal'. + +See also `-split-when'" + (declare (debug (form form))) + `(-split-when (lambda (it) (equal it ,item)) ,list)) + +(defmacro --split-when (form list) + "Anaphoric version of `-split-when'." + (declare (debug (form form))) + `(-split-when (lambda (it) ,form) ,list)) + +(defun -split-when (fn list) + "Split the LIST on each element where FN returns non-nil. + +Unlike `-partition-by', the \"matched\" element is discarded from +the results. Empty lists are also removed from the result. + +This function can be thought of as a generalization of +`split-string'." + (let (r s) + (while list + (if (not (funcall fn (car list))) + (push (car list) s) + (when s (push (nreverse s) r)) + (setq s nil)) + (!cdr list)) + (when s (push (nreverse s) r)) + (nreverse r))) + +(defmacro --separate (form list) + "Anaphoric form of `-separate'." + (declare (debug (form form))) + (let ((y (make-symbol "yes")) + (n (make-symbol "no"))) + `(let (,y ,n) + (--each ,list (if ,form (!cons it ,y) (!cons it ,n))) + (list (nreverse ,y) (nreverse ,n))))) + +(defun -separate (pred list) + "Return a list of ((-filter PRED LIST) (-remove PRED LIST)), in one pass through the list." + (--separate (funcall pred it) list)) + +(defun ---partition-all-in-steps-reversed (n step list) + "Private: Used by -partition-all-in-steps and -partition-in-steps." + (when (< step 1) + (error "Step must be a positive number, or you're looking at some juicy infinite loops.")) + (let ((result nil) + (len 0)) + (while list + (!cons (-take n list) result) + (setq list (-drop step list))) + result)) + +(defun -partition-all-in-steps (n step list) + "Return a new list with the items in LIST grouped into N-sized sublists at offsets STEP apart. +The last groups may contain less than N items." + (nreverse (---partition-all-in-steps-reversed n step list))) + +(defun -partition-in-steps (n step list) + "Return a new list with the items in LIST grouped into N-sized sublists at offsets STEP apart. +If there are not enough items to make the last group N-sized, +those items are discarded." + (let ((result (---partition-all-in-steps-reversed n step list))) + (while (and result (< (length (car result)) n)) + (!cdr result)) + (nreverse result))) + +(defun -partition-all (n list) + "Return a new list with the items in LIST grouped into N-sized sublists. +The last group may contain less than N items." + (-partition-all-in-steps n n list)) + +(defun -partition (n list) + "Return a new list with the items in LIST grouped into N-sized sublists. +If there are not enough items to make the last group N-sized, +those items are discarded." + (-partition-in-steps n n list)) + +(defmacro --partition-by (form list) + "Anaphoric form of `-partition-by'." + (declare (debug (form form))) + (let ((r (make-symbol "result")) + (s (make-symbol "sublist")) + (v (make-symbol "value")) + (n (make-symbol "new-value")) + (l (make-symbol "list"))) + `(let ((,l ,list)) + (when ,l + (let* ((,r nil) + (it (car ,l)) + (,s (list it)) + (,v ,form) + (,l (cdr ,l))) + (while ,l + (let* ((it (car ,l)) + (,n ,form)) + (unless (equal ,v ,n) + (!cons (nreverse ,s) ,r) + (setq ,s nil) + (setq ,v ,n)) + (!cons it ,s) + (!cdr ,l))) + (!cons (nreverse ,s) ,r) + (nreverse ,r)))))) + +(defun -partition-by (fn list) + "Apply FN to each item in LIST, splitting it each time FN returns a new value." + (--partition-by (funcall fn it) list)) + +(defmacro --partition-by-header (form list) + "Anaphoric form of `-partition-by-header'." + (declare (debug (form form))) + (let ((r (make-symbol "result")) + (s (make-symbol "sublist")) + (h (make-symbol "header-value")) + (b (make-symbol "seen-body?")) + (n (make-symbol "new-value")) + (l (make-symbol "list"))) + `(let ((,l ,list)) + (when ,l + (let* ((,r nil) + (it (car ,l)) + (,s (list it)) + (,h ,form) + (,b nil) + (,l (cdr ,l))) + (while ,l + (let* ((it (car ,l)) + (,n ,form)) + (if (equal ,h ,n) + (when ,b + (!cons (nreverse ,s) ,r) + (setq ,s nil) + (setq ,b nil)) + (setq ,b t)) + (!cons it ,s) + (!cdr ,l))) + (!cons (nreverse ,s) ,r) + (nreverse ,r)))))) + +(defun -partition-by-header (fn list) + "Apply FN to the first item in LIST. That is the header +value. Apply FN to each item in LIST, splitting it each time FN +returns the header value, but only after seeing at least one +other value (the body)." + (--partition-by-header (funcall fn it) list)) + +(defmacro --group-by (form list) + "Anaphoric form of `-group-by'." + (declare (debug (form form))) + (let ((l (make-symbol "list")) + (v (make-symbol "value")) + (k (make-symbol "key")) + (r (make-symbol "result"))) + `(let ((,l ,list) + ,r) + ;; Convert `list' to an alist and store it in `r'. + (while ,l + (let* ((,v (car ,l)) + (it ,v) + (,k ,form) + (kv (assoc ,k ,r))) + (if kv + (setcdr kv (cons ,v (cdr kv))) + (push (list ,k ,v) ,r)) + (setq ,l (cdr ,l)))) + ;; Reverse lists in each group. + (let ((rest ,r)) + (while rest + (let ((kv (car rest))) + (setcdr kv (nreverse (cdr kv)))) + (setq rest (cdr rest)))) + ;; Reverse order of keys. + (nreverse ,r)))) + +(defun -group-by (fn list) + "Separate LIST into an alist whose keys are FN applied to the +elements of LIST. Keys are compared by `equal'." + (--group-by (funcall fn it) list)) + +(defun -interpose (sep list) + "Return a new list of all elements in LIST separated by SEP." + (let (result) + (when list + (!cons (car list) result) + (!cdr list)) + (while list + (setq result (cons (car list) (cons sep result))) + (!cdr list)) + (nreverse result))) + +(defun -interleave (&rest lists) + "Return a new list of the first item in each list, then the second etc." + (let (result) + (while (-none? 'null lists) + (--each lists (!cons (car it) result)) + (setq lists (-map 'cdr lists))) + (nreverse result))) + +(defmacro --zip-with (form list1 list2) + "Anaphoric form of `-zip-with'. + +The elements in list1 is bound as `it`, the elements in list2 as `other`." + (declare (debug (form form form))) + (let ((r (make-symbol "result")) + (l1 (make-symbol "list1")) + (l2 (make-symbol "list2"))) + `(let ((,r nil) + (,l1 ,list1) + (,l2 ,list2)) + (while (and ,l1 ,l2) + (let ((it (car ,l1)) + (other (car ,l2))) + (!cons ,form ,r) + (!cdr ,l1) + (!cdr ,l2))) + (nreverse ,r)))) + +(defun -zip-with (fn list1 list2) + "Zip the two lists LIST1 and LIST2 using a function FN. This +function is applied pairwise taking as first argument element of +LIST1 and as second argument element of LIST2 at corresponding +position. + +The anaphoric form `--zip-with' binds the elements from LIST1 as `it`, +and the elements from LIST2 as `other`." + (--zip-with (funcall fn it other) list1 list2)) + +(defun -zip (&rest lists) + "Zip LISTS together. Group the head of each list, followed by the +second elements of each list, and so on. The lengths of the returned +groupings are equal to the length of the shortest input list. + +If two lists are provided as arguments, return the groupings as a list +of cons cells. Otherwise, return the groupings as a list of lists. " + (let (results) + (while (-none? 'null lists) + (setq results (cons (mapcar 'car lists) results)) + (setq lists (mapcar 'cdr lists))) + (setq results (nreverse results)) + (if (= (length lists) 2) + ;; to support backward compatability, return + ;; a cons cell if two lists were provided + (--map (cons (car it) (cadr it)) results) + results))) + +(defun -zip-fill (fill-value &rest lists) + "Zip LISTS, with FILL-VALUE padded onto the shorter lists. The +lengths of the returned groupings are equal to the length of the +longest input list." + (apply '-zip (apply '-pad (cons fill-value lists)))) + +(defun -cycle (list) + "Return an infinite copy of LIST that will cycle through the +elements and repeat from the beginning." + (let ((newlist (-map 'identity list))) + (nconc newlist newlist))) + +(defun -pad (fill-value &rest lists) + "Appends FILL-VALUE to the end of each list in LISTS such that they +will all have the same length." + (let* ((annotations (-annotate 'length lists)) + (n (-max (-map 'car annotations)))) + (--map (append (cdr it) (-repeat (- n (car it)) fill-value)) annotations))) + +(defun -annotate (fn list) + "Return a list of cons cells where each cell is FN applied to each +element of LIST paired with the unmodified element of LIST." + (-zip (-map fn list) list)) + +(defmacro --annotate (form list) + "Anaphoric version of `-annotate'." + (declare (debug (form form))) + `(-annotate (lambda (it) ,form) ,list)) + +(defun dash--table-carry (lists restore-lists &optional re) + "Helper for `-table' and `-table-flat'. + +If a list overflows, carry to the right and reset the list. + +Return how many lists were re-seted." + (while (and (not (car lists)) + (not (equal lists '(nil)))) + (setcar lists (car restore-lists)) + (pop (cadr lists)) + (!cdr lists) + (!cdr restore-lists) + (when re + (push (nreverse (car re)) (cadr re)) + (setcar re nil) + (!cdr re)))) + +(defun -table (fn &rest lists) + "Compute outer product of LISTS using function FN. + +The function FN should have the same arity as the number of +supplied lists. + +The outer product is computed by applying fn to all possible +combinations created by taking one element from each list in +order. The dimension of the result is (length lists). + +See also: `-table-flat'" + (let ((restore-lists (copy-sequence lists)) + (last-list (last lists)) + (re (--map nil (number-sequence 1 (length lists))))) + (while (car last-list) + (let ((item (apply fn (-map 'car lists)))) + (push item (car re)) + (setcar lists (cdar lists)) ;; silence byte compiler + (dash--table-carry lists restore-lists re))) + (nreverse (car (last re))))) + +(defun -table-flat (fn &rest lists) + "Compute flat outer product of LISTS using function FN. + +The function FN should have the same arity as the number of +supplied lists. + +The outer product is computed by applying fn to all possible +combinations created by taking one element from each list in +order. The results are flattened, ignoring the tensor structure +of the result. This is equivalent to calling: + + (-flatten-n (1- (length lists)) (-table fn lists)) + +but the implementation here is much more efficient. + +See also: `-flatten-n', `-table'" + (let ((restore-lists (copy-sequence lists)) + (last-list (last lists)) + re) + (while (car last-list) + (push (apply fn (-map 'car lists)) re) + (pop (car lists)) + (dash--table-carry lists restore-lists)) + (nreverse re))) + +(defun -partial (fn &rest args) + "Take a function FN and fewer than the normal arguments to FN, +and return a fn that takes a variable number of additional ARGS. +When called, the returned function calls FN with ARGS first and +then additional args." + (apply 'apply-partially fn args)) + +(defun -elem-index (elem list) + "Return the index of the first element in the given LIST which +is equal to the query element ELEM, or nil if there is no +such element." + (car (-elem-indices elem list))) + +(defun -elem-indices (elem list) + "Return the indices of all elements in LIST equal to the query +element ELEM, in ascending order." + (-find-indices (-partial 'equal elem) list)) + +(defun -find-indices (pred list) + "Return the indices of all elements in LIST satisfying the +predicate PRED, in ascending order." + (let ((i 0)) + (apply 'append (--map-indexed (when (funcall pred it) (list it-index)) list)))) + +(defmacro --find-indices (form list) + "Anaphoric version of `-find-indices'." + (declare (debug (form form))) + `(-find-indices (lambda (it) ,form) ,list)) + +(defun -find-index (pred list) + "Take a predicate PRED and a LIST and return the index of the +first element in the list satisfying the predicate, or nil if +there is no such element." + (car (-find-indices pred list))) + +(defmacro --find-index (form list) + "Anaphoric version of `-find-index'." + (declare (debug (form form))) + `(-find-index (lambda (it) ,form) ,list)) + +(defun -find-last-index (pred list) + "Take a predicate PRED and a LIST and return the index of the +last element in the list satisfying the predicate, or nil if +there is no such element." + (-last-item (-find-indices pred list))) + +(defmacro --find-last-index (form list) + "Anaphoric version of `-find-last-index'." + `(-find-last-index (lambda (it) ,form) ,list)) + +(defun -select-by-indices (indices list) + "Return a list whose elements are elements from LIST selected +as `(nth i list)` for all i from INDICES." + (let (r) + (--each indices + (!cons (nth it list) r)) + (nreverse r))) + +(defmacro -> (x &optional form &rest more) + "Thread the expr through the forms. Insert X as the second item +in the first form, making a list of it if it is not a list +already. If there are more forms, insert the first form as the +second item in second form, etc." + (cond + ((null form) x) + ((null more) (if (listp form) + `(,(car form) ,x ,@(cdr form)) + (list form x))) + (:else `(-> (-> ,x ,form) ,@more)))) + +(defmacro ->> (x form &rest more) + "Thread the expr through the forms. Insert X as the last item +in the first form, making a list of it if it is not a list +already. If there are more forms, insert the first form as the +last item in second form, etc." + (if (null more) + (if (listp form) + `(,(car form) ,@(cdr form) ,x) + (list form x)) + `(->> (->> ,x ,form) ,@more))) + +(defmacro --> (x form &rest more) + "Thread the expr through the forms. Insert X at the position +signified by the token `it' in the first form. If there are more +forms, insert the first form at the position signified by `it' in +in second form, etc." + (if (null more) + (if (listp form) + (--map-when (eq it 'it) x form) + (list form x)) + `(--> (--> ,x ,form) ,@more))) + +(defun -grade-up (comparator list) + "Grade elements of LIST using COMPARATOR relation, yielding a +permutation vector such that applying this permutation to LIST +sorts it in ascending order." + ;; ugly hack to "fix" lack of lexical scope + (let ((comp `(lambda (it other) (funcall ',comparator (car it) (car other))))) + (->> (--map-indexed (cons it it-index) list) + (-sort comp) + (-map 'cdr)))) + +(defun -grade-down (comparator list) + "Grade elements of LIST using COMPARATOR relation, yielding a +permutation vector such that applying this permutation to LIST +sorts it in descending order." + ;; ugly hack to "fix" lack of lexical scope + (let ((comp `(lambda (it other) (funcall ',comparator (car other) (car it))))) + (->> (--map-indexed (cons it it-index) list) + (-sort comp) + (-map 'cdr)))) + +(defvar dash--source-counter 0 + "Monotonic counter for generated symbols.") + +(defun dash--match-make-source-symbol () + "Generate a new dash-source symbol. + +All returned symbols are guaranteed to be unique." + (prog1 (make-symbol (format "--dash-source-%d--" dash--source-counter)) + (setq dash--source-counter (1+ dash--source-counter)))) + +(defun dash--match-ignore-place-p (symbol) + "Return non-nil if SYMBOL is a symbol and starts with _." + (and (symbolp symbol) + (eq (aref (symbol-name symbol) 0) ?_))) + +(defun dash--match-cons-skip-cdr (skip-cdr source) + "Helper function generating idiomatic shifting code." + (cond + ((= skip-cdr 0) + `(pop ,source)) + (t + `(prog1 ,(dash--match-cons-get-car skip-cdr source) + (setq ,source ,(dash--match-cons-get-cdr (1+ skip-cdr) source)))))) + +(defun dash--match-cons-get-car (skip-cdr source) + "Helper function generating idiomatic code to get nth car." + (cond + ((= skip-cdr 0) + `(car ,source)) + ((= skip-cdr 1) + `(cadr ,source)) + (t + `(nth ,skip-cdr ,source)))) + +(defun dash--match-cons-get-cdr (skip-cdr source) + "Helper function generating idiomatic code to get nth cdr." + (cond + ((= skip-cdr 0) + source) + ((= skip-cdr 1) + `(cdr ,source)) + (t + `(nthcdr ,skip-cdr ,source)))) + +(defun dash--match-cons (match-form source) + "Setup a cons matching environment and call the real matcher." + (let ((s (dash--match-make-source-symbol)) + (n 0) + (m match-form)) + (while (and (consp m) + (dash--match-ignore-place-p (car m))) + (setq n (1+ n)) (!cdr m)) + (cond + ;; when we only have one pattern in the list, we don't have to + ;; create a temporary binding (--dash-source--) for the source + ;; and just use the input directly + ((and (consp m) + (not (cdr m))) + (dash--match (car m) (dash--match-cons-get-car n source))) + ;; handle other special types + ((> n 0) + (dash--match m (dash--match-cons-get-cdr n source))) + ;; this is the only entry-point for dash--match-cons-1, that's + ;; why we can't simply use the above branch, it would produce + ;; infinite recursion + (t + (cons (list s source) (dash--match-cons-1 match-form s)))))) + +(defun dash--match-cons-1 (match-form source &optional props) + "Match MATCH-FORM against SOURCE. + +MATCH-FORM is a proper or improper list. Each element of +MATCH-FORM is either a symbol, which gets bound to the respective +value in source or another match form which gets destructured +recursively. + +If the cdr of last cons cell in the list is `nil', matching stops +there. + +SOURCE is a proper or improper list." + (let ((skip-cdr (or (plist-get props :skip-cdr) 0))) + (cond + ((consp match-form) + (cond + ((cdr match-form) + (cond + ((and (symbolp (car match-form)) + (eq (car match-form) '&keys)) + (dash--match-kv (cons '&plist (cdr match-form)) (dash--match-cons-get-cdr skip-cdr source))) + ((dash--match-ignore-place-p (car match-form)) + (dash--match-cons-1 (cdr match-form) source + (plist-put props :skip-cdr (1+ skip-cdr)))) + (t + (-concat (dash--match (car match-form) (dash--match-cons-skip-cdr skip-cdr source)) + (dash--match-cons-1 (cdr match-form) source))))) + (t ;; Last matching place, no need for shift + (dash--match (car match-form) (dash--match-cons-get-car skip-cdr source))))) + ((eq match-form nil) + nil) + (t ;; Handle improper lists. Last matching place, no need for shift + (dash--match match-form (dash--match-cons-get-cdr skip-cdr source)))))) + +(defun dash--vector-tail (seq start) + "Return the tail of SEQ starting at START." + (cond + ((vectorp seq) + (let* ((re-length (- (length seq) start)) + (re (make-vector re-length 0))) + (--dotimes re-length (aset re it (aref seq (+ it start)))) + re)) + ((stringp seq) + (substring seq start)))) + +(defun dash--match-vector (match-form source) + "Setup a vector matching environment and call the real matcher." + (let ((s (dash--match-make-source-symbol))) + (cond + ;; don't bind `s' if we only have one sub-pattern + ((= (length match-form) 1) + (dash--match (aref match-form 0) `(aref ,source 0))) + ;; if the source is a symbol, we don't need to re-bind it + ((symbolp source) + (dash--match-vector-1 match-form source)) + ;; don't bind `s' if we only have one sub-pattern which is not ignored + ((let* ((ignored-places (mapcar 'dash--match-ignore-place-p match-form)) + (ignored-places-n (length (-remove 'null ignored-places)))) + (when (= ignored-places-n (1- (length match-form))) + (let ((n (-find-index 'null ignored-places))) + (dash--match (aref match-form n) `(aref ,source ,n)))))) + (t + (cons (list s source) (dash--match-vector-1 match-form s)))))) + +(defun dash--match-vector-1 (match-form source) + "Match MATCH-FORM against SOURCE. + +MATCH-FORM is a vector. Each element of MATCH-FORM is either a +symbol, which gets bound to the respective value in source or +another match form which gets destructured recursively. + +If second-from-last place in MATCH-FORM is the symbol &rest, the +next element of the MATCH-FORM is matched against the tail of +SOURCE, starting at index of the &rest symbol. This is +conceptually the same as the (head . tail) match for improper +lists, where dot plays the role of &rest. + +SOURCE is a vector. + +If the MATCH-FORM vector is shorter than SOURCE vector, only +the (length MATCH-FORM) places are bound, the rest of the SOURCE +is discarded." + (let ((i 0) + (l (length match-form)) + (re)) + (while (< i l) + (let ((m (aref match-form i))) + (push (cond + ((and (symbolp m) + (eq m '&rest)) + (prog1 (dash--match + (aref match-form (1+ i)) + `(dash--vector-tail ,source ,i)) + (setq i l))) + ((and (symbolp m) + ;; do not match symbols starting with _ + (not (eq (aref (symbol-name m) 0) ?_))) + (list (list m `(aref ,source ,i)))) + ((not (symbolp m)) + (dash--match m `(aref ,source ,i)))) + re) + (setq i (1+ i)))) + (-flatten-n 1 (nreverse re)))) + +(defun dash--match-kv (match-form source) + "Setup a kv matching environment and call the real matcher. + +kv can be any key-value store, such as plist, alist or hash-table." + (let ((s (dash--match-make-source-symbol))) + (cond + ;; don't bind `s' if we only have one sub-pattern (&type key val) + ((= (length match-form) 3) + (dash--match-kv-1 (cdr match-form) source (car match-form))) + ;; if the source is a symbol, we don't need to re-bind it + ((symbolp source) + (dash--match-kv-1 (cdr match-form) source (car match-form))) + (t + (cons (list s source) (dash--match-kv-1 (cdr match-form) s (car match-form))))))) + +(defun dash--match-kv-1 (match-form source type) + "Match MATCH-FORM against SOURCE of type TYPE. + +MATCH-FORM is a proper list of the form (key1 place1 ... keyN +placeN). Each placeK is either a symbol, which gets bound to the +value of keyK retrieved from the key-value store, or another +match form which gets destructured recursively. + +SOURCE is a key-value store of type TYPE, which can be a plist, +an alist or a hash table. + +TYPE is a token specifying the type of the key-value store. +Valid values are &plist, &alist and &hash." + (-flatten-n 1 (-map + (lambda (kv) + (let* ((k (car kv)) + (v (cadr kv)) + (getter (cond + ((eq type '&plist) + `(plist-get ,source ,k)) + ((eq type '&alist) + `(cdr (assoc ,k ,source))) + ((eq type '&hash) + `(gethash ,k ,source))))) + (cond + ((symbolp v) + (list (list v getter))) + (t (dash--match v getter))))) + (-partition 2 match-form)))) + +(defun dash--match-symbol (match-form source) + "Bind a symbol. + +This works just like `let', there is no destructuring." + (list (list match-form source))) + +(defun dash--match (match-form source) + "Match MATCH-FORM against SOURCE. + +This function tests the MATCH-FORM and dispatches to specific +matchers based on the type of the expression. + +Key-value stores are disambiguated by placing a token &plist, +&alist or &hash as a first item in the MATCH-FORM." + (cond + ((symbolp match-form) + (dash--match-symbol match-form source)) + ((consp match-form) + (cond + ;; Handle the "x &as" bindings first. + ((and (consp (cdr match-form)) + (symbolp (car match-form)) + (eq '&as (cadr match-form))) + (let ((s (car match-form))) + (cons (list s source) + (dash--match (cddr match-form) s)))) + ((memq (car match-form) '(&plist &alist &hash)) + (dash--match-kv match-form source)) + ((eq (car match-form) '&keys) + (dash--match-kv (cons '&plist (cdr match-form)) source)) + (t (dash--match-cons match-form source)))) + ((vectorp match-form) + ;; We support the &as binding in vectors too + (cond + ((and (> (length match-form) 2) + (symbolp (aref match-form 0)) + (eq '&as (aref match-form 1))) + (let ((s (aref match-form 0))) + (cons (list s source) + (dash--match (dash--vector-tail match-form 2) s)))) + (t (dash--match-vector match-form source)))))) + +(defmacro -let* (varlist &rest body) + "Bind variables according to VARLIST then eval BODY. + +VARLIST is a list of lists of the form (PATTERN SOURCE). Each +PATTERN is matched against the SOURCE structurally. SOURCE is +only evaluated once for each PATTERN. + +Each SOURCE can refer to the symbols already bound by this +VARLIST. This is useful if you want to destructure SOURCE +recursively but also want to name the intermediate structures. + +See `-let' for the list of all possible patterns." + (declare (debug ((&rest (sexp form)) body)) + (indent 1)) + (let ((bindings (--mapcat (dash--match (car it) (cadr it)) varlist))) + `(let* ,bindings + ,@body))) + +(defmacro -let (varlist &rest body) + "Bind variables according to VARLIST then eval BODY. + +VARLIST is a list of lists of the form (PATTERN SOURCE). Each +PATTERN is matched against the SOURCE \"structurally\". SOURCE +is only evaluated once for each PATTERN. Each PATTERN is matched +recursively, and can therefore contain sub-patterns which are +matched against corresponding sub-expressions of SOURCE. + +All the SOURCEs are evalled before any symbols are +bound (i.e. \"in parallel\"). + +If VARLIST only contains one (PATTERN SOURCE) element, you can +optionally specify it using a vector and discarding the +outer-most parens. Thus + + (-let ((PATTERN SOURCE)) ..) + +becomes + + (-let [PATTERN SOURCE] ..). + +`-let' uses a convention of not binding places (symbols) starting +with _ whenever it's possible. You can use this to skip over +entries you don't care about. However, this is not *always* +possible (as a result of implementation) and these symbols might +get bound to undefined values. + +Following is the overview of supported patterns. Remember that +patterns can be matched recursively, so every a, b, aK in the +following can be a matching construct and not necessarily a +symbol/variable. + +Symbol: + + a - bind the SOURCE to A. This is just like regular `let'. + +Conses and lists: + + (a) - bind `car' of cons/list to A + + (a . b) - bind car of cons to A and `cdr' to B + + (a b) - bind car of list to A and `cadr' to B + + (a1 a2 a3 ...) - bind 0th car of list to A1, 1st to A2, 2nd to A3 ... + + (a1 a2 a3 ... aN . rest) - as above, but bind the Nth cdr to REST. + +Vectors: + + [a] - bind 0th element of a non-list sequence to A (works with + vectors, strings, bit arrays...) + + [a1 a2 a3 ...] - bind 0th element of non-list sequence to A0, 1st to + A1, 2nd to A2, ... + If the PATTERN is shorter than SOURCE, the values at + places not in PATTERN are ignored. + If the PATTERN is longer than SOURCE, an `error' is + thrown. + + [a1 a2 a3 ... &rest rest] ) - as above, but bind the rest of + the sequence to REST. This is + conceptually the same as improper list + matching (a1 a2 ... aN . rest) + +Key/value stores: + + (&plist key0 a0 ... keyN aN) - bind value mapped by keyK in the + SOURCE plist to aK. If the + value is not found, aK is nil. + + (&alist key0 a0 ... keyN aN) - bind value mapped by keyK in the + SOURCE alist to aK. If the + value is not found, aK is nil. + + (&hash key0 a0 ... keyN aN) - bind value mapped by keyK in the + SOURCE hash table to aK. If the + value is not found, aK is nil. + +Further, special keyword &keys supports \"inline\" matching of +plist-like key-value pairs, similarly to &keys keyword of +`cl-defun'. + + (a1 a2 ... aN &keys key1 b1 ... keyN bK) + +This binds N values from the list to a1 ... aN, then interprets +the cdr as a plist (see key/value matching above). + +You can name the source using the syntax SYMBOL &as PATTERN. +This syntax works with lists (proper or improper), vectors and +all types of maps. + + (list &as a b c) (list 1 2 3) + +binds A to 1, B to 2, C to 3 and LIST to (1 2 3). + +Similarly: + + (bounds &as beg . end) (cons 1 2) + +binds BEG to 1, END to 2 and BOUNDS to (1 . 2). + + (items &as first . rest) (list 1 2 3) + +binds FIRST to 1, REST to (2 3) and ITEMS to (1 2 3) + + [vect &as _ b c] [1 2 3] + +binds B to 2, C to 3 and VECT to [1 2 3] (_ avoids binding as usual). + + (plist &as &plist :b b) (list :a 1 :b 2 :c 3) + +binds B to 2 and PLIST to (:a 1 :b 2 :c 3). Same for &alist and &hash. + +This is especially useful when we want to capture the result of a +computation and destructure at the same time. Consider the +form (function-returning-complex-structure) returning a list of +two vectors with two items each. We want to capture this entire +result and pass it to another computation, but at the same time +we want to get the second item from each vector. We can achieve +it with pattern + + (result &as [_ a] [_ b]) (function-returning-complex-structure) + +Note: Clojure programmers may know this feature as the \":as +binding\". The difference is that we put the &as at the front +because we need to support improper list binding." + (declare (debug ([&or (&rest (sexp form)) + (vector [&rest [sexp form]])] + body)) + (indent 1)) + (if (vectorp varlist) + `(let* ,(dash--match (aref varlist 0) (aref varlist 1)) + ,@body) + (let* ((inputs (--map-indexed (list (make-symbol (format "input%d" it-index)) (cadr it)) varlist)) + (new-varlist (--map (list (caar it) (cadr it)) (-zip varlist inputs)))) + `(let ,inputs + (-let* ,new-varlist ,@body))))) + +(defmacro -lambda (match-form &rest body) + "Return a lambda which destructures its input as MATCH-FORM and executes BODY. + +Note that you have to enclose the MATCH-FORM in a pair of parens, +such that: + + (-lambda (x) body) + (-lambda (x y ...) body) + +has the usual semantics of `lambda'. Furthermore, these get +translated into normal lambda, so there is no performance +penalty. + +See `-let' for the description of destructuring mechanism." + (declare (doc-string 2) (indent defun) + (debug (&define sexp + [&optional stringp] + [&optional ("interactive" interactive)] + def-body))) + (cond + ((not (consp match-form)) + (signal 'wrong-type-argument "match-form must be a list")) + ;; no destructuring, so just return regular lambda to make things faster + ((-all? 'symbolp match-form) + `(lambda ,match-form ,@body)) + (t + (let* ((inputs (--map-indexed (list it (make-symbol (format "input%d" it-index))) match-form))) + ;; TODO: because inputs to the lambda are evaluated only once, + ;; -let* need not to create the extra bindings to ensure that. + ;; We should find a way to optimize that. Not critical however. + `(lambda ,(--map (cadr it) inputs) + (-let* ,inputs ,@body)))))) + +(defmacro -if-let* (vars-vals then &rest else) + "If all VALS evaluate to true, bind them to their corresponding +VARS and do THEN, otherwise do ELSE. VARS-VALS should be a list +of (VAR VAL) pairs. + +Note: binding is done according to `-let*'." + (declare (debug ((&rest (sexp form)) form body)) + (indent 2)) + (->> vars-vals + (--mapcat (dash--match (car it) (cadr it))) + (--reduce-r-from + (let ((var (car it)) + (val (cadr it))) + `(let ((,var ,val)) + (if ,var ,acc ,@else))) + then))) + +(defmacro -if-let (var-val then &rest else) + "If VAL evaluates to non-nil, bind it to VAR and do THEN, +otherwise do ELSE. VAR-VAL should be a (VAR VAL) pair. + +Note: binding is done according to `-let'." + (declare (debug ((sexp form) form body)) + (indent 2)) + `(-if-let* (,var-val) ,then ,@else)) + +(defmacro --if-let (val then &rest else) + "If VAL evaluates to non-nil, bind it to `it' and do THEN, +otherwise do ELSE." + (declare (debug (form form body)) + (indent 2)) + `(-if-let (it ,val) ,then ,@else)) + +(defmacro -when-let* (vars-vals &rest body) + "If all VALS evaluate to true, bind them to their corresponding +VARS and execute body. VARS-VALS should be a list of (VAR VAL) +pairs. + +Note: binding is done according to `-let*'." + (declare (debug ((&rest (sexp form)) body)) + (indent 1)) + `(-if-let* ,vars-vals (progn ,@body))) + +(defmacro -when-let (var-val &rest body) + "If VAL evaluates to non-nil, bind it to VAR and execute body. +VAR-VAL should be a (VAR VAL) pair. + +Note: binding is done according to `-let'." + (declare (debug ((sexp form) body)) + (indent 1)) + `(-if-let ,var-val (progn ,@body))) + +(defmacro --when-let (val &rest body) + "If VAL evaluates to non-nil, bind it to `it' and execute +body." + (declare (debug (form body)) + (indent 1)) + `(--if-let ,val (progn ,@body))) + +(defun -distinct (list) + "Return a new list with all duplicates removed. +The test for equality is done with `equal', +or with `-compare-fn' if that's non-nil. + +Alias: `-uniq'" + (let (result) + (--each list (unless (-contains? result it) (!cons it result))) + (nreverse result))) + +(defalias '-uniq '-distinct) + +(defun -union (list list2) + "Return a new list containing the elements of LIST1 and elements of LIST2 that are not in LIST1. +The test for equality is done with `equal', +or with `-compare-fn' if that's non-nil." + (let (result) + (--each list (!cons it result)) + (--each list2 (unless (-contains? result it) (!cons it result))) + (nreverse result))) + +(defun -intersection (list list2) + "Return a new list containing only the elements that are members of both LIST and LIST2. +The test for equality is done with `equal', +or with `-compare-fn' if that's non-nil." + (--filter (-contains? list2 it) list)) + +(defun -difference (list list2) + "Return a new list with only the members of LIST that are not in LIST2. +The test for equality is done with `equal', +or with `-compare-fn' if that's non-nil." + (--filter (not (-contains? list2 it)) list)) + +(defvar -compare-fn nil + "Tests for equality use this function or `equal' if this is nil. +It should only be set using dynamic scope with a let, like: + + (let ((-compare-fn =)) (-union numbers1 numbers2 numbers3)") + +(defun -contains? (list element) + "Return non-nil if LIST contains ELEMENT. + +The test for equality is done with `equal', or with `-compare-fn' +if that's non-nil. + +Alias: `-contains-p'" + (not + (null + (cond + ((null -compare-fn) (member element list)) + ((eq -compare-fn 'eq) (memq element list)) + ((eq -compare-fn 'eql) (memql element list)) + (t + (let ((lst list)) + (while (and lst + (not (funcall -compare-fn element (car lst)))) + (setq lst (cdr lst))) + lst)))))) + +(defalias '-contains-p '-contains?) + +(defun -same-items? (list list2) + "Return true if LIST and LIST2 has the same items. + +The order of the elements in the lists does not matter. + +Alias: `-same-items-p'" + (let ((length-a (length list)) + (length-b (length list2))) + (and + (= length-a length-b) + (= length-a (length (-intersection list list2)))))) + +(defalias '-same-items-p '-same-items?) + +(defun -is-prefix? (prefix list) + "Return non-nil if PREFIX is prefix of LIST. + +Alias: `-is-prefix-p'" + (--each-while list (equal (car prefix) it) + (!cdr prefix)) + (not prefix)) + +(defun -is-suffix? (suffix list) + "Return non-nil if SUFFIX is suffix of LIST. + +Alias: `-is-suffix-p'" + (-is-prefix? (nreverse suffix) (nreverse list))) + +(defun -is-infix? (infix list) + "Return non-nil if INFIX is infix of LIST. + +This operation runs in O(n^2) time + +Alias: `-is-infix-p'" + (let (done) + (while (and (not done) list) + (setq done (-is-prefix? infix list)) + (!cdr list)) + done)) + +(defalias '-is-prefix-p '-is-prefix?) +(defalias '-is-suffix-p '-is-suffix?) +(defalias '-is-infix-p '-is-infix?) + +(defun -sort (comparator list) + "Sort LIST, stably, comparing elements using COMPARATOR. +Return the sorted list. LIST is NOT modified by side effects. +COMPARATOR is called with two elements of LIST, and should return non-nil +if the first element should sort before the second." + (sort (copy-sequence list) comparator)) + +(defmacro --sort (form list) + "Anaphoric form of `-sort'." + (declare (debug (form form))) + `(-sort (lambda (it other) ,form) ,list)) + +(defun -list (&rest args) + "Return a list with ARGS. + +If first item of ARGS is already a list, simply return ARGS. If +not, return a list with ARGS as elements." + (let ((arg (car args))) + (if (listp arg) arg args))) + +(defun -repeat (n x) + "Return a list with X repeated N times. +Return nil if N is less than 1." + (let (ret) + (--dotimes n (!cons x ret)) + ret)) + +(defun -sum (list) + "Return the sum of LIST." + (apply '+ list)) + +(defun -product (list) + "Return the product of LIST." + (apply '* list)) + +(defun -max (list) + "Return the largest value from LIST of numbers or markers." + (apply 'max list)) + +(defun -min (list) + "Return the smallest value from LIST of numbers or markers." + (apply 'min list)) + +(defun -max-by (comparator list) + "Take a comparison function COMPARATOR and a LIST and return +the greatest element of the list by the comparison function. + +See also combinator `-on' which can transform the values before +comparing them." + (--reduce (if (funcall comparator it acc) it acc) list)) + +(defun -min-by (comparator list) + "Take a comparison function COMPARATOR and a LIST and return +the least element of the list by the comparison function. + +See also combinator `-on' which can transform the values before +comparing them." + (--reduce (if (funcall comparator it acc) acc it) list)) + +(defmacro --max-by (form list) + "Anaphoric version of `-max-by'. + +The items for the comparator form are exposed as \"it\" and \"other\"." + (declare (debug (form form))) + `(-max-by (lambda (it other) ,form) ,list)) + +(defmacro --min-by (form list) + "Anaphoric version of `-min-by'. + +The items for the comparator form are exposed as \"it\" and \"other\"." + (declare (debug (form form))) + `(-min-by (lambda (it other) ,form) ,list)) + +(defun -iterate (fun init n) + "Return a list of iterated applications of FUN to INIT. + +This means a list of form: + + (init (fun init) (fun (fun init)) ...) + +N is the length of the returned list." + (if (= n 0) nil + (let ((r (list init))) + (--dotimes (1- n) + (push (funcall fun (car r)) r)) + (nreverse r)))) + +(defun -fix (fn list) + "Compute the (least) fixpoint of FN with initial input LIST. + +FN is called at least once, results are compared with `equal'." + (let ((re (funcall fn list))) + (while (not (equal list re)) + (setq list re) + (setq re (funcall fn re))) + re)) + +(defmacro --fix (form list) + "Anaphoric form of `-fix'." + `(-fix (lambda (it) ,form) ,list)) + +(defun -unfold (fun seed) + "Build a list from SEED using FUN. + +This is \"dual\" operation to `-reduce-r': while -reduce-r +consumes a list to produce a single value, `-unfold' takes a +seed value and builds a (potentially infinite!) list. + +FUN should return `nil' to stop the generating process, or a +cons (A . B), where A will be prepended to the result and B is +the new seed." + (let ((last (funcall fun seed)) r) + (while last + (push (car last) r) + (setq last (funcall fun (cdr last)))) + (nreverse r))) + +(defmacro --unfold (form seed) + "Anaphoric version of `-unfold'." + (declare (debug (form form))) + `(-unfold (lambda (it) ,form) ,seed)) + +(defun -cons-pair? (con) + "Return non-nil if CON is true cons pair. +That is (A . B) where B is not a list." + (and (listp con) + (not (listp (cdr con))))) + +(defun -cons-to-list (con) + "Convert a cons pair to a list with `car' and `cdr' of the pair respectively." + (list (car con) (cdr con))) + +(defun -value-to-list (val) + "Convert a value to a list. + +If the value is a cons pair, make a list with two elements, `car' +and `cdr' of the pair respectively. + +If the value is anything else, wrap it in a list." + (cond + ((-cons-pair? val) (-cons-to-list val)) + (t (list val)))) + +(defun -tree-mapreduce-from (fn folder init-value tree) + "Apply FN to each element of TREE, and make a list of the results. +If elements of TREE are lists themselves, apply FN recursively to +elements of these nested lists. + +Then reduce the resulting lists using FOLDER and initial value +INIT-VALUE. See `-reduce-r-from'. + +This is the same as calling `-tree-reduce-from' after `-tree-map' +but is twice as fast as it only traverse the structure once." + (cond + ((not tree) nil) + ((-cons-pair? tree) (funcall fn tree)) + ((listp tree) + (-reduce-r-from folder init-value (mapcar (lambda (x) (-tree-mapreduce-from fn folder init-value x)) tree))) + (t (funcall fn tree)))) + +(defmacro --tree-mapreduce-from (form folder init-value tree) + "Anaphoric form of `-tree-mapreduce-from'." + (declare (debug (form form form form))) + `(-tree-mapreduce-from (lambda (it) ,form) (lambda (it acc) ,folder) ,init-value ,tree)) + +(defun -tree-mapreduce (fn folder tree) + "Apply FN to each element of TREE, and make a list of the results. +If elements of TREE are lists themselves, apply FN recursively to +elements of these nested lists. + +Then reduce the resulting lists using FOLDER and initial value +INIT-VALUE. See `-reduce-r-from'. + +This is the same as calling `-tree-reduce' after `-tree-map' +but is twice as fast as it only traverse the structure once." + (cond + ((not tree) nil) + ((-cons-pair? tree) (funcall fn tree)) + ((listp tree) + (-reduce-r folder (mapcar (lambda (x) (-tree-mapreduce fn folder x)) tree))) + (t (funcall fn tree)))) + +(defmacro --tree-mapreduce (form folder tree) + "Anaphoric form of `-tree-mapreduce'." + (declare (debug (form form form))) + `(-tree-mapreduce (lambda (it) ,form) (lambda (it acc) ,folder) ,tree)) + +(defun -tree-map (fn tree) + "Apply FN to each element of TREE while preserving the tree structure." + (cond + ((not tree) nil) + ((-cons-pair? tree) (funcall fn tree)) + ((listp tree) + (mapcar (lambda (x) (-tree-map fn x)) tree)) + (t (funcall fn tree)))) + +(defmacro --tree-map (form tree) + "Anaphoric form of `-tree-map'." + (declare (debug (form form))) + `(-tree-map (lambda (it) ,form) ,tree)) + +(defun -tree-reduce-from (fn init-value tree) + "Use FN to reduce elements of list TREE. +If elements of TREE are lists themselves, apply the reduction recursively. + +FN is first applied to INIT-VALUE and first element of the list, +then on this result and second element from the list etc. + +The initial value is ignored on cons pairs as they always contain +two elements." + (cond + ((not tree) nil) + ((-cons-pair? tree) tree) + ((listp tree) + (-reduce-r-from fn init-value (mapcar (lambda (x) (-tree-reduce-from fn init-value x)) tree))) + (t tree))) + +(defmacro --tree-reduce-from (form init-value tree) + "Anaphoric form of `-tree-reduce-from'." + (declare (debug (form form form))) + `(-tree-reduce-from (lambda (it acc) ,form) ,init-value ,tree)) + +(defun -tree-reduce (fn tree) + "Use FN to reduce elements of list TREE. +If elements of TREE are lists themselves, apply the reduction recursively. + +FN is first applied to first element of the list and second +element, then on this result and third element from the list etc. + +See `-reduce-r' for how exactly are lists of zero or one element handled." + (cond + ((not tree) nil) + ((-cons-pair? tree) tree) + ((listp tree) + (-reduce-r fn (mapcar (lambda (x) (-tree-reduce fn x)) tree))) + (t tree))) + +(defmacro --tree-reduce (form tree) + "Anaphoric form of `-tree-reduce'." + (declare (debug (form form))) + `(-tree-reduce (lambda (it acc) ,form) ,tree)) + +(defun -tree-map-nodes (pred fun tree) + "Call FUN on each node of TREE that satisfies PRED. + +If PRED returns nil, continue descending down this node. If PRED +returns non-nil, apply FUN to this node and do not descend +further." + (if (funcall pred tree) + (funcall fun tree) + (if (and (listp tree) + (not (-cons-pair? tree))) + (-map (lambda (x) (-tree-map-nodes pred fun x)) tree) + tree))) + +(defmacro --tree-map-nodes (pred form tree) + "Anaphoric form of `-tree-map-nodes'." + `(-tree-map-nodes (lambda (it) ,pred) (lambda (it) ,form) ,tree)) + +(defun -tree-seq (branch children tree) + "Return a sequence of the nodes in TREE, in depth-first search order. + +BRANCH is a predicate of one argument that returns non-nil if the +passed argument is a branch, that is, a node that can have children. + +CHILDREN is a function of one argument that returns the children +of the passed branch node. + +Non-branch nodes are simply copied." + (cons tree + (when (funcall branch tree) + (-mapcat (lambda (x) (-tree-seq branch children x)) + (funcall children tree))))) + +(defmacro --tree-seq (branch children tree) + "Anaphoric form of `-tree-seq'." + `(-tree-seq (lambda (it) ,branch) (lambda (it) ,children) ,tree)) + +(defun -clone (list) + "Create a deep copy of LIST. +The new list has the same elements and structure but all cons are +replaced with new ones. This is useful when you need to clone a +structure such as plist or alist." + (-tree-map 'identity list)) + +(defun dash-enable-font-lock () + "Add syntax highlighting to dash functions, macros and magic values." + (eval-after-load "lisp-mode" + '(progn + (let ((new-keywords '( + "-each" + "--each" + "-each-while" + "--each-while" + "-dotimes" + "--dotimes" + "-map" + "--map" + "-reduce-from" + "--reduce-from" + "-reduce" + "--reduce" + "-reduce-r-from" + "--reduce-r-from" + "-reduce-r" + "--reduce-r" + "-filter" + "--filter" + "-select" + "--select" + "-remove" + "--remove" + "-reject" + "--reject" + "-remove-first" + "--remove-first" + "-reject-first" + "--reject-first" + "-remove-last" + "--remove-last" + "-reject-last" + "--reject-last" + "-remove-item" + "-non-nil" + "-keep" + "--keep" + "-map-indexed" + "--map-indexed" + "-splice" + "--splice" + "-splice-list" + "--splice-list" + "-map-when" + "--map-when" + "-replace-where" + "--replace-where" + "-map-first" + "--map-first" + "-map-last" + "--map-last" + "-replace" + "-replace-first" + "-replace-last" + "-flatten" + "-flatten-n" + "-concat" + "-mapcat" + "--mapcat" + "-copy" + "-cons*" + "-snoc" + "-first" + "--first" + "-find" + "--find" + "-some" + "--some" + "-any" + "--any" + "-last" + "--last" + "-first-item" + "-last-item" + "-butlast" + "-count" + "--count" + "-any?" + "--any?" + "-some?" + "--some?" + "-any-p" + "--any-p" + "-some-p" + "--some-p" + "-all?" + "--all?" + "-every?" + "--every?" + "-all-p" + "--all-p" + "-every-p" + "--every-p" + "-none?" + "--none?" + "-none-p" + "--none-p" + "-only-some?" + "--only-some?" + "-only-some-p" + "--only-some-p" + "-slice" + "-take" + "-drop" + "-take-while" + "--take-while" + "-drop-while" + "--drop-while" + "-split-at" + "-rotate" + "-insert-at" + "-replace-at" + "-update-at" + "--update-at" + "-remove-at" + "-remove-at-indices" + "-split-with" + "--split-with" + "-split-on" + "-split-when" + "--split-when" + "-separate" + "--separate" + "-partition-all-in-steps" + "-partition-in-steps" + "-partition-all" + "-partition" + "-partition-by" + "--partition-by" + "-partition-by-header" + "--partition-by-header" + "-group-by" + "--group-by" + "-interpose" + "-interleave" + "-zip-with" + "--zip-with" + "-zip" + "-zip-fill" + "-cycle" + "-pad" + "-annotate" + "--annotate" + "-table" + "-table-flat" + "-partial" + "-elem-index" + "-elem-indices" + "-find-indices" + "--find-indices" + "-find-index" + "--find-index" + "-find-last-index" + "--find-last-index" + "-select-by-indices" + "-grade-up" + "-grade-down" + "->" + "->>" + "-->" + "-when-let" + "-when-let*" + "--when-let" + "-if-let" + "-if-let*" + "--if-let" + "-let*" + "-let" + "-lambda" + "-distinct" + "-uniq" + "-union" + "-intersection" + "-difference" + "-contains?" + "-contains-p" + "-same-items?" + "-same-items-p" + "-is-prefix-p" + "-is-prefix?" + "-is-suffix-p" + "-is-suffix?" + "-is-infix-p" + "-is-infix?" + "-sort" + "--sort" + "-list" + "-repeat" + "-sum" + "-product" + "-max" + "-min" + "-max-by" + "--max-by" + "-min-by" + "--min-by" + "-iterate" + "--iterate" + "-fix" + "--fix" + "-unfold" + "--unfold" + "-cons-pair?" + "-cons-to-list" + "-value-to-list" + "-tree-mapreduce-from" + "--tree-mapreduce-from" + "-tree-mapreduce" + "--tree-mapreduce" + "-tree-map" + "--tree-map" + "-tree-reduce-from" + "--tree-reduce-from" + "-tree-reduce" + "--tree-reduce" + "-tree-seq" + "--tree-seq" + "-tree-map-nodes" + "--tree-map-nodes" + "-clone" + "-rpartial" + "-juxt" + "-applify" + "-on" + "-flip" + "-const" + "-cut" + "-orfn" + "-andfn" + "-iteratefn" + "-fixfn" + "-prodfn" + )) + (special-variables '( + "it" + "it-index" + "acc" + "other" + ))) + (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "\\_<" (regexp-opt special-variables 'paren) "\\_>") + 1 font-lock-variable-name-face)) 'append) + (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "(\\s-*" (regexp-opt new-keywords 'paren) "\\_>") + 1 font-lock-keyword-face)) 'append)) + (--each (buffer-list) + (with-current-buffer it + (when (and (eq major-mode 'emacs-lisp-mode) + (boundp 'font-lock-mode) + font-lock-mode) + (font-lock-refresh-defaults))))))) + +(provide 'dash) +;;; dash.el ends here diff --git a/emacs.d/elpa/deferred-20140816.2205/deferred-autoloads.el b/emacs.d/elpa/deferred-20140816.2205/deferred-autoloads.el deleted file mode 100644 index 83750dd..0000000 --- a/emacs.d/elpa/deferred-20140816.2205/deferred-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; deferred-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("deferred.el") (21571 44954 910371 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; deferred-autoloads.el ends here diff --git a/emacs.d/elpa/deferred-20140816.2205/deferred-pkg.el b/emacs.d/elpa/deferred-20140816.2205/deferred-pkg.el deleted file mode 100644 index 6671ad7..0000000 --- a/emacs.d/elpa/deferred-20140816.2205/deferred-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "deferred" "20140816.2205" "Simple asynchronous functions for emacs lisp" 'nil :url "https://github.com/kiwanami/emacs-deferred" :keywords '("deferred" "async")) diff --git a/emacs.d/elpa/deferred-20140816.2205/deferred.el b/emacs.d/elpa/deferred-20140816.2205/deferred.el deleted file mode 100644 index 7e96302..0000000 --- a/emacs.d/elpa/deferred-20140816.2205/deferred.el +++ /dev/null @@ -1,963 +0,0 @@ -;;; deferred.el --- Simple asynchronous functions for emacs lisp - -;; Copyright (C) 2010, 2011, 2012 SAKURAI Masashi - -;; Author: SAKURAI Masashi -;; Version: 20140816.2205 -;; X-Original-Version: 0.3.2 -;; Keywords: deferred, async -;; URL: https://github.com/kiwanami/emacs-deferred - -;; 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: - -;; 'deferred.el' is a simple library for asynchronous tasks. -;; [https://github.com/kiwanami/emacs-deferred] - -;; The API is almost the same as JSDeferred written by cho45. See the -;; JSDeferred and Mochikit.Async web sites for further documentations. -;; [https://github.com/cho45/jsdeferred] -;; [http://mochikit.com/doc/html/MochiKit/Async.html] - -;; A good introduction document (JavaScript) -;; [http://cho45.stfuawsc.com/jsdeferred/doc/intro.en.html] - -;;; Samples: - -;; ** HTTP Access - -;; (require 'url) -;; (deferred:$ -;; (deferred:url-retrieve "http://www.gnu.org") -;; (deferred:nextc it -;; (lambda (buf) -;; (insert (with-current-buffer buf (buffer-string))) -;; (kill-buffer buf)))) - -;; ** Invoking command tasks - -;; (deferred:$ -;; (deferred:process "wget" "-O" "a.jpg" "http://www.gnu.org/software/emacs/tour/images/splash.png") -;; (deferred:nextc it -;; (lambda (x) (deferred:process "convert" "a.jpg" "-resize" "100x100" "jpg:b.jpg"))) -;; (deferred:nextc it -;; (lambda (x) -;; (insert-image (create-image (expand-file-name "b.jpg") 'jpeg nil))))) - -;; See the readme for further API documentation. - -;; ** Applications - -;; *Inertial scrolling for Emacs -;; [https://github.com/kiwanami/emacs-inertial-scroll] - -;; This program makes simple multi-thread function, using -;; deferred.el. - -(require 'cl) - -(defvar deferred:version nil "deferred.el version") -(setq deferred:version "0.3.2") - -;;; Code: - -(defmacro deferred:aand (test &rest rest) - "[internal] Anaphoric AND." - (declare (debug ("test" form &rest form))) - `(let ((it ,test)) - (if it ,(if rest `(deferred:aand ,@rest) 'it)))) - -(defmacro deferred:$ (&rest elements) - "Anaphoric function chain macro for deferred chains." - (declare (debug (&rest form))) - `(let (it) - ,@(loop for i in elements - with it = nil - collect - `(setq it ,i)) - it)) - -(defmacro deferred:lambda (args &rest body) - "Anaphoric lambda macro for self recursion." - (declare (debug ("args" form &rest form))) - (let ((argsyms (loop for i in args collect (gensym)))) - `(lambda (,@argsyms) - (lexical-let (self) - (setq self (lambda( ,@args ) ,@body)) - (funcall self ,@argsyms))))) - -(defmacro* deferred:try (d &key catch finally) - "Try-catch-finally macro. This macro simulates the -try-catch-finally block asynchronously. CATCH and FINALLY can be -nil. Because of asynchrony, this macro does not ensure that the -task FINALLY should be called." - (let ((chain - (if catch `((deferred:error it ,catch))))) - (when finally - (setq chain (append chain `((deferred:watch it ,finally))))) - `(deferred:$ ,d ,@chain))) - -(defun deferred:setTimeout (f msec) - "[internal] Timer function that emulates the `setTimeout' function in JS." - (run-at-time (/ msec 1000.0) nil f)) - -(defun deferred:cancelTimeout (id) - "[internal] Timer cancellation function that emulates the `cancelTimeout' function in JS." - (cancel-timer id)) - -(defun deferred:run-with-idle-timer (sec f) - "[internal] Wrapper function for run-with-idle-timer." - (run-with-idle-timer sec nil f)) - -(defun deferred:call-lambda (f &optional arg) - "[internal] Call a function with one or zero argument safely. -The lambda function can define with zero and one argument." - (condition-case err - (funcall f arg) - ('wrong-number-of-arguments - (display-warning 'deferred "\ -Callback that takes no argument may be specified. -Passing callback with no argument is deprecated. -Callback must take one argument. -Or, this error is coming from somewhere inside of the callback: %S" err) - (condition-case err2 - (funcall f) - ('wrong-number-of-arguments - (signal 'wrong-number-of-arguments (cdr err))))))) ; return the first error - -;; debug - -(eval-and-compile - (defvar deferred:debug nil "Debug output switch.")) -(defvar deferred:debug-count 0 "[internal] Debug output counter.") - -(defmacro deferred:message (&rest args) - "[internal] Debug log function." - (when deferred:debug - `(progn - (with-current-buffer (get-buffer-create "*deferred:debug*") - (save-excursion - (goto-char (point-max)) - (insert (format "%5i %s\n" deferred:debug-count (format ,@args))))) - (incf deferred:debug-count)))) - -(defun deferred:message-mark () - "[internal] Debug log function." - (interactive) - (deferred:message "==================== mark ==== %s" - (format-time-string "%H:%M:%S" (current-time)))) - -(defun deferred:pp (d) - (require 'pp) - (deferred:$ - (deferred:nextc d - (lambda (x) - (pp-display-expression x "*deferred:pp*"))) - (deferred:error it - (lambda (e) - (pp-display-expression e "*deferred:pp*"))) - (deferred:nextc it - (lambda (x) (pop-to-buffer "*deferred:pp*"))))) - -(defvar deferred:debug-on-signal nil -"If non nil, the value `debug-on-signal' is substituted this -value in the `condition-case' form in deferred -implementations. Then, Emacs debugger can catch an error occurred -in the asynchronous tasks.") - -(defmacro deferred:condition-case (var protected-form &rest handlers) - "[internal] Custom condition-case. See the comment for -`deferred:debug-on-signal'." - (declare (debug condition-case) - (indent 2)) - `(let ((debug-on-signal - (or debug-on-signal deferred:debug-on-signal))) - (condition-case ,var - ,protected-form - ,@handlers))) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Back end functions of deferred tasks - -(defvar deferred:tick-time 0.001 - "Waiting time between asynchronous tasks (second). -The shorter waiting time increases the load of Emacs. The end -user can tune this paramter. However, applications should not -modify it because the applications run on various environments.") - -(defvar deferred:queue nil - "[internal] The execution queue of deferred objects. -See the functions `deferred:post-task' and `deferred:worker'.") - -(defmacro deferred:pack (a b c) - `(cons ,a (cons ,b ,c))) - -(defun deferred:schedule-worker () - "[internal] Schedule consuming a deferred task in the execution queue." - (run-at-time deferred:tick-time nil 'deferred:worker)) - -(defun deferred:post-task (d which &optional arg) - "[internal] Add a deferred object to the execution queue -`deferred:queue' and schedule to execute. -D is a deferred object. WHICH is a symbol, `ok' or `ng'. ARG is -an argument value for execution of the deferred task." - (push (deferred:pack d which arg) deferred:queue) - (deferred:message "QUEUE-POST [%s]: %s" - (length deferred:queue) (deferred:pack d which arg)) - (deferred:schedule-worker) - d) - -(defun deferred:clear-queue () - "Clear the execution queue. For test and debugging." - (interactive) - (deferred:message "QUEUE-CLEAR [%s -> 0]" (length deferred:queue)) - (setq deferred:queue nil)) - -(defun deferred:worker () - "[internal] Consume a deferred task. -Mainly this function is called by timer asynchronously." - (when deferred:queue - (let* ((pack (car (last deferred:queue))) - (d (car pack)) - (which (cadr pack)) - (arg (cddr pack)) value) - (setq deferred:queue (nbutlast deferred:queue)) - (condition-case err - (setq value (deferred:exec-task d which arg)) - (error - (deferred:message "ERROR : %s" err) - (message "deferred error : %s" err))) - value))) - -(defun deferred:flush-queue! () - "Call all deferred tasks synchronously. For test and debugging." - (let (value) - (while deferred:queue - (setq value (deferred:worker))) - value)) - -(defun deferred:sync! (d) - "Wait for the given deferred task. For test and debugging. -Error is raised if it is not processed within deferred chain D." - (progn - (lexical-let ((last-value 'deferred:undefined*) - uncaught-error) - (deferred:try - (deferred:nextc d - (lambda (x) (setq last-value x))) - :catch - (lambda (err) (setq uncaught-error err))) - (while (and (eq 'deferred:undefined* last-value) - (not uncaught-error)) - (sit-for 0.05) - (sleep-for 0.05)) - (when uncaught-error - (deferred:resignal uncaught-error)) - last-value))) - - - -;; Struct: deferred -;; -;; callback : a callback function (default `deferred:default-callback') -;; errorback : an errorback function (default `deferred:default-errorback') -;; cancel : a canceling function (default `deferred:default-cancel') -;; next : a next chained deferred object (default nil) -;; status : if 'ok or 'ng, this deferred has a result (error) value. (default nil) -;; value : saved value (default nil) -;; -(defstruct deferred - (callback 'deferred:default-callback) - (errorback 'deferred:default-errorback) - (cancel 'deferred:default-cancel) - next status value) - -(defun deferred:default-callback (i) - "[internal] Default callback function." - (identity i)) - -(defun deferred:default-errorback (err) - "[internal] Default errorback function." - (deferred:resignal err)) - -(defun deferred:resignal (err) - "[internal] Safely resignal ERR as an Emacs condition. - -If ERR is a cons (ERROR-SYMBOL . DATA) where ERROR-SYMBOL has an -`error-conditions' property, it is re-signaled unchanged. If ERR -is a string, it is signaled as a generic error using `error'. -Otherwise, ERR is formatted into a string as if by `print' before -raising with `error'." - (cond ((and (listp err) - (symbolp (car err)) - (get (car err) 'error-conditions)) - (signal (car err) (cdr err))) - ((stringp err) - (error "%s" err)) - (t - (error "%S" err)))) - -(defun deferred:default-cancel (d) - "[internal] Default canceling function." - (deferred:message "CANCEL : %s" d) - (setf (deferred-callback d) 'deferred:default-callback) - (setf (deferred-errorback d) 'deferred:default-errorback) - (setf (deferred-next d) nil) - d) - -(defun deferred:exec-task (d which &optional arg) - "[internal] Executing deferred task. If the deferred object has -next deferred task or the return value is a deferred object, this -function adds the task to the execution queue. -D is a deferred object. WHICH is a symbol, `ok' or `ng'. ARG is -an argument value for execution of the deferred task." - (deferred:message "EXEC : %s / %s / %s" d which arg) - (when (null d) (error "deferred:exec-task was given a nil.")) - (let ((callback (if (eq which 'ok) - (deferred-callback d) - (deferred-errorback d))) - (next-deferred (deferred-next d))) - (cond - (callback - (deferred:condition-case err - (let ((value (deferred:call-lambda callback arg))) - (cond - ((deferred-p value) - (deferred:message "WAIT NEST : %s" value) - (if next-deferred - (deferred:set-next value next-deferred) - value)) - (t - (if next-deferred - (deferred:post-task next-deferred 'ok value) - (setf (deferred-status d) 'ok) - (setf (deferred-value d) value) - value)))) - (error - (cond - (next-deferred - (deferred:post-task next-deferred 'ng err)) - (deferred:onerror - (deferred:call-lambda deferred:onerror err)) - (t - (deferred:message "ERROR : %S" err) - (message "deferred error : %S" err) - (setf (deferred-status d) 'ng) - (setf (deferred-value d) err) - err))))) - (t ; <= (null callback) - (cond - (next-deferred - (deferred:exec-task next-deferred which arg)) - ((eq which 'ok) arg) - (t ; (eq which 'ng) - (deferred:resignal arg))))))) - -(defun deferred:set-next (prev next) - "[internal] Connect deferred objects." - (setf (deferred-next prev) next) - (cond - ((eq 'ok (deferred-status prev)) - (setf (deferred-status prev) nil) - (let ((ret (deferred:exec-task - next 'ok (deferred-value prev)))) - (if (deferred-p ret) ret - next))) - ((eq 'ng (deferred-status prev)) - (setf (deferred-status prev) nil) - (let ((ret (deferred:exec-task next 'ng (deferred-value prev)))) - (if (deferred-p ret) ret - next))) - (t - next))) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Basic functions for deferred objects - -(defun deferred:new (&optional callback) - "Create a deferred object." - (if callback - (make-deferred :callback callback) - (make-deferred))) - -(defun deferred:callback (d &optional arg) - "Start deferred chain with a callback message." - (deferred:exec-task d 'ok arg)) - -(defun deferred:errorback (d &optional arg) - "Start deferred chain with an errorback message." - (deferred:exec-task d 'ng arg)) - -(defun deferred:callback-post (d &optional arg) - "Add the deferred object to the execution queue." - (deferred:post-task d 'ok arg)) - -(defun deferred:errorback-post (d &optional arg) - "Add the deferred object to the execution queue." - (deferred:post-task d 'ng arg)) - -(defun deferred:cancel (d) - "Cancel all callbacks and deferred chain in the deferred object." - (deferred:message "CANCEL : %s" d) - (funcall (deferred-cancel d) d) - d) - -(defun deferred:status (d) - "Return a current status of the deferred object. The returned value means following: -`ok': the callback was called and waiting for next deferred. -`ng': the errorback was called and waiting for next deferred. - nil: The neither callback nor errorback was not called." - (deferred-status d)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Basic utility functions - -(defvar deferred:onerror nil - "Default error handler. This value is nil or a function that - have one argument for the error message.") - -(defun deferred:succeed (&optional arg) - "Create a synchronous deferred object." - (let ((d (deferred:new))) - (deferred:exec-task d 'ok arg) - d)) - -(defun deferred:fail (&optional arg) - "Create a synchronous deferred object." - (let ((d (deferred:new))) - (deferred:exec-task d 'ng arg) - d)) - -(defun deferred:next (&optional callback arg) - "Create a deferred object and schedule executing. This function -is a short cut of following code: - (deferred:callback-post (deferred:new callback))." - (let ((d (if callback - (make-deferred :callback callback) - (make-deferred)))) - (deferred:callback-post d arg) - d)) - -(defun deferred:nextc (d callback) - "Create a deferred object with OK callback and connect it to the given deferred object." - (let ((nd (make-deferred :callback callback))) - (deferred:set-next d nd))) - -(defun deferred:error (d callback) - "Create a deferred object with errorback and connect it to the given deferred object." - (let ((nd (make-deferred :errorback callback))) - (deferred:set-next d nd))) - -(defun deferred:watch (d callback) - "Create a deferred object with watch task and connect it to the given deferred object. -The watch task CALLBACK can not affect deferred chains with -return values. This function is used in following purposes, -simulation of try-finally block in asynchronous tasks, progress -monitoring of tasks." - (lexical-let* - ((callback callback) - (normal (lambda (x) (ignore-errors (deferred:call-lambda callback x)) x)) - (err (lambda (e) - (ignore-errors (deferred:call-lambda callback e)) - (deferred:resignal e)))) - (let ((nd (make-deferred :callback normal :errorback err))) - (deferred:set-next d nd)))) - -(defun deferred:wait (msec) - "Return a deferred object scheduled at MSEC millisecond later." - (lexical-let - ((d (deferred:new)) (start-time (float-time)) timer) - (deferred:message "WAIT : %s" msec) - (setq timer (deferred:setTimeout - (lambda () - (deferred:exec-task d 'ok - (* 1000.0 (- (float-time) start-time))) - nil) msec)) - (setf (deferred-cancel d) - (lambda (x) - (deferred:cancelTimeout timer) - (deferred:default-cancel x))) - d)) - -(defun deferred:wait-idle (msec) - "Return a deferred object which will run when Emacs has been -idle for MSEC millisecond." - (lexical-let - ((d (deferred:new)) (start-time (float-time)) timer) - (deferred:message "WAIT-IDLE : %s" msec) - (setq timer - (deferred:run-with-idle-timer - (/ msec 1000.0) - (lambda () - (deferred:exec-task d 'ok - (* 1000.0 (- (float-time) start-time))) - nil))) - (setf (deferred-cancel d) - (lambda (x) - (deferred:cancelTimeout timer) - (deferred:default-cancel x))) - d)) - -(defun deferred:call (f &rest args) - "Call the given function asynchronously." - (lexical-let ((f f) (args args)) - (deferred:next - (lambda (x) - (apply f args))))) - -(defun deferred:apply (f &optional args) - "Call the given function asynchronously." - (lexical-let ((f f) (args args)) - (deferred:next - (lambda (x) - (apply f args))))) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Utility functions - -(defun deferred:empty-p (times-or-list) - "[internal] Return non-nil if TIMES-OR-LIST is the number zero or nil." - (or (and (numberp times-or-list) (<= times-or-list 0)) - (and (listp times-or-list) (null times-or-list)))) - -(defun deferred:loop (times-or-list func) - "Return a iteration deferred object." - (deferred:message "LOOP : %s" times-or-list) - (if (deferred:empty-p times-or-list) (deferred:next) - (lexical-let* - (items (rd - (cond - ((numberp times-or-list) - (loop for i from 0 below times-or-list - with ld = (deferred:next) - do - (push ld items) - (setq ld - (lexical-let ((i i) (func func)) - (deferred:nextc ld (lambda (x) (deferred:call-lambda func i))))) - finally return ld)) - ((listp times-or-list) - (loop for i in times-or-list - with ld = (deferred:next) - do - (push ld items) - (setq ld - (lexical-let ((i i) (func func)) - (deferred:nextc ld (lambda (x) (deferred:call-lambda func i))))) - finally return ld))))) - (setf (deferred-cancel rd) - (lambda (x) (deferred:default-cancel x) - (loop for i in items - do (deferred:cancel i)))) - rd))) - -(defun deferred:trans-multi-args (args self-func list-func main-func) - "[internal] Check the argument values and dispatch to methods." - (cond - ((and (= 1 (length args)) (consp (car args)) (not (functionp (car args)))) - (let ((lst (car args))) - (cond - ((or (null lst) (null (car lst))) - (deferred:next)) - ((deferred:aand lst (car it) (or (functionp it) (deferred-p it))) - ;; a list of deferred objects - (funcall list-func lst)) - ((deferred:aand lst (consp it)) - ;; an alist of deferred objects - (funcall main-func lst)) - (t (error "Wrong argument type. %s" args))))) - (t (funcall self-func args)))) - -(defun deferred:parallel-array-to-alist (lst) - "[internal] Translation array to alist." - (loop for d in lst - for i from 0 below (length lst) - collect (cons i d))) - -(defun deferred:parallel-alist-to-array (alst) - "[internal] Translation alist to array." - (loop for pair in - (sort alst (lambda (x y) - (< (car x) (car y)))) - collect (cdr pair))) - -(defun deferred:parallel-func-to-deferred (alst) - "[internal] Normalization for parallel and earlier arguments." - (loop for pair in alst - for d = (cdr pair) - collect - (progn - (unless (deferred-p d) - (setf (cdr pair) (deferred:next d))) - pair))) - -(defun deferred:parallel-main (alst) - "[internal] Deferred alist implementation for `deferred:parallel'. " - (deferred:message "PARALLEL" ) - (lexical-let ((nd (deferred:new)) - (len (length alst)) - values) - (loop for pair in - (deferred:parallel-func-to-deferred alst) - with cd ; current child deferred - do - (lexical-let ((name (car pair))) - (setq cd - (deferred:nextc (cdr pair) - (lambda (x) - (push (cons name x) values) - (deferred:message "PARALLEL VALUE [%s/%s] %s" - (length values) len (cons name x)) - (when (= len (length values)) - (deferred:message "PARALLEL COLLECTED") - (deferred:post-task nd 'ok (nreverse values))) - nil))) - (deferred:error cd - (lambda (e) - (push (cons name e) values) - (deferred:message "PARALLEL ERROR [%s/%s] %s" - (length values) len (cons name e)) - (when (= (length values) len) - (deferred:message "PARALLEL COLLECTED") - (deferred:post-task nd 'ok (nreverse values))) - nil)))) - nd)) - -(defun deferred:parallel-list (lst) - "[internal] Deferred list implementation for `deferred:parallel'. " - (deferred:message "PARALLEL" ) - (lexical-let* - ((pd (deferred:parallel-main (deferred:parallel-array-to-alist lst))) - (rd (deferred:nextc pd 'deferred:parallel-alist-to-array))) - (setf (deferred-cancel rd) - (lambda (x) (deferred:default-cancel x) - (deferred:cancel pd))) - rd)) - -(defun deferred:parallel (&rest args) - "Return a deferred object that calls given deferred objects or -functions in parallel and wait for all callbacks. The following -deferred task will be called with an array of the return -values. ARGS can be a list or an alist of deferred objects or -functions." - (deferred:message "PARALLEL : %s" args) - (deferred:trans-multi-args args - 'deferred:parallel 'deferred:parallel-list 'deferred:parallel-main)) - -(defun deferred:earlier-main (alst) - "[internal] Deferred alist implementation for `deferred:earlier'. " - (deferred:message "EARLIER" ) - (lexical-let ((nd (deferred:new)) - (len (length alst)) - value results) - (loop for pair in - (deferred:parallel-func-to-deferred alst) - with cd ; current child deferred - do - (lexical-let ((name (car pair))) - (setq cd - (deferred:nextc (cdr pair) - (lambda (x) - (push (cons name x) results) - (cond - ((null value) - (setq value (cons name x)) - (deferred:message "EARLIER VALUE %s" (cons name value)) - (deferred:post-task nd 'ok value)) - (t - (deferred:message "EARLIER MISS [%s/%s] %s" (length results) len (cons name value)) - (when (eql (length results) len) - (deferred:message "EARLIER COLLECTED")))) - nil))) - (deferred:error cd - (lambda (e) - (push (cons name e) results) - (deferred:message "EARLIER ERROR [%s/%s] %s" (length results) len (cons name e)) - (when (and (eql (length results) len) (null value)) - (deferred:message "EARLIER FAILED") - (deferred:post-task nd 'ok nil)) - nil)))) - nd)) - -(defun deferred:earlier-list (lst) - "[internal] Deferred list implementation for `deferred:earlier'. " - (deferred:message "EARLIER" ) - (lexical-let* - ((pd (deferred:earlier-main (deferred:parallel-array-to-alist lst))) - (rd (deferred:nextc pd (lambda (x) (cdr x))))) - (setf (deferred-cancel rd) - (lambda (x) (deferred:default-cancel x) - (deferred:cancel pd))) - rd)) - - -(defun deferred:earlier (&rest args) - "Return a deferred object that calls given deferred objects or -functions in parallel and wait for the first callback. The -following deferred task will be called with the first return -value. ARGS can be a list or an alist of deferred objects or -functions." - (deferred:message "EARLIER : %s" args) - (deferred:trans-multi-args args - 'deferred:earlier 'deferred:earlier-list 'deferred:earlier-main)) - -(defmacro deferred:timeout (timeout-msec timeout-form d) - "Time out macro on a deferred task D. If the deferred task D -does not complete within TIMEOUT-MSEC, this macro cancels the -deferred task and return the TIMEOUT-FORM." - `(deferred:earlier - (deferred:nextc (deferred:wait ,timeout-msec) - (lambda (x) ,timeout-form)) - ,d)) - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Application functions - -(defvar deferred:uid 0 "[internal] Sequence number for some utilities. See the function `deferred:uid'.") - -(defun deferred:uid () - "[internal] Generate a sequence number." - (incf deferred:uid)) - -(defun deferred:buffer-string (strformat buf) - "[internal] Return a string in the buffer with the given format." - (format strformat - (with-current-buffer buf (buffer-string)))) - -(defun deferred:process (command &rest args) - "A deferred wrapper of `start-process'. Return a deferred -object. The process name and buffer name of the argument of the -`start-process' are generated by this function automatically. -The next deferred object receives stdout string from the command -process." - (deferred:process-gen 'start-process command args)) - -(defun deferred:process-shell (command &rest args) - "A deferred wrapper of `start-process-shell-command'. Return a deferred -object. The process name and buffer name of the argument of the -`start-process-shell-command' are generated by this function automatically. -The next deferred object receives stdout string from the command -process." - (deferred:process-gen 'start-process-shell-command command args)) - -(defun deferred:process-buffer (command &rest args) - "A deferred wrapper of `start-process'. Return a deferred -object. The process name and buffer name of the argument of the -`start-process' are generated by this function automatically. -The next deferred object receives stdout buffer from the command -process." - (deferred:process-buffer-gen 'start-process command args)) - -(defun deferred:process-shell-buffer (command &rest args) - "A deferred wrapper of `start-process-shell-command'. Return a deferred -object. The process name and buffer name of the argument of the -`start-process-shell-command' are generated by this function automatically. -The next deferred object receives stdout buffer from the command -process." - (deferred:process-buffer-gen 'start-process-shell-command command args)) - -(defun deferred:process-gen (f command args) - "[internal]" - (lexical-let - ((pd (deferred:process-buffer-gen f command args)) d) - (setq d (deferred:nextc pd - (lambda (buf) - (prog1 - (with-current-buffer buf (buffer-string)) - (kill-buffer buf))))) - (setf (deferred-cancel d) - (lambda (x) - (deferred:default-cancel d) - (deferred:default-cancel pd))) - d)) - -(defun deferred:process-buffer-gen (f command args) - "[internal]" - (let ((d (deferred:next)) (uid (deferred:uid))) - (lexical-let - ((f f) (command command) (args args) - (proc-name (format "*deferred:*%s*:%s" command uid)) - (buf-name (format " *deferred:*%s*:%s" command uid)) - (pwd default-directory) - (env process-environment) - (con-type process-connection-type) - (nd (deferred:new)) proc-buf proc) - (deferred:nextc d - (lambda (x) - (setq proc-buf (get-buffer-create buf-name)) - (condition-case err - (let ((default-directory pwd) - (process-environment env) - (process-connection-type con-type)) - (setq proc - (if (null (car args)) - (apply f proc-name buf-name command nil) - (apply f proc-name buf-name command args))) - (set-process-sentinel - proc - (lambda (proc event) - (cond - ((string-match "exited abnormally" event) - (let ((msg (if (buffer-live-p proc-buf) - (format "Process [%s] exited abnormally : %s" - command - (with-current-buffer proc-buf (buffer-string))) - (concat "Process exited abnormally: " proc-name)))) - (kill-buffer proc-buf) - (deferred:post-task nd 'ng msg))) - ((equal event "finished\n") - (deferred:post-task nd 'ok proc-buf))))) - (setf (deferred-cancel nd) - (lambda (x) (deferred:default-cancel x) - (when proc - (kill-process proc) - (kill-buffer proc-buf))))) - (error (deferred:post-task nd 'ng err))) - nil)) - nd))) - -(defmacro deferred:processc (d command &rest args) - "Process chain of `deferred:process'." - `(deferred:nextc ,d - (lambda (,(gensym)) (deferred:process ,command ,@args)))) - -(defmacro deferred:process-bufferc (d command &rest args) - "Process chain of `deferred:process-buffer'." - `(deferred:nextc ,d - (lambda (,(gensym)) (deferred:process-buffer ,command ,@args)))) - -(defmacro deferred:process-shellc (d command &rest args) - "Process chain of `deferred:process'." - `(deferred:nextc ,d - (lambda (,(gensym)) (deferred:process-shell ,command ,@args)))) - -(defmacro deferred:process-shell-bufferc (d command &rest args) - "Process chain of `deferred:process-buffer'." - `(deferred:nextc ,d - (lambda (,(gensym)) (deferred:process-shell-buffer ,command ,@args)))) - -(eval-after-load "url" - ;; for url package - ;; TODO: proxy, charaset - ;; List of gloabl variables to preserve and restore before url-retrieve call - '(lexical-let ((url-global-variables '(url-request-data - url-request-method - url-request-extra-headers))) - - (defun deferred:url-retrieve (url &optional cbargs silent inhibit-cookies) - "A wrapper function for url-retrieve. The next deferred -object receives the buffer object that URL will load -into. Values of dynamically bound 'url-request-data', 'url-request-method' and -'url-request-extra-headers' are passed to url-retrieve call." - (lexical-let ((nd (deferred:new)) (url url) - (cbargs cbargs) (silent silent) (inhibit-cookies inhibit-cookies) buf - (local-values (mapcar (lambda (symbol) (symbol-value symbol)) url-global-variables))) - (deferred:next - (lambda (x) - (progv url-global-variables local-values - (condition-case err - (setq buf - (url-retrieve - url (lambda (xx) (deferred:post-task nd 'ok buf)) - cbargs silent inhibit-cookies)) - (error (deferred:post-task nd 'ng err))) - nil))) - (setf (deferred-cancel nd) - (lambda (x) - (when (buffer-live-p buf) - (kill-buffer buf)))) - nd)) - - (defun deferred:url-delete-header (buf) - (with-current-buffer buf - (let ((pos (url-http-symbol-value-in-buffer - 'url-http-end-of-headers buf))) - (when pos - (delete-region (point-min) (1+ pos))))) - buf) - - (defun deferred:url-delete-buffer (buf) - (when (and buf (buffer-live-p buf)) - (kill-buffer buf)) - nil) - - (defun deferred:url-get (url &optional params &rest args) - "Perform a HTTP GET method with `url-retrieve'. PARAMS is -a parameter list of (key . value) or key. ARGS will be appended -to deferred:url-retrieve args list. The next deferred -object receives the buffer object that URL will load into." - (when params - (setq url - (concat url "?" (deferred:url-param-serialize params)))) - (let ((d (deferred:$ - (apply 'deferred:url-retrieve url args) - (deferred:nextc it 'deferred:url-delete-header)))) - (deferred:set-next - d (deferred:new 'deferred:url-delete-buffer)) - d)) - - (defun deferred:url-post (url &optional params &rest args) - "Perform a HTTP POST method with `url-retrieve'. PARAMS is -a parameter list of (key . value) or key. ARGS will be appended -to deferred:url-retrieve args list. The next deferred -object receives the buffer object that URL will load into." - (let ((url-request-method "POST") - (url-request-extra-headers - (append url-request-extra-headers - '(("Content-Type" . "application/x-www-form-urlencoded")))) - (url-request-data (deferred:url-param-serialize params))) - (let ((d (deferred:$ - (apply 'deferred:url-retrieve url args) - (deferred:nextc it 'deferred:url-delete-header)))) - (deferred:set-next - d (deferred:new 'deferred:url-delete-buffer)) - d))) - - (defun deferred:url-escape (val) - "[internal] Return a new string that is VAL URI-encoded." - (unless (stringp val) - (setq val (format "%s" val))) - (url-hexify-string - (encode-coding-string val 'utf-8))) - - (defun deferred:url-param-serialize (params) - "[internal] Serialize a list of (key . value) cons cells -into a query string." - (when params - (mapconcat - 'identity - (loop for p in params - collect - (cond - ((consp p) - (concat - (deferred:url-escape (car p)) "=" - (deferred:url-escape (cdr p)))) - (t - (deferred:url-escape p)))) - "&"))) - )) - - -(provide 'deferred) -;;; deferred.el ends here diff --git a/emacs.d/elpa/deferred-20150309.2052/deferred-autoloads.el b/emacs.d/elpa/deferred-20150309.2052/deferred-autoloads.el new file mode 100644 index 0000000..fc1b048 --- /dev/null +++ b/emacs.d/elpa/deferred-20150309.2052/deferred-autoloads.el @@ -0,0 +1,15 @@ +;;; deferred-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil nil ("deferred.el") (21837 24216 32814 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; deferred-autoloads.el ends here diff --git a/emacs.d/elpa/deferred-20150309.2052/deferred-pkg.el b/emacs.d/elpa/deferred-20150309.2052/deferred-pkg.el new file mode 100644 index 0000000..90de56a --- /dev/null +++ b/emacs.d/elpa/deferred-20150309.2052/deferred-pkg.el @@ -0,0 +1 @@ +(define-package "deferred" "20150309.2052" "Simple asynchronous functions for emacs lisp" 'nil :url "https://github.com/kiwanami/emacs-deferred" :keywords '("deferred" "async")) diff --git a/emacs.d/elpa/deferred-20150309.2052/deferred.el b/emacs.d/elpa/deferred-20150309.2052/deferred.el new file mode 100644 index 0000000..5d27d7c --- /dev/null +++ b/emacs.d/elpa/deferred-20150309.2052/deferred.el @@ -0,0 +1,964 @@ +;;; deferred.el --- Simple asynchronous functions for emacs lisp + +;; Copyright (C) 2010, 2011, 2012 SAKURAI Masashi + +;; Author: SAKURAI Masashi +;; Version: 0.3.2 +;; Package-Version: 20150309.2052 +;; Keywords: deferred, async +;; URL: https://github.com/kiwanami/emacs-deferred + +;; 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: + +;; 'deferred.el' is a simple library for asynchronous tasks. +;; [https://github.com/kiwanami/emacs-deferred] + +;; The API is almost the same as JSDeferred written by cho45. See the +;; JSDeferred and Mochikit.Async web sites for further documentations. +;; [https://github.com/cho45/jsdeferred] +;; [http://mochikit.com/doc/html/MochiKit/Async.html] + +;; A good introduction document (JavaScript) +;; [http://cho45.stfuawsc.com/jsdeferred/doc/intro.en.html] + +;;; Samples: + +;; ** HTTP Access + +;; (require 'url) +;; (deferred:$ +;; (deferred:url-retrieve "http://www.gnu.org") +;; (deferred:nextc it +;; (lambda (buf) +;; (insert (with-current-buffer buf (buffer-string))) +;; (kill-buffer buf)))) + +;; ** Invoking command tasks + +;; (deferred:$ +;; (deferred:process "wget" "-O" "a.jpg" "http://www.gnu.org/software/emacs/tour/images/splash.png") +;; (deferred:nextc it +;; (lambda (x) (deferred:process "convert" "a.jpg" "-resize" "100x100" "jpg:b.jpg"))) +;; (deferred:nextc it +;; (lambda (x) +;; (insert-image (create-image (expand-file-name "b.jpg") 'jpeg nil))))) + +;; See the readme for further API documentation. + +;; ** Applications + +;; *Inertial scrolling for Emacs +;; [https://github.com/kiwanami/emacs-inertial-scroll] + +;; This program makes simple multi-thread function, using +;; deferred.el. + +(require 'cl) + +(declare-function pp-display-expression 'pp) + +(defvar deferred:version nil "deferred.el version") +(setq deferred:version "0.3.2") + +;;; Code: + +(defmacro deferred:aand (test &rest rest) + "[internal] Anaphoric AND." + (declare (debug ("test" form &rest form))) + `(let ((it ,test)) + (if it ,(if rest `(deferred:aand ,@rest) 'it)))) + +(defmacro deferred:$ (&rest elements) + "Anaphoric function chain macro for deferred chains." + (declare (debug (&rest form))) + `(let (it) + ,@(loop for i in elements + collect + `(setq it ,i)) + it)) + +(defmacro deferred:lambda (args &rest body) + "Anaphoric lambda macro for self recursion." + (declare (debug ("args" form &rest form))) + (let ((argsyms (loop repeat (length args) collect (gensym)))) + `(lambda (,@argsyms) + (lexical-let (self) + (setq self (lambda( ,@args ) ,@body)) + (funcall self ,@argsyms))))) + +(defmacro* deferred:try (d &key catch finally) + "Try-catch-finally macro. This macro simulates the +try-catch-finally block asynchronously. CATCH and FINALLY can be +nil. Because of asynchrony, this macro does not ensure that the +task FINALLY should be called." + (let ((chain + (if catch `((deferred:error it ,catch))))) + (when finally + (setq chain (append chain `((deferred:watch it ,finally))))) + `(deferred:$ ,d ,@chain))) + +(defun deferred:setTimeout (f msec) + "[internal] Timer function that emulates the `setTimeout' function in JS." + (run-at-time (/ msec 1000.0) nil f)) + +(defun deferred:cancelTimeout (id) + "[internal] Timer cancellation function that emulates the `cancelTimeout' function in JS." + (cancel-timer id)) + +(defun deferred:run-with-idle-timer (sec f) + "[internal] Wrapper function for run-with-idle-timer." + (run-with-idle-timer sec nil f)) + +(defun deferred:call-lambda (f &optional arg) + "[internal] Call a function with one or zero argument safely. +The lambda function can define with zero and one argument." + (condition-case err + (funcall f arg) + ('wrong-number-of-arguments + (display-warning 'deferred "\ +Callback that takes no argument may be specified. +Passing callback with no argument is deprecated. +Callback must take one argument. +Or, this error is coming from somewhere inside of the callback: %S" err) + (condition-case nil + (funcall f) + ('wrong-number-of-arguments + (signal 'wrong-number-of-arguments (cdr err))))))) ; return the first error + +;; debug + +(eval-and-compile + (defvar deferred:debug nil "Debug output switch.")) +(defvar deferred:debug-count 0 "[internal] Debug output counter.") + +(defmacro deferred:message (&rest args) + "[internal] Debug log function." + (when deferred:debug + `(progn + (with-current-buffer (get-buffer-create "*deferred:debug*") + (save-excursion + (goto-char (point-max)) + (insert (format "%5i %s\n" deferred:debug-count (format ,@args))))) + (incf deferred:debug-count)))) + +(defun deferred:message-mark () + "[internal] Debug log function." + (interactive) + (deferred:message "==================== mark ==== %s" + (format-time-string "%H:%M:%S" (current-time)))) + +(defun deferred:pp (d) + (require 'pp) + (deferred:$ + (deferred:nextc d + (lambda (x) + (pp-display-expression x "*deferred:pp*"))) + (deferred:error it + (lambda (e) + (pp-display-expression e "*deferred:pp*"))) + (deferred:nextc it + (lambda (_x) (pop-to-buffer "*deferred:pp*"))))) + +(defvar deferred:debug-on-signal nil +"If non nil, the value `debug-on-signal' is substituted this +value in the `condition-case' form in deferred +implementations. Then, Emacs debugger can catch an error occurred +in the asynchronous tasks.") + +(defmacro deferred:condition-case (var protected-form &rest handlers) + "[internal] Custom condition-case. See the comment for +`deferred:debug-on-signal'." + (declare (debug condition-case) + (indent 2)) + `(let ((debug-on-signal + (or debug-on-signal deferred:debug-on-signal))) + (condition-case ,var + ,protected-form + ,@handlers))) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Back end functions of deferred tasks + +(defvar deferred:tick-time 0.001 + "Waiting time between asynchronous tasks (second). +The shorter waiting time increases the load of Emacs. The end +user can tune this paramter. However, applications should not +modify it because the applications run on various environments.") + +(defvar deferred:queue nil + "[internal] The execution queue of deferred objects. +See the functions `deferred:post-task' and `deferred:worker'.") + +(defmacro deferred:pack (a b c) + `(cons ,a (cons ,b ,c))) + +(defun deferred:schedule-worker () + "[internal] Schedule consuming a deferred task in the execution queue." + (run-at-time deferred:tick-time nil 'deferred:worker)) + +(defun deferred:post-task (d which &optional arg) + "[internal] Add a deferred object to the execution queue +`deferred:queue' and schedule to execute. +D is a deferred object. WHICH is a symbol, `ok' or `ng'. ARG is +an argument value for execution of the deferred task." + (push (deferred:pack d which arg) deferred:queue) + (deferred:message "QUEUE-POST [%s]: %s" + (length deferred:queue) (deferred:pack d which arg)) + (deferred:schedule-worker) + d) + +(defun deferred:clear-queue () + "Clear the execution queue. For test and debugging." + (interactive) + (deferred:message "QUEUE-CLEAR [%s -> 0]" (length deferred:queue)) + (setq deferred:queue nil)) + +(defun deferred:worker () + "[internal] Consume a deferred task. +Mainly this function is called by timer asynchronously." + (when deferred:queue + (let* ((pack (car (last deferred:queue))) + (d (car pack)) + (which (cadr pack)) + (arg (cddr pack)) value) + (setq deferred:queue (nbutlast deferred:queue)) + (condition-case err + (setq value (deferred:exec-task d which arg)) + (error + (deferred:message "ERROR : %s" err) + (message "deferred error : %s" err))) + value))) + +(defun deferred:flush-queue! () + "Call all deferred tasks synchronously. For test and debugging." + (let (value) + (while deferred:queue + (setq value (deferred:worker))) + value)) + +(defun deferred:sync! (d) + "Wait for the given deferred task. For test and debugging. +Error is raised if it is not processed within deferred chain D." + (progn + (lexical-let ((last-value 'deferred:undefined*) + uncaught-error) + (deferred:try + (deferred:nextc d + (lambda (x) (setq last-value x))) + :catch + (lambda (err) (setq uncaught-error err))) + (while (and (eq 'deferred:undefined* last-value) + (not uncaught-error)) + (sit-for 0.05) + (sleep-for 0.05)) + (when uncaught-error + (deferred:resignal uncaught-error)) + last-value))) + + + +;; Struct: deferred +;; +;; callback : a callback function (default `deferred:default-callback') +;; errorback : an errorback function (default `deferred:default-errorback') +;; cancel : a canceling function (default `deferred:default-cancel') +;; next : a next chained deferred object (default nil) +;; status : if 'ok or 'ng, this deferred has a result (error) value. (default nil) +;; value : saved value (default nil) +;; +(defstruct deferred + (callback 'deferred:default-callback) + (errorback 'deferred:default-errorback) + (cancel 'deferred:default-cancel) + next status value) + +(defun deferred:default-callback (i) + "[internal] Default callback function." + (identity i)) + +(defun deferred:default-errorback (err) + "[internal] Default errorback function." + (deferred:resignal err)) + +(defun deferred:resignal (err) + "[internal] Safely resignal ERR as an Emacs condition. + +If ERR is a cons (ERROR-SYMBOL . DATA) where ERROR-SYMBOL has an +`error-conditions' property, it is re-signaled unchanged. If ERR +is a string, it is signaled as a generic error using `error'. +Otherwise, ERR is formatted into a string as if by `print' before +raising with `error'." + (cond ((and (listp err) + (symbolp (car err)) + (get (car err) 'error-conditions)) + (signal (car err) (cdr err))) + ((stringp err) + (error "%s" err)) + (t + (error "%S" err)))) + +(defun deferred:default-cancel (d) + "[internal] Default canceling function." + (deferred:message "CANCEL : %s" d) + (setf (deferred-callback d) 'deferred:default-callback) + (setf (deferred-errorback d) 'deferred:default-errorback) + (setf (deferred-next d) nil) + d) + +(defun deferred:exec-task (d which &optional arg) + "[internal] Executing deferred task. If the deferred object has +next deferred task or the return value is a deferred object, this +function adds the task to the execution queue. +D is a deferred object. WHICH is a symbol, `ok' or `ng'. ARG is +an argument value for execution of the deferred task." + (deferred:message "EXEC : %s / %s / %s" d which arg) + (when (null d) (error "deferred:exec-task was given a nil.")) + (let ((callback (if (eq which 'ok) + (deferred-callback d) + (deferred-errorback d))) + (next-deferred (deferred-next d))) + (cond + (callback + (deferred:condition-case err + (let ((value (deferred:call-lambda callback arg))) + (cond + ((deferred-p value) + (deferred:message "WAIT NEST : %s" value) + (if next-deferred + (deferred:set-next value next-deferred) + value)) + (t + (if next-deferred + (deferred:post-task next-deferred 'ok value) + (setf (deferred-status d) 'ok) + (setf (deferred-value d) value) + value)))) + (error + (cond + (next-deferred + (deferred:post-task next-deferred 'ng err)) + (deferred:onerror + (deferred:call-lambda deferred:onerror err)) + (t + (deferred:message "ERROR : %S" err) + (message "deferred error : %S" err) + (setf (deferred-status d) 'ng) + (setf (deferred-value d) err) + err))))) + (t ; <= (null callback) + (cond + (next-deferred + (deferred:exec-task next-deferred which arg)) + ((eq which 'ok) arg) + (t ; (eq which 'ng) + (deferred:resignal arg))))))) + +(defun deferred:set-next (prev next) + "[internal] Connect deferred objects." + (setf (deferred-next prev) next) + (cond + ((eq 'ok (deferred-status prev)) + (setf (deferred-status prev) nil) + (let ((ret (deferred:exec-task + next 'ok (deferred-value prev)))) + (if (deferred-p ret) ret + next))) + ((eq 'ng (deferred-status prev)) + (setf (deferred-status prev) nil) + (let ((ret (deferred:exec-task next 'ng (deferred-value prev)))) + (if (deferred-p ret) ret + next))) + (t + next))) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Basic functions for deferred objects + +(defun deferred:new (&optional callback) + "Create a deferred object." + (if callback + (make-deferred :callback callback) + (make-deferred))) + +(defun deferred:callback (d &optional arg) + "Start deferred chain with a callback message." + (deferred:exec-task d 'ok arg)) + +(defun deferred:errorback (d &optional arg) + "Start deferred chain with an errorback message." + (deferred:exec-task d 'ng arg)) + +(defun deferred:callback-post (d &optional arg) + "Add the deferred object to the execution queue." + (deferred:post-task d 'ok arg)) + +(defun deferred:errorback-post (d &optional arg) + "Add the deferred object to the execution queue." + (deferred:post-task d 'ng arg)) + +(defun deferred:cancel (d) + "Cancel all callbacks and deferred chain in the deferred object." + (deferred:message "CANCEL : %s" d) + (funcall (deferred-cancel d) d) + d) + +(defun deferred:status (d) + "Return a current status of the deferred object. The returned value means following: +`ok': the callback was called and waiting for next deferred. +`ng': the errorback was called and waiting for next deferred. + nil: The neither callback nor errorback was not called." + (deferred-status d)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Basic utility functions + +(defvar deferred:onerror nil + "Default error handler. This value is nil or a function that + have one argument for the error message.") + +(defun deferred:succeed (&optional arg) + "Create a synchronous deferred object." + (let ((d (deferred:new))) + (deferred:exec-task d 'ok arg) + d)) + +(defun deferred:fail (&optional arg) + "Create a synchronous deferred object." + (let ((d (deferred:new))) + (deferred:exec-task d 'ng arg) + d)) + +(defun deferred:next (&optional callback arg) + "Create a deferred object and schedule executing. This function +is a short cut of following code: + (deferred:callback-post (deferred:new callback))." + (let ((d (if callback + (make-deferred :callback callback) + (make-deferred)))) + (deferred:callback-post d arg) + d)) + +(defun deferred:nextc (d callback) + "Create a deferred object with OK callback and connect it to the given deferred object." + (let ((nd (make-deferred :callback callback))) + (deferred:set-next d nd))) + +(defun deferred:error (d callback) + "Create a deferred object with errorback and connect it to the given deferred object." + (let ((nd (make-deferred :errorback callback))) + (deferred:set-next d nd))) + +(defun deferred:watch (d callback) + "Create a deferred object with watch task and connect it to the given deferred object. +The watch task CALLBACK can not affect deferred chains with +return values. This function is used in following purposes, +simulation of try-finally block in asynchronous tasks, progress +monitoring of tasks." + (lexical-let* + ((callback callback) + (normal (lambda (x) (ignore-errors (deferred:call-lambda callback x)) x)) + (err (lambda (e) + (ignore-errors (deferred:call-lambda callback e)) + (deferred:resignal e)))) + (let ((nd (make-deferred :callback normal :errorback err))) + (deferred:set-next d nd)))) + +(defun deferred:wait (msec) + "Return a deferred object scheduled at MSEC millisecond later." + (lexical-let + ((d (deferred:new)) (start-time (float-time)) timer) + (deferred:message "WAIT : %s" msec) + (setq timer (deferred:setTimeout + (lambda () + (deferred:exec-task d 'ok + (* 1000.0 (- (float-time) start-time))) + nil) msec)) + (setf (deferred-cancel d) + (lambda (x) + (deferred:cancelTimeout timer) + (deferred:default-cancel x))) + d)) + +(defun deferred:wait-idle (msec) + "Return a deferred object which will run when Emacs has been +idle for MSEC millisecond." + (lexical-let + ((d (deferred:new)) (start-time (float-time)) timer) + (deferred:message "WAIT-IDLE : %s" msec) + (setq timer + (deferred:run-with-idle-timer + (/ msec 1000.0) + (lambda () + (deferred:exec-task d 'ok + (* 1000.0 (- (float-time) start-time))) + nil))) + (setf (deferred-cancel d) + (lambda (x) + (deferred:cancelTimeout timer) + (deferred:default-cancel x))) + d)) + +(defun deferred:call (f &rest args) + "Call the given function asynchronously." + (lexical-let ((f f) (args args)) + (deferred:next + (lambda (_x) + (apply f args))))) + +(defun deferred:apply (f &optional args) + "Call the given function asynchronously." + (lexical-let ((f f) (args args)) + (deferred:next + (lambda (_x) + (apply f args))))) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Utility functions + +(defun deferred:empty-p (times-or-list) + "[internal] Return non-nil if TIMES-OR-LIST is the number zero or nil." + (or (and (numberp times-or-list) (<= times-or-list 0)) + (and (listp times-or-list) (null times-or-list)))) + +(defun deferred:loop (times-or-list func) + "Return a iteration deferred object." + (deferred:message "LOOP : %s" times-or-list) + (if (deferred:empty-p times-or-list) (deferred:next) + (lexical-let* + (items (rd + (cond + ((numberp times-or-list) + (loop for i from 0 below times-or-list + with ld = (deferred:next) + do + (push ld items) + (setq ld + (lexical-let ((i i) (func func)) + (deferred:nextc ld (lambda (_x) (deferred:call-lambda func i))))) + finally return ld)) + ((listp times-or-list) + (loop for i in times-or-list + with ld = (deferred:next) + do + (push ld items) + (setq ld + (lexical-let ((i i) (func func)) + (deferred:nextc ld (lambda (_x) (deferred:call-lambda func i))))) + finally return ld))))) + (setf (deferred-cancel rd) + (lambda (x) (deferred:default-cancel x) + (loop for i in items + do (deferred:cancel i)))) + rd))) + +(defun deferred:trans-multi-args (args self-func list-func main-func) + "[internal] Check the argument values and dispatch to methods." + (cond + ((and (= 1 (length args)) (consp (car args)) (not (functionp (car args)))) + (let ((lst (car args))) + (cond + ((or (null lst) (null (car lst))) + (deferred:next)) + ((deferred:aand lst (car it) (or (functionp it) (deferred-p it))) + ;; a list of deferred objects + (funcall list-func lst)) + ((deferred:aand lst (consp it)) + ;; an alist of deferred objects + (funcall main-func lst)) + (t (error "Wrong argument type. %s" args))))) + (t (funcall self-func args)))) + +(defun deferred:parallel-array-to-alist (lst) + "[internal] Translation array to alist." + (loop for d in lst + for i from 0 below (length lst) + collect (cons i d))) + +(defun deferred:parallel-alist-to-array (alst) + "[internal] Translation alist to array." + (loop for pair in + (sort alst (lambda (x y) + (< (car x) (car y)))) + collect (cdr pair))) + +(defun deferred:parallel-func-to-deferred (alst) + "[internal] Normalization for parallel and earlier arguments." + (loop for pair in alst + for d = (cdr pair) + collect + (progn + (unless (deferred-p d) + (setf (cdr pair) (deferred:next d))) + pair))) + +(defun deferred:parallel-main (alst) + "[internal] Deferred alist implementation for `deferred:parallel'. " + (deferred:message "PARALLEL" ) + (lexical-let ((nd (deferred:new)) + (len (length alst)) + values) + (loop for pair in + (deferred:parallel-func-to-deferred alst) + with cd ; current child deferred + do + (lexical-let ((name (car pair))) + (setq cd + (deferred:nextc (cdr pair) + (lambda (x) + (push (cons name x) values) + (deferred:message "PARALLEL VALUE [%s/%s] %s" + (length values) len (cons name x)) + (when (= len (length values)) + (deferred:message "PARALLEL COLLECTED") + (deferred:post-task nd 'ok (nreverse values))) + nil))) + (deferred:error cd + (lambda (e) + (push (cons name e) values) + (deferred:message "PARALLEL ERROR [%s/%s] %s" + (length values) len (cons name e)) + (when (= (length values) len) + (deferred:message "PARALLEL COLLECTED") + (deferred:post-task nd 'ok (nreverse values))) + nil)))) + nd)) + +(defun deferred:parallel-list (lst) + "[internal] Deferred list implementation for `deferred:parallel'. " + (deferred:message "PARALLEL" ) + (lexical-let* + ((pd (deferred:parallel-main (deferred:parallel-array-to-alist lst))) + (rd (deferred:nextc pd 'deferred:parallel-alist-to-array))) + (setf (deferred-cancel rd) + (lambda (x) (deferred:default-cancel x) + (deferred:cancel pd))) + rd)) + +(defun deferred:parallel (&rest args) + "Return a deferred object that calls given deferred objects or +functions in parallel and wait for all callbacks. The following +deferred task will be called with an array of the return +values. ARGS can be a list or an alist of deferred objects or +functions." + (deferred:message "PARALLEL : %s" args) + (deferred:trans-multi-args args + 'deferred:parallel 'deferred:parallel-list 'deferred:parallel-main)) + +(defun deferred:earlier-main (alst) + "[internal] Deferred alist implementation for `deferred:earlier'. " + (deferred:message "EARLIER" ) + (lexical-let ((nd (deferred:new)) + (len (length alst)) + value results) + (loop for pair in + (deferred:parallel-func-to-deferred alst) + with cd ; current child deferred + do + (lexical-let ((name (car pair))) + (setq cd + (deferred:nextc (cdr pair) + (lambda (x) + (push (cons name x) results) + (cond + ((null value) + (setq value (cons name x)) + (deferred:message "EARLIER VALUE %s" (cons name value)) + (deferred:post-task nd 'ok value)) + (t + (deferred:message "EARLIER MISS [%s/%s] %s" (length results) len (cons name value)) + (when (eql (length results) len) + (deferred:message "EARLIER COLLECTED")))) + nil))) + (deferred:error cd + (lambda (e) + (push (cons name e) results) + (deferred:message "EARLIER ERROR [%s/%s] %s" (length results) len (cons name e)) + (when (and (eql (length results) len) (null value)) + (deferred:message "EARLIER FAILED") + (deferred:post-task nd 'ok nil)) + nil)))) + nd)) + +(defun deferred:earlier-list (lst) + "[internal] Deferred list implementation for `deferred:earlier'. " + (deferred:message "EARLIER" ) + (lexical-let* + ((pd (deferred:earlier-main (deferred:parallel-array-to-alist lst))) + (rd (deferred:nextc pd (lambda (x) (cdr x))))) + (setf (deferred-cancel rd) + (lambda (x) (deferred:default-cancel x) + (deferred:cancel pd))) + rd)) + + +(defun deferred:earlier (&rest args) + "Return a deferred object that calls given deferred objects or +functions in parallel and wait for the first callback. The +following deferred task will be called with the first return +value. ARGS can be a list or an alist of deferred objects or +functions." + (deferred:message "EARLIER : %s" args) + (deferred:trans-multi-args args + 'deferred:earlier 'deferred:earlier-list 'deferred:earlier-main)) + +(defmacro deferred:timeout (timeout-msec timeout-form d) + "Time out macro on a deferred task D. If the deferred task D +does not complete within TIMEOUT-MSEC, this macro cancels the +deferred task and return the TIMEOUT-FORM." + `(deferred:earlier + (deferred:nextc (deferred:wait ,timeout-msec) + (lambda (x) ,timeout-form)) + ,d)) + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Application functions + +(defvar deferred:uid 0 "[internal] Sequence number for some utilities. See the function `deferred:uid'.") + +(defun deferred:uid () + "[internal] Generate a sequence number." + (incf deferred:uid)) + +(defun deferred:buffer-string (strformat buf) + "[internal] Return a string in the buffer with the given format." + (format strformat + (with-current-buffer buf (buffer-string)))) + +(defun deferred:process (command &rest args) + "A deferred wrapper of `start-process'. Return a deferred +object. The process name and buffer name of the argument of the +`start-process' are generated by this function automatically. +The next deferred object receives stdout string from the command +process." + (deferred:process-gen 'start-process command args)) + +(defun deferred:process-shell (command &rest args) + "A deferred wrapper of `start-process-shell-command'. Return a deferred +object. The process name and buffer name of the argument of the +`start-process-shell-command' are generated by this function automatically. +The next deferred object receives stdout string from the command +process." + (deferred:process-gen 'start-process-shell-command command args)) + +(defun deferred:process-buffer (command &rest args) + "A deferred wrapper of `start-process'. Return a deferred +object. The process name and buffer name of the argument of the +`start-process' are generated by this function automatically. +The next deferred object receives stdout buffer from the command +process." + (deferred:process-buffer-gen 'start-process command args)) + +(defun deferred:process-shell-buffer (command &rest args) + "A deferred wrapper of `start-process-shell-command'. Return a deferred +object. The process name and buffer name of the argument of the +`start-process-shell-command' are generated by this function automatically. +The next deferred object receives stdout buffer from the command +process." + (deferred:process-buffer-gen 'start-process-shell-command command args)) + +(defun deferred:process-gen (f command args) + "[internal]" + (lexical-let + ((pd (deferred:process-buffer-gen f command args)) d) + (setq d (deferred:nextc pd + (lambda (buf) + (prog1 + (with-current-buffer buf (buffer-string)) + (kill-buffer buf))))) + (setf (deferred-cancel d) + (lambda (_x) + (deferred:default-cancel d) + (deferred:default-cancel pd))) + d)) + +(defun deferred:process-buffer-gen (f command args) + "[internal]" + (let ((d (deferred:next)) (uid (deferred:uid))) + (lexical-let + ((f f) (command command) (args args) + (proc-name (format "*deferred:*%s*:%s" command uid)) + (buf-name (format " *deferred:*%s*:%s" command uid)) + (pwd default-directory) + (env process-environment) + (con-type process-connection-type) + (nd (deferred:new)) proc-buf proc) + (deferred:nextc d + (lambda (_x) + (setq proc-buf (get-buffer-create buf-name)) + (condition-case err + (let ((default-directory pwd) + (process-environment env) + (process-connection-type con-type)) + (setq proc + (if (null (car args)) + (apply f proc-name buf-name command nil) + (apply f proc-name buf-name command args))) + (set-process-sentinel + proc + (lambda (_proc event) + (cond + ((string-match "exited abnormally" event) + (let ((msg (if (buffer-live-p proc-buf) + (format "Process [%s] exited abnormally : %s" + command + (with-current-buffer proc-buf (buffer-string))) + (concat "Process exited abnormally: " proc-name)))) + (kill-buffer proc-buf) + (deferred:post-task nd 'ng msg))) + ((equal event "finished\n") + (deferred:post-task nd 'ok proc-buf))))) + (setf (deferred-cancel nd) + (lambda (x) (deferred:default-cancel x) + (when proc + (kill-process proc) + (kill-buffer proc-buf))))) + (error (deferred:post-task nd 'ng err))) + nil)) + nd))) + +(defmacro deferred:processc (d command &rest args) + "Process chain of `deferred:process'." + `(deferred:nextc ,d + (lambda (,(gensym)) (deferred:process ,command ,@args)))) + +(defmacro deferred:process-bufferc (d command &rest args) + "Process chain of `deferred:process-buffer'." + `(deferred:nextc ,d + (lambda (,(gensym)) (deferred:process-buffer ,command ,@args)))) + +(defmacro deferred:process-shellc (d command &rest args) + "Process chain of `deferred:process'." + `(deferred:nextc ,d + (lambda (,(gensym)) (deferred:process-shell ,command ,@args)))) + +(defmacro deferred:process-shell-bufferc (d command &rest args) + "Process chain of `deferred:process-buffer'." + `(deferred:nextc ,d + (lambda (,(gensym)) (deferred:process-shell-buffer ,command ,@args)))) + +(eval-after-load "url" + ;; for url package + ;; TODO: proxy, charaset + ;; List of gloabl variables to preserve and restore before url-retrieve call + '(lexical-let ((url-global-variables '(url-request-data + url-request-method + url-request-extra-headers))) + + (defun deferred:url-retrieve (url &optional cbargs silent inhibit-cookies) + "A wrapper function for url-retrieve. The next deferred +object receives the buffer object that URL will load +into. Values of dynamically bound 'url-request-data', 'url-request-method' and +'url-request-extra-headers' are passed to url-retrieve call." + (lexical-let ((nd (deferred:new)) (url url) + (cbargs cbargs) (silent silent) (inhibit-cookies inhibit-cookies) buf + (local-values (mapcar (lambda (symbol) (symbol-value symbol)) url-global-variables))) + (deferred:next + (lambda (_x) + (progv url-global-variables local-values + (condition-case err + (setq buf + (url-retrieve + url (lambda (_xx) (deferred:post-task nd 'ok buf)) + cbargs silent inhibit-cookies)) + (error (deferred:post-task nd 'ng err))) + nil))) + (setf (deferred-cancel nd) + (lambda (_x) + (when (buffer-live-p buf) + (kill-buffer buf)))) + nd)) + + (defun deferred:url-delete-header (buf) + (with-current-buffer buf + (let ((pos (url-http-symbol-value-in-buffer + 'url-http-end-of-headers buf))) + (when pos + (delete-region (point-min) (1+ pos))))) + buf) + + (defun deferred:url-delete-buffer (buf) + (when (and buf (buffer-live-p buf)) + (kill-buffer buf)) + nil) + + (defun deferred:url-get (url &optional params &rest args) + "Perform a HTTP GET method with `url-retrieve'. PARAMS is +a parameter list of (key . value) or key. ARGS will be appended +to deferred:url-retrieve args list. The next deferred +object receives the buffer object that URL will load into." + (when params + (setq url + (concat url "?" (deferred:url-param-serialize params)))) + (let ((d (deferred:$ + (apply 'deferred:url-retrieve url args) + (deferred:nextc it 'deferred:url-delete-header)))) + (deferred:set-next + d (deferred:new 'deferred:url-delete-buffer)) + d)) + + (defun deferred:url-post (url &optional params &rest args) + "Perform a HTTP POST method with `url-retrieve'. PARAMS is +a parameter list of (key . value) or key. ARGS will be appended +to deferred:url-retrieve args list. The next deferred +object receives the buffer object that URL will load into." + (let ((url-request-method "POST") + (url-request-extra-headers + (append url-request-extra-headers + '(("Content-Type" . "application/x-www-form-urlencoded")))) + (url-request-data (deferred:url-param-serialize params))) + (let ((d (deferred:$ + (apply 'deferred:url-retrieve url args) + (deferred:nextc it 'deferred:url-delete-header)))) + (deferred:set-next + d (deferred:new 'deferred:url-delete-buffer)) + d))) + + (defun deferred:url-escape (val) + "[internal] Return a new string that is VAL URI-encoded." + (unless (stringp val) + (setq val (format "%s" val))) + (url-hexify-string + (encode-coding-string val 'utf-8))) + + (defun deferred:url-param-serialize (params) + "[internal] Serialize a list of (key . value) cons cells +into a query string." + (when params + (mapconcat + 'identity + (loop for p in params + collect + (cond + ((consp p) + (concat + (deferred:url-escape (car p)) "=" + (deferred:url-escape (cdr p)))) + (t + (deferred:url-escape p)))) + "&"))) + )) + + +(provide 'deferred) +;;; deferred.el ends here diff --git a/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-autoloads.el b/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-autoloads.el deleted file mode 100644 index 19965df..0000000 --- a/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-autoloads.el +++ /dev/null @@ -1,76 +0,0 @@ -;;; elixir-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "elixir-mode" "elixir-mode.el" (21721 24856 -;;;;;; 0 0)) -;;; Generated autoloads from elixir-mode.el - -(autoload 'elixir-mode-iex "elixir-mode" "\ -Elixir mode interactive REPL. -Optional argument ARGS-P . - -\(fn &optional ARGS-P)" t nil) - -(autoload 'elixir-mode-open-modegithub "elixir-mode" "\ -Elixir mode open GitHub page. - -\(fn)" t nil) - -(autoload 'elixir-mode-open-elixir-home "elixir-mode" "\ -Elixir mode go to language home. - -\(fn)" t nil) - -(autoload 'elixir-mode-open-docs-master "elixir-mode" "\ -Elixir mode go to master documentation. - -\(fn)" t nil) - -(autoload 'elixir-mode-open-docs-stable "elixir-mode" "\ -Elixir mode go to stable documentation. - -\(fn)" t nil) - -(autoload 'elixir-mode-version "elixir-mode" "\ -Get the Elixir-Mode version as string. - -If called interactively or if SHOW-VERSION is non-nil, show the -version in the echo area and the messages buffer. - -The returned string includes both, the version from package.el -and the library version, if both a present and different. - -If the version number could not be determined, signal an error, -if called interactively, or if SHOW-VERSION is non-nil, otherwise -just return nil. - -\(fn &optional SHOW-VERSION)" t nil) - -(autoload 'elixir-mode "elixir-mode" "\ -Major mode for editing Elixir code. - -\\{elixir-mode-map} - -\(fn)" t nil) - -(add-to-list 'auto-mode-alist '("\\.elixir\\'" . elixir-mode)) - -(add-to-list 'auto-mode-alist '("\\.ex\\'" . elixir-mode)) - -(add-to-list 'auto-mode-alist '("\\.exs\\'" . elixir-mode)) - -;;;*** - -;;;### (autoloads nil nil ("elixir-deprecated.el" "elixir-mode-pkg.el" -;;;;;; "elixir-smie.el") (21721 24856 873809 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; elixir-mode-autoloads.el ends here diff --git a/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-pkg.el b/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-pkg.el deleted file mode 100644 index 419b178..0000000 --- a/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode-pkg.el +++ /dev/null @@ -1,5 +0,0 @@ -(define-package "elixir-mode" "20150103.439" "Major mode for editing Elixir files" 'nil :url "https://github.com/elixir-lang/emacs-elixir" :keywords - '("languages" "elixir")) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode.el b/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode.el deleted file mode 100644 index 8e81fa6..0000000 --- a/emacs.d/elpa/elixir-mode-20150103.439/elixir-mode.el +++ /dev/null @@ -1,608 +0,0 @@ -;;; elixir-mode.el --- Major mode for editing Elixir files - -;; Copyright 2011-2015 secondplanet -;; 2013-2015 Samuel Tonini, Matt DeBoard, Andreas Fuchs -;; Authors: Humza Yaqoob, -;; Andreas Fuchs , -;; Matt DeBoard -;; Samuel Tonini - -;; URL: https://github.com/elixir-lang/emacs-elixir -;; Created: Mon Nov 7 2011 -;; Keywords: languages elixir -;; Version: 2.3.0-cvs - -;; This file is not a 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -;;; Commentary: - -;; Provides font-locking, indentation and navigation support -;; for the Elixir programming language. - -;;; Code: - -(require 'comint) ; for interactive REPL -(require 'easymenu) ; for menubar features - -(require 'elixir-smie) ; syntax and indentation support -(require 'elixir-deprecated) ; deprecated messages - -(defgroup elixir-mode nil - "Provides font-locking, indentation and navigation support -for the Elixir programming language." - :prefix "elixir-mode-" - :group 'applications - :link '(url-link :tag "Github" "https://github.com/elixir-lang/emacs-elixir") - :link '(emacs-commentary-link :tag "Commentary" "elixir-mode")) - -(defvar elixir-mqode--website-url - "http://elixir-lang.org") - -(defvar elixir-mode-hook nil) - -(defvar elixir-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c ,r") 'elixir-mode-eval-on-region) - (define-key map (kbd "C-c ,c") 'elixir-mode-eval-on-current-line) - (define-key map (kbd "C-c ,b") 'elixir-mode-eval-on-current-buffer) - (define-key map (kbd "C-c ,a") 'elixir-mode-string-to-quoted-on-region) - (define-key map (kbd "C-c ,l") 'elixir-mode-string-to-quoted-on-current-line) - map) - "Keymap used in `elixir-mode'.") - -(defvar elixir-imenu-generic-expression - '(("Modules" "^\\s-*defmodule[ \n\t]+\\([A-Z][A-Za-z0-9._]+\\)\\s-+do.*$" 1) - ("Public Functions" "^\\s-*def[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) - ("Private Functions" "^\\s-*defp[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) - ("Public Macros" "^\\s-*defmacro[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) - ("Private Macros" "^\\s-*defmacrop[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) - ("Delegates" "^\\s-*defdelegate[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) - ("Overridables" "^\\s-*defoverridable[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) - ("Tests" "^\\s-*test[ \t\n]+\"?\\(:?[a-z0-9_@+() \t-]+\\)\"?[ \t\n]+do.*" 1)) - "Imenu pattern for `elixir-mode'.") - -(defgroup elixir nil - "Elixir major mode." - :group 'languages) - -(defcustom elixir-compiler-command "elixirc" - "Elixir mode command to compile code. Must be in your path." - :type 'string - :group 'elixir) - -(defcustom elixir-mode-command "elixir" - "The command for elixir." - :type 'string - :group 'elixir) - -(defcustom elixir-iex-command "iex" - "Elixir mode command for interactive REPL. Must be in your path." - :type 'string - :group 'elixir) - -(defcustom elixir-mode-cygwin-paths t - "Elixir mode use Cygwin style paths on Windows operating systems." - :type 'boolean - :group 'elixir) - -(defcustom elixir-mode-cygwin-prefix "/cygdrive/C" - "Elixir mode Cygwin prefix." - :type 'string - :group 'elixir) - -(defvar elixir-mode--eval-filename "elixir-mode-tmp-eval-file.exs") - -(defvar elixir-quoted--buffer-name "*elixir-quoted*") - -(defvar elixir-basic-offset 2) -(defvar elixir-key-label-offset 0) -(defvar elixir-match-label-offset 2) - -(defvar elixir-operator-face 'elixir-operator-face) -(defface elixir-operator-face - '((((class color) (min-colors 88) (background light)) - :foreground "darkred") - (((class color) (background dark)) - (:foreground "lemonchiffon1")) - (t nil)) - "For use with operators." - :group 'font-lock-faces) - -(defvar elixir-negation-face 'elixir-negation-face) -(defface elixir-negation-face - '((((class color) (min-colors 88) (background light)) - :foreground "#ff4500") - (((class color) (background dark)) - (:foreground "#ff4500")) - (t nil)) - "For use with standalone \"?\" to indicate code point." - :group 'font-lock-faces) - -(defvar elixir-attribute-face 'elixir-attribute-face) -(defface elixir-attribute-face - '((((class color) (min-colors 88) (background light)) - :foreground "MediumPurple4") - (((class color) (background dark)) - (:foreground "thistle")) - (t nil)) - "For use with module attribute tokens." - :group 'font-lock-faces) - -(defvar elixir-atom-face 'elixir-atom-face) -(defface elixir-atom-face - '((((class color) (min-colors 88) (background light)) - :foreground "RoyalBlue4") - (((class color) (background dark)) - (:foreground "light sky blue")) - (t nil)) - "For use with atoms & map keys." - :group 'font-lock-faces) - -(defun elixir-syntax-propertize-interpolation () - (let* ((beg (match-beginning 0)) - (context (save-excursion (save-match-data (syntax-ppss beg))))) - (put-text-property beg (1+ beg) 'elixir-interpolation - (cons (nth 3 context) (match-data))))) - -(defun elixir-syntax-propertize-function (start end) - (let ((case-fold-search nil)) - (goto-char start) - (remove-text-properties start end '(elixir-interpolation)) - (funcall - (syntax-propertize-rules - ((rx (group "#{" (0+ (not (any "}"))) "}")) - (0 (ignore (elixir-syntax-propertize-interpolation))))) - start end))) - -(defun elixir-match-interpolation (limit) - (let ((pos (next-single-char-property-change (point) 'elixir-interpolation - nil limit))) - (when (and pos (> pos (point))) - (goto-char pos) - (let ((value (get-text-property pos 'elixir-interpolation))) - (if (eq (car value) ?\") - (progn - (set-match-data (cdr value)) - t) - (elixir-match-interpolation limit)))))) - -(eval-when-compile - (defconst elixir-rx-constituents - `( - (atoms . ,(rx ":" - (or - (one-or-more (any "a-z" "A-Z" "_" "\"" "'")) - (and "\"" (one-or-more (not (any "\""))) "\"") - (and "'" (one-or-more (not (any "'"))) "'")))) - (builtin . ,(rx symbol-start - (or "case" "cond" "for" "if" "unless" "try" "receive" - "raise" "quote" "unquote" "unquote_splicing" "throw" - "super") - symbol-end)) - (builtin-declaration . ,(rx symbol-start - (or "def" "defp" "defmodule" "defprotocol" - "defmacro" "defmacrop" "defdelegate" - "defexception" "defstruct" "defimpl" - "defcallback") - symbol-end)) - (builtin-modules . ,(rx symbol-start - (or "Agent" "Application" "Atom" "Base" - "Behaviour" "Bitwise" "Builtin" "Code" "Dict" - "EEx" "Elixir" "Enum" "ExUnit" "Exception" - "File" "File.Stat" "File.Stream" "Float" - "Function" "GenEvent" "GenServer" "GenTCP" - "HashDict" "HashSet" "IO" "IO.ANSI" - "IO.Stream" "Inspect.Algebra" "Inspect.Opts" - "Integer" "Kernel" "Kernel.ParallelCompiler" - "Kernel.ParallelRequire" "Kernel.SpecialForms" - "Kernel.Typespec" "Keyword" "List" "Macro" - "Macro.Env" "Map" "Math" "Module" "Node" - "OptionParser" "OrdDict" "Path" "Port" - "Process" "Protocol" "Range" "Record" "Regex" - "Set" "Stream" "String" "StringIO" - "Supervisor" "Supervisor.Spec" "System" "Task" - "Task.Supervisor" "Tuple" "URI" - "UnboundMethod" "Version") - symbol-end)) - (builtin-namespace . ,(rx symbol-start - (or "import" "require" "use" "alias") - symbol-end)) - ;; Set aside code point syntax for `elixir-negation-face'. - (code-point . ,(rx symbol-start - "?" - anything - symbol-end)) - (function-declaration . ,(rx symbol-start - (or "def" "defp") - symbol-end)) - ;; Match `@doc' or `@moduledoc' syntax, with or without triple quotes. - (heredocs . ,(rx symbol-start - (or "@doc" "@moduledoc" "~s") - symbol-end)) - ;; The first character of an identifier must be a letter or an underscore. - ;; After that, they may contain any alphanumeric character + underscore. - ;; Additionally, the final character may be either `?' or `!'. - (identifiers . ,(rx (one-or-more (any "A-Z" "a-z" "_")) - (zero-or-more (any "A-Z" "a-z" "0-9" "_")) - (optional (or "?" "!")))) - (keyword . ,(rx symbol-start - (or "fn" "do" "end" "after" "else" "rescue" "catch") - symbol-end)) - (keyword-operator . ,(rx symbol-start - (or "not" "and" "or" "when" "in") - symbol-end)) - ;; Module and submodule names start with upper case letter. This - ;; can then be followed by any combination of alphanumeric chars. - ;; In turn, this can be followed by a `.' which begins the notation of - ;; a submodule, which follows the same naming pattern of the module. - ;; Finally, like other identifiers, it can be terminated with either `?' - ;; or `!'. - (module-names . ,(rx symbol-start - (one-or-more (any "A-Z")) - (zero-or-more (any "A-Z" "a-z" "_" "0-9")) - (zero-or-more - (and "." - (one-or-more (any "A-Z" "_")) - (zero-or-more (any "A-Z" "a-z" "_" "0-9")))) - (optional (or "!" "?")) - symbol-end)) - (operators1 . ,(rx symbol-start - (or "<" ">" "+" "-" "*" "/" "!" "^" "&") - symbol-end)) - (operators2 . ,(rx symbol-start - (or - "==" "!=" "<=" ">=" "&&" "||" "<>" "++" "--" "|>" "=~" - "->" "<-" "|" "." "=") - symbol-end)) - (operators3 . ,(rx symbol-start - (or "<<<" ">>>" "|||" "&&&" "^^^" "~~~" "===" "!==") - symbol-end)) - (pseudo-var . ,(rx symbol-start - (or "_" "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" - "__block__" "__aliases__") - symbol-end)) - (punctuation . ,(rx symbol-start - (or "\\" "<<" ">>" "=>" "(" ")" ":" ";" "" "[" "]") - symbol-end)) - (sigils . ,(rx "~" (or "B" "C" "R" "S" "b" "c" "r" "s" "w"))))) - - (defmacro elixir-rx (&rest sexps) - (let ((rx-constituents (append elixir-rx-constituents rx-constituents))) - (cond ((null sexps) - (error "No regexp")) - ((cdr sexps) - (rx-to-string `(and ,@sexps) t)) - (t - (rx-to-string (car sexps) t)))))) - -(defconst elixir-font-lock-keywords - `( - ;; String interpolation - (elixir-match-interpolation 0 font-lock-variable-name-face t) - - ;; Module-defining & namespace builtins - (,(elixir-rx (or builtin-declaration builtin-namespace) - space - (group module-names)) - 1 font-lock-type-face) - - ;; Module attributes - (,(elixir-rx (group (or heredocs - (and "@" (1+ identifiers))))) - 1 elixir-attribute-face) - - ;; Keywords - (,(elixir-rx (group (or builtin builtin-declaration builtin-namespace - keyword keyword-operator))) - 1 font-lock-keyword-face) - - ;; Function names, i.e. `def foo do'. - (,(elixir-rx (group function-declaration) - space - (group identifiers)) - 2 font-lock-function-name-face) - - ;; Variable definitions - (,(elixir-rx (group identifiers) - (one-or-more space) - "=" - (or (one-or-more space) - (one-or-more "\n"))) - 1 font-lock-variable-name-face) - - ;; Sigils - (,(elixir-rx (group sigils)) - 1 font-lock-builtin-face) - - ;; Regex patterns. Elixir has support for eight different regex delimiters. - ;; This isn't a very DRY approach here but it gets the job done. - (,(elixir-rx "~r" - (and "/" (group (one-or-more (not (any "/")))) "/")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "[" (group (one-or-more (not (any "]")))) "]")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "{" (group (one-or-more (not (any "}")))) "}")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "(" (group (one-or-more (not (any ")")))) ")")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "|" (group (one-or-more (not (any "|")))) "|")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "\"" (group (one-or-more (not (any "\"")))) "\"")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "'" (group (one-or-more (not (any "'")))) "'")) - 1 font-lock-string-face) - (,(elixir-rx "~r" - (and "<" (group (one-or-more (not (any ">")))) ">")) - 1 font-lock-string-face) - - ;; Atoms and singleton-like words like true/false/nil. - (,(elixir-rx (group atoms)) - 1 elixir-atom-face) - - ;; Map keys - (,(elixir-rx (group (and (one-or-more identifiers) ":"))) - 1 elixir-atom-face) - - ;; Built-in modules and pseudovariables - (,(elixir-rx (group (or builtin-modules pseudo-var))) - 1 font-lock-constant-face) - - ;; Code points - (,(elixir-rx (group code-point)) - 1 elixir-negation-face))) - -(defun elixir-mode-cygwin-path (expanded-file-name) - "Elixir mode get Cygwin absolute path name. -Argument EXPANDED-FILE-NAME ." - (replace-regexp-in-string "^[a-zA-Z]:" elixir-mode-cygwin-prefix expanded-file-name t)) - -(defun elixir-mode-universal-path (file-name) - "Elixir mode multi-OS path handler. -Argument FILE-NAME ." - (let ((full-file-name (expand-file-name file-name))) - (if (and (equal system-type 'windows-nt) - elixir-mode-cygwin-paths) - (elixir-mode-cygwin-path full-file-name) - full-file-name))) - -(defun elixir-mode-command-compile (file-name) - "Elixir mode command to compile a file. -Argument FILE-NAME ." - (let ((full-file-name (elixir-mode-universal-path file-name))) - (mapconcat 'identity (append (list elixir-compiler-command) (list full-file-name)) " "))) - -(defun elixir-mode-compiled-file-name (&optional filename) - "Elixir mode compiled FILENAME." - (concat (file-name-sans-extension (or filename (buffer-file-name))) ".beam")) - -(defun elixir-mode-compile-file () - "Elixir mode compile and save current file." - (interactive) - (elixir-deprecated-use-alchemist "elixir-mode-compile-file") - (let ((compiler-output (shell-command-to-string (elixir-mode-command-compile (buffer-file-name))))) - (when (string= compiler-output "") - (message "Compiled and saved as %s" (elixir-mode-compiled-file-name))))) - -(defun elixir-quoted--initialize-buffer (quoted) - (pop-to-buffer elixir-quoted--buffer-name) - (setq buffer-undo-list nil) ; Get rid of undo information from - ; previous expansions - (let ((inhibit-read-only t) - (buffer-undo-list t)) ; Ignore undo information - (erase-buffer) - (insert quoted) - (goto-char (point-min)) - (elixir-mode) - (elixir-quoted-minor-mode 1))) - -;;;###autoload -(defun elixir-mode-iex (&optional args-p) - "Elixir mode interactive REPL. -Optional argument ARGS-P ." - (interactive "P") - (let ((switches (if (equal args-p nil) - '() - (split-string (read-string "Additional args: "))))) - (unless (comint-check-proc "*IEX*") - (set-buffer - (apply 'make-comint "IEX" - elixir-iex-command nil switches)))) - (pop-to-buffer "*IEX*") - (elixir-deprecated-use-alchemist "elixir-mode-iex")) - -;;;###autoload -(defun elixir-mode-open-modegithub () - "Elixir mode open GitHub page." - (interactive) - (browse-url "https://github.com/elixir-lang/emacs-elixir")) - -;;;###autoload -(defun elixir-mode-open-elixir-home () - "Elixir mode go to language home." - (interactive) - (browse-url elixir-mode--website-url)) - -;;;###autoload -(defun elixir-mode-open-docs-master () - "Elixir mode go to master documentation." - (interactive) - (browse-url (concat elixir-mode--website-url "/docs/master/elixir"))) - -;;;###autoload -(defun elixir-mode-open-docs-stable () - "Elixir mode go to stable documentation." - (interactive) - (browse-url (concat elixir-mode--website-url "/docs/stable/elixir"))) - -;;;###autoload -(defun elixir-mode-version (&optional show-version) - "Get the Elixir-Mode version as string. - -If called interactively or if SHOW-VERSION is non-nil, show the -version in the echo area and the messages buffer. - -The returned string includes both, the version from package.el -and the library version, if both a present and different. - -If the version number could not be determined, signal an error, -if called interactively, or if SHOW-VERSION is non-nil, otherwise -just return nil." - (interactive (list t)) - (let ((version (pkg-info-version-info 'elixir-mode))) - (when show-version - (message "Elixir-Mode version: %s" version)) - version)) - -(defun elixir-mode--code-eval-string-command (file) - (format "%s -e 'IO.puts inspect(elem(Code.eval_string(File.read!(\"%s\")), 0))'" - elixir-mode-command - file)) - -(defun elixir-mode--code-string-to-quoted-command (file) - (format "%s -e 'IO.puts inspect(elem(Code.string_to_quoted(File.read!(\"%s\")), 1), pretty: true)'" - elixir-mode-command - file)) - -(defun elixir-mode--execute-elixir-with-code-eval-string (string) - (with-temp-file elixir-mode--eval-filename - (insert string)) - (let ((output (shell-command-to-string (elixir-mode--code-eval-string-command elixir-mode--eval-filename)))) - (delete-file elixir-mode--eval-filename) - output)) - -(defun elixir-mode--execute-elixir-with-code-string-to-quoted (string) - (with-temp-file elixir-mode--eval-filename - (insert string)) - (let ((output (shell-command-to-string (elixir-mode--code-string-to-quoted-command elixir-mode--eval-filename)))) - (delete-file elixir-mode--eval-filename) - output)) - -(defun elixir-mode--eval-string (string) - (let ((output (elixir-mode--execute-elixir-with-code-eval-string string))) - (message output))) - -(defun elixir-mode--string-to-quoted (string) - (let* ((output (elixir-mode--execute-elixir-with-code-string-to-quoted string))) - (elixir-quoted--initialize-buffer output))) - -(defun elixir-mode-eval-on-region (beg end) - "Evaluate the Elixir code on the marked region. -Argument BEG Start of the region. -Argument END End of the region." - (interactive (list (point) (mark))) - (elixir-deprecated-use-alchemist "elixir-mode-eval-on-region") - (unless (and beg end) - (error "The mark is not set now, so there is no region")) - (let* ((region (buffer-substring-no-properties beg end))) - (elixir-mode--eval-string region))) - -(defun elixir-mode-eval-on-current-line () - "Evaluate the Elixir code on the current line." - (interactive) - (elixir-deprecated-use-alchemist "elixir-mode-eval-on-current-line") - (let ((current-line (thing-at-point 'line))) - (elixir-mode--eval-string current-line))) - -(defun elixir-mode-eval-on-current-buffer () - "Evaluate the Elixir code on the current buffer." - (interactive) - (elixir-deprecated-use-alchemist "elixir-mode-eval-on-current-buffer") - (let ((current-buffer (buffer-substring-no-properties (point-max) (point-min)))) - (elixir-mode--eval-string current-buffer))) - -(defun elixir-mode-string-to-quoted-on-region (beg end) - "Get the representation of the expression on the marked region. -Argument BEG Start of the region. -Argument END End of the region." - (interactive (list (point) (mark))) - (elixir-deprecated-use-alchemist "elixir-mode-string-to-quoted-on-region") - (unless (and beg end) - (error "The mark is not set now, so there is no region")) - (let ((region (buffer-substring-no-properties beg end))) - (elixir-mode--string-to-quoted region))) - -(defun elixir-mode-string-to-quoted-on-current-line () - "Get the representation of the expression on the current line." - (interactive) - (elixir-deprecated-use-alchemist "elixir-mode-string-to-quoted-on-current-line") - (let ((current-line (thing-at-point 'line))) - (elixir-mode--string-to-quoted current-line))) - -(easy-menu-define elixir-mode-menu elixir-mode-map - "Elixir mode menu." - '("Elixir" - ["Indent line" smie-indent-line] - ["Compile file" elixir-mode-compile-file] - ["IEX" elixir-mode-iex] - "---" - ["elixir-mode on GitHub" elixir-mode-open-modegithub] - ["Elixir homepage" elixir-mode-open-elixirhome] - ["About" elixir-mode-version] - )) - -;;;###autoload -(define-derived-mode elixir-mode prog-mode "Elixir" - "Major mode for editing Elixir code. - -\\{elixir-mode-map}" - (set (make-local-variable 'font-lock-defaults) - '(elixir-font-lock-keywords)) - (set (make-local-variable 'comment-start) "# ") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'comment-start-skip) "#+ *") - (set (make-local-variable 'comment-use-syntax) t) - (set (make-local-variable 'tab-width) elixir-basic-offset) - (set (make-local-variable 'syntax-propertize-function) - #'elixir-syntax-propertize-function) - (set (make-local-variable 'imenu-generic-expression) - elixir-imenu-generic-expression) - (smie-setup elixir-smie-grammar 'verbose-elixir-smie-rules - :forward-token 'elixir-smie-forward-token - :backward-token 'elixir-smie-backward-token)) - -(define-minor-mode elixir-cos-mode - "Elixir mode toggle compile on save." - :group 'elixir-cos :lighter " CoS" - (cond - (elixir-cos-mode - (add-hook 'after-save-hook 'elixir-mode-compile-file nil t)) - (t - (remove-hook 'after-save-hook 'elixir-mode-compile-file t)))) - -(define-minor-mode elixir-quoted-minor-mode - "Minor mode for displaying elixir quoted expressions" - :group 'elixir-quoted :lighter " quoted" - :keymap '(("q" . quit-window)) - (setq buffer-read-only t)) - -;; Invoke elixir-mode when appropriate - -;;;###autoload -(progn - (add-to-list 'auto-mode-alist '("\\.elixir\\'" . elixir-mode)) - (add-to-list 'auto-mode-alist '("\\.ex\\'" . elixir-mode)) - (add-to-list 'auto-mode-alist '("\\.exs\\'" . elixir-mode))) - -(provide 'elixir-mode) - -;;; elixir-mode.el ends here diff --git a/emacs.d/elpa/elixir-mode-20150103.439/elixir-deprecated.el b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-deprecated.el similarity index 100% rename from emacs.d/elpa/elixir-mode-20150103.439/elixir-deprecated.el rename to emacs.d/elpa/elixir-mode-20150317.1454/elixir-deprecated.el diff --git a/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-autoloads.el b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-autoloads.el new file mode 100644 index 0000000..821e703 --- /dev/null +++ b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-autoloads.el @@ -0,0 +1,76 @@ +;;; elixir-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "elixir-mode" "elixir-mode.el" (21837 24215 +;;;;;; 0 0)) +;;; Generated autoloads from elixir-mode.el + +(autoload 'elixir-mode-iex "elixir-mode" "\ +Elixir mode interactive REPL. +Optional argument ARGS-P . + +\(fn &optional ARGS-P)" t nil) + +(autoload 'elixir-mode-open-modegithub "elixir-mode" "\ +Elixir mode open GitHub page. + +\(fn)" t nil) + +(autoload 'elixir-mode-open-elixir-home "elixir-mode" "\ +Elixir mode go to language home. + +\(fn)" t nil) + +(autoload 'elixir-mode-open-docs-master "elixir-mode" "\ +Elixir mode go to master documentation. + +\(fn)" t nil) + +(autoload 'elixir-mode-open-docs-stable "elixir-mode" "\ +Elixir mode go to stable documentation. + +\(fn)" t nil) + +(autoload 'elixir-mode-version "elixir-mode" "\ +Get the Elixir-Mode version as string. + +If called interactively or if SHOW-VERSION is non-nil, show the +version in the echo area and the messages buffer. + +The returned string includes both, the version from package.el +and the library version, if both a present and different. + +If the version number could not be determined, signal an error, +if called interactively, or if SHOW-VERSION is non-nil, otherwise +just return nil. + +\(fn &optional SHOW-VERSION)" t nil) + +(autoload 'elixir-mode "elixir-mode" "\ +Major mode for editing Elixir code. + +\\{elixir-mode-map} + +\(fn)" t nil) + +(add-to-list 'auto-mode-alist '("\\.elixir\\'" . elixir-mode)) + +(add-to-list 'auto-mode-alist '("\\.ex\\'" . elixir-mode)) + +(add-to-list 'auto-mode-alist '("\\.exs\\'" . elixir-mode)) + +;;;*** + +;;;### (autoloads nil nil ("elixir-deprecated.el" "elixir-mode-pkg.el" +;;;;;; "elixir-smie.el") (21837 24215 713052 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; elixir-mode-autoloads.el ends here diff --git a/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-pkg.el b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-pkg.el new file mode 100644 index 0000000..4b4d0e9 --- /dev/null +++ b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode-pkg.el @@ -0,0 +1,5 @@ +(define-package "elixir-mode" "20150317.1454" "Major mode for editing Elixir files" 'nil :url "https://github.com/elixir-lang/emacs-elixir" :keywords + '("languages" "elixir")) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode.el b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode.el new file mode 100644 index 0000000..d2015e5 --- /dev/null +++ b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-mode.el @@ -0,0 +1,619 @@ +;;; elixir-mode.el --- Major mode for editing Elixir files + +;; Copyright 2011-2015 secondplanet +;; 2013-2015 Samuel Tonini, Matt DeBoard, Andreas Fuchs +;; Authors: Humza Yaqoob, +;; Andreas Fuchs , +;; Matt DeBoard +;; Samuel Tonini + +;; URL: https://github.com/elixir-lang/emacs-elixir +;; Created: Mon Nov 7 2011 +;; Keywords: languages elixir +;; Version: 2.3.0-cvs + +;; This file is not a 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +;;; Commentary: + +;; Provides font-locking, indentation and navigation support +;; for the Elixir programming language. + +;;; Code: + +(require 'comint) ; for interactive REPL +(require 'easymenu) ; for menubar features + +(require 'elixir-smie) ; syntax and indentation support +(require 'elixir-deprecated) ; deprecated messages + +(defgroup elixir-mode nil + "Provides font-locking, indentation and navigation support +for the Elixir programming language." + :prefix "elixir-mode-" + :group 'applications + :link '(url-link :tag "Github" "https://github.com/elixir-lang/emacs-elixir") + :link '(emacs-commentary-link :tag "Commentary" "elixir-mode")) + +(defvar elixir-mqode--website-url + "http://elixir-lang.org") + +(defvar elixir-mode-hook nil) + +(defvar elixir-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c ,r") 'elixir-mode-eval-on-region) + (define-key map (kbd "C-c ,c") 'elixir-mode-eval-on-current-line) + (define-key map (kbd "C-c ,b") 'elixir-mode-eval-on-current-buffer) + (define-key map (kbd "C-c ,a") 'elixir-mode-string-to-quoted-on-region) + (define-key map (kbd "C-c ,l") 'elixir-mode-string-to-quoted-on-current-line) + map) + "Keymap used in `elixir-mode'.") + +(defvar elixir-imenu-generic-expression + '(("Modules" "^\\s-*defmodule[ \n\t]+\\([A-Z][A-Za-z0-9._]+\\)\\s-+do.*$" 1) + ("Public Functions" "^\\s-*def[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) + ("Private Functions" "^\\s-*defp[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) + ("Public Macros" "^\\s-*defmacro[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) + ("Private Macros" "^\\s-*defmacrop[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) + ("Delegates" "^\\s-*defdelegate[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) + ("Overridables" "^\\s-*defoverridable[ \n\t]+\\([a-z0-9_]+\\)\\(([^)]*)\\)*[ \t\n]+do.*" 1) + ("Tests" "^\\s-*test[ \t\n]+\"?\\(:?[a-z0-9_@+() \t-]+\\)\"?[ \t\n]+do.*" 1)) + "Imenu pattern for `elixir-mode'.") + +(defgroup elixir nil + "Elixir major mode." + :group 'languages) + +(defcustom elixir-compiler-command "elixirc" + "Elixir mode command to compile code. Must be in your path." + :type 'string + :group 'elixir) + +(defcustom elixir-mode-command "elixir" + "The command for elixir." + :type 'string + :group 'elixir) + +(defcustom elixir-iex-command "iex" + "Elixir mode command for interactive REPL. Must be in your path." + :type 'string + :group 'elixir) + +(defcustom elixir-mode-cygwin-paths t + "Elixir mode use Cygwin style paths on Windows operating systems." + :type 'boolean + :group 'elixir) + +(defcustom elixir-mode-cygwin-prefix "/cygdrive/C" + "Elixir mode Cygwin prefix." + :type 'string + :group 'elixir) + +(defvar elixir-mode--eval-filename "elixir-mode-tmp-eval-file.exs") + +(defvar elixir-quoted--buffer-name "*elixir-quoted*") + +(defvar elixir-basic-offset 2) +(defvar elixir-key-label-offset 0) +(defvar elixir-match-label-offset 2) + +(defvar elixir-operator-face 'elixir-operator-face) +(defface elixir-operator-face + '((((class color) (min-colors 88) (background light)) + :foreground "darkred") + (((class color) (background dark)) + (:foreground "lemonchiffon1")) + (t nil)) + "For use with operators." + :group 'font-lock-faces) + +(defvar elixir-negation-face 'elixir-negation-face) +(defface elixir-negation-face + '((((class color) (min-colors 88) (background light)) + :foreground "#ff4500") + (((class color) (background dark)) + (:foreground "#ff4500")) + (t nil)) + "For use with standalone \"?\" to indicate code point." + :group 'font-lock-faces) + +(defvar elixir-attribute-face 'elixir-attribute-face) +(defface elixir-attribute-face + '((((class color) (min-colors 88) (background light)) + :foreground "MediumPurple4") + (((class color) (background dark)) + (:foreground "thistle")) + (t nil)) + "For use with module attribute tokens." + :group 'font-lock-faces) + +(defvar elixir-atom-face 'elixir-atom-face) +(defface elixir-atom-face + '((((class color) (min-colors 88) (background light)) + :foreground "RoyalBlue4") + (((class color) (background dark)) + (:foreground "light sky blue")) + (t nil)) + "For use with atoms & map keys." + :group 'font-lock-faces) + +(defun elixir-syntax-propertize-interpolation () + (let* ((beg (match-beginning 0)) + (context (save-excursion (save-match-data (syntax-ppss beg))))) + (put-text-property beg (1+ beg) 'elixir-interpolation + (cons (nth 3 context) (match-data))))) + +(defun elixir-syntax-propertize-function (start end) + (let ((case-fold-search nil)) + (goto-char start) + (remove-text-properties start end '(elixir-interpolation)) + (funcall + (syntax-propertize-rules + ((rx (group "#{" (0+ (not (any "}"))) "}")) + (0 (ignore (elixir-syntax-propertize-interpolation))))) + start end))) + +(defun elixir-match-interpolation (limit) + (let ((pos (next-single-char-property-change (point) 'elixir-interpolation + nil limit))) + (when (and pos (> pos (point))) + (goto-char pos) + (let ((value (get-text-property pos 'elixir-interpolation))) + (if (eq (car value) ?\") + (progn + (set-match-data (cdr value)) + t) + (elixir-match-interpolation limit)))))) + +(eval-when-compile + (defconst elixir-rx-constituents + `( + (atoms . ,(rx ":" + (or + (one-or-more (any "a-z" "A-Z" "_" "\"" "'")) + (and "\"" (one-or-more (not (any "\""))) "\"") + (and "'" (one-or-more (not (any "'"))) "'")))) + (builtin . ,(rx symbol-start + (or "case" "cond" "for" "if" "unless" "try" "receive" + "raise" "quote" "unquote" "unquote_splicing" "throw" + "super") + symbol-end)) + (builtin-declaration . ,(rx symbol-start + (or "def" "defp" "defmodule" "defprotocol" + "defmacro" "defmacrop" "defdelegate" + "defexception" "defstruct" "defimpl" + "defcallback") + symbol-end)) + (builtin-modules . ,(rx symbol-start + (or "Agent" "Application" "Atom" "Base" + "Behaviour" "Bitwise" "Builtin" "Code" "Dict" + "EEx" "Elixir" "Enum" "ExUnit" "Exception" + "File" "File.Stat" "File.Stream" "Float" + "Function" "GenEvent" "GenServer" "GenTCP" + "HashDict" "HashSet" "IO" "IO.ANSI" + "IO.Stream" "Inspect.Algebra" "Inspect.Opts" + "Integer" "Kernel" "Kernel.ParallelCompiler" + "Kernel.ParallelRequire" "Kernel.SpecialForms" + "Kernel.Typespec" "Keyword" "List" "Macro" + "Macro.Env" "Map" "Math" "Module" "Node" + "OptionParser" "OrdDict" "Path" "Port" + "Process" "Protocol" "Range" "Record" "Regex" + "Set" "Stream" "String" "StringIO" + "Supervisor" "Supervisor.Spec" "System" "Task" + "Task.Supervisor" "Tuple" "URI" + "UnboundMethod" "Version") + symbol-end)) + (builtin-namespace . ,(rx symbol-start + (or "import" "require" "use" "alias") + symbol-end)) + ;; Set aside code point syntax for `elixir-negation-face'. + (code-point . ,(rx symbol-start + "?" + anything + symbol-end)) + (function-declaration . ,(rx symbol-start + (or "def" "defp") + symbol-end)) + ;; Match `@doc' or `@moduledoc' syntax, with or without triple quotes. + (heredocs . ,(rx symbol-start + (or "@doc" "@moduledoc" "~s") + symbol-end)) + ;; The first character of an identifier must be a letter or an underscore. + ;; After that, they may contain any alphanumeric character + underscore. + ;; Additionally, the final character may be either `?' or `!'. + (identifiers . ,(rx (one-or-more (any "A-Z" "a-z" "_")) + (zero-or-more (any "A-Z" "a-z" "0-9" "_")) + (optional (or "?" "!")))) + (keyword . ,(rx symbol-start + (or "fn" "do" "end" "after" "else" "rescue" "catch") + symbol-end)) + (keyword-operator . ,(rx symbol-start + (or "not" "and" "or" "when" "in") + symbol-end)) + ;; Module and submodule names start with upper case letter. This + ;; can then be followed by any combination of alphanumeric chars. + ;; In turn, this can be followed by a `.' which begins the notation of + ;; a submodule, which follows the same naming pattern of the module. + ;; Finally, like other identifiers, it can be terminated with either `?' + ;; or `!'. + (module-names . ,(rx symbol-start + (one-or-more (any "A-Z")) + (zero-or-more (any "A-Z" "a-z" "_" "0-9")) + (zero-or-more + (and "." + (one-or-more (any "A-Z" "_")) + (zero-or-more (any "A-Z" "a-z" "_" "0-9")))) + (optional (or "!" "?")) + symbol-end)) + (operators1 . ,(rx symbol-start + (or "<" ">" "+" "-" "*" "/" "!" "^" "&") + symbol-end)) + (operators2 . ,(rx symbol-start + (or + "==" "!=" "<=" ">=" "&&" "||" "<>" "++" "--" "|>" "=~" + "->" "<-" "|" "." "=") + symbol-end)) + (operators3 . ,(rx symbol-start + (or "<<<" ">>>" "|||" "&&&" "^^^" "~~~" "===" "!==") + symbol-end)) + (pseudo-var . ,(rx symbol-start + (or "_" "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" + "__block__" "__aliases__") + symbol-end)) + (punctuation . ,(rx symbol-start + (or "\\" "<<" ">>" "=>" "(" ")" ":" ";" "" "[" "]") + symbol-end)) + (sigils . ,(rx "~" (or "B" "C" "R" "S" "b" "c" "r" "s" "w"))))) + + (defmacro elixir-rx (&rest sexps) + (let ((rx-constituents (append elixir-rx-constituents rx-constituents))) + (cond ((null sexps) + (error "No regexp")) + ((cdr sexps) + (rx-to-string `(and ,@sexps) t)) + (t + (rx-to-string (car sexps) t)))))) + +(defconst elixir-font-lock-keywords + `( + ;; String interpolation + (elixir-match-interpolation 0 font-lock-variable-name-face t) + + ;; Module-defining & namespace builtins + (,(elixir-rx (or builtin-declaration builtin-namespace) + space + (group module-names)) + 1 font-lock-type-face) + + ;; Module attributes + (,(elixir-rx (group (or heredocs + (and "@" (1+ identifiers))))) + 1 elixir-attribute-face) + + ;; Keywords + (,(elixir-rx (group (or builtin builtin-declaration builtin-namespace + keyword keyword-operator))) + 1 font-lock-keyword-face) + + ;; Function names, i.e. `def foo do'. + (,(elixir-rx (group function-declaration) + space + (group identifiers)) + 2 font-lock-function-name-face) + + ;; Variable definitions + (,(elixir-rx (group identifiers) + (one-or-more space) + "=" + (or (one-or-more space) + (one-or-more "\n"))) + 1 font-lock-variable-name-face) + + ;; Sigils + (,(elixir-rx (group sigils)) + 1 font-lock-builtin-face) + + ;; Regex patterns. Elixir has support for eight different regex delimiters. + ;; This isn't a very DRY approach here but it gets the job done. + (,(elixir-rx "~r" + (and "/" (group (one-or-more (not (any "/")))) "/")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "[" (group (one-or-more (not (any "]")))) "]")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "{" (group (one-or-more (not (any "}")))) "}")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "(" (group (one-or-more (not (any ")")))) ")")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "|" (group (one-or-more (not (any "|")))) "|")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "\"" (group (one-or-more (not (any "\"")))) "\"")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "'" (group (one-or-more (not (any "'")))) "'")) + 1 font-lock-string-face) + (,(elixir-rx "~r" + (and "<" (group (one-or-more (not (any ">")))) ">")) + 1 font-lock-string-face) + + ;; Atoms and singleton-like words like true/false/nil. + (,(elixir-rx (group atoms)) + 1 elixir-atom-face) + + ;; Map keys + (,(elixir-rx (group (and (one-or-more identifiers) ":"))) + 1 elixir-atom-face) + + ;; Built-in modules and pseudovariables + (,(elixir-rx (group (or builtin-modules pseudo-var))) + 1 font-lock-constant-face) + + ;; Code points + (,(elixir-rx (group code-point)) + 1 elixir-negation-face))) + +(defun elixir-mode-cygwin-path (expanded-file-name) + "Elixir mode get Cygwin absolute path name. +Argument EXPANDED-FILE-NAME ." + (replace-regexp-in-string "^[a-zA-Z]:" elixir-mode-cygwin-prefix expanded-file-name t)) + +(defun elixir-mode-universal-path (file-name) + "Elixir mode multi-OS path handler. +Argument FILE-NAME ." + (let ((full-file-name (expand-file-name file-name))) + (if (and (equal system-type 'windows-nt) + elixir-mode-cygwin-paths) + (elixir-mode-cygwin-path full-file-name) + full-file-name))) + +(defun elixir-mode-command-compile (file-name) + "Elixir mode command to compile a file. +Argument FILE-NAME ." + (let ((full-file-name (elixir-mode-universal-path file-name))) + (mapconcat 'identity (append (list elixir-compiler-command) (list full-file-name)) " "))) + +(defun elixir-mode-compiled-file-name (&optional filename) + "Elixir mode compiled FILENAME." + (concat (file-name-sans-extension (or filename (buffer-file-name))) ".beam")) + +(defun elixir-mode-compile-file () + "Elixir mode compile and save current file." + (interactive) + (elixir-deprecated-use-alchemist "elixir-mode-compile-file") + (let ((compiler-output (shell-command-to-string (elixir-mode-command-compile (buffer-file-name))))) + (when (string= compiler-output "") + (message "Compiled and saved as %s" (elixir-mode-compiled-file-name))))) + +(defun elixir-quoted--initialize-buffer (quoted) + (pop-to-buffer elixir-quoted--buffer-name) + (setq buffer-undo-list nil) ; Get rid of undo information from + ; previous expansions + (let ((inhibit-read-only t) + (buffer-undo-list t)) ; Ignore undo information + (erase-buffer) + (insert quoted) + (goto-char (point-min)) + (elixir-mode) + (elixir-quoted-minor-mode 1))) + +;;;###autoload +(defun elixir-mode-iex (&optional args-p) + "Elixir mode interactive REPL. +Optional argument ARGS-P ." + (interactive "P") + (let ((switches (if (equal args-p nil) + '() + (split-string (read-string "Additional args: "))))) + (unless (comint-check-proc "*IEX*") + (set-buffer + (apply 'make-comint "IEX" + elixir-iex-command nil switches)))) + (pop-to-buffer "*IEX*") + (elixir-deprecated-use-alchemist "elixir-mode-iex")) + +;;;###autoload +(defun elixir-mode-open-modegithub () + "Elixir mode open GitHub page." + (interactive) + (browse-url "https://github.com/elixir-lang/emacs-elixir")) + +;;;###autoload +(defun elixir-mode-open-elixir-home () + "Elixir mode go to language home." + (interactive) + (browse-url elixir-mode--website-url)) + +;;;###autoload +(defun elixir-mode-open-docs-master () + "Elixir mode go to master documentation." + (interactive) + (browse-url (concat elixir-mode--website-url "/docs/master/elixir"))) + +;;;###autoload +(defun elixir-mode-open-docs-stable () + "Elixir mode go to stable documentation." + (interactive) + (browse-url (concat elixir-mode--website-url "/docs/stable/elixir"))) + +;;;###autoload +(defun elixir-mode-version (&optional show-version) + "Get the Elixir-Mode version as string. + +If called interactively or if SHOW-VERSION is non-nil, show the +version in the echo area and the messages buffer. + +The returned string includes both, the version from package.el +and the library version, if both a present and different. + +If the version number could not be determined, signal an error, +if called interactively, or if SHOW-VERSION is non-nil, otherwise +just return nil." + (interactive (list t)) + (let ((version (pkg-info-version-info 'elixir-mode))) + (when show-version + (message "Elixir-Mode version: %s" version)) + version)) + +(defun elixir-mode--code-eval-string-command (file) + (format "%s -e 'IO.puts inspect(elem(Code.eval_string(File.read!(\"%s\")), 0))'" + elixir-mode-command + file)) + +(defun elixir-mode--code-string-to-quoted-command (file) + (format "%s -e 'IO.puts inspect(elem(Code.string_to_quoted(File.read!(\"%s\")), 1), pretty: true)'" + elixir-mode-command + file)) + +(defun elixir-mode--execute-elixir-with-code-eval-string (string) + (with-temp-file elixir-mode--eval-filename + (insert string)) + (let ((output (shell-command-to-string (elixir-mode--code-eval-string-command elixir-mode--eval-filename)))) + (delete-file elixir-mode--eval-filename) + output)) + +(defun elixir-mode--execute-elixir-with-code-string-to-quoted (string) + (with-temp-file elixir-mode--eval-filename + (insert string)) + (let ((output (shell-command-to-string (elixir-mode--code-string-to-quoted-command elixir-mode--eval-filename)))) + (delete-file elixir-mode--eval-filename) + output)) + +(defun elixir-mode--eval-string (string) + (let ((output (elixir-mode--execute-elixir-with-code-eval-string string))) + (message output))) + +(defun elixir-mode--string-to-quoted (string) + (let* ((output (elixir-mode--execute-elixir-with-code-string-to-quoted string))) + (elixir-quoted--initialize-buffer output))) + +(defun elixir-mode-fill-doc-string () + (interactive) + (save-excursion + (re-search-backward "@\\(?:module\\)?doc +\"\"\"" nil t) + (re-search-forward "\"\"\"" nil t) + (set-mark (point)) + (re-search-forward "\"\"\"" nil t) + (re-search-backward "^ *\"\"\"" nil t) + (backward-char) + (fill-region (point) (mark)))) + +(defun elixir-mode-eval-on-region (beg end) + "Evaluate the Elixir code on the marked region. +Argument BEG Start of the region. +Argument END End of the region." + (interactive (list (point) (mark))) + (elixir-deprecated-use-alchemist "elixir-mode-eval-on-region") + (unless (and beg end) + (error "The mark is not set now, so there is no region")) + (let* ((region (buffer-substring-no-properties beg end))) + (elixir-mode--eval-string region))) + +(defun elixir-mode-eval-on-current-line () + "Evaluate the Elixir code on the current line." + (interactive) + (elixir-deprecated-use-alchemist "elixir-mode-eval-on-current-line") + (let ((current-line (thing-at-point 'line))) + (elixir-mode--eval-string current-line))) + +(defun elixir-mode-eval-on-current-buffer () + "Evaluate the Elixir code on the current buffer." + (interactive) + (elixir-deprecated-use-alchemist "elixir-mode-eval-on-current-buffer") + (let ((current-buffer (buffer-substring-no-properties (point-max) (point-min)))) + (elixir-mode--eval-string current-buffer))) + +(defun elixir-mode-string-to-quoted-on-region (beg end) + "Get the representation of the expression on the marked region. +Argument BEG Start of the region. +Argument END End of the region." + (interactive (list (point) (mark))) + (elixir-deprecated-use-alchemist "elixir-mode-string-to-quoted-on-region") + (unless (and beg end) + (error "The mark is not set now, so there is no region")) + (let ((region (buffer-substring-no-properties beg end))) + (elixir-mode--string-to-quoted region))) + +(defun elixir-mode-string-to-quoted-on-current-line () + "Get the representation of the expression on the current line." + (interactive) + (elixir-deprecated-use-alchemist "elixir-mode-string-to-quoted-on-current-line") + (let ((current-line (thing-at-point 'line))) + (elixir-mode--string-to-quoted current-line))) + +(easy-menu-define elixir-mode-menu elixir-mode-map + "Elixir mode menu." + '("Elixir" + ["Indent line" smie-indent-line] + ["Compile file" elixir-mode-compile-file] + ["IEX" elixir-mode-iex] + "---" + ["elixir-mode on GitHub" elixir-mode-open-modegithub] + ["Elixir homepage" elixir-mode-open-elixirhome] + ["About" elixir-mode-version] + )) + +;;;###autoload +(define-derived-mode elixir-mode prog-mode "Elixir" + "Major mode for editing Elixir code. + +\\{elixir-mode-map}" + (set (make-local-variable 'font-lock-defaults) + '(elixir-font-lock-keywords)) + (set (make-local-variable 'comment-start) "# ") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'comment-start-skip) "#+ *") + (set (make-local-variable 'comment-use-syntax) t) + (set (make-local-variable 'tab-width) elixir-basic-offset) + (set (make-local-variable 'syntax-propertize-function) + #'elixir-syntax-propertize-function) + (set (make-local-variable 'imenu-generic-expression) + elixir-imenu-generic-expression) + (smie-setup elixir-smie-grammar 'verbose-elixir-smie-rules + :forward-token 'elixir-smie-forward-token + :backward-token 'elixir-smie-backward-token)) + +(define-minor-mode elixir-cos-mode + "Elixir mode toggle compile on save." + :group 'elixir-cos :lighter " CoS" + (cond + (elixir-cos-mode + (add-hook 'after-save-hook 'elixir-mode-compile-file nil t)) + (t + (remove-hook 'after-save-hook 'elixir-mode-compile-file t)))) + +(define-minor-mode elixir-quoted-minor-mode + "Minor mode for displaying elixir quoted expressions" + :group 'elixir-quoted :lighter " quoted" + :keymap '(("q" . quit-window)) + (setq buffer-read-only t)) + +;; Invoke elixir-mode when appropriate + +;;;###autoload +(progn + (add-to-list 'auto-mode-alist '("\\.elixir\\'" . elixir-mode)) + (add-to-list 'auto-mode-alist '("\\.ex\\'" . elixir-mode)) + (add-to-list 'auto-mode-alist '("\\.exs\\'" . elixir-mode))) + +(provide 'elixir-mode) + +;;; elixir-mode.el ends here diff --git a/emacs.d/elpa/elixir-mode-20150103.439/elixir-smie.el b/emacs.d/elpa/elixir-mode-20150317.1454/elixir-smie.el similarity index 100% rename from emacs.d/elpa/elixir-mode-20150103.439/elixir-smie.el rename to emacs.d/elpa/elixir-mode-20150317.1454/elixir-smie.el diff --git a/emacs.d/elpa/elpy-1.7.1/LICENSE b/emacs.d/elpa/elpy-1.7.1/LICENSE deleted file mode 100644 index 94a9ed0..0000000 --- a/emacs.d/elpa/elpy-1.7.1/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/emacs.d/elpa/elpy-1.7.1/README.rst b/emacs.d/elpa/elpy-1.7.1/README.rst deleted file mode 100644 index 29c1e1b..0000000 --- a/emacs.d/elpa/elpy-1.7.1/README.rst +++ /dev/null @@ -1,65 +0,0 @@ -======================================= -Elpy, the Emacs Lisp Python Environment -======================================= - -Elpy is an Emacs package to bring powerful Python editing to Emacs. It -combines a number of other packages, both written in Emacs Lisp as -well as Python. - -.. image:: https://secure.travis-ci.org/jorgenschaefer/elpy.png?branch=master - :target: http://travis-ci.org/jorgenschaefer/elpy?branch=master - -.. image:: https://coveralls.io/repos/jorgenschaefer/elpy/badge.png?branch=master - :target: https://coveralls.io/r/jorgenschaefer/elpy?branch=master - -Documentation -============= - -Elpy is fully documented at readthedocs.org: - -http://elpy.readthedocs.org/en/latest/index.html - -Quick Installation -================== - -First, install the required Python packages::: - - # Either of these - pip install rope - pip install jedi - # flake8 for code checks - pip install flake8 - # and importmagic for automatic imports - pip install importmagic - - -Evaluate this in your ``*scratch*`` buffer: - -.. code-block:: lisp - - (require 'package) - (add-to-list 'package-archives - '("elpy" . "http://jorgenschaefer.github.io/packages/")) - - -Then run ``M-x package-refresh-contents`` to load the contents of the -new repository, and ``M-x package-install RET elpy RET`` to install -elpy. - -Finally, add the following to your ``.emacs``: - -.. code-block:: lisp - - (package-initialize) - (elpy-enable) - -Done. - -License -======= - -This project is free software: You can redistribute it and/or modify -it under the terms of the `GNU General Public License`__, either -version 3 of the License, or (at your option) any later version. - -.. __: LICENSE diff --git a/emacs.d/elpa/elpy-1.7.1/elpy-autoloads.el b/emacs.d/elpa/elpy-1.7.1/elpy-autoloads.el deleted file mode 100644 index 2713e20..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy-autoloads.el +++ /dev/null @@ -1,54 +0,0 @@ -;;; elpy-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "elpy" "elpy.el" (21786 45609 0 0)) -;;; Generated autoloads from elpy.el - -(autoload 'elpy-enable "elpy" "\ -Enable Elpy in all future Python buffers. - -\(fn &optional IGNORED)" t nil) - -(autoload 'elpy-mode "elpy" "\ -Minor mode in Python buffers for the Emacs Lisp Python Environment. - -This mode fully supports virtualenvs. Once you switch a -virtualenv using \\[pyvenv-workon], you can use -\\[elpy-rpc-restart] to make the elpy Python process use your -virtualenv. - -See https://github.com/jorgenschaefer/elpy/wiki/Keybindings for a -more structured list. - -\\{elpy-mode-map} - -\(fn &optional ARG)" t nil) - -(autoload 'elpy-config "elpy" "\ -Configure Elpy. - -This function will pop up a configuration buffer, which is mostly -a customize buffer, but has some more options. - -\(fn)" t nil) - -(autoload 'elpy-version "elpy" "\ -Display the version of Elpy. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("elpy-pkg.el" "elpy-refactor.el") (21786 -;;;;;; 45609 742650 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; elpy-autoloads.el ends here diff --git a/emacs.d/elpa/elpy-1.7.1/elpy-pkg.el b/emacs.d/elpa/elpy-1.7.1/elpy-pkg.el deleted file mode 100644 index fc35ef9..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy-pkg.el +++ /dev/null @@ -1,8 +0,0 @@ -(define-package "elpy" "1.7.1" - "Emacs Python Development Environment" - '((company "0.8.2") - (find-file-in-project "3.3") - (highlight-indentation "0.5.0") - (pyvenv "1.3") - (yasnippet "0.8.0")) - ) diff --git a/emacs.d/elpa/elpy-1.7.1/elpy.el b/emacs.d/elpa/elpy-1.7.1/elpy.el deleted file mode 100644 index 3e1101e..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy.el +++ /dev/null @@ -1,3501 +0,0 @@ -;;; elpy.el --- Emacs Python Development Environment -*- lexical-binding: t -*- - -;; Copyright (C) 2012-2014 Jorgen Schaefer - -;; Author: Jorgen Schaefer -;; URL: https://github.com/jorgenschaefer/elpy -;; Version: 1.7.1 -;; Keywords: Python, IDE, Languages, Tools -;; Package-Requires: ((company "0.8.2") (find-file-in-project "3.3") (highlight-indentation "0.5.0") (pyvenv "1.3") (yasnippet "0.8.0")) - -;; This program is free software; you can redistribute it and/or -;; modify it under the terms of the GNU General Public License -;; as published by the Free Software Foundation; either version 3 -;; of the License, or (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; The Emacs Lisp Python Environment in Emacs - -;; Elpy is an Emacs package to bring powerful Python editing to Emacs. -;; It combines a number of existing Emacs packages, and uses one of a -;; selection of Python packages for code introspection. - -;; To use, you need to install not only this package, but a few Python -;; packages as well. See the installation instructions on the wiki. - -;; Documentation is available there as well. - -;; https://github.com/jorgenschaefer/elpy/wiki - -;;; Writing Elpy Modules: - -;; A module is a function which is called with one or more arguments. -;; This first argument is the command specifier symbol, which can be -;; one of the following: - -;; global-init: -;; - Called once, when Elpy is enabled using `elpy-enable'. - -;; global-stop: -;; - Called once, when Elpy is disabled using `elpy-disable'. - -;; buffer-init: -;; - Called in a buffer when elpy-mode is enabled. - -;; buffer-stop: -;; - Called in a buffer when elpy-mode is disabled. - -;;; Writing test runners: - -;; A test runner is a function that receives four arguments, described -;; in the docstring of `elpy-test-at-point'. If only the first -;; argument is given, the test runner should find tests under this -;; directory and run them. If the others are given, the test runner -;; should run the specified test only, or as few as it can. - -;; Test runners should use an interactive spec of (interactive -;; (elpy-test-at-point)) so they can be called directly by the user. -;; For their main work, they can simply call `elpy-test-run'. See the -;; `elpy-test-discover-runner' for an example. - -;;; Code: - -(require 'cus-edit) -(require 'etags) -(require 'files-x) -(require 'grep) -(require 'ido) -(require 'json) -(require 'python) - -(require 'elpy-refactor) -(require 'pyvenv) - -(defconst elpy-version "1.7.1" - "The version of the Elpy lisp code.") - -;;;;;;;;;;;;;;;;;;;;;; -;;; User customization - -(defgroup elpy nil - "The Emacs Lisp Python Environment." - :prefix "elpy-" - :group 'languages) - -(defcustom elpy-interactive-python-command "python" - "Command to use for the interactive shell. - -Customize this option to use a different interactive shell. If -the value starts with \"ipython\", it will set up python.el so -that it deals with ipytohon's particular prompt and features. - -From your .emacs, you can use `elpy-use-ipython' and -`elpy-use-cpython' instead." - :type '(choice (const :tag "Standard Python (python)" "python") - (const :tag "Standard Python 2 (python2)" "python2") - (const :tag "Standard Python 3 (python3)" "python3") - (const :tag "IPython" "ipython") - (string :tag "Other")) - :set (lambda (var val) - (set-default var val) - (if (string-match "ipython" val) - (elpy-use-ipython val) - (elpy-use-cpython val))) - ;; Don't use the default function because the default values are - ;; correct, and `elpy-use-cpython' is not available yet. - :initialize #'set-default - :safe (lambda (val) - (member val '("python" "python2" "python3" "ipython"))) - :group 'elpy) - -(defcustom elpy-mode-hook nil - "Hook run when `elpy-mode' is enabled. - -This can be used to enable minor modes for Python development." - :type 'hook - :options '(subword-mode hl-line-mode) - :group 'elpy) - -(defcustom elpy-modules '(elpy-module-sane-defaults - elpy-module-company - elpy-module-eldoc - elpy-module-flymake - elpy-module-highlight-indentation - elpy-module-pyvenv - elpy-module-yasnippet) - "Which Elpy modules to use. - -Elpy can use a number of modules for additional features, which -can be inidividually enabled or disabled." - :type '(set (const :tag "Inline code completion (company-mode)" - elpy-module-company) - (const :tag "Show function signatures (ElDoc)" - elpy-module-eldoc) - (const :tag "Highlight syntax errors (Flymake)" - elpy-module-flymake) - (const :tag "Show the virtualenv in the mode line (pyvenv)" - elpy-module-pyvenv) - (const :tag "Display indentation markers (highlight-indentation)" - elpy-module-highlight-indentation) - (const :tag "Expand code snippets (YASnippet)" - elpy-module-yasnippet) - (const :tag "Configure some sane defaults for Emacs" - elpy-module-sane-defaults)) - :group 'elpy) - -(defcustom elpy-project-ignored-directories ' (".bzr" "CVS" ".git" ".hg" ".svn" - ".tox" "build" "dist" - ".cask") - "Directories ignored by functions working on the whole project." - :type '(repeat string) - :safe (lambda (val) - (cl-every #'stringp val)) - :group 'elpy) - -(defcustom elpy-project-root nil - "The root of the project the current buffer is in. - -There is normally no use in setting this variable directly, as -Elpy tries to detect the project root automatically. See -`elpy-project-root-finder-functions' for a way of influencing -this. - -Setting this variable globally will override Elpy's automatic -project detection facilities entirely. - -Alternatively, you can set this in file- or directory-local -variables using \\[add-file-local-variable] or -\\[add-dir-local-variable]. - -Do not use this variable in Emacs Lisp programs. Instead, call -the `elpy-project-root' function. It will do the right thing." - :type 'directory - :safe 'file-directory-p - :group 'elpy) -(make-variable-buffer-local 'elpy-project-root) - -(defcustom elpy-project-root-finder-functions - '(elpy-project-find-projectile-root - elpy-project-find-python-root - elpy-project-find-git-root - elpy-project-find-hg-root - elpy-project-find-svn-root) - "List of functions to ask for the current project root. - -These will be checked in turn. The first directory found is used." - :type '(set (const :tag "Projectile project root" - elpy-project-find-projectile-root) - (const :tag "Python project (setup.py, setup.cfg)" - elpy-project-find-python-root) - (const :tag "Git repository root (.git)" - elpy-project-find-git-root) - (const :tag "Mercurial project root (.hg)" - elpy-project-find-hg-root) - (const :tag "Subversion project root (.svn)" - elpy-project-find-svn-root)) - :group 'elpy) - -(defcustom elpy-rpc-backend nil - "Your preferred backend. - -Elpy can use different backends for code introspection. These -need to be installed separately using pip or other mechanisms to -make them available to Python. If you prefer not to do this, you -can use the native backend, which is very limited but does not -have any external requirements." - :type '(choice (const :tag "Rope" "rope") - (const :tag "Jedi" "jedi") - (const :tag "Automatic" nil)) - :safe (lambda (val) - (member val '("rope" "jedi" "native" nil))) - :group 'elpy) - -(defcustom elpy-rpc-large-buffer-size 4096 - "Size for a source buffer up to which it will be sent directly. - -The Elpy RPC protocol uses JSON as the serialization format. -Large buffers take a long time to encode, so Elpy can transmit -them via temporary files. If a buffer is larger than this value, -it is sent via a temporary file." - :type 'integer - :safe #'integerp - :group 'elpy) - -(defcustom elpy-rpc-python-command (if (eq window-system 'w32) - "pythonw" - "python") - "The Python interpreter for the RPC backend. - -This should be the same interpreter the project will be run with, -and not an interactive shell like ipython." - :type '(choice (const :tag "python" "python") - (const :tag "python2" "python2") - (const :tag "python3" "python3") - (const :tag "pythonw (Python on Windows)" "pythonw") - (string :tag "Other")) - :safe (lambda (val) - (member val '("python" "python2" "python3" "pythonw"))) - :group 'elpy) - -(defcustom elpy-rpc-pythonpath (file-name-directory (locate-library "elpy")) - "A directory to add to the PYTHONPATH for the RPC process. - -This should be a directory where the elpy module can be found. If -this is nil, it's assumed elpy can be found in the standard path. -Usually, there is no need to change this." - :type 'directory - :safe #'file-directory-p - :group 'elpy) - -(defcustom elpy-rpc-timeout 1 - "Number of seconds to wait for a response when blocking. - -When Elpy blocks Emacs to wait for a response from the RPC -process, it will assume it won't come or wait too long after this -many seconds. On a slow computer, or if you have a large project, -you might want to increase this. - -A setting of nil means to block indefinitely." - :type '(choice (const :tag "Block indefinitely" nil) - integer) - :safe (lambda (val) - (or (integerp val) - (null val))) - :group 'elpy) - -(defcustom elpy-rpc-error-timeout 30 - "Minimum number of seconds between error popups. - -When Elpy encounters an error in the backend, it will display a -lengthy description of the problem for a bug report. This hangs -Emacs for a moment, and can be rather annoying if it happens -repeatedly while editing a source file. - -If this variabl is non-nil, Elpy will not display the error -message again within this amount of seconds." - :type 'integer - :group 'elpy) - -(defcustom elpy-eldoc-show-current-function t - "If true, show the current function if no calltip is available. - -When Elpy can not find the calltip of the function call at point, -it can show the name of the function or class and method being -edited instead. Setting this variable to nil disables this feature." - :type 'boolean - :group 'elpy) - -(defcustom elpy-test-runner 'elpy-test-discover-runner - "The test runner to use to run tests." - :type '(choice (const :tag "Unittest Discover" elpy-test-discover-runner) - (const :tag "Django Discover" elpy-test-django-runner) - (const :tag "Nose" elpy-test-nose-runner) - (const :tag "py.test" elpy-test-pytest-runner) - (const :tag "Twisted Trial" elpy-test-trial-runner)) - :safe 'elpy-test-runner-p - :group 'elpy) - -(defcustom elpy-test-discover-runner-command '("python" "-m" "unittest") - "The command to use for `elpy-test-discover-runner'." - :type '(repeat string) - :group 'elpy) - -(defcustom elpy-test-django-runner-command '("django-admin.py" "test" - "--noinput") - "The command to use for `elpy-test-django-runner'." - :type '(repeat string) - :group 'elpy) - -(defcustom elpy-test-nose-runner-command '("nosetests") - "The command to use for `elpy-test-django-runner'." - :type '(repeat string) - :group 'elpy) - -(defcustom elpy-test-trial-runner-command '("trial") - "The command to use for `elpy-test-django-runner'." - :type '(repeat string) - :group 'elpy) - -(defcustom elpy-test-pytest-runner-command '("py.test") - "The command to use for `elpy-test-django-runner'." - :type '(repeat string) - :group 'elpy) - -;;;;;;;;;;;;; -;;; Elpy Mode - -(defvar elpy-mode-map - (let ((map (make-sparse-keymap))) - ;; Alphabetical order to make it easier to find free C-c C-X - ;; bindings in the future. Heh. - - ;; (define-key map (kbd "") 'python-indent-dedent-line-backspace) - ;; (define-key map (kbd "") 'python-indent-dedent-line) - - ;; (define-key map (kbd "C-M-x") 'python-shell-send-defun) - ;; (define-key map (kbd "C-c <") 'python-indent-shift-left) - ;; (define-key map (kbd "C-c >") 'python-indent-shift-right) - (define-key map (kbd "C-c C-c") 'elpy-shell-send-region-or-buffer) - (define-key map (kbd "C-c C-z") 'elpy-shell-switch-to-shell) - (define-key map (kbd "C-c C-d") 'elpy-doc) - (define-key map (kbd "C-c C-e") 'elpy-multiedit-python-symbol-at-point) - (define-key map (kbd "C-c C-f") 'elpy-find-file) - (define-key map (kbd "C-c RET") 'elpy-importmagic-add-import) - (define-key map (kbd "C-c ") 'elpy-importmagic-fixup) - (define-key map (kbd "C-c C-n") 'elpy-flymake-next-error) - (define-key map (kbd "C-c C-o") 'elpy-occur-definitions) - (define-key map (kbd "C-c C-p") 'elpy-flymake-previous-error) - (define-key map (kbd "C-c C-r") 'elpy-refactor) - (define-key map (kbd "C-c C-s") 'elpy-rgrep-symbol) - (define-key map (kbd "C-c C-t") 'elpy-test) - (define-key map (kbd "C-c C-v") 'elpy-check) - ;; (define-key map (kbd "C-c C-z") 'python-shell-switch-to-shell) - - (define-key map (kbd "") 'elpy-open-and-indent-line-below) - (define-key map (kbd "") 'elpy-open-and-indent-line-above) - - (define-key map (kbd "") 'elpy-nav-forward-block) - (define-key map (kbd "") 'elpy-nav-backward-block) - (define-key map (kbd "") 'elpy-nav-backward-indent) - (define-key map (kbd "") 'elpy-nav-forward-indent) - - (define-key map (kbd "") 'elpy-nav-move-iblock-down) - (define-key map (kbd "") 'elpy-nav-move-iblock-up) - (define-key map (kbd "") 'elpy-nav-move-iblock-left) - (define-key map (kbd "") 'elpy-nav-move-iblock-right) - - (define-key map (kbd "M-.") 'elpy-goto-definition) - (define-key map (kbd "M-TAB") 'elpy-company-backend) - - map) - "Key map for the Emacs Lisp Python Environment.") - -(easy-menu-define elpy-menu elpy-mode-map - "Elpy Mode Menu" - '("Elpy" - ["Documentation" elpy-doc - :help "Get documentation for symbol at point"] - ["Run Tests" elpy-test - :help "Run test at point, or all tests in the project"] - ["Go to Definition" elpy-goto-definition - :help "Go to the definition of the symbol at point"] - ["Go to previous definition" pop-tag-mark - :active (not (ring-empty-p find-tag-marker-ring)) - :help "Return to the position"] - ["Complete" elpy-company-backend - :keys "M-TAB" - :help "Complete at point"] - ["Refactor" elpy-refactor - :help "Refactor options"] - "---" - ("Interactive Python" - ["Switch to Python Shell" elpy-shell-switch-to-shell - :help "Start and switch to the interactive Python"] - ["Send Region or Buffer" elpy-shell-send-region-or-buffer - :label (if (use-region-p) - "Send Region to Python" - "Send Buffer to Python") - :help "Send the current region or the whole buffer to Python"] - ["Send Definition" python-shell-send-defun - :help "Send current definition to Python"]) - ("Project" - ["Find File" elpy-find-file - :help "Interactively find a file in the current project"] - ["Find Symbol" elpy-rgrep-symbol - :help "Find occurrences of a symbol in the current project"] - ["Set Project Root" elpy-set-project-root - :help "Change the current project root"] - ["Set Project Variable" elpy-set-project-variable - :help "Configure a project-specific option"]) - ("Syntax Check" - ["Check Syntax" elpy-check - :help "Check the syntax of the current file"] - ["Next Error" elpy-flymake-next-error - :help "Go to the next inline error, if any"] - ["Previous Error" elpy-flymake-previous-error - :help "Go to the previous inline error, if any"]) - ("Indentation Blocks" - ["Dedent" elpy-nav-move-iblock-left - :help "Dedent current block or region" - :suffix (if (use-region-p) "Region" "Block")] - ["Indent" elpy-nav-move-iblock-right - :help "Indent current block or region" - :suffix (if (use-region-p) "Region" "Block")] - ["Up" elpy-nav-move-iblock-up - :help "Move current block or region up" - :suffix (if (use-region-p) "Region" "Block")] - ["Down" elpy-nav-move-iblock-down - :help "Move current block or region down" - :suffix (if (use-region-p) "Region" "Block")]) - "---" - ["News" elpy-news t] - ["Configure" elpy-config t])) - -;;;###autoload -(defun elpy-enable (&optional ignored) - "Enable Elpy in all future Python buffers." - (interactive) - (when (< emacs-major-version 24) - (error "Elpy requires Emacs 24 or newer")) - (when ignored - (warn "The argument to `elpy-enable' is deprecated, customize `elpy-modules' instead")) - (let ((filename (find-lisp-object-file-name 'python-mode - 'symbol-function))) - (when (and filename - (string-match "/python-mode\\.el\\'" - filename)) - (error (concat "You are using python-mode.el. " - "Elpy only works with python.el from " - "Emacs 24 and above")))) - (elpy-modules-global-init) - (add-hook 'python-mode-hook 'elpy-mode)) - -(defun elpy-disable () - "Disable Elpy in all future Python buffers." - (interactive) - (remove-hook 'python-mode-hook 'elpy-mode) - (elpy-modules-global-stop)) - -;;;###autoload -(define-minor-mode elpy-mode - "Minor mode in Python buffers for the Emacs Lisp Python Environment. - -This mode fully supports virtualenvs. Once you switch a -virtualenv using \\[pyvenv-workon], you can use -\\[elpy-rpc-restart] to make the elpy Python process use your -virtualenv. - -See https://github.com/jorgenschaefer/elpy/wiki/Keybindings for a -more structured list. - -\\{elpy-mode-map}" - :lighter " Elpy" - (when (not (eq major-mode 'python-mode)) - (error "Elpy only works with `python-mode'")) - (cond - (elpy-mode - (elpy-modules-buffer-init)) - ((not elpy-mode) - (elpy-modules-buffer-stop)))) - -;;;;;;;;;;;;; -;;; Elpy News - -(defun elpy-news () - "Display Elpy's release notes." - (interactive) - (with-current-buffer (get-buffer-create "*Elpy News*") - (let ((inhibit-read-only t)) - (erase-buffer) - (insert-file (concat (file-name-directory (locate-library "elpy")) - "NEWS.rst")) - (help-mode)) - (pop-to-buffer (current-buffer)))) - -;;;;;;;;;;;;;;; -;;; Elpy Config - -(defvar elpy-config--related-custom-groups - '(("Elpy" elpy "elpy-") - ("Python" python "python-") - ("Virtual Environments (Pyvenv)" pyvenv "pyvenv-") - ("Completion (Company)" company "company-") - ("Call Signatures (ElDoc)" eldoc "eldoc-") - ("Inline Errors (Flymake)" flymake "flymake-") - ("Snippets (YASnippet)" yasnippet "yas-") - ("Directory Grep (rgrep)" grep "grep-") - ("Search as You Type (ido)" ido "ido-") - ;; ffip does not use defcustom - ;; highlight-indent does not use defcustom, either. Its sole face - ;; is defined in basic-faces. - )) - -(defvar elpy-config--get-config "import json -import sys - -try: - import xmlrpclib -except ImportError: - import xmlrpc.client as xmlrpclib - -from distutils.version import LooseVersion - - -def latest(package, version=None): - try: - pypi = xmlrpclib.ServerProxy('https://pypi.python.org/pypi') - latest = pypi.package_releases(package)[0] - if version is None or LooseVersion(version) < LooseVersion(latest): - return latest - else: - return None - except: - return None - - -config = {} -config['python_version'] = ('{major}.{minor}.{micro}' - .format(major=sys.version_info[0], - minor=sys.version_info[1], - micro=sys.version_info[2])) - -try: - import elpy - config['elpy_version'] = elpy.__version__ -except: - config['elpy_version'] = None - -try: - import jedi - if isinstance(jedi.__version__, tuple): - config['jedi_version'] = '.'.join(str(x) for x in jedi.__version__) - else: - config['jedi_version'] = jedi.__version__ - config['jedi_latest'] = latest('jedi', config['jedi_version']) -except: - config['jedi_version'] = None - config['jedi_latest'] = latest('jedi') - -try: - import rope - config['rope_version'] = rope.VERSION - if sys.version_info[0] <= 2: - config['rope_latest'] = latest('rope', config['rope_version']) - else: - config['rope_latest'] = latest('rope_py3k', config['rope_version']) -except: - config['rope_version'] = None - config['rope_latest'] = latest('rope') - -try: - import importmagic - config['importmagic_version'] = importmagic.__version__ - config['importmagic_latest'] = latest('importmagic', config['importmagic_version']) -except: - config['importmagic_version'] = None - config['importmagic_latest'] = latest('importmagic') - -json.dump(config, sys.stdout) -") - -(defun elpy-config-error (&optional fmt &rest args) - "Note a configuration problem. - -This will show a message in the minibuffer that tells the user to -use \\[elpy-config]." - (let ((msg (if fmt - (apply #'format fmt args) - "Elpy is not properly configured"))) - (error "%s; use M-x elpy-config to configure it" msg))) - -;;;###autoload -(defun elpy-config () - "Configure Elpy. - -This function will pop up a configuration buffer, which is mostly -a customize buffer, but has some more options." - (interactive) - (let ((buf (custom-get-fresh-buffer "*Elpy Config*")) - (config (elpy-config--get-config)) - (custom-search-field nil)) - (with-current-buffer buf - (elpy-insert--header "Elpy Configuration") - - (elpy-config--insert-configuration-problems config) - - (elpy-insert--header "Options") - - (let ((custom-buffer-style 'tree)) - (Custom-mode) - (elpy-config--insert-help) - (dolist (cust elpy-config--related-custom-groups) - (widget-create 'custom-group - :custom-last t - :custom-state 'hidden - :tag (car cust) - :value (cadr cust))) - (widget-setup) - (goto-char (point-min)))) - (pop-to-buffer-same-window buf))) - -;;;###autoload -(defun elpy-version () - "Display the version of Elpy." - (interactive) - (message "Elpy %s (use M-x elpy-config for details)" elpy-version)) - -(defun elpy-config--insert-help () - (let ((start (point))) - ;; Help display from `customize-browse' - (widget-insert (format "\ -%s buttons; type RET or click mouse-1 -on a button to invoke its action. -Invoke [+] to expand a group, and [-] to collapse an expanded group.\n" - (if custom-raised-buttons - "`Raised' text indicates" - "Square brackets indicate"))) - (if custom-browse-only-groups - (widget-insert "\ -Invoke the [Group] button below to edit that item in another window.\n\n") - (widget-insert "Invoke the ") - (widget-create 'item - :format "%t" - :tag "[Group]" - :tag-glyph "folder") - (widget-insert ", ") - (widget-create 'item - :format "%t" - :tag "[Face]" - :tag-glyph "face") - (widget-insert ", and ") - (widget-create 'item - :format "%t" - :tag "[Option]" - :tag-glyph "option") - (widget-insert " buttons below to edit that -item in another window.\n\n") - - (fill-region start (point))))) - -(defun elpy-config--insert-configuration-problems (&optional config) - "Insert help text and widgets for configuration problems." - (when (not config) - (setq config (elpy-config--get-config))) - (let* ((python-version (gethash "python_version" config)) - (rope-pypi-package (if (and python-version - (string-match "^3\\." python-version)) - "rope_py3k" - "rope"))) - - (elpy-config--insert-configuration-table config) - (insert "\n") - - ;; Python not found - (when (not (gethash "python_rpc_executable" config)) - (elpy-insert--para - "Elpy can not find the configured Python interpreter. Please make " - "sure that the variable `elpy-rpc-python-command' points to a " - "command in your PATH. You can change the variable below.\n\n")) - - ;; No virtual env - (when (and (gethash "python_rpc_executable" config) - (not (gethash "virtual_env" config))) - (elpy-insert--para - "You have not activated a virtual env. While Elpy supports this, " - "it is often a good idea to work inside a virtual env. You can use " - "M-x pyvenv-activate or M-x pyvenv-workon to activate a virtual " - "env.\n\n")) - - ;; No virtual env, but ~/.local/bin not in PATH - (when (and (not (memq system-type '(ms-dos windows-nt))) - (gethash "python_rpc_executable" config) - (not pyvenv-virtual-env) - (not (or (member (expand-file-name "~/.local/bin") - exec-path) - (member (expand-file-name "~/.local/bin/") - exec-path)))) - (elpy-insert--para - "The directory ~/.local/bin/ is not in your PATH, even though you " - "do not have an active virtualenv. Installing Python packages " - "locally will create executables in that directory, so Emacs " - "won't find them. If you are missing some commands, do add this " - "directory to your PATH.\n\n")) - - ;; Python found, but can't find the elpy module - (when (and (gethash "python_rpc_executable" config) - (not (gethash "elpy_version" config))) - (elpy-insert--para - "The Python interpreter could not find the elpy module. " - "Make sure the module is installed" - (if (gethash "virtual_env" config) - " in the current virtualenv.\n" - ".\n")) - (insert "\n") - (widget-create 'elpy-insert--pip-button :package "elpy") - (insert "\n\n")) - - ;; Bad backend version - (when (and (gethash "elpy_version" config) - (not (equal (gethash "elpy_version" config) - elpy-version))) - (let ((elpy-python-version (gethash "elpy_version" config))) - (elpy-insert--para - "The Elpy backend is version " elpy-python-version " while " - "the Emacs package is " elpy-version ". This is incompatible. " - (if (version< elpy-python-version elpy-version) - "Please upgrade the Python module." - "Please upgrade the Emacs Lisp package.") - "\n"))) - - ;; Otherwise unparseable output. - (when (gethash "error_output" config) - (elpy-insert--para - "There was an unexpected problem starting the RPC process. Please " - "check the following output to see if this makes sense to you. " - "To me, it doesn't.\n") - (insert "\n" - (gethash "error_output" config) "\n" - "\n")) - - ;; Requested backend unavailable - (when (and (gethash "python_rpc_executable" config) - (or (and (equal elpy-rpc-backend "rope") - (not (gethash "rope_version" config))) - (and (equal elpy-rpc-backend "jedi") - (not (gethash "jedi_version" config))))) - (elpy-insert--para - "You requested Elpy to use the backend " elpy-rpc-backend ", " - "but the Python interpreter could not load that module. Make " - "sure the module is installed, or change the value of " - "`elpy-rpc-backend' below to one of the available backends.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button - :package (if (equal elpy-rpc-backend "rope") - rope-pypi-package - "jedi")) - (insert "\n\n")) - - ;; No backend available. - (when (and (gethash "python_rpc_executable" config) - (and (not elpy-rpc-backend) - (not (gethash "rope_version" config)) - (not (gethash "jedi_version" config)))) - (elpy-insert--para - "There is no backend available. Please install either Rope or Jedi.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button :package rope-pypi-package) - (insert "\n") - (widget-create 'elpy-insert--pip-button :package "jedi") - (insert "\n\n")) - - ;; Newer version of Rope available - (when (and (gethash "rope_version" config) - (gethash "rope_latest" config)) - (elpy-insert--para - "There is a newer version of Rope available.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button - :package rope-pypi-package :upgrade t) - (insert "\n\n")) - - ;; Newer version of Jedi available - (when (and (gethash "jedi_version" config) - (gethash "jedi_latest" config)) - (elpy-insert--para - "There is a newer version of Jedi available.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button - :package "jedi" :upgrade t) - (insert "\n\n")) - - ;; No importmagic available - (when (not (gethash "importmagic_version" config)) - (elpy-insert--para - "The importmagic package is not available. Commands using this will " - "not work.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button - :package "importmagic") - (insert "\n\n")) - - ;; Newer version of importmagic available - (when (and (gethash "importmagic_version" config) - (gethash "importmagic_latest" config)) - (elpy-insert--para - "There is a newer version of the importmagic package available.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button - :package "importmagic" :upgrade t) - (insert "\n\n")) - - ;; flake8, the default syntax checker, not found - (when (not (executable-find "flake8")) - (elpy-insert--para - "The configured syntax checker could not be found. Elpy uses this " - "program to provide syntax checks of your programs, so you might " - "want to install one. Elpy by default uses flake8.\n") - (insert "\n") - (widget-create 'elpy-insert--pip-button :package "flake8") - (insert "\n\n")) - - )) - -(defun elpy-config--get-config () - "Return the configuration from `elpy-rpc-python-command'. - -This returns a hash table with the following keys (all strings): - -emacs_version -python_rpc -python_rpc_executable -python_interactive -python_interactive_executable -python_version (RPC) -elpy_version -jedi_version -rope_version -virtual_env -virtual_env_short" - (with-temp-buffer - (let ((config (make-hash-table :test #'equal))) - (puthash "emacs_version" emacs-version config) - (puthash "python_rpc" elpy-rpc-python-command config) - (puthash "python_rpc_executable" - (executable-find elpy-rpc-python-command) - config) - (let ((interactive-python (if (boundp 'python-python-command) - python-python-command - python-shell-interpreter))) - (puthash "python_interactive" - interactive-python - config) - (puthash "python_interactive_executable" - (executable-find interactive-python) - config)) - (let ((venv (getenv "VIRTUAL_ENV"))) - (puthash "virtual_env" venv config) - (if venv - (puthash "virtual_env_short" (file-name-nondirectory venv) config) - (puthash "virtual_env_short" nil config))) - (let ((return-value (ignore-errors - (let ((process-environment - (elpy-rpc--environment)) - (default-directory "/")) - (call-process elpy-rpc-python-command - nil - (current-buffer) - nil - "-c" - elpy-config--get-config))))) - (when return-value - (let ((data (ignore-errors - (let ((json-array-type 'list)) - (goto-char (point-min)) - (json-read))))) - (if (not data) - (puthash "error_output" (buffer-string) config) - (dolist (pair data) - (puthash (symbol-name (car pair)) (cdr pair) config)))))) - config))) - -(defun elpy-config--insert-configuration-table (&optional config) - "Insert a table describing the current Elpy config." - (when (not config) - (setq config (elpy-config--get-config))) - (let ((emacs-version (gethash "emacs_version" config)) - (python-version (gethash "python_version" config)) - (python-rpc (gethash "python_rpc" config)) - (python-rpc-executable (gethash "python_rpc_executable" config)) - (python-interactive (gethash "python_interactive" config)) - (python-interactive-executable (gethash "python_interactive_executable" - config)) - (elpy-python-version (gethash "elpy_version" config)) - (jedi-version (gethash "jedi_version" config)) - (jedi-latest (gethash "jedi_latest" config)) - (rope-version (gethash "rope_version" config)) - (rope-latest (gethash "rope_latest" config)) - (importmagic-version (gethash "importmagic_version" config)) - (importmagic-latest (gethash "importmagic_latest" config)) - (virtual-env (gethash "virtual_env" config)) - (virtual-env-short (gethash "virtual_env_short" config)) - table maxwidth) - (setq table - `(("Virtualenv" . ,(if (gethash "virtual_env" config) - (format "%s (%s)" - virtual-env-short - virtual-env) - "None")) - ("RPC Python" . ,(cond - (python-version - (format "%s (%s)" - python-version - python-rpc-executable)) - (python-rpc-executable - python-rpc-executable) - (python-rpc - (format "%s (not found)" python-rpc)) - (t - (format "Not configured")))) - ("Interactive Python" . ,(cond - (python-interactive-executable - (format "%s (%s)" - python-interactive - python-interactive-executable)) - (python-interactive - (format "%s (not found)" - python-interactive)) - (t - "Not configured"))) - ("Emacs" . ,emacs-version) - ("Elpy" . ,(cond - ((and elpy-python-version elpy-version - (equal elpy-python-version elpy-version)) - elpy-version) - (elpy-python-version - (format "%s (Python), %s (Emacs Lisp)" - elpy-python-version - elpy-version)) - (t - (format "Not found (Python), %s (Emacs Lisp)" - elpy-version)))) - ("Jedi" . ,(elpy-config--package-link "jedi" - jedi-version - jedi-latest)) - ("Rope" . ,(elpy-config--package-link "rope" - rope-version - rope-latest)) - ("Importmagic" . ,(elpy-config--package-link "importmagic" - importmagic-version - importmagic-latest)) - ("Syntax checker" . ,(let ((syntax-checker - (executable-find - python-check-command))) - (if syntax-checker - (format "%s (%s)" - (file-name-nondirectory - syntax-checker) - syntax-checker) - (format "Not found (%s)" - python-check-command)))))) - (setq maxwidth 0) - (dolist (row table) - (when (> (length (car row)) - maxwidth) - (setq maxwidth (length (car row))))) - (dolist (row table) - (insert (car row) - (make-string (- maxwidth (length (car row))) - ?.) - ": " - (cdr row) - "\n")))) - -(defun elpy-config--package-link (name version latest) - "Return a string detailing a Python package. - -NAME is the PyPI name of the package. VERSION is the currently -installed version. LATEST is the latest-available version on -PyPI, or nil if that's VERSION." - (cond - ((and (not version) (not latest)) - "Not found") - ((not latest) - version) - ((not version) - (format "Not found (%s available)" latest)) - (t - (format "%s (%s available)" version latest)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Elpy Formatted Insertion - -(defmacro elpy-insert--popup (buffer-name &rest body) - "Pop up a help buffer named BUFFER-NAME and execute BODY in it." - (declare (indent 1)) - `(with-help-window ,buffer-name - (with-current-buffer standard-output - ,@body))) - -(defun elpy-insert--para (&rest messages) - "Insert a bunch of text and then fill it." - (let ((start (point))) - (mapc (lambda (obj) - (if (stringp obj) - (insert obj) - (insert (format "%s" obj)))) - messages) - (fill-region start (point)))) - -(defun elpy-insert--header (&rest text) - "Insert TEXT has a header for a buffer." - (insert (propertize (mapconcat #'(lambda (x) x) - text - "") - 'face 'header-line) - "\n" - "\n")) - -(define-widget 'elpy-insert--pip-button 'item - "A button that runs pip (or an alternative)." - :button-prefix "[" - :button-suffix "]" - :format "%[run%] %v" - :value-create 'elpy-insert--pip-button-value-create - :action 'elpy-insert--pip-button-action) - -(defun elpy-insert--pip-button-value-create (widget) - "The :value-create option for the pip button widget." - (let* ((python-package (widget-get widget :package)) - (do-upgrade (widget-get widget :upgrade)) - (upgrade-option (if do-upgrade - "--upgrade " - "")) - (do-user-install (not (or (getenv "VIRTUAL_ENV") - pyvenv-virtual-env))) - (user-option (if do-user-install - "--user " - "")) - - (command (cond - ((executable-find "pip") - (format "pip install %s%s%s" - user-option upgrade-option python-package)) - ((executable-find "easy_install") - (format "easy_install %s%s" - user-option python-package)) - (t - (error "Neither easy_install nor pip found"))))) - (widget-put widget :command command) - (insert command))) - -(defun elpy-insert--pip-button-action (widget &optional event) - "The :action option for the pip button widget." - (async-shell-command (widget-get widget :command))) - -;;;;;;;;;;;; -;;; Projects - -(defvar elpy-project--variable-name-history nil - "The history for `elpy-project--read-project-variable'") - -(defun elpy-project-root () - "Return the root of the current buffer's project. - -This can very well be nil if the current file is not part of a -project. - -See `elpy-project-root-finder-functions' for a way to configure -how the project root is found. You can also set the variable -`elpy-project-root' in, for example, .dir-locals.el to override -this." - (when (not elpy-project-root) - (setq elpy-project-root - (run-hook-with-args-until-success - 'elpy-project-root-finder-functions))) - elpy-project-root) - -(defun elpy-set-project-root (new-root) - "Set the Elpy project root to NEW-ROOT." - (interactive "DNew project root: ") - (setq elpy-project-root new-root)) - -(defun elpy-project-find-python-root () - "Return the current Python project root, if any. - -This is marked with setup.py or setup.cfg." - (or (locate-dominating-file default-directory "setup.py") - (locate-dominating-file default-directory "setup.cfg"))) - -(defun elpy-project-find-git-root () - "Return the current git repository root, if any." - (locate-dominating-file default-directory ".git")) - -(defun elpy-project-find-hg-root () - "Return the current git repository root, if any." - (locate-dominating-file default-directory ".hg")) - -(defun elpy-project-find-svn-root () - "Return the current git repository root, if any." - (locate-dominating-file default-directory - (lambda (dir) - (and (file-directory-p (format "%s/.svn" dir)) - (not (file-directory-p (format "%s/../.svn" - dir))))))) - -(defun elpy-project-find-projectile-root () - "Return the current project root according to projectile." - ;; `ignore-errors' both to avoid an unbound function error as well - ;; as ignore projectile saying there is no project root here. - (ignore-errors - (projectile-project-root))) - -(defun elpy-library-root () - "Return the root of the Python package chain of the current buffer. - -That is, if you have /foo/package/module.py, it will return /foo, -so that import package.module will pick up module.py." - (locate-dominating-file default-directory - (lambda (dir) - (not (file-exists-p - (format "%s/__init__.py" - dir)))))) - -(defun elpy-project--read-project-variable (prompt) - "Prompt the user for a variable name to set project-wide." - (let* ((prefixes (mapcar (lambda (cust) - (nth 2 cust)) - elpy-config--related-custom-groups)) - (var-regex (format "^%s" (regexp-opt prefixes)))) - (intern - (completing-read - prompt - obarray - (lambda (sym) - (and (get sym 'safe-local-variable) - (string-match var-regex (symbol-name sym)) - (get sym 'custom-type))) - :require-match - nil - 'elpy-project--variable-name-history)))) - -(defun elpy-project--read-variable-value (prompt variable) - "Read the value for VARIABLE from the user." - (let ((custom-type (get variable 'custom-type))) - (if custom-type - (widget-prompt-value (if (listp custom-type) - custom-type - (list custom-type)) - prompt - (if (boundp variable) - (funcall - (or (get variable 'custom-get) - 'symbol-value) - variable)) - (not (boundp variable))) - (eval-minibuffer prompt)))) - -(defun elpy-set-project-variable (variable value) - "Set or remove a variable in the project-wide .dir-locals.el. - -With prefix argument, remove the variable." - (interactive - (let* ((variable (elpy-project--read-project-variable - (if current-prefix-arg - "Remove project variable: " - "Set project variable: "))) - (value (if current-prefix-arg - nil - (elpy-project--read-variable-value (format "Value for %s: " - variable) - variable)))) - (list variable value))) - (with-current-buffer (find-file-noselect (format "%s/%s" - (elpy-project-root) - dir-locals-file)) - (modify-dir-local-variable nil - variable - value - (if current-prefix-arg - 'delete - 'add-or-replace)))) - -;;;;;;;;;;;;;;;;;;;;;;;; -;;; Search Project Files - -(defun elpy-rgrep-symbol (regexp) - "Search for REGEXP in the current project. - -REGEXP defaults to the symbol at point, or the current region if -active. - -With a prefix argument, always prompt for a string to search -for." - (interactive - (list - (cond - (current-prefix-arg - (read-from-minibuffer "Search in project for regexp: ")) - ((use-region-p) - (buffer-substring-no-properties (region-beginning) - (region-end))) - (t - (let ((symbol (thing-at-point 'symbol))) - (if symbol - (format "\\<%s\\>" symbol) - (read-from-minibuffer "Search in project for regexp: "))))))) - (grep-compute-defaults) - (let ((grep-find-ignored-directories (append elpy-project-ignored-directories - grep-find-ignored-directories))) - (rgrep regexp - "*.py" - (or (elpy-project-root) - default-directory))) - (with-current-buffer next-error-last-buffer - (let ((inhibit-read-only t)) - (save-excursion - (goto-char (point-min)) - (when (re-search-forward "^find .*" nil t) - (replace-match (format "Searching for '%s'\n" - (regexp-quote regexp)))))))) - -;;;;;;;;;;;;;;;;;;;;;; -;;; Find Project Files - -(defun elpy-find-file (&optional dwim) - "Efficiently find a file in the current project. - -With prefix argument, tries to guess what kind of file the user -wants to open. - -On an import line, it opens the file of that module. - -Otherwise, it opens a test file associated with the current file, -if one exists. A test file is named test_.py if the current -file is .py, and is either in the same directors or a -\"test\" or \"tests\" subdirectory." - (interactive "P") - (cond - ((and dwim - (buffer-file-name) - (save-excursion - (goto-char (line-beginning-position)) - (or (looking-at "^ *import +\\([[:alnum:]._]+\\)") - (looking-at "^ *from +\\([[:alnum:]._]+\\) +import +\\([[:alnum:]._]+\\)")))) - (let* ((module (if (match-string 2) - (format "%s.%s" (match-string 1) (match-string 2)) - (match-string 1))) - (path (elpy-find--resolve-module module))) - (if path - (find-file path) - (elpy-find-file nil)))) - ((and dwim - (buffer-file-name)) - (let ((test-file (elpy-find--test-file))) - (if test-file - (find-file test-file) - (elpy-find-file nil)))) - (t - (let ((ffip-prune-patterns elpy-project-ignored-directories) - (ffip-project-root (elpy-project-root)) - ;; Set up ido to use vertical file lists. - (ido-decorations '("\n" "" "\n" "\n..." - "[" "]" " [No match]" " [Matched]" - " [Not readable]" " [Too big]" - " [Confirm]")) - (ido-setup-hook (cons (lambda () - (define-key ido-completion-map (kbd "") - 'ido-next-match) - (define-key ido-completion-map (kbd "") - 'ido-prev-match)) - ido-setup-hook))) - (find-file-in-project))))) - -(defun elpy-find--test-file () - "Return the test file for the current file, if any. - -If this is a test file, return the non-test file. - -A test file is named test_.py if the current file is -.py, and is either in the same directors or a \"test\" or -\"tests\" subdirectory." - (catch 'return - (let (full-name directory file) - (setq full-name (buffer-file-name)) - (when (not full-name) - (throw 'return nil)) - (setq full-name (expand-file-name full-name) - directory (file-name-directory full-name) - file (file-name-nondirectory full-name)) - (if (string-match "^test_" file) - (let ((file (substring file 5))) - (dolist (implementation (list (format "%s/%s" directory file) - (format "%s/../%s" directory file))) - (when (file-exists-p implementation) - (throw 'return implementation)))) - (dolist (test (list (format "%s/test_%s" directory file) - (format "%s/test/test_%s" directory file) - (format "%s/tests/test_%s" directory file) - (format "%s/../test/test_%s" directory file) - (format "%s/../tests/test_%s" directory file))) - (when (file-exists-p test) - (throw 'return test))))))) - -(defun elpy-find--module-path (module) - "Return a directory path for MODULE. - -The resulting path is not guaranteed to exist. This simply -resolves leading periods relative to the current directory and -replaces periods in the middle of the string with slashes. - -Only works with absolute imports. Stop using implicit relative -imports. They're a bad idea." - (let* ((relative-depth (when(string-match "^\\.+" module) - (length (match-string 0 module)))) - (base-directory (if relative-depth - (format "%s/%s" - (buffer-file-name) - (mapconcat (lambda (_) - "../") - (make-vector relative-depth - nil) - "")) - (elpy-library-root))) - (file-name (replace-regexp-in-string - "\\." - "/" - (if relative-depth - (substring module relative-depth) - module)))) - (expand-file-name (format "%s/%s" base-directory file-name)))) - -(defun elpy-find--resolve-module (module) - "Resolve MODULE relative to the current file and project. - -Returns a full path name for that module." - (catch 'return - (let ((path (elpy-find--module-path module))) - (while (string-prefix-p (expand-file-name (elpy-library-root)) - path) - (dolist (name (list (format "%s.py" path) - (format "%s/__init__.py" path))) - (when (file-exists-p name) - (throw 'return name))) - (if (string-match "/$" path) - (setq path (substring path 0 -1)) - (setq path (file-name-directory path))))) - nil)) - -;;;;;;;;;;;;;;;;;;;;; -;;; Interactive Shell - -(defun elpy-use-ipython (&optional ipython) - "Set defaults to use IPython instead of the standard interpreter. - -With prefix arg, prompt for the command to use." - (interactive (list (when current-prefix-arg - (read-file-name "IPython command: ")))) - (when (not ipython) - (setq ipython "ipython")) - (cond - ;; Emacs 24 until 24.3 - ((boundp 'python-python-command) - (setq python-python-command ipython)) - ;; Emacs 24.3 - ((and (version<= "24.3" emacs-version) - (not (boundp 'python-shell-interpreter-interactive-arg))) - ;; This is from the python.el commentary. - ;; Settings for IPython 0.11: - (setq python-shell-interpreter ipython - python-shell-interpreter-args "" - python-shell-prompt-regexp "In \\[[0-9]+\\]: " - python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " - python-shell-completion-setup-code - "from IPython.core.completerlib import module_completion" - python-shell-completion-module-string-code - "';'.join(module_completion('''%s'''))\n" - python-shell-completion-string-code - "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")) - ;; Emacs 24.4 - ((boundp 'python-shell-interpreter-interactive-arg) - (setq python-shell-interpreter ipython - python-shell-interpreter-args "-i")) - (t - (error "I don't know how to set ipython settings for this Emacs")))) - -(defun elpy-use-cpython (&optional cpython) - "Set defaults to use the standard interpreter instead of IPython. - -With prefix arg, prompt for the command to use." - (interactive (list (when current-prefix-arg - (read-file-name "Python command: ")))) - (when (not cpython) - (setq cpython "python")) - (cond - ;; Emacs 24 until 24.3 - ((boundp 'python-python-command) - (setq python-python-command cpython)) - ;; Emacs 24.3 and onwards. - ((and (version<= "24.3" emacs-version) - (not (boundp 'python-shell-interpreter-interactive-arg))) - (setq python-shell-interpreter cpython - python-shell-interpreter-args "-i" - python-shell-prompt-regexp ">>> " - python-shell-prompt-output-regexp "" - python-shell-completion-setup-code -"try: - import readline -except ImportError: - def __COMPLETER_all_completions(text): [] -else: - import rlcompleter - readline.set_completer(rlcompleter.Completer().complete) - def __COMPLETER_all_completions(text): - import sys - completions = [] - try: - i = 0 - while True: - res = readline.get_completer()(text, i) - if not res: break - i += 1 - completions.append(res) - except NameError: - pass - return completions" - python-shell-completion-module-string-code "" - python-shell-completion-string-code - "';'.join(__COMPLETER_all_completions('''%s'''))\n")) - ;; Emacs 24.4 - ((boundp 'python-shell-interpreter-interactive-arg) - (setq python-shell-interpreter cpython - python-shell-interpreter-args "-i")) - (t - (error "I don't know how to set ipython settings for this Emacs")))) - -(defun elpy-shell-send-region-or-buffer (&optional arg) - "Send the active region or the buffer to the Python shell. - -If there is an active region, send that. Otherwise, send the -whole buffer. - -In Emacs 24.3 and later, without prefix argument, this will -escape the Python idiom of if __name__ == '__main__' to be false -to avoid accidental execution of code. With prefix argument, this -code is executed." - (interactive "P") - ;; Ensure process exists - (elpy-shell-get-or-create-process) - (let ((if-main-regex "^if +__name__ +== +[\"']__main__[\"'] *:") - (has-if-main nil)) - (if (use-region-p) - (let ((region (elpy-shell--region-without-indentation - (region-beginning) (region-end)))) - (setq has-if-main (string-match if-main-regex region)) - (python-shell-send-string region)) - (save-excursion - (goto-char (point-min)) - (setq has-if-main (re-search-forward if-main-regex nil t))) - (python-shell-send-buffer arg)) - (display-buffer (process-buffer (elpy-shell-get-or-create-process)) - nil - 'visible) - (when has-if-main - (message (concat "Removed if __main__ == '__main__' construct, " - "use a prefix argument to evaluate."))))) - -(defun elpy-shell-switch-to-shell () - "Switch to inferior Python process buffer." - (interactive) - (pop-to-buffer (process-buffer (elpy-shell-get-or-create-process)))) - -(defun elpy-shell-get-or-create-process () - "Get or create an inferior Python process for current buffer and return it." - (let* ((bufname (format "*%s*" (python-shell-get-process-name nil))) - (proc (get-buffer-process bufname))) - (if proc - proc - (run-python (python-shell-parse-command)) - (get-buffer-process bufname)))) - -(defun elpy-shell--region-without-indentation (beg end) - "Return the current region as a string, but without indentation." - (if (= beg end) - "" - (let ((region (buffer-substring beg end)) - (indent-level nil)) - (with-temp-buffer - (insert region) - (goto-char (point-min)) - (while (< (point) (point-max)) - (cond - ((and (not indent-level) - (not (looking-at "[ \t]*$"))) - (setq indent-level (current-indentation))) - ((and indent-level - (not (looking-at "[ \t]*$")) - (< (current-indentation) - indent-level)) - (error "Can't adjust indentation, consecutive lines indented less than starting line"))) - (forward-line)) - (indent-rigidly (point-min) - (point-max) - (- indent-level)) - (buffer-string))))) - -;;;;;;;;;;;;;;;;; -;;; Syntax Checks - -(defun elpy-check (&optional whole-project-p) - "Run `python-check-command' on the current buffer's file, - -or the project root if WHOLE-PROJECT-P is non-nil (interactively, -with a prefix argument)." - (interactive "P") - (when (not (buffer-file-name)) - (error "Can't check a buffer without a file.")) - (save-some-buffers (not compilation-ask-about-save) nil) - (let ((process-environment (python-shell-calculate-process-environment)) - (exec-path (python-shell-calculate-exec-path)) - (file-name-or-directory (expand-file-name - (if whole-project-p - (or (elpy-project-root) - (buffer-file-name)) - (buffer-file-name)))) - (extra-args (if whole-project-p - (concat " --exclude=" - (mapconcat #'identity - elpy-project-ignored-directories - ",")) - ""))) - (compilation-start (concat python-check-command - " " - (shell-quote-argument file-name-or-directory) - extra-args) - nil - (lambda (mode-name) - "*Python Check*")))) - -;;;;;;;;;;;;;; -;;; Navigation - -(defun elpy-goto-definition () - "Go to the definition of the symbol at point, if found." - (interactive) - (let ((location (elpy-rpc-get-definition))) - (if location - (elpy-goto-location (car location) (cadr location)) - (error "No definition found")))) - -(defun elpy-goto-location (filename offset) - "Show FILENAME at OFFSET to the user." - (ring-insert find-tag-marker-ring (point-marker)) - (let ((buffer (find-file filename))) - (with-current-buffer buffer - (with-selected-window (get-buffer-window buffer) - (goto-char (1+ offset)))))) - -(defun elpy-nav-forward-block () - "Move to the next line indented like point. - -This will skip over lines and statements with different -indentation levels." - (interactive) - (let ((indent (current-column)) - (start (point))) - (when (/= (% indent python-indent-offset) - 0) - (setq indent (* (1+ (/ indent python-indent-offset)) - python-indent-offset))) - (python-nav-forward-statement) - (while (and (< indent (current-indentation)) - (not (eobp))) - (python-nav-forward-statement)) - (when (< (current-indentation) - indent) - (goto-char start)))) - -(defun elpy-nav-backward-block () - "Move to the previous line indented like point. - -This will skip over lines and statements with different -indentation levels." - (interactive) - (let ((indent (current-column)) - (start (point))) - (when (/= (% indent python-indent-offset) - 0) - (setq indent (* (1+ (/ indent python-indent-offset)) - python-indent-offset))) - (python-nav-backward-statement) - (while (and (< indent (current-indentation)) - (not (bobp))) - (python-nav-backward-statement)) - (when (< (current-indentation) - indent) - (goto-char start)))) - -(defun elpy-nav-forward-indent () - "Move forward to the next indent level, or over the next word." - (interactive) - (if (< (current-column) (current-indentation)) - (let* ((current (current-column)) - (next (* (1+ (/ current python-indent-offset)) - python-indent-offset))) - (goto-char (+ (point-at-bol) - next))) - (let ((eol (point-at-eol))) - (forward-word) - (when (> (point) eol) - (goto-char (point-at-bol)))))) - -(defun elpy-nav-backward-indent () - "Move backward to the previous indent level, or over the previous word." - (interactive) - (if (and (<= (current-column) (current-indentation)) - (/= (current-column) 0)) - (let* ((current (current-column)) - (next (* (1- (/ current python-indent-offset)) - python-indent-offset))) - (goto-char (+ (point-at-bol) - next))) - (backward-word))) - -(defun elpy-nav--iblock (direction skip) - "Move point forward, skipping lines indented more than the current one. - -DIRECTION should be 1 or -1 for forward or backward. - -SKIP should be #'> to skip lines with larger indentation or #'< -to skip lines with smaller indentation." - (let ((start-indentation (current-indentation))) - (python-nav-forward-statement direction) - (while (and (not (eobp)) - (not (bobp)) - (or (looking-at "^\\s-*$") - (funcall skip - (current-indentation) - start-indentation))) - (python-nav-forward-statement direction)))) - -(defun elpy-nav-move-iblock-down (&optional beg end) - "Move the current indentation block below the next one. - -With an active region, move that instead of the current block. - -An indentation block is a block indented further than the current -one." - (interactive "r") - (let ((use-region (use-region-p)) - (startm (make-marker)) - (starti nil) - (midm (make-marker)) - (midi nil) - (endm (make-marker)) - (deactivate-mark nil)) - (save-excursion - (when use-region - (goto-char beg)) - (set-marker startm (line-beginning-position)) - (setq starti (current-indentation)) - (if use-region - (progn - (goto-char end) - (when (> (current-column) - 0) - (forward-line 1))) - (elpy-nav--iblock 1 #'>)) - (set-marker midm (line-beginning-position)) - (setq midi (current-indentation)) - (elpy-nav--iblock 1 #'>) - (goto-char (line-beginning-position)) - (when (<= (current-indentation) - starti) - (when (/= (skip-chars-backward "[:space:]\n") 0) - (forward-line 1))) - (when (and (= midm (point)) - (/= (point) - (line-end-position)) - (= (line-end-position) - (point-max))) - (goto-char (point-max)) - (insert "\n")) - (set-marker endm (line-beginning-position))) - (when (and (/= startm midm) - (/= midm endm) - (/= startm endm) - (= starti midi)) - (goto-char endm) - (insert (buffer-substring startm midm)) - (when use-region - (set-mark (point))) - (delete-region startm midm) - (goto-char endm) - (back-to-indentation)))) - -(defun elpy-nav-move-iblock-up (&optional beg end) - "Move the current indentation block below the next one. - -With an active region, move that instead of the current block. - -An indentation block is a block indented further than the current -one." - (interactive "r") - (let ((use-region (use-region-p)) - (startm (make-marker)) - (starti nil) - (midm (make-marker)) - (midi nil) - (endm (make-marker)) - (deactivate-mark nil)) - (save-excursion - (when use-region - (goto-char beg)) - (set-marker startm (line-beginning-position)) - (setq starti (current-indentation)) - (if use-region - (progn - (goto-char end) - (when (> (current-column) - 0) - (forward-line 1))) - (elpy-nav--iblock 1 #'>) - (cond - ((and (save-excursion - (goto-char (line-end-position)) - (and (> (current-column) 0) - (= (point-max) (point))))) - (goto-char (line-end-position)) - (insert "\n")) - ((< (current-indentation) - starti) - (when (/= (skip-chars-backward "[:space:]\n") 0) - (forward-line 1))))) - (set-marker midm (line-beginning-position)) - (goto-char startm) - (elpy-nav--iblock -1 #'>) - (goto-char (line-beginning-position)) - (set-marker endm (line-beginning-position)) - (setq midi (current-indentation))) - (when (and (/= startm midm) - (/= midm endm) - (/= startm endm) - (= starti midi)) - (goto-char endm) - (insert (buffer-substring startm midm)) - (when use-region - (set-mark (point))) - (delete-region startm midm) - (goto-char endm) - (back-to-indentation)))) - -(defun elpy-nav-move-iblock-left () - "Dedent the current indentation block, or the active region." - (interactive) - (let (beg end) - (if (use-region-p) - (setq beg (region-beginning) - end (region-end)) - (save-excursion - (setq beg (line-beginning-position)) - (elpy-nav--iblock 1 #'>) - (setq end (line-beginning-position)))) - (python-indent-shift-left beg end))) - -(defun elpy-nav-move-iblock-right () - "Indent the current indentation block, or the active region." - (interactive) - (let (beg end) - (if (use-region-p) - (setq beg (region-beginning) - end (region-end)) - (save-excursion - (setq beg (line-beginning-position)) - (elpy-nav--iblock 1 #'>) - (setq end (line-beginning-position)))) - (python-indent-shift-right beg end))) - -(defun elpy-open-and-indent-line-below () - "Open a line below the current one, move there, and indent." - (interactive) - (move-end-of-line 1) - (newline-and-indent)) - -(defun elpy-open-and-indent-line-above () - "Open a line above the current one, move there, and indent." - (interactive) - (move-beginning-of-line 1) - (save-excursion - (insert "\n")) - (indent-according-to-mode)) - -;;;;;;;;;;;;;;;; -;;; Test running - -(defvar elpy-set-test-runner-history nil - "History variable for `elpy-set-test-runner'.") - -(defun elpy-test (&optional test-whole-project) - "Run tests on the current test, or the whole project. - -If there is a test at point, run that test. If not, or if a -prefix is given, run all tests in the current project." - (interactive "P") - (let ((current-test (elpy-test-at-point))) - (if test-whole-project - ;; With prefix arg, test the whole project. - (funcall elpy-test-runner - (car current-test) - nil nil nil) - ;; Else, run only this test - (apply elpy-test-runner current-test)))) - -(defun elpy-set-test-runner (test-runner) - "Tell Elpy to use TEST-RUNNER to run tests. - -See `elpy-test' for how to invoke it." - (interactive - (list - (let* ((runners (mapcar (lambda (value) - (cons (nth 2 value) - (nth 3 value))) - (cdr (get 'elpy-test-runner 'custom-type)))) - (current (cdr (assq elpy-test-runner - (mapcar (lambda (cell) - (cons (cdr cell) (car cell))) - runners)))) - (choice (completing-read (if current - (format "Test runner (currently %s): " - current) - "Test runner: ") - runners - nil t nil 'elpy-set-test-runner-history))) - (if (equal choice "") - elpy-test-runner - (cdr (assoc choice runners)))))) - (setq elpy-test-runner test-runner)) - -(defun elpy-test-at-point () - "Return a list specifying the test at point, if any. - -This is used as the interactive - -This list has four elements. - -- Top level directory: - All test files should be importable from here. -- Test file: - The current file name. -- Test module: - The module name, relative to the top level directory. -- Test name: - The full name of the current test within the module, for - example TestClass.test_method - -If there is no test at point, test name is nil. -If the current buffer is not visiting a file, only the top level -directory is not nil." - (if (not buffer-file-name) - (progn - (save-some-buffers) - (list (elpy-library-root) nil nil nil)) - (let* ((top (elpy-library-root)) - (file buffer-file-name) - (module (elpy-test--module-name-for-file top file)) - (test (python-info-current-defun))) - (if (and file (string-match "/test[^/]*$" file)) - (progn - (save-buffer) - (list top file module test)) - (save-some-buffers) - (list top nil nil nil))))) - -(defun elpy-test--module-name-for-file (top-level module-file) - "Return the module name relative to TOP-LEVEL for MODULE-FILE. - -For example, for a top level of /project/root/ and a module file -of /project/root/package/module.py, this would return -\"package.module\"." - (let* ((relative-name (file-relative-name module-file top-level)) - (no-extension (replace-regexp-in-string "\\.py\\'" "" relative-name)) - (no-init (replace-regexp-in-string "/__init__\\'" "" no-extension)) - (dotted (replace-regexp-in-string "/" "." no-init))) - (if (string-match "^\\." dotted) - (concat "." (replace-regexp-in-string (regexp-quote "...") "." dotted)) - dotted))) - -(defun elpy-test-runner-p (obj) - "Return t iff OBJ is a test runner. - -This uses the `elpy-test-runner-p' symbol property." - (get obj 'elpy-test-runner-p)) - -(defun elpy-test-run (working-directory command &rest args) - "Run COMMAND with ARGS in WORKING-DIRECTORY as a test command." - (let ((default-directory working-directory)) - (compile (mapconcat #'shell-quote-argument - (cons command args) - " ")))) - -(defun elpy-test-discover-runner (top file module test) - "Test the project using the python unittest discover runner. - -This requires Python 2.7 or later." - (interactive (elpy-test-at-point)) - (let ((test (cond - (test (format "%s.%s" module test)) - (module module) - (t "discover")))) - (apply #'elpy-test-run - top - (append elpy-test-discover-runner-command - (list test))))) -(put 'elpy-test-discover-runner 'elpy-test-runner-p t) - -(defun elpy-test-django-runner (top file module test) - "Test the project using the Django discover runner. - -This requires Django 1.6 or the django-discover-runner package." - (interactive (elpy-test-at-point)) - (if module - (apply #'elpy-test-run - top - (append elpy-test-django-runner-command - (list (if test - (format "%s.%s" module test) - module)))) - (apply #'elpy-test-run - top - elpy-test-django-runner-command))) -(put 'elpy-test-django-runner 'elpy-test-runner-p t) - -(defun elpy-test-nose-runner (top file module test) - "Test the project using the nose test runner. - -This requires the nose package to be installed." - (interactive (elpy-test-at-point)) - (if module - (apply #'elpy-test-run - top - (append elpy-test-nose-runner-command - (list (if test - (format "%s:%s" module test) - module)))) - (apply #'elpy-test-run - top - elpy-test-nose-runner-command))) -(put 'elpy-test-nose-runner 'elpy-test-runner-p t) - -(defun elpy-test-trial-runner (top file module test) - "Test the project using Twisted's Trial test runner. - -This requires the twisted-core package to be installed." - (interactive (elpy-test-at-point)) - (if module - (apply #'elpy-test-run - top - (append elpy-test-trial-runner-command - (list (if test - (format "%s.%s" module test) - module)))) - (apply #'elpy-test-run top elpy-test-trial-runner-command))) -(put 'elpy-test-trial-runner 'elpy-test-runner-p t) - -(defun elpy-test-pytest-runner (top file module test) - "Test the project using the py.test test runner. - -This requires the pytest package to be installed." - (interactive (elpy-test-at-point)) - (cond - (test - (let ((test-list (split-string test "\\."))) - (apply #'elpy-test-run - top - (append elpy-test-pytest-runner-command - (list (mapconcat #'identity - (cons file test-list) - "::")))))) - (module - (apply #'elpy-test-run top (append elpy-test-pytest-runner-command - (list file)))) - (t - (apply #'elpy-test-run top elpy-test-pytest-runner-command)))) -(put 'elpy-test-pytest-runner 'elpy-test-runner-p t) - -;;;;;;;;;;;;;;;;; -;;; Documentation - -(defvar elpy-doc-history nil - "History for the `elpy-doc' command.") - -(defun elpy-doc () - "Show documentation for the symbol at point. - -If there is no documentation for the symbol at point, or if a -prefix argument is given, prompt for a symbol from the user." - (interactive) - (let ((symbol-at-point nil) - (doc nil)) - (when (not current-prefix-arg) - (setq doc (elpy-rpc-get-docstring)) - (when (not doc) - (save-excursion - (python-nav-backward-up-list) - (setq doc (elpy-rpc-get-docstring)))) - (when (not doc) - (setq doc (elpy-rpc-get-pydoc-documentation - (elpy-doc--symbol-at-point)))) - (when (not doc) - (save-excursion - (python-nav-backward-up-list) - (setq doc (elpy-rpc-get-pydoc-documentation - (elpy-doc--symbol-at-point)))))) - (when (not doc) - (setq doc (elpy-rpc-get-pydoc-documentation - (elpy-doc--read-identifier-from-minibuffer - (elpy-doc--symbol-at-point))))) - (if doc - (elpy-doc--show doc) - (error "No documentation found.")))) - -(defun elpy-doc--read-identifier-from-minibuffer (initial) - "Read a pydoc-able identifier from the minibuffer." - (completing-read "Pydoc for: " - (completion-table-dynamic #'elpy-rpc-get-pydoc-completions) - nil nil initial 'elpy-doc-history)) - -(defun elpy-doc--show (documentation) - "Show DOCUMENTATION to the user, replacing ^H with bold." - (with-help-window "*Python Doc*" - (with-current-buffer "*Python Doc*" - (erase-buffer) - (insert documentation) - (goto-char (point-min)) - (while (re-search-forward "\\(.\\)\\1" nil t) - (replace-match (propertize (match-string 1) - 'face 'bold) - t t))))) - -(defun elpy-doc--symbol-at-point () - "Return the Python symbol at point, including dotted paths." - (with-syntax-table python-dotty-syntax-table - (let ((symbol (symbol-at-point))) - (if symbol - (symbol-name symbol) - nil)))) - -;;;;;;;;;;;;;; -;;; Import manipulation - -(defun elpy-importmagic--replace-block (spec) - "Replace an imports block. SPEC is (startline endline newblock)." - (let ((start-line (nth 0 spec)) - (end-line (nth 1 spec)) - (new-block (nth 2 spec))) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (forward-line start-line) - (let ((beg (point)) - (end (progn (forward-line (- end-line start-line)) (point)))) - ;; Avoid deleting and re-inserting when the blocks are equal. - (unless (string-equal (buffer-substring beg end) new-block) - (delete-region beg end) - (insert new-block))))))) - -(defun elpy-importmagic--add-import-read-args (&optional object prompt) - (let* ((default-object (save-excursion - (let ((bounds (with-syntax-table python-dotty-syntax-table - (bounds-of-thing-at-point 'symbol)))) - (if bounds (buffer-substring (car bounds) (cdr bounds)) "")))) - (object-to-import (or object (read-string "Object to import: " default-object))) - (possible-imports (elpy-rpc "get_import_symbols" (list buffer-file-name - (elpy-rpc--buffer-contents) - object-to-import))) - (statement-prompt (or prompt "New import statement: "))) - (cond - ;; An elpy warning (i.e. index not ready) is returned as a string. - ((stringp possible-imports) - (list "")) - ;; If there is no candidate, we exit immediately. - ((null possible-imports) - (message "No import candidate found") - (list "")) - ;; We have some candidates, let the user choose one. - (t - (let ((first-choice (car possible-imports)) - (user-choice (completing-read statement-prompt possible-imports))) - (list (if (equal user-choice "") first-choice user-choice))))))) - -(defun elpy-importmagic-add-import (statement) - (interactive (elpy-importmagic--add-import-read-args)) - (unless (equal statement "") - (let* ((res (elpy-rpc "add_import" (list buffer-file-name - (elpy-rpc--buffer-contents) - statement)))) - (elpy-importmagic--replace-block res)))) - -(defun elpy-importmagic-fixup () - "Query for new imports of unresolved symbols, and remove unreferenced imports. - -Also sort the imports in the import statement blocks." - (interactive) - ;; get all unresolved names, and interactively add imports for them - (let* ((res (elpy-rpc "get_unresolved_symbols" (list buffer-file-name - (elpy-rpc--buffer-contents))))) - (unless (stringp res) - (if (null res) (message "No imports to add.")) - (dolist (object res) - (let* ((prompt (format "How to import \"%s\": " object)) - (choice (elpy-importmagic--add-import-read-args object prompt))) - (elpy-importmagic-add-import (car choice)))))) - ;; now get a new import statement block (this also sorts) - (let* ((res (elpy-rpc "remove_unreferenced_imports" (list buffer-file-name - (elpy-rpc--buffer-contents))))) - (unless (stringp res) - (elpy-importmagic--replace-block res)))) - -;;;;;;;;;;;;;; -;;; Multi-Edit - -(defvar elpy-multiedit-overlays nil - "List of overlays currently being edited.") - -(defun elpy-multiedit-add-overlay (beg end) - "Add an editable overlay between BEG and END. - -A modification in any of these overlays will modify all other -overlays, too." - (interactive "r") - (when (elpy-multiedit--overlays-in-p beg end) - (error "Overlapping multiedit overlays are not allowed")) - (let ((ov (make-overlay beg end nil nil :rear-advance))) - (overlay-put ov 'elpy-multiedit t) - (overlay-put ov 'face 'highlight) - (overlay-put ov 'modification-hooks '(elpy-multiedit--overlay-changed)) - (overlay-put ov 'insert-in-front-hooks '(elpy-multiedit--overlay-changed)) - (overlay-put ov 'insert-behind-hooks '(elpy-multiedit--overlay-changed)) - (push ov elpy-multiedit-overlays))) - -(defun elpy-multiedit--overlays-in-p (beg end) - "Return t iff there are multiedit overlays between beg and end." - (catch 'return - (dolist (ov (overlays-in beg end)) - (when (overlay-get ov 'elpy-multiedit) - (throw 'return t))) - nil)) - -(defun elpy-multiedit-stop () - "Stop editing multiple places at once." - (interactive) - (dolist (ov elpy-multiedit-overlays) - (delete-overlay ov)) - (setq elpy-multiedit-overlays nil)) - -(defun elpy-multiedit--overlay-changed (ov after-change beg end - &optional pre-change-length) - "Called for each overlay that changes. - -This updates all other overlays." - (when (and after-change - (not undo-in-progress) - (overlay-buffer ov)) - (let ((text (buffer-substring (overlay-start ov) - (overlay-end ov))) - (inhibit-modification-hooks t)) - (dolist (other-ov elpy-multiedit-overlays) - (when (and (not (equal other-ov ov)) - (buffer-live-p (overlay-buffer other-ov))) - (with-current-buffer (overlay-buffer other-ov) - (save-excursion - (goto-char (overlay-start other-ov)) - (insert text) - (delete-region (point) (overlay-end other-ov))))))))) - -(defun elpy-multiedit () - "Edit all occurences of the symbol at point, or the active region. - -If multiedit is active, stop it." - (interactive) - (if elpy-multiedit-overlays - (elpy-multiedit-stop) - (let ((regex (if (use-region-p) - (regexp-quote (buffer-substring (region-beginning) - (region-end))) - (format "\\_<%s\\_>" (regexp-quote - (symbol-name - (symbol-at-point)))))) - (case-fold-search nil)) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward regex nil t) - (elpy-multiedit-add-overlay (match-beginning 0) - (match-end 0))))))) - -(defun elpy-multiedit-python-symbol-at-point (&optional use-symbol-p) - "Edit all usages of the the Python symbol at point. - -With prefix arg, edit all syntactic usages of the symbol at -point. This might include unrelated symbols that just share the -name." - (interactive "P") - (if (or elpy-multiedit-overlays - use-symbol-p - (use-region-p)) - ;; If we are already doing a multiedit, or are explicitly told - ;; to use the symbol at point, or if we are on an active region, - ;; call the multiedit function that does just that already. - (call-interactively 'elpy-multiedit) - ;; Otherwise, fetch usages from backend. - (save-some-buffers) - (let ((usages (condition-case err - (elpy-rpc-get-usages) - ;; This is quite the stunt, but elisp parses JSON - ;; null as nil, which is indistinguishable from - ;; the empty list, we stick to the error. - (error - (if (and (eq (car err) 'error) - (stringp (cadr err)) - (string-match "not implemented" (cadr err))) - 'not-supported - (error (cadr err))))))) - (cond - ((eq usages 'not-supported) - (call-interactively 'elpy-multiedit) - (message (concat "Using syntactic editing " - "as current backend does not support get_usages."))) - ((null usages) - (call-interactively 'elpy-multiedit) - (if elpy-multiedit-overlays - (message (concat "Using syntactic editing as no usages of the " - "symbol at point were found by the backend.")) - (message "No occurrences of the symbol at point found"))) - (t - (elpy-multiedit--usages usages)))))) - -(defun elpy-multiedit--usages (usages) - "Mark the usages in USAGES for editing." - (let ((name nil) - (locations (make-hash-table :test #'equal))) - (dolist (usage usages) - (let* ((filename (cdr (assq 'filename usage))) - (this-name (cdr (assq 'name usage))) - (offset (cdr (assq 'offset usage)))) - (setq name this-name) - (with-current-buffer (if filename - (find-file-noselect filename) - (current-buffer)) - (elpy-multiedit-add-overlay (+ offset 1) - (+ offset 1 (length this-name))) - (save-excursion - (goto-char (+ offset 1)) - (puthash filename - (cons (list offset - (buffer-substring (line-beginning-position) - (line-end-position)) - (- (point) - (line-beginning-position)) - (- (+ (point) (length this-name)) - (line-beginning-position))) - (gethash filename locations)) - locations))))) - (if (<= (hash-table-count locations) - 1) - (message "Editing %s usages of '%s' in this buffer" - (length usages) name) - (with-current-buffer (get-buffer-create "*Elpy Edit Usages*") - (let ((inhibit-read-only t) - (filenames nil)) - (erase-buffer) - (elpy-insert--para - "The symbol '" name "' was found in multiple files. Editing " - "all locations:\n\n") - (maphash (lambda (key value) - (when (not (member key filenames)) - (setq filenames (cons key filenames)))) - locations) - (dolist (filename (sort filenames #'string<)) - (elpy-insert--header filename) - (dolist (location (sort (gethash filename locations) - (lambda (loc1 loc2) - (< (car loc1) - (car loc2))))) - (let ((line (nth 1 location)) - (start (+ (line-beginning-position) - (nth 2 location))) - (end (+ (line-end-position) - (nth 3 location)))) - ;; Insert the \n first, else we extend the overlay. - (insert line "\n") - (elpy-multiedit-add-overlay start end))) - (insert "\n")) - (goto-char (point-min)) - (display-buffer (current-buffer) - nil - 'visible)))))) - -;;;;;;;;;;;;;;;;;;;;; -;;; Occur Definitions - -(defun elpy-occur-definitions () - "Display an occur buffer of all definitions in the current buffer. - -Also, switch to that buffer." - (interactive) - (let ((list-matching-lines-face nil)) - (occur "^ *\\(def\\|class\\) ")) - (let ((window (get-buffer-window "*Occur*"))) - (if window - (select-window window) - (switch-to-buffer "*Occur*")))) - -;;;;;;;;;;;;;;;;;;; -;;; Promise objects - -(defvar elpy-promise-marker (make-symbol "*elpy-promise*") - "An uninterned symbol marking an Elpy promise object.") - -(defun elpy-promise (success &optional error) - "Return a new promise. - -A promise is an object with a success and error callback. If the -promise is resolved using `elpy-promise-resolve', its success -callback is called with the given value. The current buffer is -restored, too. - -If the promise is rejected using `elpy-promise-reject', its error -callback is called. For this function, the current buffer is not -necessarily restored, as it is also called when the buffer does -not exist anymore." - (vector elpy-promise-marker ; 0 id - success ; 1 success-callback - error ; 2 error-callback - (current-buffer) ; 3 current-buffer - nil ; 4 run - )) - -(defun elpy-promise-p (obj) - "Return non-nil if the argument is a promise object." - (and (vectorp obj) - (= (length obj) 5) - (eq (aref obj 0) elpy-promise-marker))) - -(defsubst elpy-promise-success-callback (promise) - "Return the success callback for PROMISE." - (aref promise 1)) - -(defsubst elpy-promise-error-callback (promise) - "Return the error callback for PROMISE." - (aref promise 2)) - -(defsubst elpy-promise-buffer (promise) - "Return the buffer for PROMISE." - (aref promise 3)) - -(defsubst elpy-promise-resolved-p (promise) - "Return non-nil if the PROMISE has been resolved or rejected." - (aref promise 4)) - -(defsubst elpy-promise-set-resolved (promise) - "Mark PROMISE as having been resolved." - (aset promise 4 t)) - -(defun elpy-promise-resolve (promise value) - "Resolve PROMISE with VALUE." - (when (not (elpy-promise-resolved-p promise)) - (unwind-protect - (let ((success-callback (elpy-promise-success-callback promise))) - (when success-callback - (condition-case err - (with-current-buffer (elpy-promise-buffer promise) - (funcall success-callback value)) - (error - (elpy-promise-reject promise err))))) - (elpy-promise-set-resolved promise)))) - -(defun elpy-promise-reject (promise reason) - "Reject PROMISE because of REASON." - (when (not (elpy-promise-resolved-p promise)) - (unwind-protect - (let ((error-callback (elpy-promise-error-callback promise))) - (when error-callback - (if (buffer-live-p (elpy-promise-buffer promise)) - (with-current-buffer (elpy-promise-buffer promise) - (funcall error-callback reason)) - (with-temp-buffer - (funcall error-callback reason))))) - (elpy-promise-set-resolved promise)))) - -(defun elpy-promise-wait (promise &optional timeout) - "Wait for PROMISE to be resolved, for up to TIMEOUT seconds. - -This will accept process output while waiting. - -This will wait for the current Elpy RPC process specifically, as -Emacs currently has a bug where it can wait for the entire time -of the timeout, even if output arrives. - -See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17647" - (let ((end-time (when timeout - (time-add (current-time) - (seconds-to-time timeout)))) - (process (get-buffer-process (elpy-rpc--get-rpc-buffer)))) - (while (and (not (elpy-promise-resolved-p promise)) - (or (not end-time) - (time-less-p (current-time) - end-time))) - (accept-process-output process timeout)))) - -;;;;;;; -;;; RPC - -;; elpy-rpc is a simple JSON-based RPC protocol. It's mostly JSON-RPC -;; 1.0, except we do not implement the full protocol as we do not need -;; all the features. Emacs starts a Python subprocess which runs a -;; special module. The module reads JSON-RPC requests and responds -;; with JSON-RPC responses. - -(defvar elpy-rpc--call-id 0 - "Call id of the last elpy-rpc call. - -Used to associate responses to callbacks.") -(make-variable-buffer-local 'elpy-rpc--call-id) - -(defvar elpy-rpc--buffer-p nil - "True iff the current buffer is an elpy-rpc buffer.") -(make-variable-buffer-local 'elpy-rpc--buffer-p) - -(defvar elpy-rpc--buffer nil - "The elpy-rpc buffer associated with this buffer.") -(make-variable-buffer-local 'elpy-rpc--buffer) - -(defvar elpy-rpc--backend-library-root nil - "The project root used by this backend.") -(make-variable-buffer-local 'elpy-rpc--backend-library-root) - -(defvar elpy-rpc--backend-python-command nil - "The Python interpreter used by this backend.") -(make-variable-buffer-local 'elpy-rpc--backend-python-command) - -(defvar elpy-rpc--backend-callbacks nil - "The callbacks registered for calls to the current backend. - -This maps call IDs to functions.") -(make-variable-buffer-local 'elpy-rpc--backend-callbacks) - -(defvar elpy-rpc--last-error-popup nil - "The last time an error popup happened.") - -(defun elpy-rpc (method params &optional success error) - "Call METHOD with PARAMS in the backend. - -If SUCCESS and optionally ERROR is given, return immediately and -call those when a result is available. Otherwise, wait for a -result and return that." - (when (not error) - (setq error #'elpy-rpc--default-error-callback)) - (if success - (elpy-rpc--call method params success error) - (elpy-rpc--call-blocking method params))) - -(defun elpy-rpc--call-blocking (method-name params) - "Call METHOD-NAME with PARAMS in the current RPC backend. - -Returns the result, blocking until this arrived." - (let* ((result-arrived nil) - (error-occured nil) - (result-value nil) - (error-object nil) - (promise (elpy-rpc--call method-name params - (lambda (result) - (setq result-value result - result-arrived t)) - (lambda (err) - (setq error-object err - error-occured t))))) - (elpy-promise-wait promise elpy-rpc-timeout) - (cond - (error-occured - (elpy-rpc--default-error-callback error-object)) - (result-arrived - result-value) - (t - (error "Timeout during RPC call %s from backend" - method-name))))) - -(defun elpy-rpc--call (method-name params success error) - "Call METHOD-NAME with PARAMS in the current RPC backend. - -When a result is available, SUCCESS will be called with that -value as its sole argument. If an error occurs, ERROR will be -called with the error list. - -Returns a PROMISE object." - (let ((promise (elpy-promise success error))) - (with-current-buffer (elpy-rpc--get-rpc-buffer) - (setq elpy-rpc--call-id (1+ elpy-rpc--call-id)) - (elpy-rpc--register-callback elpy-rpc--call-id promise) - (process-send-string - (get-buffer-process (current-buffer)) - (concat (json-encode `((id . ,elpy-rpc--call-id) - (method . ,method-name) - (params . ,params))) - "\n"))) - promise)) - -(defun elpy-rpc--register-callback (call-id promise) - "Register for PROMISE to be called when CALL-ID returns. - -Must be called in an elpy-rpc buffer." - (when (not elpy-rpc--buffer-p) - (error "Must be called in RPC buffer")) - (when (not elpy-rpc--backend-callbacks) - (setq elpy-rpc--backend-callbacks (make-hash-table :test #'equal))) - (puthash call-id promise elpy-rpc--backend-callbacks)) - -(defun elpy-rpc--get-rpc-buffer () - "Return the RPC buffer associated with the current buffer, -creating one if necessary." - (when (not (elpy-rpc--process-buffer-p elpy-rpc--buffer)) - (setq elpy-rpc--buffer - (or (elpy-rpc--find-buffer (elpy-library-root) - elpy-rpc-python-command) - (elpy-rpc--open (elpy-library-root) - elpy-rpc-python-command)))) - elpy-rpc--buffer) - -(defun elpy-rpc--process-buffer-p (buffer) - "Return non-nil when BUFFER is a live elpy-rpc process buffer. - -If BUFFER is a buffer for an elpy-rpc process, but the process -died, this will kill the process and buffer." - (cond - ((or (not buffer) - (not (buffer-live-p buffer))) - nil) - ((not (buffer-local-value 'elpy-rpc--buffer-p buffer)) - nil) - ((and (get-buffer-process buffer) - (process-live-p (get-buffer-process buffer))) - t) - (t - (ignore-errors - (kill-process (get-buffer-process buffer))) - (ignore-errors - (kill-buffer buffer)) - nil))) - -(defun elpy-rpc--find-buffer (library-root python-command) - "Return an existing RPC buffer for this project root and command." - (catch 'return - (let ((full-python-command (executable-find python-command))) - (dolist (buf (buffer-list)) - (when (and (elpy-rpc--process-buffer-p buf) - (equal (buffer-local-value 'elpy-rpc--backend-library-root - buf) - library-root) - (equal (buffer-local-value 'elpy-rpc--backend-python-command - buf) - full-python-command)) - (throw 'return buf)))) - nil)) - -(defun elpy-rpc--open (library-root python-command) - "Start a new RPC process and return the associated buffer." - ;; Prevent configuration errors - (when (and elpy-rpc-backend - (not (stringp elpy-rpc-backend))) - (error "`elpy-rpc-backend' should be nil or a string.")) - (let* ((full-python-command (executable-find python-command)) - (name (format " *elpy-rpc [project:%s python:%s]*" - library-root - full-python-command)) - (new-elpy-rpc-buffer (generate-new-buffer name)) - (proc nil)) - (with-current-buffer new-elpy-rpc-buffer - (setq elpy-rpc--buffer-p t - elpy-rpc--buffer (current-buffer) - elpy-rpc--backend-library-root library-root - elpy-rpc--backend-python-command full-python-command - default-directory "/" - proc (condition-case err - (let ((process-connection-type nil) - (process-environment (elpy-rpc--environment))) - (start-process name - (current-buffer) - full-python-command - "-W" "ignore" - "-m" "elpy.__main__")) - (error - (elpy-config-error - "Elpy can't start Python (%s: %s)" - (car err) (cadr err))))) - (set-process-query-on-exit-flag proc nil) - (set-process-sentinel proc #'elpy-rpc--sentinel) - (set-process-filter proc #'elpy-rpc--filter) - (elpy-rpc-init elpy-rpc-backend library-root - (lambda (result) - (let ((backend (cdr (assq 'backend result)))) - (when (and elpy-rpc-backend - (not (equal backend elpy-rpc-backend))) - (elpy-config-error - "Can't set backend %s, using %s instead" - elpy-rpc-backend backend)))))) - new-elpy-rpc-buffer)) - -(defun elpy-rpc--sentinel (process event) - "The sentinel for the RPC process. - -As process sentinels are only ever called when the process -terminates, this will call the error handler of all registered -RPC calls with the event." - (let ((buffer (process-buffer process)) - (err (list 'process-sentinel (substring event 0 -1)))) - (when (and buffer - (buffer-live-p buffer)) - (with-current-buffer buffer - (when elpy-rpc--backend-callbacks - (maphash (lambda (call-id promise) - (ignore-errors - (elpy-promise-reject promise err))) - elpy-rpc--backend-callbacks) - (setq elpy-rpc--backend-callbacks nil)))))) - -(defun elpy-rpc--filter (process output) - "The filter for the RPC process." - (let ((buffer (process-buffer process))) - (when (and buffer - (buffer-live-p buffer)) - (with-current-buffer buffer - (goto-char (point-max)) - (insert output) - (while (progn - (goto-char (point-min)) - (search-forward "\n" nil t)) - (let ((line-end (point)) - (json nil) - (did-read-json nil)) - (goto-char (point-min)) - (condition-case err - (setq json (let ((json-array-type 'list)) - (json-read)) - line-end (1+ (point)) - did-read-json t) - (error - (goto-char (point-min)))) - (cond - (did-read-json - (delete-region (point-min) line-end) - (elpy-rpc--handle-json json)) - ((looking-at "elpy-rpc ready\n") - (replace-match "") - (elpy-rpc--check-backend-version "1.1")) - ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") - (let ((rpc-version (match-string 1))) - (replace-match "") - (elpy-rpc--check-backend-version rpc-version))) - ((looking-at ".*No module named elpy\n") - (replace-match "") - (elpy-config-error "Elpy module not found")) - (t - (let ((line (buffer-substring (point-min) - line-end))) - (delete-region (point-min) line-end) - (elpy-rpc--handle-unexpected-line line)))))))))) - -(defun elpy-rpc--check-backend-version (rpc-version) - "Check that we are using the right version." - (when (not (equal rpc-version elpy-version)) - (elpy-insert--popup "*Elpy Version Mismatch*" - (elpy-insert--header "Elpy Version Mismatch") - (elpy-insert--para - "You are not using the same version of Elpy in Emacs Lisp" - "compared to Python. This can cause random problems. Please" - "do make sure to use compatible versions.\n") - (insert - "\n" - "Elpy Emacs Lisp version: " elpy-version "\n" - "Elpy Python version....: " rpc-version "\n")))) - -(defun elpy-rpc--handle-unexpected-line (line) - "Handle an unexpected line from the backend. - -This is usually an error or backtrace." - (let ((buf (get-buffer "*Elpy Output*"))) - (when (not buf) - (elpy-insert--popup "*Elpy Output*" - (elpy-insert--header "Output from Backend") - (elpy-insert--para - "There was some unexpected output from the Elpy backend. " - "This is usually some module that does not use correct logging, " - "but might indicate a configuration problem.\n\n") - (elpy-insert--header "Output") - (setq buf (current-buffer)))) - (with-current-buffer buf - (goto-char (point-max)) - (let ((inhibit-read-only t)) - (insert line))))) - -(defun elpy-rpc--handle-json (json) - "Handle a single JSON object from the RPC backend." - (let ((call-id (cdr (assq 'id json))) - (error-object (cdr (assq 'error json))) - (result (cdr (assq 'result json)))) - (let ((promise (gethash call-id elpy-rpc--backend-callbacks))) - (when (not promise) - (error "Received a response for unknown call-id %s" call-id)) - (remhash call-id elpy-rpc--backend-callbacks) - (if error-object - (elpy-promise-reject promise error-object) - (elpy-promise-resolve promise result))))) - -(defun elpy-rpc--default-error-callback (error-object) - "Display an error from the RPC backend." - ;; We actually might get an (error "foo") thing here. - (if (and (consp error-object) - (not (consp (car error-object)))) - (signal (car error-object) (cdr error-object)) - (let ((message (cdr (assq 'message error-object))) - (code (cdr (assq 'code error-object))) - (data (cdr (assq 'data error-object)))) - (cond - ((not (numberp code)) - (error "Bad response from RPC: %S" error-object)) - ((< code 300) - (message "Elpy warning: %s" message)) - ((< code 500) - (error "Elpy error: %s" message)) - ((and elpy-rpc-error-timeout - elpy-rpc--last-error-popup - (<= (float-time) - (+ elpy-rpc--last-error-popup - elpy-rpc-error-timeout))) - (message "Elpy error popup ignored, see `elpy-rpc-error-timeout': %s" - message)) - (t - (let ((config (elpy-config--get-config))) - (elpy-insert--popup "*Elpy Error*" - (elpy-insert--header "Elpy Error") - (elpy-insert--para - "The backend encountered an unexpected error. This indicates " - "a bug in Elpy. Please open a bug report with the data below " - "in the Elpy bug tracker:") - (insert "\n" - "\n") - (insert-button - "https://github.com/jorgenschaefer/elpy/issues/new" - 'action (lambda (button) - (browse-url (button-get button 'url))) - 'url "https://github.com/jorgenschaefer/elpy/issues/new") - (insert "\n" - "\n" - "```\n") - (elpy-insert--header "Error Message") - (insert message "\n\n") - (elpy-insert--header "Configuration") - (elpy-config--insert-configuration-table config) - (let ((traceback (cdr (assq 'traceback data)))) - (when traceback - (insert "\n") - (elpy-insert--header "Traceback") - (insert traceback))) - (let ((jedi-info (cdr (assq 'jedi_debug_info data)))) - (when jedi-info - (insert "\n") - (elpy-insert--header "Jedi Debug Information") - (pcase (cdr (assq 'debug_info jedi-info)) - (`nil (insert "Jedi did not emit any debug info.\n")) - (infos - (dolist (outstr infos) - (insert outstr "\n")))) - (insert "\n" - "```\n" - "\n" - "Reproduction:\n" - "\n") - (let ((method (cdr (assq 'method jedi-info))) - (source (cdr (assq 'source jedi-info))) - (script-args (cdr (assq 'script_args jedi-info)))) - (insert "```Python\n") - (insert "import jedi\n" - "\n" - "source = '''\\\n" - source - "'''\n" - "\n" - "script = jedi.Script(" script-args ")\n" - "script." method "()\n")))) - (let ((rope-info (cdr (assq 'rope_debug_info data)))) - (when rope-info - (insert "\n") - (elpy-insert--header "Rope Debug Information") - (insert "```\n" - "\n" - "Reproduction:\n" - "\n") - (let ((project-root (cdr (assq 'project_root rope-info))) - (filename (cdr (assq 'filename rope-info))) - (source (cdr (assq 'source rope-info))) - (function-name (cdr (assq 'function_name rope-info))) - (function-args (cdr (assq 'function_args rope-info)))) - (insert "```Python\n") - (insert "\n" - "source = '''\n" - source - "'''\n" - "\n") - (insert "project = rope.base.project.Project(\n" - (format " %S,\n" project-root) - " ropefolder=None\n" - ")\n") - (insert "resource = rope.base.libutils.path_to_resource(\n" - " project,\n" - (format " %S,\n" filename) - " 'file'\n" - ")\n") - (insert (format "%s(\n %s\n)\n" - function-name function-args))))) - (when (not (= 0 (current-column))) - (insert "\n")) - (insert "```")) - (setq elpy-rpc--last-error-popup (float-time)))))))) - -(defun elpy-rpc--environment () - "Return a `process-environment' for the RPC process. - -This includes `elpy-rpc-pythonpath' in the PYTHONPATH, if set." - (if (or (not elpy-rpc-pythonpath) - (not (file-exists-p (expand-file-name "elpy/__init__.py" - elpy-rpc-pythonpath)))) - process-environment - (let* ((old-pythonpath (getenv "PYTHONPATH")) - (new-pythonpath (if old-pythonpath - (concat elpy-rpc-pythonpath - path-separator - old-pythonpath) - elpy-rpc-pythonpath))) - (cons (concat "PYTHONPATH=" new-pythonpath) - process-environment)))) - -(defun elpy-rpc--buffer-contents () - "Return the contents of the current buffer. - -This returns either a string, or a file object for the RPC -protocol if the buffer is larger than -`elpy-rpc-large-buffer-size'." - (if (< (buffer-size) elpy-rpc-large-buffer-size) - (buffer-string) - (let ((file-name (make-temp-file "elpy-rpc-")) - (coding-system-for-write 'utf-8)) - (write-region nil nil file-name nil :nomessage) - `((filename . ,file-name) - (delete_after_use . t))))) - -;; RPC API functions - -(defun elpy-rpc-restart () - "Restart all RPC processes." - (interactive) - (dolist (buffer (buffer-list)) - (when (elpy-rpc--process-buffer-p buffer) - (ignore-errors - (kill-process (get-buffer-process buffer))) - (ignore-errors - (kill-buffer buffer))))) - -(defun elpy-rpc-init (backend library-root &optional success error) - "Initialize the backend. - -This has to be called as the first method, else Elpy won't be -able to respond to other calls." - (elpy-rpc "init" - ;; This uses a vector because otherwise, json-encode in - ;; older Emacsen gets seriously confused, especially when - ;; backend is nil. - (vector `((backend . ,backend) - (project_root . ,(expand-file-name library-root)))) - success error)) - -(defun elpy-rpc-get-calltip (&optional success error) - "Call the get_calltip API function. - -Returns a calltip string for the function call at point." - (elpy-rpc "get_calltip" - (list buffer-file-name - (elpy-rpc--buffer-contents) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-completions (&optional success error) - "Call the get_completions API function. - -Returns a list of possible completions for the Python symbol at -point." - (elpy-rpc "get_completions" - (list buffer-file-name - (elpy-rpc--buffer-contents) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-completion-docstring (completion &optional success error) - "Call the get_completion_docstring API function. - -Returns a doc string or nil" - (elpy-rpc "get_completion_docstring" (list completion) success error)) - -(defun elpy-rpc-get-completion-location (completion &optional success error) - "Call the get_completion_location API function. - -Returns a list of file name and line number, or nil" - (elpy-rpc "get_completion_location" (list completion) success error)) - -(defun elpy-rpc-get-definition (&optional success error) - "Call the find_definition API function. - -Returns nil or a list of (filename, point)." - (elpy-rpc "get_definition" - (list buffer-file-name - (elpy-rpc--buffer-contents) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-docstring (&optional success error) - "Call the get_docstring API function. - -Returns a possible multi-line docstring for the symbol at point." - (elpy-rpc "get_docstring" - (list buffer-file-name - (elpy-rpc--buffer-contents) - (- (point) - (point-min))) - success error)) - -(defun elpy-rpc-get-pydoc-completions (prefix &optional success error) - "Return a list of modules available in pydoc starting with PREFIX." - (elpy-rpc "get_pydoc_completions" (list prefix) - success error)) - -(defun elpy-rpc-get-pydoc-documentation (symbol &optional success error) - "Get the Pydoc documentation for SYMBOL. - -Returns a possible multi-line docstring." - (elpy-rpc "get_pydoc_documentation" (list symbol) - success error)) - -(defun elpy-rpc-get-usages (&optional success error) - (elpy-rpc "get_usages" - (list buffer-file-name - (elpy-rpc--buffer-contents) - (- (point) - (point-min))) - success error)) - -;;;;;;;;;;; -;;; Modules - -(defvar elpy-modules-initialized-p nil - "Boolean, set to true if modules were run with `global-init'.") - -(defun elpy-modules-run (command &rest args) - "Run COMMAND with ARGS for all modules in `elpy-modules'." - (dolist (module elpy-modules) - (apply module command args))) - -(defun elpy-modules-global-init () - "Run the global-init method of Elpy modules. - -Make sure this only happens once." - (when (not elpy-modules-initialized-p) - (elpy-modules-run 'global-init) - (setq elpy-modules-initialized-p t))) - -(defun elpy-modules-global-stop () - "Run the global-stop method of Elpy modules. - -Make sure this only happens once per global-init call." - (when elpy-modules-initialized-p - (elpy-modules-run 'global-stop) - (setq elpy-modules-initialized-p nil))) - -(defun elpy-modules-buffer-init () - "Run the buffer-init method of Elpy modules. - -Make sure global-init is called first." - (elpy-modules-global-init) - (elpy-modules-run 'buffer-init)) - -(defun elpy-modules-buffer-stop () - "Run the buffer-stop method of Elpy modules." - (elpy-modules-run 'buffer-stop)) - -(defun elpy-modules-remove-modeline-lighter (mode-name) - "Remove the lighter for MODE-NAME. - -It's not necessary to see (Python Elpy yas company ElDoc) all the -time. Honestly." - (interactive) - (cond - ((eq mode-name 'eldoc-minor-mode) - (setq eldoc-minor-mode-string nil)) - (t - (let ((cell (assq mode-name minor-mode-alist))) - (when cell - (setcdr cell - (list ""))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Module: Sane Defaults - -(defun elpy-module-sane-defaults (command &rest args) - (pcase command - (`buffer-init - ;; Set `forward-sexp-function' to nil in python-mode. See - ;; http://debbugs.gnu.org/db/13/13642.html - (set (make-local-variable 'forward-sexp-function) nil) - ;; PEP8 recommends two spaces in front of inline comments. - (set (make-local-variable 'comment-inline-offset) 2)) - (`buffer-stop - (kill-local-variable 'forward-sexp-function) - (kill-local-variable 'comment-inline-offset)))) - -;;;;;;;;;;;;;;;;;;; -;;; Module: Company - -(defun elpy-module-company (command &rest args) - "Module to support company-mode completions." - (pcase command - (`global-init - (require 'company) - (elpy-modules-remove-modeline-lighter 'company-mode) - (define-key company-active-map (kbd "C-d") - 'company-show-doc-buffer)) - (`buffer-init - ;; We want immediate completions from company. - (set (make-local-variable 'company-idle-delay) - 0) - ;; And annotations should be right-aligned. - (set (make-local-variable 'company-tooltip-align-annotations) - t) - ;; Also, dabbrev in comments and strings is nice. - (set (make-local-variable 'company-dabbrev-code-everywhere) - t) - ;; Add our own backend and remove a bunch of backends that - ;; interfere in Python mode. - (set (make-local-variable 'company-backends) - (cons 'elpy-company-backend - (delq 'company-semantic - (delq 'company-ropemacs - (delq 'company-capf - (mapcar #'identity company-backends)))))) - (company-mode 1)) - (`buffer-stop - (company-mode -1) - (kill-local-variable 'company-idle-delay) - (kill-local-variable 'company-tooltip-align-annotations) - (kill-local-variable 'company-backends)) - )) - -(defvar elpy-company--cache nil - "Buffer-local cache for candidate information.") -(make-variable-buffer-local 'elpy-company--cache) - -(defun elpy-company--cache-clear () - "Clear and initialize the cache." - (if elpy-company--cache - (clrhash elpy-company--cache) - (setq elpy-company--cache - (make-hash-table :test #'equal)))) - -(defun elpy-company--cache-annotation (name) - "Return the cached annotation for NAME." - (when elpy-company--cache - (cdr (assq 'annotation (gethash name elpy-company--cache))))) - -(defun elpy-company--cache-meta (name) - "Return the cached annotation for NAME." - (when elpy-company--cache - (cdr (assq 'meta (gethash name elpy-company--cache))))) - -(defun elpy-company--cache-name (name) - "Return the cached name for NAME. - -Confused yet? We pass \"our\" name, that is, prefix + suffix, -here, and return the \"name\" as used by the backend." - (when elpy-company--cache - (cdr (assq 'name (gethash name elpy-company--cache))))) - -(defun elpy-company--cache-completions (prefix result) - "Store RESULT in the candidate cache and return candidates." - (elpy-company--cache-clear) - (mapcar (lambda (completion) - (let* ((suffix (cdr (assq 'suffix completion))) - (name (concat prefix suffix))) - (puthash name completion elpy-company--cache) - name)) - result)) - -(defun elpy-company-backend (command &optional arg &rest ignored) - "A company-mode backend for Elpy." - (interactive (list 'interactive)) - (pcase command - (`interactive - (company-begin-backend 'elpy-company-backend)) - ;; init => Called once per buffer - ;; prefix => return the prefix at point - (`prefix - (when (and elpy-mode - (not (company-in-string-or-comment))) - (company-grab-symbol-cons "\\." 1))) - ;; candidates => return candidates for this prefix - (`candidates - (cons :async - (lambda (callback) - (elpy-rpc-get-completions - (lambda (result) - (elpy-company--cache-clear) - (funcall - callback - (cond - ;; The backend returned something - (result - (elpy-company--cache-completions arg result)) - ;; Nothing from the backend, try dabbrev-code. - ((> (length arg) company-minimum-prefix-length) - (elpy--sort-and-strip-duplicates - (company-dabbrev-code 'candidates arg))) - ;; Well, ok, let's go meh. - (t - nil)))))))) - ;; sorted => t if the list is already sorted - (`sorted - t) - ;; duplicates => t if there could be duplicates - (`duplicates - nil) - ;; no-cache => t if company shouldn't cache results - ;; meta => short docstring for minibuffer - (`meta - (let ((meta (elpy-company--cache-meta arg))) - (when (and meta - (string-match "\\`\\(.*\n.*\\)\n.*" meta)) - (setq meta (match-string 1 meta))) - meta)) - ;; annotation => short docstring for completion buffer - (`annotation - (elpy-company--cache-annotation arg)) - ;; doc-buffer => put doc buffer in `company-doc-buffer' - (`doc-buffer - (let* ((name (elpy-company--cache-name arg)) - (doc (elpy-rpc-get-completion-docstring name))) - (when doc - (company-doc-buffer doc)))) - ;; require-match => Never require a match, even if the user - ;; started to interact with company. See `company-require-match'. - (`require-match - 'never) - ;; location => (buffer . point) or (file . - ;; line-number) - (`location - (let* ((name (elpy-company--cache-name arg)) - (loc (elpy-rpc-get-completion-location name))) - (when loc - (cons (car loc) - (cadr loc))))) - ;; match => for non-prefix based backends - ;; post-completion => after insertion, for snippets - )) - -(defun elpy--sort-and-strip-duplicates (seq) - "Sort SEQ and remove any duplicates." - (sort (delete-dups seq) - (lambda (a b) - (string< a b)))) - -;;;;;;;;;;;;;;;;; -;;; Module: ElDoc - -(defun elpy-module-eldoc (command &rest args) - "Module to support ElDoc for Python files." - (pcase command - (`global-init - (require 'eldoc) - (setq eldoc-minor-mode-string nil)) - (`buffer-init - (set (make-local-variable 'eldoc-documentation-function) - 'elpy-eldoc-documentation) - (eldoc-mode 1)) - (`buffer-stop - (eldoc-mode -1) - (kill-local-variable 'eldoc-documentation-function)))) - -(defun elpy-eldoc-documentation () - "Return some interesting information for the code at point. - -This will return flymake errors for the line at point if there -are any. If not, this will do an asynchronous call to the RPC -backend to get a call tip, and display that using -`eldoc-message'. If the backend has no call tip, this will -display the current class and method instead." - (let ((flymake-error (elpy-flymake-error-at-point))) - (if flymake-error - flymake-error - (elpy-rpc-get-calltip - (lambda (calltip) - (eldoc-message - (cond - ((not calltip) - (when elpy-eldoc-show-current-function - (let ((current-defun (python-info-current-defun))) - (when current-defun - (format "In: %s()" current-defun))))) - ((stringp calltip) - calltip) - (t - (let ((name (cdr (assq 'name calltip))) - (index (cdr (assq 'index calltip))) - (params (cdr (assq 'params calltip)))) - (when index - (setf (nth index params) - (propertize (nth index params) - 'face - 'eldoc-highlight-function-argument))) - (format "%s(%s)" - name - (mapconcat #'identity params ", ")) - )))))) - ;; Return the last message until we're done - eldoc-last-message))) - -;;;;;;;;;;;;;;;;;;; -;;; Module: Flymake - -(defun elpy-module-flymake (command &rest args) - "Enable Flymake support for Python." - (pcase command - (`global-init - (require 'flymake) - (elpy-modules-remove-modeline-lighter 'flymake-mode) - ;; Flymake support using flake8, including warning faces. - (when (and (executable-find "flake8") - (equal python-check-command - (elpy-flymake--standard-value 'python-check-command))) - (setq python-check-command "flake8")) - - ;; Add our initializer function - (add-to-list 'flymake-allowed-file-name-masks - '("\\.py\\'" elpy-flymake-python-init))) - (`buffer-init - ;; `flymake-no-changes-timeout': The original value of 0.5 is too - ;; short for Python code, as that will result in the current line - ;; to be highlighted most of the time, and that's annoying. This - ;; value might be on the long side, but at least it does not, in - ;; general, interfere with normal interaction. - (set (make-local-variable 'flymake-no-changes-timeout) - 60) - - ;; `flymake-start-syntax-check-on-newline': This should be nil for - ;; Python, as;; most lines with a colon at the end will mean the - ;; next line is always highlighted as error, which is not helpful - ;; and mostly annoying. - (set (make-local-variable 'flymake-start-syntax-check-on-newline) - nil) - - ;; Enable warning faces for flake8 output. - ;; COMPAT: Obsolete variable as of 24.4 - (if (boundp 'flymake-warning-predicate) - (set (make-local-variable 'flymake-warning-predicate) "^W[0-9]") - (set (make-local-variable 'flymake-warning-re) "^W[0-9]")) - - (flymake-mode 1)) - (`buffer-stop - (flymake-mode -1) - (kill-local-variable 'flymake-no-changes-timeout) - (kill-local-variable 'flymake-start-syntax-check-on-newline) - ;; COMPAT: Obsolete variable as of 24.4 - (if (boundp 'flymake-warning-predicate) - (kill-local-variable 'flymake-warning-predicate) - (kill-local-variable 'flymake-warning-re))))) - -(defun elpy-flymake-python-init () - ;; Make sure it's not a remote buffer as flymake would not work - (when (not (file-remote-p buffer-file-name)) - (let* ((temp-file (flymake-init-create-temp-buffer-copy - 'flymake-create-temp-inplace))) - (list python-check-command - (list temp-file) - ;; Run flake8 from / to avoid import problems (#169) - "/")))) - -(defun elpy-flymake-next-error () - "Move forward to the next Flymake error and show a -description." - (interactive) - (flymake-goto-next-error) - (elpy-flymake-show-error)) - -(defun elpy-flymake-previous-error () - "Move backward to the previous Flymake error and show a -description." - (interactive) - (flymake-goto-prev-error) - (elpy-flymake-show-error)) - -(defun elpy-flymake-show-error () - "Show the flymake error message at point." - (interactive) - (message "%s" (elpy-flymake-error-at-point))) - -(defun elpy-flymake-error-at-point () - "Return the flymake error at point, or nil if there is none." - (when (boundp 'flymake-err-info) - (let* ((lineno (line-number-at-pos)) - (err-info (car (flymake-find-err-info flymake-err-info - lineno)))) - (when err-info - (mapconcat #'flymake-ler-text - err-info - ", "))))) - -(defun elpy-flymake--standard-value (var) - "Return the standard value of the given variable." - (let ((sv (get var 'standard-value))) - (when (consp sv) - (ignore-errors - (eval (car sv)))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Module: Highlight Indentation - -(defun elpy-module-highlight-indentation (command &rest args) - "Module to highlight indentation in Python files." - (pcase command - (`global-init - (require 'highlight-indentation)) - (`buffer-init - (highlight-indentation-mode 1)) - (`buffer-stop - (highlight-indentation-mode -1)))) - -;;;;;;;;;;;;;;;;;; -;;; Module: pyvenv - -(defun elpy-module-pyvenv (command &rest args) - "Module to display the current virtualenv in the mode line." - (pcase command - (`global-init - (pyvenv-mode 1)) - (`global-stop - (pyvenv-mode -1)))) - -;;;;;;;;;;;;;;;;;;;;; -;;; Module: Yasnippet - -(defun elpy-module-yasnippet (command &rest args) - "Module to enable YASnippet snippets." - (pcase command - (`global-init - (require 'yasnippet) - (elpy-modules-remove-modeline-lighter 'yas-minor-mode) - - ;; We provide some YASnippet snippets. Add them. - - ;; yas-snippet-dirs can be a string for a single directory. Make - ;; sure it's a list in that case so we can add our own entry. - (when (not (listp yas-snippet-dirs)) - (setq yas-snippet-dirs (list yas-snippet-dirs))) - (add-to-list 'yas-snippet-dirs - (concat (file-name-directory (locate-library "elpy")) - "snippets/") - t) - - ;; Now load yasnippets. - (yas-reload-all)) - (`global-stop - (setq yas-snippet-dirs - (delete (concat (file-name-directory (locate-library "elpy")) - "snippets/") - yas-snippet-dirs))) - (`buffer-init - (yas-minor-mode 1)) - (`buffer-stop - (yas-minor-mode -1)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Backwards compatibility - -;; Functions for Emacs 24 before 24.3 -(when (not (fboundp 'python-info-current-defun)) - (defalias 'python-info-current-defun 'python-current-defun)) - -(when (not (fboundp 'python-nav-forward-statement)) - (defun python-nav-forward-statement (&rest ignored) - "Function added in Emacs 24.3" - (error "Enhanced Python navigation only available in Emacs 24.3+"))) - -(when (not (fboundp 'python-nav-backward-up-list)) - (defun python-nav-backward-up-list () - "Compatibility function for older Emacsen" - (ignore-errors - (backward-up-list)))) - -(when (not (fboundp 'python-shell-calculate-exec-path)) - (defun python-shell-calculate-exec-path () - "Compatibility function for older Emacsen." - exec-path)) - -(when (not (fboundp 'python-shell-calculate-process-environment)) - (defun python-shell-calculate-process-environment () - "Compatibility function for older Emacsen." - process-environment)) - -(when (not (fboundp 'python-shell-get-process-name)) - (defun python-shell-get-process-name (dedicated) - "Compatibility function for older Emacsen." - "Python")) - -(when (not (fboundp 'python-shell-parse-command)) - (defun python-shell-parse-command () - "Compatibility function for older Emacsen." - python-python-command)) - -(when (not (fboundp 'python-shell-send-buffer)) - (defun python-shell-send-buffer (&optional arg) - (python-send-buffer))) - -(when (not (fboundp 'python-shell-send-string)) - (defalias 'python-shell-send-string 'python-send-string)) - -;; Emacs 24.2 made `locate-dominating-file' accept a predicate instead -;; of a string. Simply overwrite the current one, it's -;; backwards-compatible. The code below is taken from Emacs 24.3. -(when (or (< emacs-major-version 24) - (and (= emacs-major-version 24) - (<= emacs-minor-version 2))) - (defun locate-dominating-file (file name) - "Look up the directory hierarchy from FILE for a directory containing NAME. -Stop at the first parent directory containing a file NAME, -and return the directory. Return nil if not found. -Instead of a string, NAME can also be a predicate taking one argument -\(a directory) and returning a non-nil value if that directory is the one for -which we're looking." - ;; We used to use the above locate-dominating-files code, but the - ;; directory-files call is very costly, so we're much better off doing - ;; multiple calls using the code in here. - ;; - ;; Represent /home/luser/foo as ~/foo so that we don't try to look for - ;; `name' in /home or in /. - (setq file (abbreviate-file-name file)) - (let ((root nil) - ;; `user' is not initialized outside the loop because - ;; `file' may not exist, so we may have to walk up part of the - ;; hierarchy before we find the "initial UID". Note: currently unused - ;; (user nil) - try) - (while (not (or root - (null file) - ;; FIXME: Disabled this heuristic because it is sometimes - ;; inappropriate. - ;; As a heuristic, we stop looking up the hierarchy of - ;; directories as soon as we find a directory belonging - ;; to another user. This should save us from looking in - ;; things like /net and /afs. This assumes that all the - ;; files inside a project belong to the same user. - ;; (let ((prev-user user)) - ;; (setq user (nth 2 (file-attributes file))) - ;; (and prev-user (not (equal user prev-user)))) - (string-match locate-dominating-stop-dir-regexp file))) - (setq try (if (stringp name) - (file-exists-p (expand-file-name name file)) - (funcall name file))) - (cond (try (setq root file)) - ((equal file (setq file (file-name-directory - (directory-file-name file)))) - (setq file nil)))) - (if root (file-name-as-directory root)))) - ) - -;; highlight-indentation 0.5 does not use modes yet -(when (not (fboundp 'highlight-indentation-mode)) - (defun highlight-indentation-mode (on-or-off) - (cond - ((and (> on-or-off 0) - (not highlight-indent-active)) - (highlight-indentation)) - ((and (<= on-or-off 0) - highlight-indent-active) - (highlight-indentation))))) - -(provide 'elpy) -;;; elpy.el ends here diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/__init__.py b/emacs.d/elpa/elpy-1.7.1/elpy/__init__.py deleted file mode 100644 index 11f88d6..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# Elpy, the Emacs Lisp Python Environment - -# Copyright (C) 2013 Jorgen Schaefer - -# Author: Jorgen Schaefer -# URL: http://github.com/jorgenschaefer/elpy - -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 3 -# of the License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -"""The Emacs Lisp Python Environment. - -Elpy is a mode for Emacs to support writing Python code. This package -provides the backend within Python to support auto-completion, -documentation extraction, and navigation. - -Emacs will start the protocol by running the module itself, like so: - - python -m elpy - -This will emit a greeting string on a single line, and then wait for -the protocol to start. Details of the protocol can be found in -elpy.rpc. - -This package is unlikely to be useful on its own. - -""" - -__author__ = "Jorgen Schaefer" -__version__ = "1.7.1" -__license__ = "GPL" diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/__main__.py b/emacs.d/elpa/elpy-1.7.1/elpy/__main__.py deleted file mode 100644 index eac1b11..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy/__main__.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Main interface to the RPC server. - -You should be able to just run the following to use this module: - -python -m elpy - -The first line should be "elpy-rpc ready". If it isn't, something -broke. - -""" - -import sys - -import elpy -from elpy.server import ElpyRPCServer - -if __name__ == '__main__': - # Workaround for libraries writing to stderr while they should - # not. See #458. Can be removed once #461 is implemented. - import os - sys.stderr = open(os.devnull) - # End workaround - sys.stdout.write('elpy-rpc ready ({0})\n' - .format(elpy.__version__)) - sys.stdout.flush() - ElpyRPCServer().serve_forever() diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/impmagic.py b/emacs.d/elpa/elpy-1.7.1/elpy/impmagic.py deleted file mode 100644 index 5bc8fb7..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy/impmagic.py +++ /dev/null @@ -1,82 +0,0 @@ -"""Glue for the "importmagic" library. - -""" - -import os -import sys -import threading - - -try: - import importmagic.index - import importmagic.symbols - import importmagic.importer -except ImportError: # pragma: no cover - importmagic = None - - -class ImportMagic(object): - - def __init__(self): - self.is_enabled = bool(importmagic) - # fail_message is reported to the user when symbol_index - # is (still) None - self.fail_message = "symbol index is not yet ready" - self.project_root = None - self.symbol_index = None - self._thread = None - - def _build_symbol_index(self, project_root, custom_path, blacklist_re): - try: - index = importmagic.index.SymbolIndex(blacklist_re=blacklist_re) - if os.environ.get('ELPY_TEST'): - # test suite support: do not index the whole PYTHONPATH, it - # takes much too long - index.build_index([]) - elif custom_path: - index.build_index(custom_path) - else: - index.build_index([project_root] + sys.path) - except Exception as e: - self.fail_message = "symbol index failed to build: %s" % e - else: - self.symbol_index = index - - def build_index(self, project_root, custom_path=None, blacklist_re=None): - self.project_root = None - self._thread = threading.Thread(target=self._build_symbol_index, - args=(project_root, custom_path, - blacklist_re)) - self._thread.setDaemon(True) - self._thread.start() - - def get_import_symbols(self, symbol): - scores = self.symbol_index.symbol_scores(symbol) - return ["from %s import %s" % (mod, var) if var else "import %s" % mod - for (_, mod, var) in scores] - - def add_import(self, source, statement): - imports = importmagic.importer.Imports(self.symbol_index, source) - if statement.startswith('import '): - imports.add_import(statement[7:]) - else: - sep = statement.find(' import ') - if sep > -1: - imports.add_import_from(statement[5:sep], statement[sep+8:]) - start_line, end_line, import_block = imports.get_update() - return start_line, end_line, import_block - - def get_unresolved_symbols(self, source): - scope = importmagic.symbols.Scope.from_source(source) - unres, unref = scope.find_unresolved_and_unreferenced_symbols() - return list(unres) - - def remove_unreferenced_imports(self, source): - scope = importmagic.symbols.Scope.from_source(source) - unres, unref = scope.find_unresolved_and_unreferenced_symbols() - # Note: we do not supply "unres" to the call below, since we do - # not want to add imports without querying the user from which - # module symbols should be imported. - start_line, end_line, import_block = importmagic.importer.get_update( - source, self.symbol_index, set(), unref) - return start_line, end_line, import_block diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/jedibackend.py b/emacs.d/elpa/elpy-1.7.1/elpy/jedibackend.py deleted file mode 100644 index 2c65151..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy/jedibackend.py +++ /dev/null @@ -1,320 +0,0 @@ -"""Elpy backend using the Jedi library. - -This backend uses the Jedi library: - -https://github.com/davidhalter/jedi - -""" - -import sys -import traceback - -import jedi - -from elpy import rpc - - -class JediBackend(object): - """The Jedi backend class. - - Implements the RPC calls we can pass on to Jedi. - - Documentation: http://jedi.jedidjah.ch/en/latest/docs/plugin-api.html - - """ - name = "jedi" - - def __init__(self, project_root): - self.project_root = project_root - self.completions = {} - sys.path.append(project_root) - - def rpc_get_completions(self, filename, source, offset): - line, column = pos_to_linecol(source, offset) - proposals = run_with_debug(jedi, 'completions', - source=source, line=line, column=column, - path=filename, encoding='utf-8') - if proposals is None: - return [] - self.completions = dict((proposal.name, proposal) - for proposal in proposals) - return [{'name': proposal.name, - 'suffix': proposal.complete, - 'annotation': proposal.type, - 'meta': proposal.description} - for proposal in proposals] - - def rpc_get_completion_docstring(self, completion): - proposal = self.completions.get(completion) - if proposal is None: - return None - else: - return proposal.docstring(fast=False) - - def rpc_get_completion_location(self, completion): - proposal = self.completions.get(completion) - if proposal is None: - return None - else: - return (proposal.module_path, proposal.line) - - def rpc_get_docstring(self, filename, source, offset): - line, column = pos_to_linecol(source, offset) - try: - locations = run_with_debug(jedi, 'goto_definitions', - source=source, line=line, column=column, - path=filename, encoding='utf-8', - re_raise=jedi.NotFoundError) - except jedi.NotFoundError: - return None - if locations: - return locations[-1].docstring() - else: - return None - - def rpc_get_definition(self, filename, source, offset): - line, column = pos_to_linecol(source, offset) - try: - locations = run_with_debug(jedi, 'goto_definitions', - source=source, line=line, column=column, - path=filename, encoding='utf-8', - re_raise=jedi.NotFoundError) - except jedi.NotFoundError: - return None - # goto_definitions() can return silly stuff like __builtin__ - # for int variables, so we fall back on goto() in those - # cases. See issue #76. - if ( - locations and - locations[0].module_path is None - ): - locations = run_with_debug(jedi, 'goto_assignments', - source=source, line=line, - column=column, - path=filename, encoding='utf-8') - if not locations: - return None - else: - loc = locations[-1] - try: - if loc.module_path: - if loc.module_path == filename: - offset = linecol_to_pos(source, - loc.line, - loc.column) - else: - with open(loc.module_path) as f: - offset = linecol_to_pos(f.read(), - loc.line, - loc.column) - except IOError: - return None - return (loc.module_path, offset) - - def rpc_get_calltip(self, filename, source, offset): - line, column = pos_to_linecol(source, offset) - calls = run_with_debug(jedi, 'call_signatures', - source=source, line=line, column=column, - path=filename, encoding='utf-8') - if calls: - call = calls[0] - else: - call = None - if not call: - return None - return {"name": call.name, - "index": call.index, - "params": [param.description for param in call.params]} - - def rpc_get_usages(self, filename, source, offset): - """Return the uses of the symbol at offset. - - Returns a list of occurrences of the symbol, as dicts with the - fields name, filename, and offset. - - """ - line, column = pos_to_linecol(source, offset) - try: - uses = run_with_debug(jedi, 'usages', - source=source, line=line, column=column, - path=filename, encoding='utf-8', - re_raise=(jedi.NotFoundError,)) - except jedi.NotFoundError: - return [] - - if uses is None: - return None - result = [] - for use in uses: - if use.module_path == filename: - offset = linecol_to_pos(source, use.line, use.column) - elif use.module_path is not None: - with open(use.module_path) as f: - text = f.read() - offset = linecol_to_pos(text, use.line, use.column) - - result.append({"name": use.name, - "filename": use.module_path, - "offset": offset}) - - return result - - -# From the Jedi documentation: -# -# line is the current line you want to perform actions on (starting -# with line #1 as the first line). column represents the current -# column/indent of the cursor (starting with zero). source_path -# should be the path of your file in the file system. - -def pos_to_linecol(text, pos): - """Return a tuple of line and column for offset pos in text. - - Lines are one-based, columns zero-based. - - This is how Jedi wants it. Don't ask me why. - - """ - line_start = text.rfind("\n", 0, pos) + 1 - line = text.count("\n", 0, line_start) + 1 - col = pos - line_start - return line, col - - -def linecol_to_pos(text, line, col): - """Return the offset of this line and column in text. - - Lines are one-based, columns zero-based. - - This is how Jedi wants it. Don't ask me why. - - """ - nth_newline_offset = 0 - for i in range(line - 1): - new_offset = text.find("\n", nth_newline_offset) - if new_offset < 0: - raise ValueError("Text does not have {0} lines." - .format(line)) - nth_newline_offset = new_offset + 1 - offset = nth_newline_offset + col - if offset > len(text): - raise ValueError("Line {0} column {1} is not within the text" - .format(line, col)) - return offset - - -def run_with_debug(jedi, name, *args, **kwargs): - re_raise = kwargs.pop('re_raise', ()) - # Remove form feed characters, they confuse Jedi (jedi#424) - if 'source' in kwargs: - kwargs['source'] = kwargs['source'].replace("\f", " ") - try: - script = jedi.Script(*args, **kwargs) - return getattr(script, name)() - except Exception as e: - if isinstance(e, re_raise): - raise - # Bug jedi#417 - if isinstance(e, TypeError) and str(e) == 'no dicts allowed': - return None - # Bug jedi#427 - if isinstance(e, UnicodeDecodeError): - return None - # Bug jedi#429 - if isinstance(e, IndexError): - return None - # Bug jedi#431 - if isinstance(e, AttributeError) and str(e).endswith("'end_pos'"): - return None - # Bug in Python 2.6, see #275 - if isinstance(e, OSError) and e.errno == 13: - return None - # Bug jedi#466 - if ( - isinstance(e, SyntaxError) and - "EOL while scanning string literal" in str(e) - ): - return None - # Bug jedi#482 - if isinstance(e, UnicodeEncodeError): - return None - # Bug jedi#485 - if ( - isinstance(e, ValueError) and - "invalid \\x escape" in str(e) - ): - return None - # Bug jedi#485 in Python 3 - if ( - isinstance(e, SyntaxError) and - "truncated \\xXX escape" in str(e) - ): - return None - # Bug jedi#465 - if ( - isinstance(e, SyntaxError) and - "encoding declaration in Unicode string" in str(e) - ): - return None - # Bug #337 / jedi#471 - if ( - isinstance(e, ImportError) and - "No module named" in str(e) - ): - return None - # Bug #365 / jedi#486 - fixed in Jedi 0.8.2 - if ( - isinstance(e, UnboundLocalError) and - "local variable 'path' referenced before assignment" in str(e) - ): - return None - # Bug #366 / jedi#491 - if ( - isinstance(e, ValueError) and - "__loader__ is None" in str(e) - ): - return None - # Bug #353 - if ( - isinstance(e, OSError) and - "No such file or directory" in str(e) - ): - return None - - from jedi import debug - - debug_info = [] - - def _debug(level, str_out): - if level == debug.NOTICE: - prefix = "[N]" - elif level == debug.WARNING: - prefix = "[W]" - else: - prefix = "[?]" - debug_info.append(u"{0} {1}".format(prefix, str_out)) - - jedi.set_debug_function(_debug, speed=False) - try: - script = jedi.Script(*args, **kwargs) - return getattr(script, name)() - except Exception as e: - source = kwargs.get('source') - sc_args = [] - sc_args.extend(repr(arg) for arg in args) - sc_args.extend("{0}={1}".format(k, "source" if k == "source" - else repr(v)) - for (k, v) in kwargs.items()) - - data = { - "traceback": traceback.format_exc(), - "jedi_debug_info": {'script_args': ", ".join(sc_args), - 'source': source, - 'method': name, - 'debug_info': debug_info} - } - raise rpc.Fault(message=str(e), - code=500, - data=data) - finally: - jedi.set_debug_function(None) diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/ropebackend.py b/emacs.d/elpa/elpy-1.7.1/elpy/ropebackend.py deleted file mode 100644 index 8328efd..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy/ropebackend.py +++ /dev/null @@ -1,322 +0,0 @@ -"""Elpy backend using the Rope library. - -This backend uses the Rope library: - -http://rope.sourceforge.net/ - -""" - -import os -import time -import traceback - -import rope.contrib.codeassist -import rope.base.project -import rope.base.libutils -import rope.base.exceptions -import rope.contrib.findit - -from elpy import rpc -import elpy.pydocutils - -VALIDATE_EVERY_SECONDS = 5 -MAXFIXES = 5 - - -class RopeBackend(object): - """The Rope backend class. - - Implements the RPC calls we can pass on to Rope. Also subclasses - the native backend to provide methods Rope does not provide, if - any. - - """ - name = "rope" - - def __init__(self, project_root): - super(RopeBackend, self).__init__() - self.last_validation = 0 - if not os.path.exists(project_root): - project_root = "" - self.project_root = project_root - self.completions = {} - prefs = dict(ignored_resources=['*.pyc', '*~', '.ropeproject', - '.hg', '.svn', '_svn', '.git'], - python_files=['*.py'], - save_objectdb=False, - compress_objectdb=False, - automatic_soa=True, - soa_followed_calls=0, - perform_doa=True, - validate_objectdb=True, - max_history_items=32, - save_history=False, - compress_history=False, - indent_size=4, - extension_modules=[], - import_dynload_stdmods=True, - ignore_syntax_errors=False, - ignore_bad_imports=False) - self.project = rope.base.project.Project(self.project_root, - ropefolder=None, - **prefs) - - def get_resource(self, filename): - if filename is not None and os.path.exists(filename): - return rope.base.libutils.path_to_resource(self.project, - filename, - 'file') - else: - return None - - def validate(self): - """Validate the stored project. - - This should be called before every use of Rope. It will - revalidate the project, but do some call throttling. - - """ - now = time.time() - if now > self.last_validation + VALIDATE_EVERY_SECONDS: - try: - self.project.validate() - except rope.base.exceptions.ResourceNotFoundError: - pass - self.last_validation = now - - def call_rope(self, rope_function, filename, source, offset, - **kwargs): - self.validate() - resource = self.get_resource(filename) - try: - return rope_function(self.project, - source, offset, - resource, - maxfixes=MAXFIXES, - **kwargs) - except (rope.base.exceptions.BadIdentifierError, - rope.base.exceptions.ModuleSyntaxError, - rope.base.exceptions.ResourceNotFoundError, - IndentationError, - LookupError, - AttributeError): - return None - except Exception as e: - data = { - "traceback": traceback.format_exc(), - "rope_debug_info": { - "project_root": self.project_root, - "filename": filename, - "source": source, - "function_name": (rope_function.__module__ + - "." + - rope_function.__name__), - "function_args": ", ".join([ - "project", "source", str(offset), "resource", - "maxfixes={0}".format(MAXFIXES) - ] + [ - u"{}={}".format(k, v) - for (k, v) in kwargs.items() - ]) - } - } - raise rpc.Fault( - code=500, - message=str(e), - data=data - ) - - def rpc_get_completions(self, filename, source, offset): - proposals = self.call_rope( - rope.contrib.codeassist.code_assist, - filename, source, offset - ) - if proposals is None: - return [] - try: - starting_offset = rope.contrib.codeassist.starting_offset(source, - offset) - except (rope.base.exceptions.BadIdentifierError, - rope.base.exceptions.ModuleSyntaxError, - IndentationError, - LookupError, - AttributeError): - return [] - prefixlen = offset - starting_offset - self.completions = dict((proposal.name, proposal) - for proposal in proposals) - try: - return [{'name': proposal.name, - 'suffix': proposal.name[prefixlen:], - 'annotation': proposal.type, - 'meta': str(proposal)} - for proposal in proposals] - except rope.base.exceptions.ModuleSyntaxError: - # Bug#406 - return [] - - def rpc_get_completion_docstring(self, completion): - proposal = self.completions.get(completion) - if proposal is None: - return None - else: - return proposal.get_doc() - - def rpc_get_completion_location(self, completion): - proposal = self.completions.get(completion) - if proposal is None: - return None - else: - if not proposal.pyname: - return None - module, lineno = proposal.pyname.get_definition_location() - if module is None: - return None - resource = module.get_module().get_resource() - return (resource.real_path, lineno) - - def rpc_get_definition(self, filename, source, offset): - location = self.call_rope( - rope.contrib.findit.find_definition, - filename, source, offset - ) - if location is None: - return None - else: - return (location.resource.real_path, location.offset) - - def rpc_get_calltip(self, filename, source, offset): - offset = find_called_name_offset(source, offset) - if 0 < offset < len(source) and source[offset] == ')': - offset -= 1 - - calltip = self.call_rope( - rope.contrib.codeassist.get_calltip, - filename, source, offset, - remove_self=True - ) - if calltip is None: - return None - - calltip = calltip.replace(".__init__(", "(") - calltip = calltip.replace("(self)", "()") - calltip = calltip.replace("(self, ", "(") - # "elpy.tests.support.source_and_offset(source)" - # => - # "support.source_and_offset(source)" - try: - openpos = calltip.index("(") - period2 = calltip.rindex(".", 0, openpos) - period1 = calltip.rindex(".", 0, period2) - calltip = calltip[period1 + 1:] - except ValueError: - pass - return calltip - - def rpc_get_docstring(self, filename, source, offset): - return self.call_rope( - rope.contrib.codeassist.get_doc, - filename, source, offset - ) - - -def find_called_name_offset(source, orig_offset): - """Return the offset of a calling function. - - This only approximates movement. - - """ - offset = min(orig_offset, len(source) - 1) - paren_count = 0 - while True: - if offset <= 1: - return orig_offset - elif source[offset] == '(': - if paren_count == 0: - return offset - 1 - else: - paren_count -= 1 - elif source[offset] == ')': - paren_count += 1 - offset -= 1 - - -################################################################## -# A recurring problem in Rope for Elpy is that it searches the whole -# project root for Python files. If the user edits a file in their -# home directory, this can easily read a whole lot of files, making -# Rope practically useless. We change the file finding algorithm here -# to only recurse into directories with an __init__.py file in them. -def find_source_folders(self, folder): - for resource in folder.get_folders(): - if self._is_package(resource): - return [folder] - result = [] - for resource in folder.get_files(): - if resource.name.endswith('.py'): - result.append(folder) - break - for resource in folder.get_folders(): - if self._is_package(resource): - result.append(resource) - return result - -import rope.base.pycore -rope.base.pycore.PyCore._find_source_folders = find_source_folders - - -def get_files(self): - if self.files is None: - self.files = get_python_project_files(self.project) - return self.files - -rope.base.project._FileListCacher.get_files = get_files - - -def get_python_project_files(project): - for dirname, subdirs, files in os.walk(project.root.real_path): - for filename in files: - yield rope.base.libutils.path_to_resource( - project, os.path.join(dirname, filename), 'file') - subdirs[:] = [subdir for subdir in subdirs - if os.path.exists(os.path.join(dirname, subdir, - "__init__.py"))] - - -################################################################## -# Monkey patching a method in rope because it doesn't complete import -# statements. - -orig_code_completions = (rope.contrib.codeassist. - _PythonCodeAssist._code_completions) - - -def code_completions(self): - proposals = get_import_completions(self) - if proposals: - return proposals - else: - return orig_code_completions(self) - - -def get_import_completions(self): - if not self.word_finder.is_import_statement(self.offset): - return [] - modulename = self.word_finder.get_primary_at(self.offset) - # Rope can handle modules in packages - if "." in modulename: - return [] - return dict((name, FakeProposal(name)) - for name in elpy.pydocutils.get_modules() - if name.startswith(modulename)) - - -class FakeProposal(object): - def __init__(self, name): - self.name = name - self.type = "mock" - - def get_doc(self): - return None - -rope.contrib.codeassist._PythonCodeAssist._code_completions = code_completions diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/server.py b/emacs.d/elpa/elpy-1.7.1/elpy/server.py deleted file mode 100644 index 909cd0e..0000000 --- a/emacs.d/elpa/elpy-1.7.1/elpy/server.py +++ /dev/null @@ -1,275 +0,0 @@ -"""Method implementations for the Elpy JSON-RPC server. - -This file implements the methods exported by the JSON-RPC server. It -handles backend selection and passes methods on to the selected -backend. - -""" -import io -import os -import pydoc - -from elpy.pydocutils import get_pydoc_completions -from elpy.rpc import JSONRPCServer, Fault -from elpy.impmagic import ImportMagic - - -try: - from elpy import jedibackend -except ImportError: # pragma: no cover - jedibackend = None - -try: - from elpy import ropebackend -except ImportError: # pragma: no cover - ropebackend = None - - -class ElpyRPCServer(JSONRPCServer): - """The RPC server for elpy. - - See the rpc_* methods for exported method documentation. - - """ - def __init__(self): - super(ElpyRPCServer, self).__init__() - self.backend = None - self.import_magic = ImportMagic() - self.project_root = None - - def _call_backend(self, method, default, *args, **kwargs): - """Call the backend method with args. - - If there is currently no backend, return default.""" - meth = getattr(self.backend, method, None) - if meth is None: - return default - else: - return meth(*args, **kwargs) - - def rpc_echo(self, *args): - """Return the arguments. - - This is a simple test method to see if the protocol is - working. - - """ - return args - - def rpc_init(self, options): - self.project_root = options["project_root"] - - if self.import_magic.is_enabled: - self.import_magic.build_index(self.project_root) - - if ropebackend and options["backend"] == "rope": - self.backend = ropebackend.RopeBackend(self.project_root) - elif jedibackend and options["backend"] == "jedi": - self.backend = jedibackend.JediBackend(self.project_root) - elif ropebackend: - self.backend = ropebackend.RopeBackend(self.project_root) - elif jedibackend: - self.backend = jedibackend.JediBackend(self.project_root) - else: - self.backend = None - - return { - 'backend': (self.backend.name if self.backend is not None - else None) - } - - def rpc_get_calltip(self, filename, source, offset): - """Get the calltip for the function at the offset. - - """ - return self._call_backend("rpc_get_calltip", None, filename, - get_source(source), offset) - - def rpc_get_completions(self, filename, source, offset): - """Get a list of completion candidates for the symbol at offset. - - """ - results = self._call_backend("rpc_get_completions", [], filename, - get_source(source), offset) - # Uniquify by name - results = list(dict((res['name'], res) for res in results) - .values()) - results.sort(key=lambda cand: _pysymbol_key(cand["name"])) - return results - - def rpc_get_completion_docstring(self, completion): - """Return documentation for a previously returned completion. - - """ - return self._call_backend("rpc_get_completion_docstring", - None, completion) - - def rpc_get_completion_location(self, completion): - """Return the location for a previously returned completion. - - This returns a list of [file name, line number]. - - """ - return self._call_backend("rpc_get_completion_location", None, - completion) - - def rpc_get_definition(self, filename, source, offset): - """Get the location of the definition for the symbol at the offset. - - """ - return self._call_backend("rpc_get_definition", None, filename, - get_source(source), offset) - - def rpc_get_docstring(self, filename, source, offset): - """Get the docstring for the symbol at the offset. - - """ - return self._call_backend("rpc_get_docstring", None, filename, - get_source(source), offset) - - def rpc_get_pydoc_completions(self, name=None): - """Return a list of possible strings to pass to pydoc. - - If name is given, the strings are under name. If not, top - level modules are returned. - - """ - return get_pydoc_completions(name) - - def rpc_get_pydoc_documentation(self, symbol): - """Get the Pydoc documentation for the given symbol. - - Uses pydoc and can return a string with backspace characters - for bold highlighting. - - """ - try: - docstring = pydoc.render_doc(str(symbol), - "Elpy Pydoc Documentation for %s", - False) - except (ImportError, pydoc.ErrorDuringImport): - return None - else: - if isinstance(docstring, bytes): - docstring = docstring.decode("utf-8", "replace") - return docstring - - def rpc_get_refactor_options(self, filename, start, end=None): - """Return a list of possible refactoring options. - - This list will be filtered depending on whether it's - applicable at the point START and possibly the region between - START and END. - - """ - try: - from elpy import refactor - except: - raise ImportError("Rope not installed, refactorings unavailable") - ref = refactor.Refactor(self.project_root, filename) - return ref.get_refactor_options(start, end) - - def rpc_refactor(self, filename, method, args): - """Return a list of changes from the refactoring action. - - A change is a dictionary describing the change. See - elpy.refactor.translate_changes for a description. - - """ - try: - from elpy import refactor - except: - raise ImportError("Rope not installed, refactorings unavailable") - if args is None: - args = () - ref = refactor.Refactor(self.project_root, filename) - return ref.get_changes(method, *args) - - def rpc_get_usages(self, filename, source, offset): - """Get usages for the symbol at point. - - """ - source = get_source(source) - if hasattr(self.backend, "rpc_get_usages"): - return self.backend.rpc_get_usages(filename, source, offset) - else: - raise Fault("get_usages not implemented by current backend", - code=400) - - def _ensure_import_magic(self): # pragma: no cover - if not self.import_magic.is_enabled: - raise Fault("fixup_imports not enabled; install importmagic module", - code=400) - if not self.import_magic.symbol_index: - raise Fault(self.import_magic.fail_message, code=200) # XXX code? - - def rpc_get_import_symbols(self, filename, source, symbol): - """Return a list of modules from which the given symbol can be imported. - - """ - self._ensure_import_magic() - return self.import_magic.get_import_symbols(symbol) - - def rpc_add_import(self, filename, source, statement): - """Add an import statement to the module. - - """ - self._ensure_import_magic() - source = get_source(source) - return self.import_magic.add_import(source, statement) - - def rpc_get_unresolved_symbols(self, filename, source): - """Return a list of unreferenced symbols in the module. - - """ - self._ensure_import_magic() - source = get_source(source) - return self.import_magic.get_unresolved_symbols(source) - - def rpc_remove_unreferenced_imports(self, filename, source): - """Remove unused import statements. - - """ - self._ensure_import_magic() - source = get_source(source) - return self.import_magic.remove_unreferenced_imports(source) - - -def get_source(fileobj): - """Translate fileobj into file contents. - - fileobj is either a string or a dict. If it's a string, that's the - file contents. If it's a string, then the filename key contains - the name of the file whose contents we are to use. - - If the dict contains a true value for the key delete_after_use, - the file should be deleted once read. - - """ - if not isinstance(fileobj, dict): - return fileobj - else: - try: - with io.open(fileobj["filename"], encoding="utf-8") as f: - return f.read() - finally: - if fileobj.get('delete_after_use'): - try: - os.remove(fileobj["filename"]) - except: # pragma: no cover - pass - - -def _pysymbol_key(name): - """Return a sortable key index for name. - - Sorting is case-insensitive, with the first underscore counting as - worse than any character, but subsequent underscores do not. This - means that dunder symbols (like __init__) are sorted after symbols - that start with an alphabetic character, but before those that - start with only a single underscore. - - """ - if name.startswith("_"): - name = "~" + name[1:] - return name.lower() diff --git a/emacs.d/elpa/elpy-20150502.740/NEWS.rst b/emacs.d/elpa/elpy-20150502.740/NEWS.rst new file mode 100644 index 0000000..9783ced --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/NEWS.rst @@ -0,0 +1,375 @@ +New in Elpy 1.8.0 +================= + +- Emacs 24.5 is now officially supported +- The new configuration option ``elpy-rpc-ignored-buffer-size`` defines a maximum buffer size to be handle completion in, to avoid laggy interaction in unusually large files +- Indentation block movement was replaced with code that just moves the marked block or the current line; this should be a lot less magical and more predictable +- Running the test at point now correctly ignores any inner methods +- Jedi docstrings now show the full name of the object +- The RPC interpreter is now chosen correctly on cygwin +- ``elpy-shell-send-region-or-buffer`` now warns of tabs in the data being sent +- Elpy now binds stdout and stderr to ``/dev/null`` to avoid being confused by spurious output from other libraries +- RPC buffers (and processes) are removed after some time to avoid them piling up endlessly +- It is not possibly anymore to use customize alone to use ipython, because of some bad interaction between custom options in Elpy and python.el +- And lots of bugfixes (50 issues closed!) + + +New in Elpy 1.7.1 +================= + +- Do not fail on errors from importmagic. +- Handle new minor mode behavior of new versions of yasnippet. +- Do use the argument to ``elpy-use-ipython`` correctly. +- Handle unexpected data from the backend more gracefully. + + +New in Elpy 1.7.0 +================= + +- Elpy now can add missing import directives automatically, by using + Alec Thomas' excellent importmagic_ library. Use ``C-c C-m`` to add + a single import statement, or ``C-c C-S-m`` to include all missing + import statements. Many thanks to Georg Brandl for doing a lot of + work to bring this feature to Elpy! +- The Jedi backend now also supports ``C-c C-d`` to display a + docstring. Thanks again to Georg Brandl for the patch. +- It is now possible to disable the display of the current function in + the echo area by setting ``elpy-eldoc-show-current-function`` to + ``nil``. +- idomenu was removed. +- Twisted's Trial test runner is now supported. Thanks to Elric Milon + for the patch! +- All test runners now use a variable to decide which command to run, + which for example allows using ``manage.py`` for the Django test + runner, or your own test script which sets up the environment + correctly. +- Emacs 24.4 is now officially supported. +- Various bugfixes. + +.. _importmagic: https://github.com/alecthomas/importmagic + +New in Elpy 1.6.0 +================= + +- When point is on a line with a flymake error, Elpy will now show the + error in the echo area. +- The movement commands (``C-``) have been reworked again. + Going left and right will now move by indentation levels left of the + current indentation, i.e. jump four spaces, and by words right of + the current indentation. Going up and down will go to the previous + or next line with the indentation level point is at, not the + indentation the line has. Try it, it's more difficult to explain + than to use. +- Completion results are now sorted more sensibly, with + single-underscore symbols at the end, and double-underscore symbols + after normal symbols, but before single-underscore ones. +- ``M-x elpy-config`` will now point out if there are newer versions + available for packages used by Elpy. +- ``M-x elpy-config`` will now warn if ``~/.local/bin`` is not in + ``PATH`` while there is no virtualenv active. +- The ``M-x elpy-version`` command is back by popular demand. +- RPC buffers used by Elpy are now hidden by default, having a space + at the beginning of the name. +- When the Rope library throws an error, Elpy will now also attempt to + provide reproduction steps. This used to only happen for Jedi. +- Various bug fixes. + + +New in Elpy 1.5.1 +================= + +- Fix a bug where company-mode might get confused about the current + backend, leading to an error about ``Symbol's function definition is + void: nil`` +- Fix Rope so it won’t search the whole project directory. This was an + intended feature in v1.5 which did not work originally. +- Use ``yas-text`` instead of ``text`` in snippets for compatibility + with the unreleased yasnippet from MELPA (thanks to Daniel Wu!) + +New in Elpy 1.5.0 +================= + +- Elpy now has a `manual`_. Additionally, there's a menu bar now which + should make it easier to discover Elpy features. +- The Elpy Python package now ships with the Emacs Lisp package, + removing the need to install Elpy via pip. +- Python 3.4 is now officially supported. +- The new command ``elpy-config`` can be used to configure Elpy using + Emacs' built-in customize system. Elpy has been changed to make the + most of this. +- Elpy now uses company-mode instead of auto-complete for on-the-fly + auto completion. This changes a few things. There is no automatic + documentation popup anymore. Instead, you can type ``C-d`` and get + the documentation buffer. In addition, you can type ``C-w`` to see + the source of the current candidate in context. +- Elpy now uses pyvenv as the virtualenv module, enabling + virtualenvwrapper hooks. +- We now ship with a large number of YASnippet snippets. Try ``M-x + yas-insert-snippet``. +- The new unified test running interface on ``C-c C-t`` will try to + determine the current test and run it, or, failing that, run all + tests. Provide a prefix argument to just run all tests no matter + what. You can change the test runner to be used using + ``elpy-set-test-runner``. Elpy supports the default unittest + discover runner, the Django discover runner, nosetests and py.test + by default. New test runners can easily be defined. +- There's a new multi-edit functionality. ``C-c C-e`` will edit all + occurrences of the symbol under point. When using Jedi, this is + using semantic information as opposed to just syntactic one. When a + region is active, edit all occurrences of the text in region in the + current buffer. +- When sending Python code to the interactive interpreter using ``C-c + C-c``, Elpy will now not automatically pop to the interpreter + anymore. Use ``C-c C-z`` to switch to the interpreter. +- Elpy will now display the current class and function if there is no + call tip to be displayed. Removes the ``C-c C-q`` binding. +- If there is a call tip, highlight the current argument (requires Jedi). +- The documentation interface using ``C-c C-d`` is much smarter now, + falling back to pydoc when necessary and providing sensible + completion for that, too. Provide a prefix argument if you want no + smarts, just pydoc. +- ```` and ```` now open a line below or above + the current one. +- ```` will now navigate between Python blocks of the same + indentation level. ```` will move the current block. Try + it, it's easier to understand when you see it than to explain it. +- There's a new concept of modules. The variable + ``elpy-default-minor-modes`` is gone (use ``elpy-mode-hook`` for + minor modes). Instead, there's now ``elpy-modules`` which can be + used to enable or disable certain features of Elpy. +- ``elpy-clean-modeline`` is gone, modules now clean themselves up. +- Elpy now distinguishes between the project root, where project files + are located, and the library root, which should be part of + ``sys.path`` to import the module under development. +- ``elpy-project-ignored-directories`` replaces the old + ``elpy-rgrep-ignored-directories`` and is used by more features. +- ``elpy-doc-websearch`` has been removed as it was barely useable + as is. +- Elpy now tries to be more helpful when errors in the backend happen. + This removes ``elpy-rpc-traceback``, as that will be displayed by + default. +- Optimizations were added to handle large files, making general + interaction a lot faster. +- When Rope is being used, do not search through unusually large + directories. This should speed up interaction in those cases, + especially when editing a file in the home directory. +- And a whole lot of minor bug fixes and little improvements. + +.. _manual: http://elpy.readthedocs.org/ + + +New in Elpy 1.4.2 +================== + +- Minor bugfix to prevent an error from projectile-project-root to + interfere with Elpy’s project finding strategy. + +New in Elpy 1.4.1 +================= + +- Elpy now sets project-wide preferences for Rope, enabling completion + in the sys package, among others. +- An error is avoided in the Jedi backend when trying to go to symbols + in compiled packages. +- A compatibility alias was added for nose.el, which insists on + breaking backwards compatibility with Emacs 24.x. + +New in Elpy 1.4.0 +================= + +- Elpy has moved to its own ELPA. Make sure to update your + package-archives (as described above). +- For a file in a Projectile-managed project is opened, Elpy will now + use Projectile’s project root. +- When the user has set a valid python-check-command, elpy will now + refrain from overriding it. +- On Windows, elpy is now using the pythonw.exe interpreter for the + RPC process, as that seems to be causing fewer issues. +- And various smaller bugfixes. + +New in Elpy 1.3.0 +================= + +- virtualenv.el has been replaced by pyvenv.el, as that library offers + more features. +- elpy-rpc-restart now works globally, not just in Elpy buffers. +- Elpy does not try to complete in comments anymore. +- The new command elpy-rpc-traceback gives access to the last stack + trace in the Elpy backend, helping with debugging problems. +- The flymake check function is now run with the current directory as + / to avoid accidental imports. +- Ensure correct handling of yas-snippet-dirs by Elpy. This variable + can be a string, so ensure it’s a list before adding to it. +- The new variable elpy-show-installation-instructions can be used to + disable the installation screen. +- Fix a very nasty bug causing spurious empty lines in a buffer or + consume 100% CPU in certain situations when using the Jedi backend. + Thanks to Matthias Dahl for finding this bug. +- Various other bugfixes. + +New in Elpy 1.2.1 +================= + +Bugfix release. + +- The refactoring was not ported to the new asynchronous API, + resulting in an error when refactoring was attempted. +- The project root now always returns a directory. Too many parts of + elpy relies on this. If the project root turns out to be your home + directory, elpy will warn you about it. +- Elpy now works correctly with Emacs 24.2. There were some + compatibility functions missing. +- Blocking RPC calls now do not block for one second even if there is + process output. + +New in Elpy 1.2 +=============== + +- Elpy now uses asynchronous RPC. This means that Emacs should not + freeze anymore while eldoc or auto-complete functions run. +- ``elpy-shell-send-region-or-buffer`` will now remove common + indentation of the region, making it possible to easily send parts + of an if statement or function body without manually adjusting the + indentation. +- The Python package depends on ``flake8``, and will also try to be + smarter when detecting ``flake8`` for on-the-fly checking. +- ``elpy-check`` can be run with a prefix argument to check the whole + project, instead of only the current file. +- ``elpy-rgrep-symbol`` now ignores a few common directories + (``.tox``, ``build``, ``dist``). +- When using the rope backend, Elpy will not create the + ``.ropeproject`` folders anymore. This should keep projects a lot + cleaner. + +New in Elpy 1.1 +=============== + +- Elpy now always uses the root directory of the package as the + project root; this should avoid some confusion and improve + auto-completion suggestions +- ``elpy-shell-send-region-or-buffer`` now accepts a prefix argument + to run code wrapped behind ``if __name__ == '__main__'``, which is + ignored by default +- ``elpy-project-root`` is now a safe local variable and can be set + from file variables +- Elpy now supports project-specific RPC processes, see + ``elpy-rpc-project-specific`` for how to use this +- ``M-*`` now works to go back where you came from after a ``M-.`` +- Elpy now ships with a few dedicated snippets for YASnippet +- Support and require Jedi 0.6.0 + +New in Elpy 1.0 +=============== + +- Version 0.9 was a release candidate, so this release focused on bug + fixes instead of new features. +- ``elpy-enable`` now takes an optional argument that skips variable + initialization for those users who prefer their own defaults for + other modes. +- ``python-check.sh`` has been removed from Elpy, as the flake8 tool + from pypi does everything it does, only better. +- Elpy will now start the helper subprocess in the root directory, + avoiding accidental Python path clobbering. + +New in Elpy 0.9 +=============== + +- Elpy now officially support Python 2.6, 2.7 and 3.3 on Emacs 24.2 + and 24.3, with continuous integration tests thanks to + `Travis CI`_. +- Extended support for Pydoc. ``C-u C-c C-d`` will now prompt for an + auto-completed symbol to run Pydoc on. The pydoc output will be + formatted and placed in a help buffer for easy review. +- Refactoring support is back. ``C-c C-r`` will pop up a refactoring + wizard offering various refactoring options. Most of them depend on + the presence of Rope, though, even if Jedi is used as a completion + backend. +- The Rope backend has been extended to provide completions for + modules in an import clause. +- New refactoring option: Add missing imports. This will search for + undefined symbols in the current file and automatically add + appropriate imports. +- ``C-c C-c (elpy-rgrep-symbol)`` now prompts for a regexp when a prefix + argument is given instead of using the symbol at point. + +.. _Travis CI: https://travis-ci.org/ + +New in Elpy 0.8 +=============== + +Python Backend Rewrite +---------------------- + +- Elpy does not use Pymacs, Ropemacs and Ropemode anymore, but instead + provides its own Python interface with the elpy package on PyPI. +- This not only should improve performance, but also enables using + Jedi as an alternative backend for completion. Use ``M-x + elpy-set-backend`` to change between rope and jedi. For now, this + does disable all refactoring support, though. + +Project Support +--------------- + +- Elpy now has built-in project support. The interface is rather + simple: You can set ``elpy-project-root`` to the correct value in + ``.dir-locals.el``, or just rely on the automatic detection. If you + change your mind, you can always just ``elpy-set-project-root``. +- New dependency: Find File in Project (ffip), bound to ``C-c C-f`` by + default. This will allow you to find files anywhere in your project + using a search-as-you-type interface like ido. +- New dependency: nose, bound to ``C-c C-t`` by default. This will run + the nosetests binary in the root of your current library directory. + You can restrict the tests being run to the current test or the + current module by adding prefix arguments. +- New function: Recursive grep for symbol, bound to ``C-c C-s`` by + default. This will search for the symbol at point in the whole + project. + +New dependencies +---------------- + +- idomenu, bound to ``C-c C-j`` by default. This replaces the standard + imenu interface with an ido-based search-as-you-type interface for + definitions in the current buffer. +- virtualenv.el, replacing pyvirtualenv.el). Use ``M-x + virtualenv-workon`` to enable a virtualenv. +- iedit.el, bound to ``M-,`` by default. This highlights all occurrences + of the symbol at point or the active region in the current buffer or + narrowing. When you edit any of them, all others will be edited the + same. This allows some basic and very quick refactoring. +- New variable ``elpy-default-minor-modes`` which is run by ``elpy-mode`` + on startup. If you don’t want to use some modes, remove them from + here. + +Key Bindings and Functions +-------------------------- + +- The key bindings have been reworked and cleaned up. Sorry, this + might cause confusion. +- Yasnippet is now on its own keybinding, ``C-c C-i``, instead of + sharing the auto-complete interface. This was done because some + snippets conflicted with legitimate, unsnippy completions. +- New function: Occur Definitions, bound to ``C-c C-o`` by default. This + will run the standard occur command to show definitions (classes and + functions) in your current buffer, giving you a very quick outline + and the ability to jump to different definitions quickly. +- New function: Show Defun, bound to ``C-c C-q`` by default. This will + show the current method and possibly class in the mode line, which + is helpful in long functions. +- New functions: Forward/backward definition, bound to ``M-n`` and ``M-p`` + as well as ```` and ```` by default. These will jump to + the next or previous definition (class or function), helping with + quick navigation through a file. + +Miscellaneous +------------- + +- The documentation function (``C-c C-d``) now uses pydoc when a prefix + arg is given. +- The web search function (``C-c C-w``) now searches for the current + symbol by default. The tab-completing web documentation interface + was removed and is scheduled to be replaced with a new pydoc + interface in future versions. +- The ``python-check.sh`` is now shipped with elpy. If you load elpy.el + before you load python.el, it should be the default + ``python-check-command``. diff --git a/emacs.d/elpa/elpy-20150502.740/elpy-autoloads.el b/emacs.d/elpa/elpy-20150502.740/elpy-autoloads.el new file mode 100644 index 0000000..5e6db34 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy-autoloads.el @@ -0,0 +1,51 @@ +;;; elpy-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "elpy" "elpy.el" (21837 24215 0 0)) +;;; Generated autoloads from elpy.el + +(autoload 'elpy-enable "elpy" "\ +Enable Elpy in all future Python buffers. + +\(fn &optional IGNORED)" t nil) + +(autoload 'elpy-mode "elpy" "\ +Minor mode in Python buffers for the Emacs Lisp Python Environment. + +This mode fully supports virtualenvs. Once you switch a +virtualenv using \\[pyvenv-workon], you can use +\\[elpy-rpc-restart] to make the elpy Python process use your +virtualenv. + +\\{elpy-mode-map} + +\(fn &optional ARG)" t nil) + +(autoload 'elpy-config "elpy" "\ +Configure Elpy. + +This function will pop up a configuration buffer, which is mostly +a customize buffer, but has some more options. + +\(fn)" t nil) + +(autoload 'elpy-version "elpy" "\ +Display the version of Elpy. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil nil ("elpy-pkg.el" "elpy-refactor.el") (21837 +;;;;;; 24215 521841 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; elpy-autoloads.el ends here diff --git a/emacs.d/elpa/elpy-20150502.740/elpy-pkg.el b/emacs.d/elpa/elpy-20150502.740/elpy-pkg.el new file mode 100644 index 0000000..d0fdb5f --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy-pkg.el @@ -0,0 +1,9 @@ +(define-package "elpy" "20150502.740" "Emacs Python Development Environment" + '((company "0.8.2") + (find-file-in-project "3.3") + (highlight-indentation "0.5.0") + (pyvenv "1.3") + (yasnippet "0.8.0"))) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/elpy-1.7.1/elpy-refactor.el b/emacs.d/elpa/elpy-20150502.740/elpy-refactor.el similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/elpy-refactor.el rename to emacs.d/elpa/elpy-20150502.740/elpy-refactor.el diff --git a/emacs.d/elpa/elpy-20150502.740/elpy.el b/emacs.d/elpa/elpy-20150502.740/elpy.el new file mode 100644 index 0000000..6d35838 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy.el @@ -0,0 +1,3449 @@ +;;; elpy.el --- Emacs Python Development Environment -*- lexical-binding: t -*- + +;; Copyright (C) 2012-2014 Jorgen Schaefer + +;; Author: Jorgen Schaefer +;; URL: https://github.com/jorgenschaefer/elpy +;; Version: 1.8.0 +;; Keywords: Python, IDE, Languages, Tools +;; Package-Requires: ((company "0.8.2") (find-file-in-project "3.3") (highlight-indentation "0.5.0") (pyvenv "1.3") (yasnippet "0.8.0")) + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; The Emacs Lisp Python Environment in Emacs + +;; Elpy is an Emacs package to bring powerful Python editing to Emacs. +;; It combines a number of existing Emacs packages, both written in +;; Emacs Lisp as well as Python. + +;; For more information, read the Elpy manual: + +;; http://elpy.readthedocs.org/en/latest/index.html + +;;; Code: + +(require 'cus-edit) +(require 'etags) +(require 'files-x) +(require 'grep) +(require 'ido) +(require 'json) +(require 'python) + +(require 'elpy-refactor) +(require 'pyvenv) + +(defconst elpy-version "1.8.0" + "The version of the Elpy lisp code.") + +;;;;;;;;;;;;;;;;;;;;;; +;;; User customization + +(defgroup elpy nil + "The Emacs Lisp Python Environment." + :prefix "elpy-" + :group 'languages) + +(defcustom elpy-mode-hook nil + "Hook run when `elpy-mode' is enabled. + +This can be used to enable minor modes for Python development." + :type 'hook + :options '(subword-mode hl-line-mode) + :group 'elpy) + +(defcustom elpy-modules '(elpy-module-sane-defaults + elpy-module-company + elpy-module-eldoc + elpy-module-flymake + elpy-module-highlight-indentation + elpy-module-pyvenv + elpy-module-yasnippet) + "Which Elpy modules to use. + +Elpy can use a number of modules for additional features, which +can be inidividually enabled or disabled." + :type '(set (const :tag "Inline code completion (company-mode)" + elpy-module-company) + (const :tag "Show function signatures (ElDoc)" + elpy-module-eldoc) + (const :tag "Highlight syntax errors (Flymake)" + elpy-module-flymake) + (const :tag "Show the virtualenv in the mode line (pyvenv)" + elpy-module-pyvenv) + (const :tag "Display indentation markers (highlight-indentation)" + elpy-module-highlight-indentation) + (const :tag "Expand code snippets (YASnippet)" + elpy-module-yasnippet) + (const :tag "Configure some sane defaults for Emacs" + elpy-module-sane-defaults)) + :group 'elpy) + +(defcustom elpy-project-ignored-directories ' (".bzr" "CVS" ".git" ".hg" ".svn" + ".tox" "build" "dist" + ".cask") + "Directories ignored by functions working on the whole project." + :type '(repeat string) + :safe (lambda (val) + (cl-every #'stringp val)) + :group 'elpy) + +(defcustom elpy-project-root nil + "The root of the project the current buffer is in. + +There is normally no use in setting this variable directly, as +Elpy tries to detect the project root automatically. See +`elpy-project-root-finder-functions' for a way of influencing +this. + +Setting this variable globally will override Elpy's automatic +project detection facilities entirely. + +Alternatively, you can set this in file- or directory-local +variables using \\[add-file-local-variable] or +\\[add-dir-local-variable]. + +Do not use this variable in Emacs Lisp programs. Instead, call +the `elpy-project-root' function. It will do the right thing." + :type 'directory + :safe 'file-directory-p + :group 'elpy) +(make-variable-buffer-local 'elpy-project-root) + +(defcustom elpy-project-root-finder-functions + '(elpy-project-find-projectile-root + elpy-project-find-python-root + elpy-project-find-git-root + elpy-project-find-hg-root + elpy-project-find-svn-root) + "List of functions to ask for the current project root. + +These will be checked in turn. The first directory found is used." + :type '(set (const :tag "Projectile project root" + elpy-project-find-projectile-root) + (const :tag "Python project (setup.py, setup.cfg)" + elpy-project-find-python-root) + (const :tag "Git repository root (.git)" + elpy-project-find-git-root) + (const :tag "Mercurial project root (.hg)" + elpy-project-find-hg-root) + (const :tag "Subversion project root (.svn)" + elpy-project-find-svn-root)) + :group 'elpy) + +(defcustom elpy-rpc-backend nil + "Your preferred backend. + +Elpy can use different backends for code introspection. These +need to be installed separately using pip or other mechanisms to +make them available to Python. If you prefer not to do this, you +can use the native backend, which is very limited but does not +have any external requirements." + :type '(choice (const :tag "Rope" "rope") + (const :tag "Jedi" "jedi") + (const :tag "Automatic" nil)) + :safe (lambda (val) + (member val '("rope" "jedi" "native" nil))) + :group 'elpy) + +(defcustom elpy-rpc-maximum-buffer-age (* 5 60) + "Seconds after which Elpy automatically closes an unused RPC buffer. + +Elpy creates RPC buffers over time, depending on python interpreters +and the project root. When there are many projects being worked on, +these can accumulate. Setting this variable to an integer will close +buffers and processes when they have not been used for this amount of +seconds. + +Setting this variable to nil will disable the behavior." + :type '(choice (const :tag "Never" nil) + integer) + :group 'elpy) + +(defcustom elpy-rpc-large-buffer-size 4096 + "Size for a source buffer up to which it will be sent directly. + +The Elpy RPC protocol uses JSON as the serialization format. +Large buffers take a long time to encode, so Elpy can transmit +them via temporary files. If a buffer is larger than this value, +it is sent via a temporary file." + :type 'integer + :safe #'integerp + :group 'elpy) + +(defcustom elpy-rpc-ignored-buffer-size 102400 + "Size for a source buffer over which Elpy completion will not work. + +To provide completion, Elpy's backends have to parse the whole +file every time. For very large files, this is slow, and can make +Emacs laggy. Elpy will simply not work on buffers larger than +this to prevent this from happening." + :type 'integer + :safe #'integerp + :group 'elpy) + +(defcustom elpy-rpc-python-command (if (equal system-type "windows-nt") + "pythonw" + "python") + "The Python interpreter for the RPC backend. + +This should be the same interpreter the project will be run with, +and not an interactive shell like ipython." + :type '(choice (const :tag "python" "python") + (const :tag "python2" "python2") + (const :tag "python3" "python3") + (const :tag "pythonw (Python on Windows)" "pythonw") + (string :tag "Other")) + :safe (lambda (val) + (member val '("python" "python2" "python3" "pythonw"))) + :group 'elpy) + +(defcustom elpy-rpc-pythonpath (file-name-directory (locate-library "elpy")) + "A directory to add to the PYTHONPATH for the RPC process. + +This should be a directory where the elpy module can be found. If +this is nil, it's assumed elpy can be found in the standard path. +Usually, there is no need to change this." + :type 'directory + :safe #'file-directory-p + :group 'elpy) + +(defcustom elpy-rpc-timeout 1 + "Number of seconds to wait for a response when blocking. + +When Elpy blocks Emacs to wait for a response from the RPC +process, it will assume it won't come or wait too long after this +many seconds. On a slow computer, or if you have a large project, +you might want to increase this. + +A setting of nil means to block indefinitely." + :type '(choice (const :tag "Block indefinitely" nil) + integer) + :safe (lambda (val) + (or (integerp val) + (null val))) + :group 'elpy) + +(defcustom elpy-rpc-error-timeout 30 + "Minimum number of seconds between error popups. + +When Elpy encounters an error in the backend, it will display a +lengthy description of the problem for a bug report. This hangs +Emacs for a moment, and can be rather annoying if it happens +repeatedly while editing a source file. + +If this variabl is non-nil, Elpy will not display the error +message again within this amount of seconds." + :type 'integer + :group 'elpy) + +(defcustom elpy-eldoc-show-current-function t + "If true, show the current function if no calltip is available. + +When Elpy can not find the calltip of the function call at point, +it can show the name of the function or class and method being +edited instead. Setting this variable to nil disables this feature." + :type 'boolean + :group 'elpy) + +(defcustom elpy-test-runner 'elpy-test-discover-runner + "The test runner to use to run tests." + :type '(choice (const :tag "Unittest Discover" elpy-test-discover-runner) + (const :tag "Django Discover" elpy-test-django-runner) + (const :tag "Nose" elpy-test-nose-runner) + (const :tag "py.test" elpy-test-pytest-runner) + (const :tag "Twisted Trial" elpy-test-trial-runner)) + :safe 'elpy-test-runner-p + :group 'elpy) + +(defcustom elpy-test-discover-runner-command '("python" "-m" "unittest") + "The command to use for `elpy-test-discover-runner'." + :type '(repeat string) + :group 'elpy) + +(defcustom elpy-test-django-runner-command '("django-admin.py" "test" + "--noinput") + "The command to use for `elpy-test-django-runner'." + :type '(repeat string) + :group 'elpy) + +(defcustom elpy-test-nose-runner-command '("nosetests") + "The command to use for `elpy-test-nose-runner'." + :type '(repeat string) + :group 'elpy) + +(defcustom elpy-test-trial-runner-command '("trial") + "The command to use for `elpy-test-trial-runner'." + :type '(repeat string) + :group 'elpy) + +(defcustom elpy-test-pytest-runner-command '("py.test") + "The command to use for `elpy-test-pytest-runner'." + :type '(repeat string) + :group 'elpy) + +;;;;;;;;;;;;; +;;; Elpy Mode + +(defvar elpy-mode-map + (let ((map (make-sparse-keymap))) + ;; Alphabetical order to make it easier to find free C-c C-X + ;; bindings in the future. Heh. + + ;; (define-key map (kbd "") 'python-indent-dedent-line-backspace) + ;; (define-key map (kbd "") 'python-indent-dedent-line) + + ;; (define-key map (kbd "C-M-x") 'python-shell-send-defun) + ;; (define-key map (kbd "C-c <") 'python-indent-shift-left) + ;; (define-key map (kbd "C-c >") 'python-indent-shift-right) + (define-key map (kbd "C-c C-c") 'elpy-shell-send-region-or-buffer) + (define-key map (kbd "C-c C-z") 'elpy-shell-switch-to-shell) + (define-key map (kbd "C-c C-d") 'elpy-doc) + (define-key map (kbd "C-c C-e") 'elpy-multiedit-python-symbol-at-point) + (define-key map (kbd "C-c C-f") 'elpy-find-file) + (define-key map (kbd "C-c RET") 'elpy-importmagic-add-import) + (define-key map (kbd "C-c ") 'elpy-importmagic-fixup) + (define-key map (kbd "C-c C-n") 'elpy-flymake-next-error) + (define-key map (kbd "C-c C-o") 'elpy-occur-definitions) + (define-key map (kbd "C-c C-p") 'elpy-flymake-previous-error) + (define-key map (kbd "C-c C-r") 'elpy-refactor) + (define-key map (kbd "C-c C-s") 'elpy-rgrep-symbol) + (define-key map (kbd "C-c C-t") 'elpy-test) + (define-key map (kbd "C-c C-v") 'elpy-check) + ;; (define-key map (kbd "C-c C-z") 'python-shell-switch-to-shell) + + (define-key map (kbd "") 'elpy-open-and-indent-line-below) + (define-key map (kbd "") 'elpy-open-and-indent-line-above) + + (define-key map (kbd "") 'elpy-nav-forward-block) + (define-key map (kbd "") 'elpy-nav-backward-block) + (define-key map (kbd "") 'elpy-nav-backward-indent) + (define-key map (kbd "") 'elpy-nav-forward-indent) + + (define-key map (kbd "") 'elpy-nav-move-line-or-region-down) + (define-key map (kbd "") 'elpy-nav-move-line-or-region-up) + (define-key map (kbd "") 'elpy-nav-move-region-or-line-left) + (define-key map (kbd "") 'elpy-nav-move-region-or-line-right) + + (define-key map (kbd "M-.") 'elpy-goto-definition) + (define-key map (kbd "M-TAB") 'elpy-company-backend) + + map) + "Key map for the Emacs Lisp Python Environment.") + +(easy-menu-define elpy-menu elpy-mode-map + "Elpy Mode Menu" + '("Elpy" + ["Documentation" elpy-doc + :help "Get documentation for symbol at point"] + ["Run Tests" elpy-test + :help "Run test at point, or all tests in the project"] + ["Go to Definition" elpy-goto-definition + :help "Go to the definition of the symbol at point"] + ["Go to previous definition" pop-tag-mark + :active (not (ring-empty-p find-tag-marker-ring)) + :help "Return to the position"] + ["Complete" elpy-company-backend + :keys "M-TAB" + :help "Complete at point"] + ["Refactor" elpy-refactor + :help "Refactor options"] + "---" + ("Interactive Python" + ["Switch to Python Shell" elpy-shell-switch-to-shell + :help "Start and switch to the interactive Python"] + ["Send Region or Buffer" elpy-shell-send-region-or-buffer + :label (if (use-region-p) + "Send Region to Python" + "Send Buffer to Python") + :help "Send the current region or the whole buffer to Python"] + ["Send Definition" python-shell-send-defun + :help "Send current definition to Python"]) + ("Project" + ["Find File" elpy-find-file + :help "Interactively find a file in the current project"] + ["Find Symbol" elpy-rgrep-symbol + :help "Find occurrences of a symbol in the current project"] + ["Set Project Root" elpy-set-project-root + :help "Change the current project root"] + ["Set Project Variable" elpy-set-project-variable + :help "Configure a project-specific option"]) + ("Syntax Check" + ["Check Syntax" elpy-check + :help "Check the syntax of the current file"] + ["Next Error" elpy-flymake-next-error + :help "Go to the next inline error, if any"] + ["Previous Error" elpy-flymake-previous-error + :help "Go to the previous inline error, if any"]) + ("Indentation Blocks" + ["Dedent" elpy-nav-move-region-or-line-left + :help "Dedent current block or region" + :suffix (if (use-region-p) "Region" "Block")] + ["Indent" elpy-nav-move-region-or-line-right + :help "Indent current block or region" + :suffix (if (use-region-p) "Region" "Block")] + ["Up" elpy-nav-move-line-or-region-up + :help "Move current block or region up" + :suffix (if (use-region-p) "Region" "Block")] + ["Down" elpy-nav-move-line-or-region-down + :help "Move current block or region down" + :suffix (if (use-region-p) "Region" "Block")]) + "---" + ["News" elpy-news t] + ["Configure" elpy-config t])) + +;;;###autoload +(defun elpy-enable (&optional ignored) + "Enable Elpy in all future Python buffers." + (interactive) + (when (< emacs-major-version 24) + (error "Elpy requires Emacs 24 or newer")) + (when ignored + (warn "The argument to `elpy-enable' is deprecated, customize `elpy-modules' instead")) + (let ((filename (find-lisp-object-file-name 'python-mode + 'symbol-function))) + (when (and filename + (string-match "/python-mode\\.el\\'" + filename)) + (error (concat "You are using python-mode.el. " + "Elpy only works with python.el from " + "Emacs 24 and above")))) + (elpy-modules-global-init) + (add-hook 'python-mode-hook 'elpy-mode)) + +(defun elpy-disable () + "Disable Elpy in all future Python buffers." + (interactive) + (remove-hook 'python-mode-hook 'elpy-mode) + (elpy-modules-global-stop)) + +;;;###autoload +(define-minor-mode elpy-mode + "Minor mode in Python buffers for the Emacs Lisp Python Environment. + +This mode fully supports virtualenvs. Once you switch a +virtualenv using \\[pyvenv-workon], you can use +\\[elpy-rpc-restart] to make the elpy Python process use your +virtualenv. + +\\{elpy-mode-map}" + :lighter " Elpy" + (when (not (eq major-mode 'python-mode)) + (error "Elpy only works with `python-mode'")) + (cond + (elpy-mode + (elpy-modules-buffer-init)) + ((not elpy-mode) + (elpy-modules-buffer-stop)))) + +;;;;;;;;;;;;; +;;; Elpy News + +(defun elpy-news () + "Display Elpy's release notes." + (interactive) + (with-current-buffer (get-buffer-create "*Elpy News*") + (let ((inhibit-read-only t)) + (erase-buffer) + (insert-file (concat (file-name-directory (locate-library "elpy")) + "NEWS.rst")) + (help-mode)) + (pop-to-buffer (current-buffer)))) + +;;;;;;;;;;;;;;; +;;; Elpy Config + +(defvar elpy-config--related-custom-groups + '(("Elpy" elpy "elpy-") + ("Python" python "python-") + ("Virtual Environments (Pyvenv)" pyvenv "pyvenv-") + ("Completion (Company)" company "company-") + ("Call Signatures (ElDoc)" eldoc "eldoc-") + ("Inline Errors (Flymake)" flymake "flymake-") + ("Snippets (YASnippet)" yasnippet "yas-") + ("Directory Grep (rgrep)" grep "grep-") + ("Search as You Type (ido)" ido "ido-") + ;; ffip does not use defcustom + ;; highlight-indent does not use defcustom, either. Its sole face + ;; is defined in basic-faces. + )) + +(defvar elpy-config--get-config "import json +import sys + +try: + import xmlrpclib +except ImportError: + import xmlrpc.client as xmlrpclib + +from distutils.version import LooseVersion + + +def latest(package, version=None): + try: + pypi = xmlrpclib.ServerProxy('https://pypi.python.org/pypi') + latest = pypi.package_releases(package)[0] + if version is None or LooseVersion(version) < LooseVersion(latest): + return latest + else: + return None + except: + return None + + +config = {} +config['python_version'] = ('{major}.{minor}.{micro}' + .format(major=sys.version_info[0], + minor=sys.version_info[1], + micro=sys.version_info[2])) + +try: + import elpy + config['elpy_version'] = elpy.__version__ +except: + config['elpy_version'] = None + +try: + import jedi + if isinstance(jedi.__version__, tuple): + config['jedi_version'] = '.'.join(str(x) for x in jedi.__version__) + else: + config['jedi_version'] = jedi.__version__ + config['jedi_latest'] = latest('jedi', config['jedi_version']) +except: + config['jedi_version'] = None + config['jedi_latest'] = latest('jedi') + +try: + import rope + config['rope_version'] = rope.VERSION + if sys.version_info[0] <= 2: + config['rope_latest'] = latest('rope', config['rope_version']) + else: + config['rope_latest'] = latest('rope_py3k', config['rope_version']) +except: + config['rope_version'] = None + config['rope_latest'] = latest('rope') + +try: + import importmagic + config['importmagic_version'] = importmagic.__version__ + config['importmagic_latest'] = latest('importmagic', config['importmagic_version']) +except: + config['importmagic_version'] = None + config['importmagic_latest'] = latest('importmagic') + +json.dump(config, sys.stdout) +") + +(defun elpy-config-error (&optional fmt &rest args) + "Note a configuration problem. + +This will show a message in the minibuffer that tells the user to +use \\[elpy-config]." + (let ((msg (if fmt + (apply #'format fmt args) + "Elpy is not properly configured"))) + (error "%s; use M-x elpy-config to configure it" msg))) + +;;;###autoload +(defun elpy-config () + "Configure Elpy. + +This function will pop up a configuration buffer, which is mostly +a customize buffer, but has some more options." + (interactive) + (let ((buf (custom-get-fresh-buffer "*Elpy Config*")) + (config (elpy-config--get-config)) + (custom-search-field nil)) + (with-current-buffer buf + (elpy-insert--header "Elpy Configuration") + + (elpy-config--insert-configuration-problems config) + + (elpy-insert--header "Options") + + (let ((custom-buffer-style 'tree)) + (Custom-mode) + (elpy-config--insert-help) + (dolist (cust elpy-config--related-custom-groups) + (widget-create 'custom-group + :custom-last t + :custom-state 'hidden + :tag (car cust) + :value (cadr cust))) + (widget-setup) + (goto-char (point-min)))) + (pop-to-buffer-same-window buf))) + +;;;###autoload +(defun elpy-version () + "Display the version of Elpy." + (interactive) + (message "Elpy %s (use M-x elpy-config for details)" elpy-version)) + +(defun elpy-config--insert-help () + (let ((start (point))) + ;; Help display from `customize-browse' + (widget-insert (format "\ +%s buttons; type RET or click mouse-1 +on a button to invoke its action. +Invoke [+] to expand a group, and [-] to collapse an expanded group.\n" + (if custom-raised-buttons + "`Raised' text indicates" + "Square brackets indicate"))) + (if custom-browse-only-groups + (widget-insert "\ +Invoke the [Group] button below to edit that item in another window.\n\n") + (widget-insert "Invoke the ") + (widget-create 'item + :format "%t" + :tag "[Group]" + :tag-glyph "folder") + (widget-insert ", ") + (widget-create 'item + :format "%t" + :tag "[Face]" + :tag-glyph "face") + (widget-insert ", and ") + (widget-create 'item + :format "%t" + :tag "[Option]" + :tag-glyph "option") + (widget-insert " buttons below to edit that +item in another window.\n\n") + + (fill-region start (point))))) + +(defun elpy-config--insert-configuration-problems (&optional config) + "Insert help text and widgets for configuration problems." + (when (not config) + (setq config (elpy-config--get-config))) + (let* ((python-version (gethash "python_version" config)) + (rope-pypi-package (if (and python-version + (string-match "^3\\." python-version)) + "rope_py3k" + "rope"))) + + (elpy-config--insert-configuration-table config) + (insert "\n") + + ;; Python not found + (when (not (gethash "python_rpc_executable" config)) + (elpy-insert--para + "Elpy can not find the configured Python interpreter. Please make " + "sure that the variable `elpy-rpc-python-command' points to a " + "command in your PATH. You can change the variable below.\n\n")) + + ;; No virtual env + (when (and (gethash "python_rpc_executable" config) + (not (gethash "virtual_env" config))) + (elpy-insert--para + "You have not activated a virtual env. While Elpy supports this, " + "it is often a good idea to work inside a virtual env. You can use " + "M-x pyvenv-activate or M-x pyvenv-workon to activate a virtual " + "env.\n\n")) + + ;; No virtual env, but ~/.local/bin not in PATH + (when (and (not (memq system-type '(ms-dos windows-nt))) + (gethash "python_rpc_executable" config) + (not pyvenv-virtual-env) + (not (or (member (expand-file-name "~/.local/bin") + exec-path) + (member (expand-file-name "~/.local/bin/") + exec-path)))) + (elpy-insert--para + "The directory ~/.local/bin/ is not in your PATH, even though you " + "do not have an active virtualenv. Installing Python packages " + "locally will create executables in that directory, so Emacs " + "won't find them. If you are missing some commands, do add this " + "directory to your PATH.\n\n")) + + ;; Python found, but can't find the elpy module + (when (and (gethash "python_rpc_executable" config) + (not (gethash "elpy_version" config))) + (elpy-insert--para + "The Python interpreter could not find the elpy module. " + "Make sure the module is installed" + (if (gethash "virtual_env" config) + " in the current virtualenv.\n" + ".\n")) + (insert "\n") + (widget-create 'elpy-insert--pip-button :package "elpy") + (insert "\n\n")) + + ;; Bad backend version + (when (and (gethash "elpy_version" config) + (not (equal (gethash "elpy_version" config) + elpy-version))) + (let ((elpy-python-version (gethash "elpy_version" config))) + (elpy-insert--para + "The Elpy backend is version " elpy-python-version " while " + "the Emacs package is " elpy-version ". This is incompatible. " + (if (version< elpy-python-version elpy-version) + "Please upgrade the Python module." + "Please upgrade the Emacs Lisp package.") + "\n"))) + + ;; Otherwise unparseable output. + (when (gethash "error_output" config) + (elpy-insert--para + "There was an unexpected problem starting the RPC process. Please " + "check the following output to see if this makes sense to you. " + "To me, it doesn't.\n") + (insert "\n" + (gethash "error_output" config) "\n" + "\n")) + + ;; Requested backend unavailable + (when (and (gethash "python_rpc_executable" config) + (or (and (equal elpy-rpc-backend "rope") + (not (gethash "rope_version" config))) + (and (equal elpy-rpc-backend "jedi") + (not (gethash "jedi_version" config))))) + (elpy-insert--para + "You requested Elpy to use the backend " elpy-rpc-backend ", " + "but the Python interpreter could not load that module. Make " + "sure the module is installed, or change the value of " + "`elpy-rpc-backend' below to one of the available backends.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button + :package (if (equal elpy-rpc-backend "rope") + rope-pypi-package + "jedi")) + (insert "\n\n")) + + ;; No backend available. + (when (and (gethash "python_rpc_executable" config) + (and (not elpy-rpc-backend) + (not (gethash "rope_version" config)) + (not (gethash "jedi_version" config)))) + (elpy-insert--para + "There is no backend available. Please install either Rope or Jedi.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button :package rope-pypi-package) + (insert "\n") + (widget-create 'elpy-insert--pip-button :package "jedi") + (insert "\n\n")) + + ;; Newer version of Rope available + (when (and (gethash "rope_version" config) + (gethash "rope_latest" config)) + (elpy-insert--para + "There is a newer version of Rope available.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button + :package rope-pypi-package :upgrade t) + (insert "\n\n")) + + ;; Newer version of Jedi available + (when (and (gethash "jedi_version" config) + (gethash "jedi_latest" config)) + (elpy-insert--para + "There is a newer version of Jedi available.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button + :package "jedi" :upgrade t) + (insert "\n\n")) + + ;; No importmagic available + (when (not (gethash "importmagic_version" config)) + (elpy-insert--para + "The importmagic package is not available. Commands using this will " + "not work.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button + :package "importmagic") + (insert "\n\n")) + + ;; Newer version of importmagic available + (when (and (gethash "importmagic_version" config) + (gethash "importmagic_latest" config)) + (elpy-insert--para + "There is a newer version of the importmagic package available.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button + :package "importmagic" :upgrade t) + (insert "\n\n")) + + ;; flake8, the default syntax checker, not found + (when (not (executable-find "flake8")) + (elpy-insert--para + "The configured syntax checker could not be found. Elpy uses this " + "program to provide syntax checks of your programs, so you might " + "want to install one. Elpy by default uses flake8.\n") + (insert "\n") + (widget-create 'elpy-insert--pip-button :package "flake8") + (insert "\n\n")) + + )) + +(defun elpy-config--get-config () + "Return the configuration from `elpy-rpc-python-command'. + +This returns a hash table with the following keys (all strings): + +emacs_version +python_rpc +python_rpc_executable +python_interactive +python_interactive_executable +python_version (RPC) +elpy_version +jedi_version +rope_version +virtual_env +virtual_env_short" + (with-temp-buffer + (let ((config (make-hash-table :test #'equal))) + (puthash "emacs_version" emacs-version config) + (puthash "python_rpc" elpy-rpc-python-command config) + (puthash "python_rpc_executable" + (executable-find elpy-rpc-python-command) + config) + (let ((interactive-python (if (boundp 'python-python-command) + python-python-command + python-shell-interpreter))) + (puthash "python_interactive" + interactive-python + config) + (puthash "python_interactive_executable" + (executable-find interactive-python) + config)) + (let ((venv (getenv "VIRTUAL_ENV"))) + (puthash "virtual_env" venv config) + (if venv + (puthash "virtual_env_short" (file-name-nondirectory venv) config) + (puthash "virtual_env_short" nil config))) + (let ((return-value (ignore-errors + (let ((process-environment + (elpy-rpc--environment)) + (default-directory "/")) + (call-process elpy-rpc-python-command + nil + (current-buffer) + nil + "-c" + elpy-config--get-config))))) + (when return-value + (let ((data (ignore-errors + (let ((json-array-type 'list)) + (goto-char (point-min)) + (json-read))))) + (if (not data) + (puthash "error_output" (buffer-string) config) + (dolist (pair data) + (puthash (symbol-name (car pair)) (cdr pair) config)))))) + config))) + +(defun elpy-config--insert-configuration-table (&optional config) + "Insert a table describing the current Elpy config." + (when (not config) + (setq config (elpy-config--get-config))) + (let ((emacs-version (gethash "emacs_version" config)) + (python-version (gethash "python_version" config)) + (python-rpc (gethash "python_rpc" config)) + (python-rpc-executable (gethash "python_rpc_executable" config)) + (python-interactive (gethash "python_interactive" config)) + (python-interactive-executable (gethash "python_interactive_executable" + config)) + (elpy-python-version (gethash "elpy_version" config)) + (jedi-version (gethash "jedi_version" config)) + (jedi-latest (gethash "jedi_latest" config)) + (rope-version (gethash "rope_version" config)) + (rope-latest (gethash "rope_latest" config)) + (importmagic-version (gethash "importmagic_version" config)) + (importmagic-latest (gethash "importmagic_latest" config)) + (virtual-env (gethash "virtual_env" config)) + (virtual-env-short (gethash "virtual_env_short" config)) + table maxwidth) + (setq table + `(("Virtualenv" . ,(if (gethash "virtual_env" config) + (format "%s (%s)" + virtual-env-short + virtual-env) + "None")) + ("RPC Python" . ,(cond + (python-version + (format "%s (%s)" + python-version + python-rpc-executable)) + (python-rpc-executable + python-rpc-executable) + (python-rpc + (format "%s (not found)" python-rpc)) + (t + (format "Not configured")))) + ("Interactive Python" . ,(cond + (python-interactive-executable + (format "%s (%s)" + python-interactive + python-interactive-executable)) + (python-interactive + (format "%s (not found)" + python-interactive)) + (t + "Not configured"))) + ("Emacs" . ,emacs-version) + ("Elpy" . ,(cond + ((and elpy-python-version elpy-version + (equal elpy-python-version elpy-version)) + elpy-version) + (elpy-python-version + (format "%s (Python), %s (Emacs Lisp)" + elpy-python-version + elpy-version)) + (t + (format "Not found (Python), %s (Emacs Lisp)" + elpy-version)))) + ("Jedi" . ,(elpy-config--package-link "jedi" + jedi-version + jedi-latest)) + ("Rope" . ,(elpy-config--package-link "rope" + rope-version + rope-latest)) + ("Importmagic" . ,(elpy-config--package-link "importmagic" + importmagic-version + importmagic-latest)) + ("Syntax checker" . ,(let ((syntax-checker + (executable-find + python-check-command))) + (if syntax-checker + (format "%s (%s)" + (file-name-nondirectory + syntax-checker) + syntax-checker) + (format "Not found (%s)" + python-check-command)))))) + (setq maxwidth 0) + (dolist (row table) + (when (> (length (car row)) + maxwidth) + (setq maxwidth (length (car row))))) + (dolist (row table) + (insert (car row) + (make-string (- maxwidth (length (car row))) + ?.) + ": " + (cdr row) + "\n")))) + +(defun elpy-config--package-link (name version latest) + "Return a string detailing a Python package. + +NAME is the PyPI name of the package. VERSION is the currently +installed version. LATEST is the latest-available version on +PyPI, or nil if that's VERSION." + (cond + ((and (not version) (not latest)) + "Not found") + ((not latest) + version) + ((not version) + (format "Not found (%s available)" latest)) + (t + (format "%s (%s available)" version latest)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Elpy Formatted Insertion + +(defmacro elpy-insert--popup (buffer-name &rest body) + "Pop up a help buffer named BUFFER-NAME and execute BODY in it." + (declare (indent 1)) + `(with-help-window ,buffer-name + (with-current-buffer standard-output + ,@body))) + +(defun elpy-insert--para (&rest messages) + "Insert a bunch of text and then fill it." + (let ((start (point))) + (mapc (lambda (obj) + (if (stringp obj) + (insert obj) + (insert (format "%s" obj)))) + messages) + (fill-region start (point)))) + +(defun elpy-insert--header (&rest text) + "Insert TEXT has a header for a buffer." + (insert (propertize (mapconcat #'(lambda (x) x) + text + "") + 'face 'header-line) + "\n" + "\n")) + +(define-widget 'elpy-insert--pip-button 'item + "A button that runs pip (or an alternative)." + :button-prefix "[" + :button-suffix "]" + :format "%[run%] %v" + :value-create 'elpy-insert--pip-button-value-create + :action 'elpy-insert--pip-button-action) + +(defun elpy-insert--pip-button-value-create (widget) + "The :value-create option for the pip button widget." + (let* ((python-package (widget-get widget :package)) + (do-upgrade (widget-get widget :upgrade)) + (upgrade-option (if do-upgrade + "--upgrade " + "")) + (do-user-install (not (or (getenv "VIRTUAL_ENV") + pyvenv-virtual-env))) + (user-option (if do-user-install + "--user " + "")) + + (command (cond + ((executable-find "pip") + (format "pip install %s%s%s" + user-option upgrade-option python-package)) + ((executable-find "easy_install") + (format "easy_install %s%s" + user-option python-package)) + (t + (error "Neither easy_install nor pip found"))))) + (widget-put widget :command command) + (insert command))) + +(defun elpy-insert--pip-button-action (widget &optional event) + "The :action option for the pip button widget." + (async-shell-command (widget-get widget :command))) + +;;;;;;;;;;;; +;;; Projects + +(defvar elpy-project--variable-name-history nil + "The history for `elpy-project--read-project-variable'") + +(defun elpy-project-root () + "Return the root of the current buffer's project. + +This can very well be nil if the current file is not part of a +project. + +See `elpy-project-root-finder-functions' for a way to configure +how the project root is found. You can also set the variable +`elpy-project-root' in, for example, .dir-locals.el to override +this." + (when (not elpy-project-root) + (setq elpy-project-root + (run-hook-with-args-until-success + 'elpy-project-root-finder-functions))) + elpy-project-root) + +(defun elpy-set-project-root (new-root) + "Set the Elpy project root to NEW-ROOT." + (interactive "DNew project root: ") + (setq elpy-project-root new-root)) + +(defun elpy-project-find-python-root () + "Return the current Python project root, if any. + +This is marked with setup.py or setup.cfg." + (or (locate-dominating-file default-directory "setup.py") + (locate-dominating-file default-directory "setup.cfg"))) + +(defun elpy-project-find-git-root () + "Return the current git repository root, if any." + (locate-dominating-file default-directory ".git")) + +(defun elpy-project-find-hg-root () + "Return the current git repository root, if any." + (locate-dominating-file default-directory ".hg")) + +(defun elpy-project-find-svn-root () + "Return the current git repository root, if any." + (locate-dominating-file default-directory + (lambda (dir) + (and (file-directory-p (format "%s/.svn" dir)) + (not (file-directory-p (format "%s/../.svn" + dir))))))) + +(defun elpy-project-find-projectile-root () + "Return the current project root according to projectile." + ;; `ignore-errors' both to avoid an unbound function error as well + ;; as ignore projectile saying there is no project root here. + (ignore-errors + (projectile-project-root))) + +(defun elpy-library-root () + "Return the root of the Python package chain of the current buffer. + +That is, if you have /foo/package/module.py, it will return /foo, +so that import package.module will pick up module.py." + (locate-dominating-file default-directory + (lambda (dir) + (not (file-exists-p + (format "%s/__init__.py" + dir)))))) + +(defun elpy-project--read-project-variable (prompt) + "Prompt the user for a variable name to set project-wide." + (let* ((prefixes (mapcar (lambda (cust) + (nth 2 cust)) + elpy-config--related-custom-groups)) + (var-regex (format "^%s" (regexp-opt prefixes)))) + (intern + (completing-read + prompt + obarray + (lambda (sym) + (and (get sym 'safe-local-variable) + (string-match var-regex (symbol-name sym)) + (get sym 'custom-type))) + :require-match + nil + 'elpy-project--variable-name-history)))) + +(defun elpy-project--read-variable-value (prompt variable) + "Read the value for VARIABLE from the user." + (let ((custom-type (get variable 'custom-type))) + (if custom-type + (widget-prompt-value (if (listp custom-type) + custom-type + (list custom-type)) + prompt + (if (boundp variable) + (funcall + (or (get variable 'custom-get) + 'symbol-value) + variable)) + (not (boundp variable))) + (eval-minibuffer prompt)))) + +(defun elpy-set-project-variable (variable value) + "Set or remove a variable in the project-wide .dir-locals.el. + +With prefix argument, remove the variable." + (interactive + (let* ((variable (elpy-project--read-project-variable + (if current-prefix-arg + "Remove project variable: " + "Set project variable: "))) + (value (if current-prefix-arg + nil + (elpy-project--read-variable-value (format "Value for %s: " + variable) + variable)))) + (list variable value))) + (with-current-buffer (find-file-noselect (format "%s/%s" + (elpy-project-root) + dir-locals-file)) + (modify-dir-local-variable nil + variable + value + (if current-prefix-arg + 'delete + 'add-or-replace)))) + +;;;;;;;;;;;;;;;;;;;;;;;; +;;; Search Project Files + +(defun elpy-rgrep-symbol (regexp) + "Search for REGEXP in the current project. + +REGEXP defaults to the symbol at point, or the current region if +active. + +With a prefix argument, always prompt for a string to search +for." + (interactive + (list + (cond + (current-prefix-arg + (read-from-minibuffer "Search in project for regexp: ")) + ((use-region-p) + (buffer-substring-no-properties (region-beginning) + (region-end))) + (t + (let ((symbol (thing-at-point 'symbol))) + (if symbol + (format "\\<%s\\>" symbol) + (read-from-minibuffer "Search in project for regexp: "))))))) + (grep-compute-defaults) + (let ((grep-find-ignored-directories (append elpy-project-ignored-directories + grep-find-ignored-directories))) + (rgrep regexp + "*.py" + (or (elpy-project-root) + default-directory))) + (with-current-buffer next-error-last-buffer + (let ((inhibit-read-only t)) + (save-excursion + (goto-char (point-min)) + (when (re-search-forward "^find .*" nil t) + (replace-match (format "Searching for '%s'\n" + (regexp-quote regexp)))))))) + +;;;;;;;;;;;;;;;;;;;;;; +;;; Find Project Files + +(defun elpy-find-file (&optional dwim) + "Efficiently find a file in the current project. + +With prefix argument, tries to guess what kind of file the user +wants to open. + +On an import line, it opens the file of that module. + +Otherwise, it opens a test file associated with the current file, +if one exists. A test file is named test_.py if the current +file is .py, and is either in the same directors or a +\"test\" or \"tests\" subdirectory." + (interactive "P") + (cond + ((and dwim + (buffer-file-name) + (save-excursion + (goto-char (line-beginning-position)) + (or (looking-at "^ *import +\\([[:alnum:]._]+\\)") + (looking-at "^ *from +\\([[:alnum:]._]+\\) +import +\\([[:alnum:]._]+\\)")))) + (let* ((module (if (match-string 2) + (format "%s.%s" (match-string 1) (match-string 2)) + (match-string 1))) + (path (elpy-find--resolve-module module))) + (if path + (find-file path) + (elpy-find-file nil)))) + ((and dwim + (buffer-file-name)) + (let ((test-file (elpy-find--test-file))) + (if test-file + (find-file test-file) + (elpy-find-file nil)))) + (t + (let ((ffip-prune-patterns elpy-project-ignored-directories) + (ffip-project-root (elpy-project-root)) + ;; Set up ido to use vertical file lists. + (ido-decorations '("\n" "" "\n" "\n..." + "[" "]" " [No match]" " [Matched]" + " [Not readable]" " [Too big]" + " [Confirm]")) + (ido-setup-hook (cons (lambda () + (define-key ido-completion-map (kbd "") + 'ido-next-match) + (define-key ido-completion-map (kbd "") + 'ido-prev-match)) + ido-setup-hook))) + (find-file-in-project))))) + +(defun elpy-find--test-file () + "Return the test file for the current file, if any. + +If this is a test file, return the non-test file. + +A test file is named test_.py if the current file is +.py, and is either in the same directors or a \"test\" or +\"tests\" subdirectory." + (catch 'return + (let (full-name directory file) + (setq full-name (buffer-file-name)) + (when (not full-name) + (throw 'return nil)) + (setq full-name (expand-file-name full-name) + directory (file-name-directory full-name) + file (file-name-nondirectory full-name)) + (if (string-match "^test_" file) + (let ((file (substring file 5))) + (dolist (implementation (list (format "%s/%s" directory file) + (format "%s/../%s" directory file))) + (when (file-exists-p implementation) + (throw 'return implementation)))) + (dolist (test (list (format "%s/test_%s" directory file) + (format "%s/test/test_%s" directory file) + (format "%s/tests/test_%s" directory file) + (format "%s/../test/test_%s" directory file) + (format "%s/../tests/test_%s" directory file))) + (when (file-exists-p test) + (throw 'return test))))))) + +(defun elpy-find--module-path (module) + "Return a directory path for MODULE. + +The resulting path is not guaranteed to exist. This simply +resolves leading periods relative to the current directory and +replaces periods in the middle of the string with slashes. + +Only works with absolute imports. Stop using implicit relative +imports. They're a bad idea." + (let* ((relative-depth (when(string-match "^\\.+" module) + (length (match-string 0 module)))) + (base-directory (if relative-depth + (format "%s/%s" + (buffer-file-name) + (mapconcat (lambda (_) + "../") + (make-vector relative-depth + nil) + "")) + (elpy-library-root))) + (file-name (replace-regexp-in-string + "\\." + "/" + (if relative-depth + (substring module relative-depth) + module)))) + (expand-file-name (format "%s/%s" base-directory file-name)))) + +(defun elpy-find--resolve-module (module) + "Resolve MODULE relative to the current file and project. + +Returns a full path name for that module." + (catch 'return + (let ((path (elpy-find--module-path module))) + (while (string-prefix-p (expand-file-name (elpy-library-root)) + path) + (dolist (name (list (format "%s.py" path) + (format "%s/__init__.py" path))) + (when (file-exists-p name) + (throw 'return name))) + (if (string-match "/$" path) + (setq path (substring path 0 -1)) + (setq path (file-name-directory path))))) + nil)) + +;;;;;;;;;;;;;;;;;;;;; +;;; Interactive Shell + +(defun elpy-use-ipython (&optional ipython) + "Set defaults to use IPython instead of the standard interpreter. + +With prefix arg, prompt for the command to use." + (interactive (list (when current-prefix-arg + (read-file-name "IPython command: ")))) + (when (not ipython) + (setq ipython "ipython")) + (when (not (executable-find ipython)) + (error "Command %S not found" ipython)) + (cond + ;; Emacs 24 until 24.3 + ((boundp 'python-python-command) + (setq python-python-command ipython)) + ;; Emacs 24.3 + ((and (version<= "24.3" emacs-version) + (not (boundp 'python-shell-interpreter-interactive-arg))) + ;; This is from the python.el commentary. + ;; Settings for IPython 0.11: + (setq python-shell-interpreter ipython + python-shell-interpreter-args "" + python-shell-prompt-regexp "In \\[[0-9]+\\]: " + python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " + python-shell-completion-setup-code + "from IPython.core.completerlib import module_completion" + python-shell-completion-module-string-code + "';'.join(module_completion('''%s'''))\n" + python-shell-completion-string-code + "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")) + ;; Emacs 24.4 + ((boundp 'python-shell-interpreter-interactive-arg) + (setq python-shell-interpreter ipython + python-shell-interpreter-args "-i") + ;; Windows requires some special handling here, see #422 + (let ((exe "C:\\Python27\\python.exe") + (ipython_py "C:\\Python27\\Scripts\\ipython-script.py")) + (when (and (eq system-type 'windows-nt) + (file-exists-p exe) + (file-exists-p ipython_py)) + (setq python-shell-interpreter exe + python-shell-interpreter-args "-i " + ipython_py)))) + (t + (error "I don't know how to set ipython settings for this Emacs")))) + +(defun elpy-use-cpython (&optional cpython) + "Set defaults to use the standard interpreter instead of IPython. + +With prefix arg, prompt for the command to use." + (interactive (list (when current-prefix-arg + (read-file-name "Python command: ")))) + (when (not cpython) + (setq cpython "python")) + (when (not (executable-find cpython)) + (error "Command %S not found" cpython)) + (cond + ;; Emacs 24 until 24.3 + ((boundp 'python-python-command) + (setq python-python-command cpython)) + ;; Emacs 24.3 and onwards. + ((and (version<= "24.3" emacs-version) + (not (boundp 'python-shell-interpreter-interactive-arg))) + (setq python-shell-interpreter cpython + python-shell-interpreter-args "-i" + python-shell-prompt-regexp ">>> " + python-shell-prompt-output-regexp "" + python-shell-completion-setup-code + "try: + import readline +except ImportError: + def __COMPLETER_all_completions(text): [] +else: + import rlcompleter + readline.set_completer(rlcompleter.Completer().complete) + def __COMPLETER_all_completions(text): + import sys + completions = [] + try: + i = 0 + while True: + res = readline.get_completer()(text, i) + if not res: break + i += 1 + completions.append(res) + except NameError: + pass + return completions" + python-shell-completion-module-string-code "" + python-shell-completion-string-code + "';'.join(__COMPLETER_all_completions('''%s'''))\n")) + ;; Emacs 24.4 + ((boundp 'python-shell-interpreter-interactive-arg) + (setq python-shell-interpreter cpython + python-shell-interpreter-args "-i")) + (t + (error "I don't know how to set ipython settings for this Emacs")))) + +(defun elpy-shell-send-region-or-buffer (&optional arg) + "Send the active region or the buffer to the Python shell. + +If there is an active region, send that. Otherwise, send the +whole buffer. + +In Emacs 24.3 and later, without prefix argument, this will +escape the Python idiom of if __name__ == '__main__' to be false +to avoid accidental execution of code. With prefix argument, this +code is executed." + (interactive "P") + ;; Ensure process exists + (elpy-shell-get-or-create-process) + (let ((if-main-regex "^if +__name__ +== +[\"']__main__[\"'] *:") + (has-if-main nil)) + (if (use-region-p) + (let ((region (elpy-shell--region-without-indentation + (region-beginning) (region-end)))) + (setq has-if-main (string-match if-main-regex region)) + (when (string-match "\t" region) + (message "Region contained tabs, this might cause weird errors")) + (python-shell-send-string region)) + (save-excursion + (goto-char (point-min)) + (setq has-if-main (re-search-forward if-main-regex nil t))) + (python-shell-send-buffer arg)) + (display-buffer (process-buffer (elpy-shell-get-or-create-process)) + nil + 'visible) + (when has-if-main + (message (concat "Removed if __main__ == '__main__' construct, " + "use a prefix argument to evaluate."))))) + +(defun elpy-shell-switch-to-shell () + "Switch to inferior Python process buffer." + (interactive) + (pop-to-buffer (process-buffer (elpy-shell-get-or-create-process)))) + +(defun elpy-shell-get-or-create-process () + "Get or create an inferior Python process for current buffer and return it." + (let* ((bufname (format "*%s*" (python-shell-get-process-name nil))) + (proc (get-buffer-process bufname))) + (if proc + proc + (run-python (python-shell-parse-command)) + (get-buffer-process bufname)))) + +(defun elpy-shell--region-without-indentation (beg end) + "Return the current region as a string, but without indentation." + (if (= beg end) + "" + (let ((region (buffer-substring beg end)) + (indent-level nil)) + (with-temp-buffer + (insert region) + (goto-char (point-min)) + (while (< (point) (point-max)) + (cond + ((and (not indent-level) + (not (looking-at "[ \t]*$"))) + (setq indent-level (current-indentation))) + ((and indent-level + (not (looking-at "[ \t]*$")) + (< (current-indentation) + indent-level)) + (error "Can't adjust indentation, consecutive lines indented less than starting line"))) + (forward-line)) + (indent-rigidly (point-min) + (point-max) + (- indent-level)) + (buffer-string))))) + +;;;;;;;;;;;;;;;;; +;;; Syntax Checks + +(defun elpy-check (&optional whole-project-p) + "Run `python-check-command' on the current buffer's file, + +or the project root if WHOLE-PROJECT-P is non-nil (interactively, +with a prefix argument)." + (interactive "P") + (when (not (buffer-file-name)) + (error "Can't check a buffer without a file.")) + (save-some-buffers (not compilation-ask-about-save) nil) + (let ((process-environment (python-shell-calculate-process-environment)) + (exec-path (python-shell-calculate-exec-path)) + (file-name-or-directory (expand-file-name + (if whole-project-p + (or (elpy-project-root) + (buffer-file-name)) + (buffer-file-name)))) + (extra-args (if whole-project-p + (concat " --exclude=" + (mapconcat #'identity + elpy-project-ignored-directories + ",")) + ""))) + (compilation-start (concat python-check-command + " " + (shell-quote-argument file-name-or-directory) + extra-args) + nil + (lambda (mode-name) + "*Python Check*")))) + +;;;;;;;;;;;;;; +;;; Navigation + +(defun elpy-goto-definition () + "Go to the definition of the symbol at point, if found." + (interactive) + (let ((location (elpy-rpc-get-definition))) + (if location + (elpy-goto-location (car location) (cadr location)) + (error "No definition found")))) + +(defun elpy-goto-location (filename offset) + "Show FILENAME at OFFSET to the user." + (ring-insert find-tag-marker-ring (point-marker)) + (let ((buffer (find-file filename))) + (with-current-buffer buffer + (with-selected-window (get-buffer-window buffer) + (goto-char (1+ offset)) + (recenter 0))))) + +(defun elpy-nav-forward-block () + "Move to the next line indented like point. + +This will skip over lines and statements with different +indentation levels." + (interactive) + (let ((indent (current-column)) + (start (point))) + (when (/= (% indent python-indent-offset) + 0) + (setq indent (* (1+ (/ indent python-indent-offset)) + python-indent-offset))) + (python-nav-forward-statement) + (while (and (< indent (current-indentation)) + (not (eobp))) + (python-nav-forward-statement)) + (when (< (current-indentation) + indent) + (goto-char start)))) + +(defun elpy-nav-backward-block () + "Move to the previous line indented like point. + +This will skip over lines and statements with different +indentation levels." + (interactive) + (let ((indent (current-column)) + (start (point))) + (when (/= (% indent python-indent-offset) + 0) + (setq indent (* (1+ (/ indent python-indent-offset)) + python-indent-offset))) + (python-nav-backward-statement) + (while (and (< indent (current-indentation)) + (not (bobp))) + (python-nav-backward-statement)) + (when (< (current-indentation) + indent) + (goto-char start)))) + +(defun elpy-nav-forward-indent () + "Move forward to the next indent level, or over the next word." + (interactive "^") + (if (< (current-column) (current-indentation)) + (let* ((current (current-column)) + (next (* (1+ (/ current python-indent-offset)) + python-indent-offset))) + (goto-char (+ (point-at-bol) + next))) + (let ((eol (point-at-eol))) + (forward-word) + (when (> (point) eol) + (goto-char (point-at-bol)))))) + +(defun elpy-nav-backward-indent () + "Move backward to the previous indent level, or over the previous word." + (interactive "^") + (if (and (<= (current-column) (current-indentation)) + (/= (current-column) 0)) + (let* ((current (current-column)) + (next (* (1- (/ current python-indent-offset)) + python-indent-offset))) + (goto-char (+ (point-at-bol) + next))) + (backward-word))) + +(defun elpy-nav-move-line-or-region-down (&optional beg end) + "Move the current line or active region down." + (interactive "r") + (if (use-region-p) + (elpy--nav-move-region-vertically beg end 1) + (elpy--nav-move-line-vertically 1))) + +(defun elpy-nav-move-line-or-region-up (&optional beg end) + "Move the current line or active region down." + (interactive "r") + (if (use-region-p) + (elpy--nav-move-region-vertically beg end -1) + (elpy--nav-move-line-vertically -1))) + +(defun elpy--nav-move-line-vertically (dir) + (let* ((beg (point-at-bol)) + (end (point-at-bol 2)) + (col (current-column)) + (region (delete-and-extract-region beg end))) + (forward-line dir) + (save-excursion + (insert region)) + (goto-char (+ (point) col)))) + +(defun elpy--nav-move-region-vertically (beg end dir) + (let* ((point-before-mark (< (point) (mark))) + (beg (save-excursion + (goto-char beg) + (point-at-bol))) + (end (save-excursion + (goto-char end) + (if (bolp) + (point) + (point-at-bol 2)))) + (region (delete-and-extract-region beg end))) + (goto-char beg) + (forward-line dir) + (save-excursion + (insert region)) + (if point-before-mark + (set-mark (+ (point) + (length region))) + (set-mark (point)) + (goto-char (+ (point) + (length region)))) + (setq deactivate-mark nil))) + +(defun elpy-nav-move-region-or-line-left () + "Dedent the current indentation block, or the active region." + (interactive) + (if (use-region-p) + (elpy--nav-move-region-left) + (elpy--nav-move-line-left))) + +(defun elpy-nav-move-region-or-line-right () + "Indent the current indentation block, or the active region." + (interactive) + (if (use-region-p) + (elpy--nav-move-region-right) + (elpy--nav-move-line-right ))) + +(defun elpy--nav-move-line-left () + (save-excursion + (goto-char (point-at-bol)) + (when (looking-at (format "^ \\{%i\\}" python-indent)) + (replace-match "")))) + +(defun elpy--nav-move-line-right () + (save-excursion + (goto-char (point-at-bol)) + (insert (make-string python-indent ?\s)))) + +(defun elpy--nav-move-region-left () + (save-excursion + (let ((beg (region-beginning)) + (end (region-end))) + (goto-char beg) + (goto-char (point-at-bol)) + (while (< (point) end) + (elpy--nav-move-line-left) + (forward-line 1))) + (setq deactivate-mark nil))) + +(defun elpy--nav-move-region-right () + (save-excursion + (let ((beg (region-beginning)) + (end (region-end))) + (goto-char beg) + (goto-char (point-at-bol)) + (while (< (point) end) + (elpy--nav-move-line-right) + (forward-line 1))) + (setq deactivate-mark nil))) + +(defun elpy-open-and-indent-line-below () + "Open a line below the current one, move there, and indent." + (interactive) + (move-end-of-line 1) + (newline-and-indent)) + +(defun elpy-open-and-indent-line-above () + "Open a line above the current one, move there, and indent." + (interactive) + (move-beginning-of-line 1) + (save-excursion + (insert "\n")) + (indent-according-to-mode)) + +;;;;;;;;;;;;;;;; +;;; Test running + +(defvar elpy-set-test-runner-history nil + "History variable for `elpy-set-test-runner'.") + +(defun elpy-test (&optional test-whole-project) + "Run tests on the current test, or the whole project. + +If there is a test at point, run that test. If not, or if a +prefix is given, run all tests in the current project." + (interactive "P") + (let ((current-test (elpy-test-at-point))) + (if test-whole-project + ;; With prefix arg, test the whole project. + (funcall elpy-test-runner + (car current-test) + nil nil nil) + ;; Else, run only this test + (apply elpy-test-runner current-test)))) + +(defun elpy-set-test-runner (test-runner) + "Tell Elpy to use TEST-RUNNER to run tests. + +See `elpy-test' for how to invoke it." + (interactive + (list + (let* ((runners (mapcar (lambda (value) + (cons (nth 2 value) + (nth 3 value))) + (cdr (get 'elpy-test-runner 'custom-type)))) + (current (cdr (assq elpy-test-runner + (mapcar (lambda (cell) + (cons (cdr cell) (car cell))) + runners)))) + (choice (completing-read (if current + (format "Test runner (currently %s): " + current) + "Test runner: ") + runners + nil t nil 'elpy-set-test-runner-history))) + (if (equal choice "") + elpy-test-runner + (cdr (assoc choice runners)))))) + (setq elpy-test-runner test-runner)) + +(defun elpy-test-at-point () + "Return a list specifying the test at point, if any. + +This is used as the interactive + +This list has four elements. + +- Top level directory: + All test files should be importable from here. +- Test file: + The current file name. +- Test module: + The module name, relative to the top level directory. +- Test name: + The full name of the current test within the module, for + example TestClass.test_method + +If there is no test at point, test name is nil. +If the current buffer is not visiting a file, only the top level +directory is not nil." + (if (not buffer-file-name) + (progn + (save-some-buffers) + (list (elpy-library-root) nil nil nil)) + (let* ((top (elpy-library-root)) + (file buffer-file-name) + (module (elpy-test--module-name-for-file top file)) + (test (elpy-test--current-test-name))) + (if (and file (string-match "/test[^/]*$" file)) + (progn + (save-buffer) + (list top file module test)) + (save-some-buffers) + (list top nil nil nil))))) + +(defun elpy-test--current-test-name () + (let ((name (python-info-current-defun))) + (if (and name + (string-match "\\`\\([^.]+\\.[^.]+\\)\\." name)) + (match-string 1 name) + name))) + +(defun elpy-test--module-name-for-file (top-level module-file) + "Return the module name relative to TOP-LEVEL for MODULE-FILE. + +For example, for a top level of /project/root/ and a module file +of /project/root/package/module.py, this would return +\"package.module\"." + (let* ((relative-name (file-relative-name module-file top-level)) + (no-extension (replace-regexp-in-string "\\.py\\'" "" relative-name)) + (no-init (replace-regexp-in-string "/__init__\\'" "" no-extension)) + (dotted (replace-regexp-in-string "/" "." no-init))) + (if (string-match "^\\." dotted) + (concat "." (replace-regexp-in-string (regexp-quote "...") "." dotted)) + dotted))) + +(defun elpy-test-runner-p (obj) + "Return t iff OBJ is a test runner. + +This uses the `elpy-test-runner-p' symbol property." + (get obj 'elpy-test-runner-p)) + +(defun elpy-test-run (working-directory command &rest args) + "Run COMMAND with ARGS in WORKING-DIRECTORY as a test command." + (let ((default-directory working-directory)) + (compile (mapconcat #'shell-quote-argument + (cons command args) + " ")))) + +(defun elpy-test-discover-runner (top file module test) + "Test the project using the python unittest discover runner. + +This requires Python 2.7 or later." + (interactive (elpy-test-at-point)) + (let ((test (cond + (test (format "%s.%s" module test)) + (module module) + (t "discover")))) + (apply #'elpy-test-run + top + (append elpy-test-discover-runner-command + (list test))))) +(put 'elpy-test-discover-runner 'elpy-test-runner-p t) + +(defun elpy-test-django-runner (top file module test) + "Test the project using the Django discover runner. + +This requires Django 1.6 or the django-discover-runner package." + (interactive (elpy-test-at-point)) + (if module + (apply #'elpy-test-run + top + (append elpy-test-django-runner-command + (list (if test + (format "%s.%s" module test) + module)))) + (apply #'elpy-test-run + top + elpy-test-django-runner-command))) +(put 'elpy-test-django-runner 'elpy-test-runner-p t) + +(defun elpy-test-nose-runner (top file module test) + "Test the project using the nose test runner. + +This requires the nose package to be installed." + (interactive (elpy-test-at-point)) + (if module + (apply #'elpy-test-run + top + (append elpy-test-nose-runner-command + (list (if test + (format "%s:%s" module test) + module)))) + (apply #'elpy-test-run + top + elpy-test-nose-runner-command))) +(put 'elpy-test-nose-runner 'elpy-test-runner-p t) + +(defun elpy-test-trial-runner (top file module test) + "Test the project using Twisted's Trial test runner. + +This requires the twisted-core package to be installed." + (interactive (elpy-test-at-point)) + (if module + (apply #'elpy-test-run + top + (append elpy-test-trial-runner-command + (list (if test + (format "%s.%s" module test) + module)))) + (apply #'elpy-test-run top elpy-test-trial-runner-command))) +(put 'elpy-test-trial-runner 'elpy-test-runner-p t) + +(defun elpy-test-pytest-runner (top file module test) + "Test the project using the py.test test runner. + +This requires the pytest package to be installed." + (interactive (elpy-test-at-point)) + (cond + (test + (let ((test-list (split-string test "\\."))) + (apply #'elpy-test-run + top + (append elpy-test-pytest-runner-command + (list (mapconcat #'identity + (cons file test-list) + "::")))))) + (module + (apply #'elpy-test-run top (append elpy-test-pytest-runner-command + (list file)))) + (t + (apply #'elpy-test-run top elpy-test-pytest-runner-command)))) +(put 'elpy-test-pytest-runner 'elpy-test-runner-p t) + +;;;;;;;;;;;;;;;;; +;;; Documentation + +(defvar elpy-doc-history nil + "History for the `elpy-doc' command.") + +(defun elpy-doc () + "Show documentation for the symbol at point. + +If there is no documentation for the symbol at point, or if a +prefix argument is given, prompt for a symbol from the user." + (interactive) + (let ((symbol-at-point nil) + (doc nil)) + (when (not current-prefix-arg) + (setq doc (elpy-rpc-get-docstring)) + (when (not doc) + (save-excursion + (python-nav-backward-up-list) + (setq doc (elpy-rpc-get-docstring)))) + (when (not doc) + (setq doc (elpy-rpc-get-pydoc-documentation + (elpy-doc--symbol-at-point)))) + (when (not doc) + (save-excursion + (python-nav-backward-up-list) + (setq doc (elpy-rpc-get-pydoc-documentation + (elpy-doc--symbol-at-point)))))) + (when (not doc) + (setq doc (elpy-rpc-get-pydoc-documentation + (elpy-doc--read-identifier-from-minibuffer + (elpy-doc--symbol-at-point))))) + (if doc + (elpy-doc--show doc) + (error "No documentation found.")))) + +(defun elpy-doc--read-identifier-from-minibuffer (initial) + "Read a pydoc-able identifier from the minibuffer." + (completing-read "Pydoc for: " + (completion-table-dynamic #'elpy-rpc-get-pydoc-completions) + nil nil initial 'elpy-doc-history)) + +(defun elpy-doc--show (documentation) + "Show DOCUMENTATION to the user, replacing ^H with bold." + (with-help-window "*Python Doc*" + (with-current-buffer "*Python Doc*" + (erase-buffer) + (insert documentation) + (goto-char (point-min)) + (while (re-search-forward "\\(.\\)\\1" nil t) + (replace-match (propertize (match-string 1) + 'face 'bold) + t t))))) + +(defun elpy-doc--symbol-at-point () + "Return the Python symbol at point, including dotted paths." + (with-syntax-table python-dotty-syntax-table + (let ((symbol (symbol-at-point))) + (if symbol + (symbol-name symbol) + nil)))) + +;;;;;;;;;;;;;; +;;; Import manipulation + +(defun elpy-importmagic--replace-block (spec) + "Replace an imports block. SPEC is (startline endline newblock)." + (let ((start-line (nth 0 spec)) + (end-line (nth 1 spec)) + (new-block (nth 2 spec))) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line start-line) + (let ((beg (point)) + (end (progn (forward-line (- end-line start-line)) (point)))) + ;; Avoid deleting and re-inserting when the blocks are equal. + (unless (string-equal (buffer-substring beg end) new-block) + (delete-region beg end) + (insert new-block))))))) + +(defun elpy-importmagic--add-import-read-args (&optional object prompt) + (let* ((default-object (save-excursion + (let ((bounds (with-syntax-table python-dotty-syntax-table + (bounds-of-thing-at-point 'symbol)))) + (if bounds (buffer-substring (car bounds) (cdr bounds)) "")))) + (object-to-import (or object (read-string "Object to import: " default-object))) + (possible-imports (elpy-rpc "get_import_symbols" (list buffer-file-name + (elpy-rpc--buffer-contents) + object-to-import))) + (statement-prompt (or prompt "New import statement: "))) + (cond + ;; An elpy warning (i.e. index not ready) is returned as a string. + ((stringp possible-imports) + (list "")) + ;; If there is no candidate, we exit immediately. + ((null possible-imports) + (message "No import candidate found") + (list "")) + ;; We have some candidates, let the user choose one. + (t + (let ((first-choice (car possible-imports)) + (user-choice (completing-read statement-prompt possible-imports))) + (list (if (equal user-choice "") first-choice user-choice))))))) + +(defun elpy-importmagic-add-import (statement) + (interactive (elpy-importmagic--add-import-read-args)) + (unless (equal statement "") + (let* ((res (elpy-rpc "add_import" (list buffer-file-name + (elpy-rpc--buffer-contents) + statement)))) + (elpy-importmagic--replace-block res)))) + +(defun elpy-importmagic-fixup () + "Query for new imports of unresolved symbols, and remove unreferenced imports. + +Also sort the imports in the import statement blocks." + (interactive) + ;; get all unresolved names, and interactively add imports for them + (let* ((res (elpy-rpc "get_unresolved_symbols" (list buffer-file-name + (elpy-rpc--buffer-contents))))) + (unless (stringp res) + (if (null res) (message "No imports to add.")) + (dolist (object res) + (let* ((prompt (format "How to import \"%s\": " object)) + (choice (elpy-importmagic--add-import-read-args object prompt))) + (elpy-importmagic-add-import (car choice)))))) + ;; now get a new import statement block (this also sorts) + (let* ((res (elpy-rpc "remove_unreferenced_imports" (list buffer-file-name + (elpy-rpc--buffer-contents))))) + (unless (stringp res) + (elpy-importmagic--replace-block res)))) + +;;;;;;;;;;;;;; +;;; Multi-Edit + +(defvar elpy-multiedit-overlays nil + "List of overlays currently being edited.") + +(defun elpy-multiedit-add-overlay (beg end) + "Add an editable overlay between BEG and END. + +A modification in any of these overlays will modify all other +overlays, too." + (interactive "r") + (when (elpy-multiedit--overlays-in-p beg end) + (error "Overlapping multiedit overlays are not allowed")) + (let ((ov (make-overlay beg end nil nil :rear-advance))) + (overlay-put ov 'elpy-multiedit t) + (overlay-put ov 'face 'highlight) + (overlay-put ov 'modification-hooks '(elpy-multiedit--overlay-changed)) + (overlay-put ov 'insert-in-front-hooks '(elpy-multiedit--overlay-changed)) + (overlay-put ov 'insert-behind-hooks '(elpy-multiedit--overlay-changed)) + (push ov elpy-multiedit-overlays))) + +(defun elpy-multiedit--overlays-in-p (beg end) + "Return t iff there are multiedit overlays between beg and end." + (catch 'return + (dolist (ov (overlays-in beg end)) + (when (overlay-get ov 'elpy-multiedit) + (throw 'return t))) + nil)) + +(defun elpy-multiedit-stop () + "Stop editing multiple places at once." + (interactive) + (dolist (ov elpy-multiedit-overlays) + (delete-overlay ov)) + (setq elpy-multiedit-overlays nil)) + +(defun elpy-multiedit--overlay-changed (ov after-change beg end + &optional pre-change-length) + "Called for each overlay that changes. + +This updates all other overlays." + (when (and after-change + (not undo-in-progress) + (overlay-buffer ov)) + (let ((text (buffer-substring (overlay-start ov) + (overlay-end ov))) + (inhibit-modification-hooks t)) + (dolist (other-ov elpy-multiedit-overlays) + (when (and (not (equal other-ov ov)) + (buffer-live-p (overlay-buffer other-ov))) + (with-current-buffer (overlay-buffer other-ov) + (save-excursion + (goto-char (overlay-start other-ov)) + (insert text) + (delete-region (point) (overlay-end other-ov))))))))) + +(defun elpy-multiedit () + "Edit all occurences of the symbol at point, or the active region. + +If multiedit is active, stop it." + (interactive) + (if elpy-multiedit-overlays + (elpy-multiedit-stop) + (let ((regex (if (use-region-p) + (regexp-quote (buffer-substring (region-beginning) + (region-end))) + (format "\\_<%s\\_>" (regexp-quote + (symbol-name + (symbol-at-point)))))) + (case-fold-search nil)) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward regex nil t) + (elpy-multiedit-add-overlay (match-beginning 0) + (match-end 0))))))) + +(defun elpy-multiedit-python-symbol-at-point (&optional use-symbol-p) + "Edit all usages of the the Python symbol at point. + +With prefix arg, edit all syntactic usages of the symbol at +point. This might include unrelated symbols that just share the +name." + (interactive "P") + (if (or elpy-multiedit-overlays + use-symbol-p + (use-region-p)) + ;; If we are already doing a multiedit, or are explicitly told + ;; to use the symbol at point, or if we are on an active region, + ;; call the multiedit function that does just that already. + (call-interactively 'elpy-multiedit) + ;; Otherwise, fetch usages from backend. + (save-some-buffers) + (let ((usages (condition-case err + (elpy-rpc-get-usages) + ;; This is quite the stunt, but elisp parses JSON + ;; null as nil, which is indistinguishable from + ;; the empty list, we stick to the error. + (error + (if (and (eq (car err) 'error) + (stringp (cadr err)) + (string-match "not implemented" (cadr err))) + 'not-supported + (error (cadr err))))))) + (cond + ((eq usages 'not-supported) + (call-interactively 'elpy-multiedit) + (message (concat "Using syntactic editing " + "as current backend does not support get_usages."))) + ((null usages) + (call-interactively 'elpy-multiedit) + (if elpy-multiedit-overlays + (message (concat "Using syntactic editing as no usages of the " + "symbol at point were found by the backend.")) + (message "No occurrences of the symbol at point found"))) + (t + (elpy-multiedit--usages usages)))))) + +(defun elpy-multiedit--usages (usages) + "Mark the usages in USAGES for editing." + (let ((name nil) + (locations (make-hash-table :test #'equal))) + (dolist (usage usages) + (let* ((filename (cdr (assq 'filename usage))) + (this-name (cdr (assq 'name usage))) + (offset (cdr (assq 'offset usage)))) + (setq name this-name) + (with-current-buffer (if filename + (find-file-noselect filename) + (current-buffer)) + (elpy-multiedit-add-overlay (+ offset 1) + (+ offset 1 (length this-name))) + (save-excursion + (goto-char (+ offset 1)) + (puthash filename + (cons (list offset + (buffer-substring (line-beginning-position) + (line-end-position)) + (- (point) + (line-beginning-position)) + (- (+ (point) (length this-name)) + (line-beginning-position))) + (gethash filename locations)) + locations))))) + (if (<= (hash-table-count locations) + 1) + (message "Editing %s usages of '%s' in this buffer" + (length usages) name) + (with-current-buffer (get-buffer-create "*Elpy Edit Usages*") + (let ((inhibit-read-only t) + (filenames nil)) + (erase-buffer) + (elpy-insert--para + "The symbol '" name "' was found in multiple files. Editing " + "all locations:\n\n") + (maphash (lambda (key value) + (when (not (member key filenames)) + (setq filenames (cons key filenames)))) + locations) + (dolist (filename (sort filenames #'string<)) + (elpy-insert--header filename) + (dolist (location (sort (gethash filename locations) + (lambda (loc1 loc2) + (< (car loc1) + (car loc2))))) + (let ((line (nth 1 location)) + (start (+ (line-beginning-position) + (nth 2 location))) + (end (+ (line-end-position) + (nth 3 location)))) + ;; Insert the \n first, else we extend the overlay. + (insert line "\n") + (elpy-multiedit-add-overlay start end))) + (insert "\n")) + (goto-char (point-min)) + (display-buffer (current-buffer) + nil + 'visible)))))) + +;;;;;;;;;;;;;;;;;;;;; +;;; Occur Definitions + +(defun elpy-occur-definitions () + "Display an occur buffer of all definitions in the current buffer. + +Also, switch to that buffer." + (interactive) + (let ((list-matching-lines-face nil)) + (occur "^ *\\(def\\|class\\) ")) + (let ((window (get-buffer-window "*Occur*"))) + (if window + (select-window window) + (switch-to-buffer "*Occur*")))) + +;;;;;;;;;;;;;;;;;;; +;;; Promise objects + +(defvar elpy-promise-marker (make-symbol "*elpy-promise*") + "An uninterned symbol marking an Elpy promise object.") + +(defun elpy-promise (success &optional error) + "Return a new promise. + +A promise is an object with a success and error callback. If the +promise is resolved using `elpy-promise-resolve', its success +callback is called with the given value. The current buffer is +restored, too. + +If the promise is rejected using `elpy-promise-reject', its error +callback is called. For this function, the current buffer is not +necessarily restored, as it is also called when the buffer does +not exist anymore." + (vector elpy-promise-marker ; 0 id + success ; 1 success-callback + error ; 2 error-callback + (current-buffer) ; 3 current-buffer + nil ; 4 run + )) + +(defun elpy-promise-p (obj) + "Return non-nil if the argument is a promise object." + (and (vectorp obj) + (= (length obj) 5) + (eq (aref obj 0) elpy-promise-marker))) + +(defsubst elpy-promise-success-callback (promise) + "Return the success callback for PROMISE." + (aref promise 1)) + +(defsubst elpy-promise-error-callback (promise) + "Return the error callback for PROMISE." + (aref promise 2)) + +(defsubst elpy-promise-buffer (promise) + "Return the buffer for PROMISE." + (aref promise 3)) + +(defsubst elpy-promise-resolved-p (promise) + "Return non-nil if the PROMISE has been resolved or rejected." + (aref promise 4)) + +(defsubst elpy-promise-set-resolved (promise) + "Mark PROMISE as having been resolved." + (aset promise 4 t)) + +(defun elpy-promise-resolve (promise value) + "Resolve PROMISE with VALUE." + (when (not (elpy-promise-resolved-p promise)) + (unwind-protect + (let ((success-callback (elpy-promise-success-callback promise))) + (when success-callback + (condition-case err + (with-current-buffer (elpy-promise-buffer promise) + (funcall success-callback value)) + (error + (elpy-promise-reject promise err))))) + (elpy-promise-set-resolved promise)))) + +(defun elpy-promise-reject (promise reason) + "Reject PROMISE because of REASON." + (when (not (elpy-promise-resolved-p promise)) + (unwind-protect + (let ((error-callback (elpy-promise-error-callback promise))) + (when error-callback + (if (buffer-live-p (elpy-promise-buffer promise)) + (with-current-buffer (elpy-promise-buffer promise) + (funcall error-callback reason)) + (with-temp-buffer + (funcall error-callback reason))))) + (elpy-promise-set-resolved promise)))) + +(defun elpy-promise-wait (promise &optional timeout) + "Wait for PROMISE to be resolved, for up to TIMEOUT seconds. + +This will accept process output while waiting. + +This will wait for the current Elpy RPC process specifically, as +Emacs currently has a bug where it can wait for the entire time +of the timeout, even if output arrives. + +See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17647" + (let ((end-time (when timeout + (time-add (current-time) + (seconds-to-time timeout)))) + (process (get-buffer-process (elpy-rpc--get-rpc-buffer)))) + (while (and (not (elpy-promise-resolved-p promise)) + (or (not end-time) + (time-less-p (current-time) + end-time))) + (accept-process-output process timeout)))) + +;;;;;;; +;;; RPC + +;; elpy-rpc is a simple JSON-based RPC protocol. It's mostly JSON-RPC +;; 1.0, except we do not implement the full protocol as we do not need +;; all the features. Emacs starts a Python subprocess which runs a +;; special module. The module reads JSON-RPC requests and responds +;; with JSON-RPC responses. + +(defvar elpy-rpc--call-id 0 + "Call id of the last elpy-rpc call. + +Used to associate responses to callbacks.") +(make-variable-buffer-local 'elpy-rpc--call-id) + +(defvar elpy-rpc--buffer-p nil + "True iff the current buffer is an elpy-rpc buffer.") +(make-variable-buffer-local 'elpy-rpc--buffer-p) + +(defvar elpy-rpc--buffer nil + "The elpy-rpc buffer associated with this buffer.") +(make-variable-buffer-local 'elpy-rpc--buffer) + +(defvar elpy-rpc--backend-library-root nil + "The project root used by this backend.") +(make-variable-buffer-local 'elpy-rpc--backend-library-root) + +(defvar elpy-rpc--backend-python-command nil + "The Python interpreter used by this backend.") +(make-variable-buffer-local 'elpy-rpc--backend-python-command) + +(defvar elpy-rpc--backend-callbacks nil + "The callbacks registered for calls to the current backend. + +This maps call IDs to functions.") +(make-variable-buffer-local 'elpy-rpc--backend-callbacks) + +(defvar elpy-rpc--last-call nil + "The time of the last RPC call issued for this backend.") +(make-variable-buffer-local 'elpy-rpc--last-call) + +(defvar elpy-rpc--last-error-popup nil + "The last time an error popup happened.") + +(defun elpy-rpc (method params &optional success error) + "Call METHOD with PARAMS in the backend. + +If SUCCESS and optionally ERROR is given, return immediately and +call those when a result is available. Otherwise, wait for a +result and return that." + (when (not error) + (setq error #'elpy-rpc--default-error-callback)) + (if success + (elpy-rpc--call method params success error) + (elpy-rpc--call-blocking method params))) + +(defun elpy-rpc--call-blocking (method-name params) + "Call METHOD-NAME with PARAMS in the current RPC backend. + +Returns the result, blocking until this arrived." + (let* ((result-arrived nil) + (error-occured nil) + (result-value nil) + (error-object nil) + (promise (elpy-rpc--call method-name params + (lambda (result) + (setq result-value result + result-arrived t)) + (lambda (err) + (setq error-object err + error-occured t))))) + (elpy-promise-wait promise elpy-rpc-timeout) + (cond + (error-occured + (elpy-rpc--default-error-callback error-object)) + (result-arrived + result-value) + (t + (error "Timeout during RPC call %s from backend" + method-name))))) + +(defun elpy-rpc--call (method-name params success error) + "Call METHOD-NAME with PARAMS in the current RPC backend. + +When a result is available, SUCCESS will be called with that +value as its sole argument. If an error occurs, ERROR will be +called with the error list. + +Returns a PROMISE object." + (let ((promise (elpy-promise success error))) + (with-current-buffer (elpy-rpc--get-rpc-buffer) + (setq elpy-rpc--call-id (1+ elpy-rpc--call-id) + elpy-rpc--last-call (float-time)) + (elpy-rpc--register-callback elpy-rpc--call-id promise) + (process-send-string + (get-buffer-process (current-buffer)) + (concat (json-encode `((id . ,elpy-rpc--call-id) + (method . ,method-name) + (params . ,params))) + "\n"))) + promise)) + +(defun elpy-rpc--register-callback (call-id promise) + "Register for PROMISE to be called when CALL-ID returns. + +Must be called in an elpy-rpc buffer." + (when (not elpy-rpc--buffer-p) + (error "Must be called in RPC buffer")) + (when (not elpy-rpc--backend-callbacks) + (setq elpy-rpc--backend-callbacks (make-hash-table :test #'equal))) + (puthash call-id promise elpy-rpc--backend-callbacks)) + +(defun elpy-rpc--get-rpc-buffer () + "Return the RPC buffer associated with the current buffer, +creating one if necessary." + (when (not (elpy-rpc--process-buffer-p elpy-rpc--buffer)) + (setq elpy-rpc--buffer + (or (elpy-rpc--find-buffer (elpy-library-root) + elpy-rpc-python-command) + (elpy-rpc--open (elpy-library-root) + elpy-rpc-python-command)))) + elpy-rpc--buffer) + +(defun elpy-rpc--process-buffer-p (buffer) + "Return non-nil when BUFFER is a live elpy-rpc process buffer. + +If BUFFER is a buffer for an elpy-rpc process, but the process +died, this will kill the process and buffer." + (cond + ((or (not buffer) + (not (buffer-live-p buffer))) + nil) + ((not (buffer-local-value 'elpy-rpc--buffer-p buffer)) + nil) + ((and (get-buffer-process buffer) + (process-live-p (get-buffer-process buffer))) + t) + (t + (ignore-errors + (kill-process (get-buffer-process buffer))) + (ignore-errors + (kill-buffer buffer)) + nil))) + +(defun elpy-rpc--find-buffer (library-root python-command) + "Return an existing RPC buffer for this project root and command." + (catch 'return + (let ((full-python-command (executable-find python-command))) + (dolist (buf (buffer-list)) + (when (and (elpy-rpc--process-buffer-p buf) + (equal (buffer-local-value 'elpy-rpc--backend-library-root + buf) + library-root) + (equal (buffer-local-value 'elpy-rpc--backend-python-command + buf) + full-python-command)) + (throw 'return buf)))) + nil)) + +(defun elpy-rpc--open (library-root python-command) + "Start a new RPC process and return the associated buffer." + (when (and elpy-rpc-backend + (not (stringp elpy-rpc-backend))) + (error "`elpy-rpc-backend' should be nil or a string.")) + (elpy-rpc--cleanup-buffers) + (let* ((full-python-command (executable-find python-command)) + (name (format " *elpy-rpc [project:%s python:%s]*" + library-root + full-python-command)) + (new-elpy-rpc-buffer (generate-new-buffer name)) + (proc nil)) + (with-current-buffer new-elpy-rpc-buffer + (setq elpy-rpc--buffer-p t + elpy-rpc--buffer (current-buffer) + elpy-rpc--backend-library-root library-root + elpy-rpc--backend-python-command full-python-command + default-directory "/" + proc (condition-case err + (let ((process-connection-type nil) + (process-environment (elpy-rpc--environment))) + (start-process name + (current-buffer) + full-python-command + "-W" "ignore" + "-m" "elpy.__main__")) + (error + (elpy-config-error + "Elpy can't start Python (%s: %s)" + (car err) (cadr err))))) + (set-process-query-on-exit-flag proc nil) + (set-process-sentinel proc #'elpy-rpc--sentinel) + (set-process-filter proc #'elpy-rpc--filter) + (elpy-rpc-init elpy-rpc-backend library-root + (lambda (result) + (let ((backend (cdr (assq 'backend result)))) + (when (and elpy-rpc-backend + (not (equal backend elpy-rpc-backend))) + (elpy-config-error + "Can't set backend %s, using %s instead" + elpy-rpc-backend backend)))))) + new-elpy-rpc-buffer)) + +(defun elpy-rpc--cleanup-buffers () + "Close RPC buffers that have not been used in five minutes." + (when elpy-rpc-maximum-buffer-age + (let ((old (- (float-time) + elpy-rpc-maximum-buffer-age))) + (dolist (buffer (buffer-list)) + (when (and (elpy-rpc--process-buffer-p buffer) + (< (or (buffer-local-value 'elpy-rpc--last-call buffer) + old) + old)) + (ignore-errors + (kill-process (get-buffer-process buffer))) + (ignore-errors + (kill-buffer buffer))))))) + +(defun elpy-rpc--sentinel (process event) + "The sentinel for the RPC process. + +As process sentinels are only ever called when the process +terminates, this will call the error handler of all registered +RPC calls with the event." + (let ((buffer (process-buffer process)) + (err (list 'process-sentinel (substring event 0 -1)))) + (when (and buffer + (buffer-live-p buffer)) + (with-current-buffer buffer + (when elpy-rpc--backend-callbacks + (maphash (lambda (call-id promise) + (ignore-errors + (elpy-promise-reject promise err))) + elpy-rpc--backend-callbacks) + (setq elpy-rpc--backend-callbacks nil)))))) + +(defun elpy-rpc--filter (process output) + "The filter for the RPC process." + (let ((buffer (process-buffer process))) + (when (and buffer + (buffer-live-p buffer)) + (with-current-buffer buffer + (goto-char (point-max)) + (insert output) + (while (progn + (goto-char (point-min)) + (search-forward "\n" nil t)) + (let ((line-end (point)) + (json nil) + (did-read-json nil)) + (goto-char (point-min)) + (condition-case err + (setq json (let ((json-array-type 'list)) + (json-read)) + line-end (1+ (point)) + did-read-json t) + (error + (goto-char (point-min)))) + (cond + (did-read-json + (delete-region (point-min) line-end) + (elpy-rpc--handle-json json)) + ((looking-at "elpy-rpc ready\n") + (replace-match "") + (elpy-rpc--check-backend-version "1.1")) + ((looking-at "elpy-rpc ready (\\([^ ]*\\))\n") + (let ((rpc-version (match-string 1))) + (replace-match "") + (elpy-rpc--check-backend-version rpc-version))) + ((looking-at ".*No module named elpy\n") + (replace-match "") + (elpy-config-error "Elpy module not found")) + (t + (let ((line (buffer-substring (point-min) + line-end))) + (delete-region (point-min) line-end) + (elpy-rpc--handle-unexpected-line line)))))))))) + +(defun elpy-rpc--check-backend-version (rpc-version) + "Check that we are using the right version." + (when (not (equal rpc-version elpy-version)) + (elpy-insert--popup "*Elpy Version Mismatch*" + (elpy-insert--header "Elpy Version Mismatch") + (elpy-insert--para + "You are not using the same version of Elpy in Emacs Lisp" + "compared to Python. This can cause random problems. Please" + "do make sure to use compatible versions.\n") + (insert + "\n" + "Elpy Emacs Lisp version: " elpy-version "\n" + "Elpy Python version....: " rpc-version "\n")))) + +(defun elpy-rpc--handle-unexpected-line (line) + "Handle an unexpected line from the backend. + +This is usually an error or backtrace." + (let ((buf (get-buffer "*Elpy Output*"))) + (when (not buf) + (elpy-insert--popup "*Elpy Output*" + (elpy-insert--header "Output from Backend") + (elpy-insert--para + "There was some unexpected output from the Elpy backend. " + "This is usually some module that does not use correct logging, " + "but might indicate a configuration problem.\n\n") + (elpy-insert--header "Output") + (setq buf (current-buffer)))) + (with-current-buffer buf + (goto-char (point-max)) + (let ((inhibit-read-only t)) + (insert line))))) + +(defun elpy-rpc--handle-json (json) + "Handle a single JSON object from the RPC backend." + (let ((call-id (cdr (assq 'id json))) + (error-object (cdr (assq 'error json))) + (result (cdr (assq 'result json)))) + (let ((promise (gethash call-id elpy-rpc--backend-callbacks))) + (when (not promise) + (error "Received a response for unknown call-id %s" call-id)) + (remhash call-id elpy-rpc--backend-callbacks) + (if error-object + (elpy-promise-reject promise error-object) + (elpy-promise-resolve promise result))))) + +(defun elpy-rpc--default-error-callback (error-object) + "Display an error from the RPC backend." + ;; We actually might get an (error "foo") thing here. + (if (and (consp error-object) + (not (consp (car error-object)))) + (signal (car error-object) (cdr error-object)) + (let ((message (cdr (assq 'message error-object))) + (code (cdr (assq 'code error-object))) + (data (cdr (assq 'data error-object)))) + (cond + ((not (numberp code)) + (error "Bad response from RPC: %S" error-object)) + ((< code 300) + (message "Elpy warning: %s" message)) + ((< code 500) + (error "Elpy error: %s" message)) + ((and elpy-rpc-error-timeout + elpy-rpc--last-error-popup + (<= (float-time) + (+ elpy-rpc--last-error-popup + elpy-rpc-error-timeout))) + (message "Elpy error popup ignored, see `elpy-rpc-error-timeout': %s" + message)) + (t + (let ((config (elpy-config--get-config))) + (elpy-insert--popup "*Elpy Error*" + (elpy-insert--header "Elpy Error") + (elpy-insert--para + "The backend encountered an unexpected error. This indicates " + "a bug in Elpy. Please open a bug report with the data below " + "in the Elpy bug tracker:") + (insert "\n" + "\n") + (insert-button + "https://github.com/jorgenschaefer/elpy/issues/new" + 'action (lambda (button) + (browse-url (button-get button 'url))) + 'url "https://github.com/jorgenschaefer/elpy/issues/new") + (insert "\n" + "\n" + "```\n") + (elpy-insert--header "Error Message") + (insert message "\n\n") + (elpy-insert--header "Configuration") + (elpy-config--insert-configuration-table config) + (let ((traceback (cdr (assq 'traceback data)))) + (when traceback + (insert "\n") + (elpy-insert--header "Traceback") + (insert traceback))) + (let ((jedi-info (cdr (assq 'jedi_debug_info data)))) + (when jedi-info + (insert "\n") + (elpy-insert--header "Jedi Debug Information") + (pcase (cdr (assq 'debug_info jedi-info)) + (`nil (insert "Jedi did not emit any debug info.\n")) + (infos + (dolist (outstr infos) + (insert outstr "\n")))) + (insert "\n" + "```\n" + "\n" + "Reproduction:\n" + "\n") + (let ((method (cdr (assq 'method jedi-info))) + (source (cdr (assq 'source jedi-info))) + (script-args (cdr (assq 'script_args jedi-info)))) + (insert "```Python\n") + (insert "import jedi\n" + "\n" + "source = '''\\\n" + source + "'''\n" + "\n" + "script = jedi.Script(" script-args ")\n" + "script." method "()\n")))) + (let ((rope-info (cdr (assq 'rope_debug_info data)))) + (when rope-info + (insert "\n") + (elpy-insert--header "Rope Debug Information") + (insert "```\n" + "\n" + "Reproduction:\n" + "\n") + (let ((project-root (cdr (assq 'project_root rope-info))) + (filename (cdr (assq 'filename rope-info))) + (source (cdr (assq 'source rope-info))) + (function-name (cdr (assq 'function_name rope-info))) + (function-args (cdr (assq 'function_args rope-info)))) + (insert "```Python\n") + (insert "\n" + "source = '''\n" + source + "'''\n" + "\n") + (insert "project = rope.base.project.Project(\n" + (format " %S,\n" project-root) + " ropefolder=None\n" + ")\n") + (insert "resource = rope.base.libutils.path_to_resource(\n" + " project,\n" + (format " %S,\n" filename) + " 'file'\n" + ")\n") + (insert (format "%s(\n %s\n)\n" + function-name function-args))))) + (when (not (= 0 (current-column))) + (insert "\n")) + (insert "```")) + (setq elpy-rpc--last-error-popup (float-time)))))))) + +(defun elpy-rpc--environment () + "Return a `process-environment' for the RPC process. + +This includes `elpy-rpc-pythonpath' in the PYTHONPATH, if set." + (if (or (not elpy-rpc-pythonpath) + (not (file-exists-p (expand-file-name "elpy/__init__.py" + elpy-rpc-pythonpath)))) + process-environment + (let* ((old-pythonpath (getenv "PYTHONPATH")) + (new-pythonpath (if old-pythonpath + (concat elpy-rpc-pythonpath + path-separator + old-pythonpath) + elpy-rpc-pythonpath))) + (cons (concat "PYTHONPATH=" new-pythonpath) + process-environment)))) + +(defun elpy-rpc--buffer-contents () + "Return the contents of the current buffer. + +This returns either a string, or a file object for the RPC +protocol if the buffer is larger than +`elpy-rpc-large-buffer-size'." + (if (< (buffer-size) elpy-rpc-large-buffer-size) + (buffer-string) + (let ((file-name (make-temp-file "elpy-rpc-")) + (coding-system-for-write 'utf-8)) + (write-region nil nil file-name nil :nomessage) + `((filename . ,file-name) + (delete_after_use . t))))) + +;; RPC API functions + +(defun elpy-rpc-restart () + "Restart all RPC processes." + (interactive) + (dolist (buffer (buffer-list)) + (when (elpy-rpc--process-buffer-p buffer) + (ignore-errors + (kill-process (get-buffer-process buffer))) + (ignore-errors + (kill-buffer buffer))))) + +(defun elpy-rpc-init (backend library-root &optional success error) + "Initialize the backend. + +This has to be called as the first method, else Elpy won't be +able to respond to other calls." + (elpy-rpc "init" + ;; This uses a vector because otherwise, json-encode in + ;; older Emacsen gets seriously confused, especially when + ;; backend is nil. + (vector `((backend . ,backend) + (project_root . ,(expand-file-name library-root)))) + success error)) + +(defun elpy-rpc-get-calltip (&optional success error) + "Call the get_calltip API function. + +Returns a calltip string for the function call at point." + (when (< (buffer-size) elpy-rpc-ignored-buffer-size) + (elpy-rpc "get_calltip" + (list buffer-file-name + (elpy-rpc--buffer-contents) + (- (point) + (point-min))) + success error))) + +(defun elpy-rpc-get-completions (&optional success error) + "Call the get_completions API function. + +Returns a list of possible completions for the Python symbol at +point." + (when (< (buffer-size) elpy-rpc-ignored-buffer-size) + (elpy-rpc "get_completions" + (list buffer-file-name + (elpy-rpc--buffer-contents) + (- (point) + (point-min))) + success error))) + +(defun elpy-rpc-get-completion-docstring (completion &optional success error) + "Call the get_completion_docstring API function. + +Returns a doc string or nil" + (elpy-rpc "get_completion_docstring" (list completion) success error)) + +(defun elpy-rpc-get-completion-location (completion &optional success error) + "Call the get_completion_location API function. + +Returns a list of file name and line number, or nil" + (elpy-rpc "get_completion_location" (list completion) success error)) + +(defun elpy-rpc-get-definition (&optional success error) + "Call the find_definition API function. + +Returns nil or a list of (filename, point)." + (elpy-rpc "get_definition" + (list buffer-file-name + (elpy-rpc--buffer-contents) + (- (point) + (point-min))) + success error)) + +(defun elpy-rpc-get-docstring (&optional success error) + "Call the get_docstring API function. + +Returns a possible multi-line docstring for the symbol at point." + (elpy-rpc "get_docstring" + (list buffer-file-name + (elpy-rpc--buffer-contents) + (- (point) + (point-min))) + success error)) + +(defun elpy-rpc-get-pydoc-completions (prefix &optional success error) + "Return a list of modules available in pydoc starting with PREFIX." + (elpy-rpc "get_pydoc_completions" (list prefix) + success error)) + +(defun elpy-rpc-get-pydoc-documentation (symbol &optional success error) + "Get the Pydoc documentation for SYMBOL. + +Returns a possible multi-line docstring." + (elpy-rpc "get_pydoc_documentation" (list symbol) + success error)) + +(defun elpy-rpc-get-usages (&optional success error) + (elpy-rpc "get_usages" + (list buffer-file-name + (elpy-rpc--buffer-contents) + (- (point) + (point-min))) + success error)) + +;;;;;;;;;;; +;;; Modules + +(defvar elpy-modules-initialized-p nil + "Boolean, set to true if modules were run with `global-init'.") + +(defun elpy-modules-run (command &rest args) + "Run COMMAND with ARGS for all modules in `elpy-modules'." + (dolist (module elpy-modules) + (apply module command args))) + +(defun elpy-modules-global-init () + "Run the global-init method of Elpy modules. + +Make sure this only happens once." + (when (not elpy-modules-initialized-p) + (elpy-modules-run 'global-init) + (setq elpy-modules-initialized-p t))) + +(defun elpy-modules-global-stop () + "Run the global-stop method of Elpy modules. + +Make sure this only happens once per global-init call." + (when elpy-modules-initialized-p + (elpy-modules-run 'global-stop) + (setq elpy-modules-initialized-p nil))) + +(defun elpy-modules-buffer-init () + "Run the buffer-init method of Elpy modules. + +Make sure global-init is called first." + (elpy-modules-global-init) + (elpy-modules-run 'buffer-init)) + +(defun elpy-modules-buffer-stop () + "Run the buffer-stop method of Elpy modules." + (elpy-modules-run 'buffer-stop)) + +(defun elpy-modules-remove-modeline-lighter (mode-name) + "Remove the lighter for MODE-NAME. + +It's not necessary to see (Python Elpy yas company ElDoc) all the +time. Honestly." + (interactive) + (cond + ((eq mode-name 'eldoc-minor-mode) + (setq eldoc-minor-mode-string nil)) + (t + (let ((cell (assq mode-name minor-mode-alist))) + (when cell + (setcdr cell + (list ""))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Module: Sane Defaults + +(defun elpy-module-sane-defaults (command &rest args) + (pcase command + (`buffer-init + ;; Set `forward-sexp-function' to nil in python-mode. See + ;; http://debbugs.gnu.org/db/13/13642.html + (set (make-local-variable 'forward-sexp-function) nil) + ;; PEP8 recommends two spaces in front of inline comments. + (set (make-local-variable 'comment-inline-offset) 2)) + (`buffer-stop + (kill-local-variable 'forward-sexp-function) + (kill-local-variable 'comment-inline-offset)))) + +;;;;;;;;;;;;;;;;;;; +;;; Module: Company + +(defun elpy-module-company (command &rest args) + "Module to support company-mode completions." + (pcase command + (`global-init + (require 'company) + (elpy-modules-remove-modeline-lighter 'company-mode) + (define-key company-active-map (kbd "C-d") + 'company-show-doc-buffer)) + (`buffer-init + ;; We want immediate completions from company. + (set (make-local-variable 'company-idle-delay) + 0) + ;; And annotations should be right-aligned. + (set (make-local-variable 'company-tooltip-align-annotations) + t) + ;; Also, dabbrev in comments and strings is nice. + (set (make-local-variable 'company-dabbrev-code-everywhere) + t) + ;; Add our own backend and remove a bunch of backends that + ;; interfere in Python mode. + (set (make-local-variable 'company-backends) + (cons 'elpy-company-backend + (delq 'company-semantic + (delq 'company-ropemacs + (delq 'company-capf + (mapcar #'identity company-backends)))))) + (company-mode 1)) + (`buffer-stop + (company-mode -1) + (kill-local-variable 'company-idle-delay) + (kill-local-variable 'company-tooltip-align-annotations) + (kill-local-variable 'company-backends)) + )) + +(defvar elpy-company--cache nil + "Buffer-local cache for candidate information.") +(make-variable-buffer-local 'elpy-company--cache) + +(defun elpy-company--cache-clear () + "Clear and initialize the cache." + (if elpy-company--cache + (clrhash elpy-company--cache) + (setq elpy-company--cache + (make-hash-table :test #'equal)))) + +(defun elpy-company--cache-annotation (name) + "Return the cached annotation for NAME." + (when elpy-company--cache + (cdr (assq 'annotation (gethash name elpy-company--cache))))) + +(defun elpy-company--cache-meta (name) + "Return the cached annotation for NAME." + (when elpy-company--cache + (cdr (assq 'meta (gethash name elpy-company--cache))))) + +(defun elpy-company--cache-name (name) + "Return the cached name for NAME. + +Confused yet? We pass \"our\" name, that is, prefix + suffix, +here, and return the \"name\" as used by the backend." + (when elpy-company--cache + (cdr (assq 'name (gethash name elpy-company--cache))))) + +(defun elpy-company--cache-completions (prefix result) + "Store RESULT in the candidate cache and return candidates." + (elpy-company--cache-clear) + (mapcar (lambda (completion) + (let* ((suffix (cdr (assq 'suffix completion))) + (name (concat prefix suffix))) + (puthash name completion elpy-company--cache) + name)) + result)) + +(defun elpy-company-backend (command &optional arg &rest ignored) + "A company-mode backend for Elpy." + (interactive (list 'interactive)) + (pcase command + (`interactive + (company-begin-backend 'elpy-company-backend)) + ;; init => Called once per buffer + ;; prefix => return the prefix at point + (`prefix + (when (and elpy-mode + (not (company-in-string-or-comment))) + (company-grab-symbol-cons "\\." 1))) + ;; candidates => return candidates for this prefix + (`candidates + (cons :async + (lambda (callback) + (elpy-rpc-get-completions + (lambda (result) + (elpy-company--cache-clear) + (funcall + callback + (cond + ;; The backend returned something + (result + (elpy-company--cache-completions arg result)) + ;; Nothing from the backend, try dabbrev-code. + ((> (length arg) company-minimum-prefix-length) + (elpy--sort-and-strip-duplicates + (company-dabbrev-code 'candidates arg))) + ;; Well, ok, let's go meh. + (t + nil)))))))) + ;; sorted => t if the list is already sorted + (`sorted + t) + ;; duplicates => t if there could be duplicates + (`duplicates + nil) + ;; no-cache => t if company shouldn't cache results + ;; meta => short docstring for minibuffer + (`meta + (let ((meta (elpy-company--cache-meta arg))) + (when (and meta + (string-match "\\`\\(.*\n.*\\)\n.*" meta)) + (setq meta (match-string 1 meta))) + meta)) + ;; annotation => short docstring for completion buffer + (`annotation + (elpy-company--cache-annotation arg)) + ;; doc-buffer => put doc buffer in `company-doc-buffer' + (`doc-buffer + (let* ((name (elpy-company--cache-name arg)) + (doc (elpy-rpc-get-completion-docstring name))) + (when doc + (company-doc-buffer doc)))) + ;; require-match => Never require a match, even if the user + ;; started to interact with company. See `company-require-match'. + (`require-match + 'never) + ;; location => (buffer . point) or (file . + ;; line-number) + (`location + (let* ((name (elpy-company--cache-name arg)) + (loc (elpy-rpc-get-completion-location name))) + (when loc + (cons (car loc) + (cadr loc))))) + ;; match => for non-prefix based backends + ;; post-completion => after insertion, for snippets + )) + +(defun elpy--sort-and-strip-duplicates (seq) + "Sort SEQ and remove any duplicates." + (sort (delete-dups seq) + (lambda (a b) + (string< a b)))) + +;;;;;;;;;;;;;;;;; +;;; Module: ElDoc + +(defun elpy-module-eldoc (command &rest args) + "Module to support ElDoc for Python files." + (pcase command + (`global-init + (require 'eldoc) + (setq eldoc-minor-mode-string nil)) + (`buffer-init + (set (make-local-variable 'eldoc-documentation-function) + 'elpy-eldoc-documentation) + (eldoc-mode 1)) + (`buffer-stop + (eldoc-mode -1) + (kill-local-variable 'eldoc-documentation-function)))) + +(defun elpy-eldoc-documentation () + "Return some interesting information for the code at point. + +This will return flymake errors for the line at point if there +are any. If not, this will do an asynchronous call to the RPC +backend to get a call tip, and display that using +`eldoc-message'. If the backend has no call tip, this will +display the current class and method instead." + (let ((flymake-error (elpy-flymake-error-at-point))) + (if flymake-error + flymake-error + (elpy-rpc-get-calltip + (lambda (calltip) + (eldoc-message + (cond + ((not calltip) + (when elpy-eldoc-show-current-function + (let ((current-defun (python-info-current-defun))) + (when current-defun + (format "In: %s()" current-defun))))) + ((stringp calltip) + calltip) + (t + (let ((name (cdr (assq 'name calltip))) + (index (cdr (assq 'index calltip))) + (params (cdr (assq 'params calltip)))) + (when index + (setf (nth index params) + (propertize (nth index params) + 'face + 'eldoc-highlight-function-argument))) + (format "%s(%s)" + name + (mapconcat #'identity params ", ")) + )))))) + ;; Return the last message until we're done + eldoc-last-message))) + +;;;;;;;;;;;;;;;;;;; +;;; Module: Flymake + +(defun elpy-module-flymake (command &rest args) + "Enable Flymake support for Python." + (pcase command + (`global-init + (require 'flymake) + (elpy-modules-remove-modeline-lighter 'flymake-mode) + ;; Flymake support using flake8, including warning faces. + (when (and (executable-find "flake8") + (equal python-check-command + (elpy-flymake--standard-value 'python-check-command))) + (setq python-check-command "flake8")) + + ;; Add our initializer function + (add-to-list 'flymake-allowed-file-name-masks + '("\\.py\\'" elpy-flymake-python-init))) + (`buffer-init + ;; `flymake-no-changes-timeout': The original value of 0.5 is too + ;; short for Python code, as that will result in the current line + ;; to be highlighted most of the time, and that's annoying. This + ;; value might be on the long side, but at least it does not, in + ;; general, interfere with normal interaction. + (set (make-local-variable 'flymake-no-changes-timeout) + 60) + + ;; `flymake-start-syntax-check-on-newline': This should be nil for + ;; Python, as;; most lines with a colon at the end will mean the + ;; next line is always highlighted as error, which is not helpful + ;; and mostly annoying. + (set (make-local-variable 'flymake-start-syntax-check-on-newline) + nil) + + ;; Enable warning faces for flake8 output. + ;; COMPAT: Obsolete variable as of 24.4 + (if (boundp 'flymake-warning-predicate) + (set (make-local-variable 'flymake-warning-predicate) "^W[0-9]") + (set (make-local-variable 'flymake-warning-re) "^W[0-9]")) + + (flymake-mode 1)) + (`buffer-stop + (flymake-mode -1) + (kill-local-variable 'flymake-no-changes-timeout) + (kill-local-variable 'flymake-start-syntax-check-on-newline) + ;; COMPAT: Obsolete variable as of 24.4 + (if (boundp 'flymake-warning-predicate) + (kill-local-variable 'flymake-warning-predicate) + (kill-local-variable 'flymake-warning-re))))) + +(defun elpy-flymake-python-init () + ;; Make sure it's not a remote buffer as flymake would not work + (when (not (file-remote-p buffer-file-name)) + (let* ((temp-file (flymake-init-create-temp-buffer-copy + 'flymake-create-temp-inplace))) + (list python-check-command + (list temp-file) + ;; Run flake8 from / to avoid import problems (#169) + "/")))) + +(defun elpy-flymake-next-error () + "Move forward to the next Flymake error and show a +description." + (interactive) + (flymake-goto-next-error) + (elpy-flymake-show-error)) + +(defun elpy-flymake-previous-error () + "Move backward to the previous Flymake error and show a +description." + (interactive) + (flymake-goto-prev-error) + (elpy-flymake-show-error)) + +(defun elpy-flymake-show-error () + "Show the flymake error message at point." + (interactive) + (let ((error-message (elpy-flymake-error-at-point))) + (when error-message + (message "%s" error-message)))) + +(defun elpy-flymake-error-at-point () + "Return the flymake error at point, or nil if there is none." + (when (boundp 'flymake-err-info) + (let* ((lineno (line-number-at-pos)) + (err-info (car (flymake-find-err-info flymake-err-info + lineno)))) + (when err-info + (mapconcat #'flymake-ler-text + err-info + ", "))))) + +(defun elpy-flymake--standard-value (var) + "Return the standard value of the given variable." + (let ((sv (get var 'standard-value))) + (when (consp sv) + (ignore-errors + (eval (car sv)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Module: Highlight Indentation + +(defun elpy-module-highlight-indentation (command &rest args) + "Module to highlight indentation in Python files." + (pcase command + (`global-init + (require 'highlight-indentation)) + (`buffer-init + (highlight-indentation-mode 1)) + (`buffer-stop + (highlight-indentation-mode -1)))) + +;;;;;;;;;;;;;;;;;; +;;; Module: pyvenv + +(defun elpy-module-pyvenv (command &rest args) + "Module to display the current virtualenv in the mode line." + (pcase command + (`global-init + (pyvenv-mode 1)) + (`global-stop + (pyvenv-mode -1)))) + +;;;;;;;;;;;;;;;;;;;;; +;;; Module: Yasnippet + +(defun elpy-module-yasnippet (command &rest args) + "Module to enable YASnippet snippets." + (pcase command + (`global-init + (require 'yasnippet) + (elpy-modules-remove-modeline-lighter 'yas-minor-mode) + + ;; We provide some YASnippet snippets. Add them. + + ;; yas-snippet-dirs can be a string for a single directory. Make + ;; sure it's a list in that case so we can add our own entry. + (when (not (listp yas-snippet-dirs)) + (setq yas-snippet-dirs (list yas-snippet-dirs))) + (add-to-list 'yas-snippet-dirs + (concat (file-name-directory (locate-library "elpy")) + "snippets/") + t) + + ;; Now load yasnippets. + (yas-reload-all)) + (`global-stop + (setq yas-snippet-dirs + (delete (concat (file-name-directory (locate-library "elpy")) + "snippets/") + yas-snippet-dirs))) + (`buffer-init + (yas-minor-mode 1)) + (`buffer-stop + (yas-minor-mode -1)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Backwards compatibility + +;; Functions for Emacs 24 before 24.3 +(when (not (fboundp 'python-info-current-defun)) + (defalias 'python-info-current-defun 'python-current-defun)) + +(when (not (fboundp 'python-nav-forward-statement)) + (defun python-nav-forward-statement (&rest ignored) + "Function added in Emacs 24.3" + (error "Enhanced Python navigation only available in Emacs 24.3+"))) + +(when (not (fboundp 'python-nav-backward-up-list)) + (defun python-nav-backward-up-list () + "Compatibility function for older Emacsen" + (ignore-errors + (backward-up-list)))) + +(when (not (fboundp 'python-shell-calculate-exec-path)) + (defun python-shell-calculate-exec-path () + "Compatibility function for older Emacsen." + exec-path)) + +(when (not (fboundp 'python-shell-calculate-process-environment)) + (defun python-shell-calculate-process-environment () + "Compatibility function for older Emacsen." + process-environment)) + +(when (not (fboundp 'python-shell-get-process-name)) + (defun python-shell-get-process-name (dedicated) + "Compatibility function for older Emacsen." + "Python")) + +(when (not (fboundp 'python-shell-parse-command)) + (defun python-shell-parse-command () + "Compatibility function for older Emacsen." + python-python-command)) + +(when (not (fboundp 'python-shell-send-buffer)) + (defun python-shell-send-buffer (&optional arg) + (python-send-buffer))) + +(when (not (fboundp 'python-shell-send-string)) + (defalias 'python-shell-send-string 'python-send-string)) + +;; Emacs 24.2 made `locate-dominating-file' accept a predicate instead +;; of a string. Simply overwrite the current one, it's +;; backwards-compatible. The code below is taken from Emacs 24.3. +(when (or (< emacs-major-version 24) + (and (= emacs-major-version 24) + (<= emacs-minor-version 2))) + (defun locate-dominating-file (file name) + "Look up the directory hierarchy from FILE for a directory containing NAME. +Stop at the first parent directory containing a file NAME, +and return the directory. Return nil if not found. +Instead of a string, NAME can also be a predicate taking one argument +\(a directory) and returning a non-nil value if that directory is the one for +which we're looking." + ;; We used to use the above locate-dominating-files code, but the + ;; directory-files call is very costly, so we're much better off doing + ;; multiple calls using the code in here. + ;; + ;; Represent /home/luser/foo as ~/foo so that we don't try to look for + ;; `name' in /home or in /. + (setq file (abbreviate-file-name file)) + (let ((root nil) + ;; `user' is not initialized outside the loop because + ;; `file' may not exist, so we may have to walk up part of the + ;; hierarchy before we find the "initial UID". Note: currently unused + ;; (user nil) + try) + (while (not (or root + (null file) + ;; FIXME: Disabled this heuristic because it is sometimes + ;; inappropriate. + ;; As a heuristic, we stop looking up the hierarchy of + ;; directories as soon as we find a directory belonging + ;; to another user. This should save us from looking in + ;; things like /net and /afs. This assumes that all the + ;; files inside a project belong to the same user. + ;; (let ((prev-user user)) + ;; (setq user (nth 2 (file-attributes file))) + ;; (and prev-user (not (equal user prev-user)))) + (string-match locate-dominating-stop-dir-regexp file))) + (setq try (if (stringp name) + (file-exists-p (expand-file-name name file)) + (funcall name file))) + (cond (try (setq root file)) + ((equal file (setq file (file-name-directory + (directory-file-name file)))) + (setq file nil)))) + (if root (file-name-as-directory root)))) + ) + +;; highlight-indentation 0.5 does not use modes yet +(when (not (fboundp 'highlight-indentation-mode)) + (defun highlight-indentation-mode (on-or-off) + (cond + ((and (> on-or-off 0) + (not highlight-indent-active)) + (highlight-indentation)) + ((and (<= on-or-off 0) + highlight-indent-active) + (highlight-indentation))))) + +(provide 'elpy) +;;; elpy.el ends here diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/__init__.py b/emacs.d/elpa/elpy-20150502.740/elpy/__init__.py new file mode 100644 index 0000000..1204963 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/__init__.py @@ -0,0 +1,41 @@ +# Elpy, the Emacs Lisp Python Environment + +# Copyright (C) 2013 Jorgen Schaefer + +# Author: Jorgen Schaefer +# URL: http://github.com/jorgenschaefer/elpy + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +"""The Emacs Lisp Python Environment. + +Elpy is a mode for Emacs to support writing Python code. This package +provides the backend within Python to support auto-completion, +documentation extraction, and navigation. + +Emacs will start the protocol by running the module itself, like so: + + python -m elpy + +This will emit a greeting string on a single line, and then wait for +the protocol to start. Details of the protocol can be found in +elpy.rpc. + +This package is unlikely to be useful on its own. + +""" + +__author__ = "Jorgen Schaefer" +__version__ = "1.8.0" +__license__ = "GPL" diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/__main__.py b/emacs.d/elpa/elpy-20150502.740/elpy/__main__.py new file mode 100644 index 0000000..5683fdd --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/__main__.py @@ -0,0 +1,25 @@ +"""Main interface to the RPC server. + +You should be able to just run the following to use this module: + +python -m elpy + +The first line should be "elpy-rpc ready". If it isn't, something +broke. + +""" + +import os +import sys + +import elpy +from elpy.server import ElpyRPCServer + +if __name__ == '__main__': + stdin = sys.stdin + stdout = sys.stdout + sys.stdout = sys.stderr = open(os.devnull, "w") + stdout.write('elpy-rpc ready ({0})\n' + .format(elpy.__version__)) + stdout.flush() + ElpyRPCServer(stdin, stdout).serve_forever() diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/compat.py b/emacs.d/elpa/elpy-20150502.740/elpy/compat.py similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/elpy/compat.py rename to emacs.d/elpa/elpy-20150502.740/elpy/compat.py diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/impmagic.py b/emacs.d/elpa/elpy-20150502.740/elpy/impmagic.py new file mode 100644 index 0000000..436552b --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/impmagic.py @@ -0,0 +1,95 @@ +"""Glue for the "importmagic" library. + +""" + +import os +import sys +import threading + + +try: + import importmagic.index + import importmagic.symbols + import importmagic.importer +except ImportError: # pragma: no cover + importmagic = None + + +class ImportMagic(object): + + def __init__(self): + self.is_enabled = bool(importmagic) + # fail_message is reported to the user when symbol_index + # is (still) None + self.fail_message = "symbol index is not yet ready" + self.project_root = None + self.symbol_index = None + self.favorites = set() + self._thread = None + + def _build_symbol_index(self, project_root, custom_path, blacklist_re): + try: + index = importmagic.index.SymbolIndex(blacklist_re=blacklist_re) + if os.environ.get('ELPY_TEST'): + # test suite support: do not index the whole PYTHONPATH, it + # takes much too long + index.build_index([]) + elif custom_path: + index.build_index(custom_path) + else: + index.build_index([project_root] + sys.path) + except Exception as e: + self.fail_message = "symbol index failed to build: %s" % e + else: + self.symbol_index = index + + def build_index(self, project_root, custom_path=None, blacklist_re=None): + self.project_root = None + self._thread = threading.Thread(target=self._build_symbol_index, + args=(project_root, custom_path, + blacklist_re)) + self._thread.setDaemon(True) + self._thread.start() + + def get_import_symbols(self, symbol): + scores = self.symbol_index.symbol_scores(symbol) + + def sort_key(item): + score, mod, var = item + if mod in self.favorites: + return 2 + score, mod, var + return score, mod, var + + scores.sort(key=sort_key, reverse=True) + return ["from %s import %s" % (mod, var) if var else "import %s" % mod + for (_, mod, var) in scores] + + def add_import(self, source, statement): + imports = importmagic.importer.Imports(self.symbol_index, source) + if statement.startswith('import '): + modname = statement[7:] + imports.add_import(modname) + self.favorites.add(modname) + else: + sep = statement.find(' import ') + modname = statement[5:sep] + if sep > -1: + self.favorites.add(modname) + imports.add_import_from(statement[5:sep], statement[sep+8:]) + start_line, end_line, import_block = imports.get_update() + return start_line, end_line, import_block + + def get_unresolved_symbols(self, source): + scope = importmagic.symbols.Scope.from_source(source) + unres, unref = scope.find_unresolved_and_unreferenced_symbols() + return list(unres) + + def remove_unreferenced_imports(self, source): + scope = importmagic.symbols.Scope.from_source(source) + unres, unref = scope.find_unresolved_and_unreferenced_symbols() + # Note: we do not supply "unres" to the call below, since we do + # not want to add imports without querying the user from which + # module symbols should be imported. + start_line, end_line, import_block = importmagic.importer.get_update( + source, self.symbol_index, set(), unref) + return start_line, end_line, import_block diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/jedibackend.py b/emacs.d/elpa/elpy-20150502.740/elpy/jedibackend.py new file mode 100644 index 0000000..e51f250 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/jedibackend.py @@ -0,0 +1,323 @@ +"""Elpy backend using the Jedi library. + +This backend uses the Jedi library: + +https://github.com/davidhalter/jedi + +""" + +import sys +import traceback + +import jedi + +from elpy import rpc + + +class JediBackend(object): + """The Jedi backend class. + + Implements the RPC calls we can pass on to Jedi. + + Documentation: http://jedi.jedidjah.ch/en/latest/docs/plugin-api.html + + """ + name = "jedi" + + def __init__(self, project_root): + self.project_root = project_root + self.completions = {} + sys.path.append(project_root) + + def rpc_get_completions(self, filename, source, offset): + line, column = pos_to_linecol(source, offset) + proposals = run_with_debug(jedi, 'completions', + source=source, line=line, column=column, + path=filename, encoding='utf-8') + if proposals is None: + return [] + self.completions = dict((proposal.name, proposal) + for proposal in proposals) + return [{'name': proposal.name, + 'suffix': proposal.complete, + 'annotation': proposal.type, + 'meta': proposal.description} + for proposal in proposals] + + def rpc_get_completion_docstring(self, completion): + proposal = self.completions.get(completion) + if proposal is None: + return None + else: + return proposal.docstring(fast=False) + + def rpc_get_completion_location(self, completion): + proposal = self.completions.get(completion) + if proposal is None: + return None + else: + return (proposal.module_path, proposal.line) + + def rpc_get_docstring(self, filename, source, offset): + line, column = pos_to_linecol(source, offset) + try: + locations = run_with_debug(jedi, 'goto_definitions', + source=source, line=line, column=column, + path=filename, encoding='utf-8', + re_raise=jedi.NotFoundError) + except jedi.NotFoundError: + return None + if locations: + return ('Documentation for {0}:\n\n'.format( + locations[-1].full_name) + locations[-1].docstring()) + else: + return None + + def rpc_get_definition(self, filename, source, offset): + line, column = pos_to_linecol(source, offset) + try: + locations = run_with_debug(jedi, 'goto_definitions', + source=source, line=line, column=column, + path=filename, encoding='utf-8', + re_raise=jedi.NotFoundError) + except jedi.NotFoundError: + return None + # goto_definitions() can return silly stuff like __builtin__ + # for int variables, so we fall back on goto() in those + # cases. See issue #76. + if ( + locations and + locations[0].module_path is None + ): + locations = run_with_debug(jedi, 'goto_assignments', + source=source, line=line, + column=column, + path=filename, encoding='utf-8') + if not locations: + return None + else: + loc = locations[-1] + try: + if loc.module_path: + if loc.module_path == filename: + offset = linecol_to_pos(source, + loc.line, + loc.column) + else: + with open(loc.module_path) as f: + offset = linecol_to_pos(f.read(), + loc.line, + loc.column) + else: + return None + except IOError: + return None + return (loc.module_path, offset) + + def rpc_get_calltip(self, filename, source, offset): + line, column = pos_to_linecol(source, offset) + calls = run_with_debug(jedi, 'call_signatures', + source=source, line=line, column=column, + path=filename, encoding='utf-8') + if calls: + call = calls[0] + else: + call = None + if not call: + return None + return {"name": call.name, + "index": call.index, + "params": [param.description for param in call.params]} + + def rpc_get_usages(self, filename, source, offset): + """Return the uses of the symbol at offset. + + Returns a list of occurrences of the symbol, as dicts with the + fields name, filename, and offset. + + """ + line, column = pos_to_linecol(source, offset) + try: + uses = run_with_debug(jedi, 'usages', + source=source, line=line, column=column, + path=filename, encoding='utf-8', + re_raise=(jedi.NotFoundError,)) + except jedi.NotFoundError: + return [] + + if uses is None: + return None + result = [] + for use in uses: + if use.module_path == filename: + offset = linecol_to_pos(source, use.line, use.column) + elif use.module_path is not None: + with open(use.module_path) as f: + text = f.read() + offset = linecol_to_pos(text, use.line, use.column) + + result.append({"name": use.name, + "filename": use.module_path, + "offset": offset}) + + return result + + +# From the Jedi documentation: +# +# line is the current line you want to perform actions on (starting +# with line #1 as the first line). column represents the current +# column/indent of the cursor (starting with zero). source_path +# should be the path of your file in the file system. + +def pos_to_linecol(text, pos): + """Return a tuple of line and column for offset pos in text. + + Lines are one-based, columns zero-based. + + This is how Jedi wants it. Don't ask me why. + + """ + line_start = text.rfind("\n", 0, pos) + 1 + line = text.count("\n", 0, line_start) + 1 + col = pos - line_start + return line, col + + +def linecol_to_pos(text, line, col): + """Return the offset of this line and column in text. + + Lines are one-based, columns zero-based. + + This is how Jedi wants it. Don't ask me why. + + """ + nth_newline_offset = 0 + for i in range(line - 1): + new_offset = text.find("\n", nth_newline_offset) + if new_offset < 0: + raise ValueError("Text does not have {0} lines." + .format(line)) + nth_newline_offset = new_offset + 1 + offset = nth_newline_offset + col + if offset > len(text): + raise ValueError("Line {0} column {1} is not within the text" + .format(line, col)) + return offset + + +def run_with_debug(jedi, name, *args, **kwargs): + re_raise = kwargs.pop('re_raise', ()) + # Remove form feed characters, they confuse Jedi (jedi#424) + if 'source' in kwargs: + kwargs['source'] = kwargs['source'].replace("\f", " ") + try: + script = jedi.Script(*args, **kwargs) + return getattr(script, name)() + except Exception as e: + if isinstance(e, re_raise): + raise + # Bug jedi#417 + if isinstance(e, TypeError) and str(e) == 'no dicts allowed': + return None + # Bug jedi#427 + if isinstance(e, UnicodeDecodeError): + return None + # Bug jedi#429 + if isinstance(e, IndexError): + return None + # Bug jedi#431 + if isinstance(e, AttributeError) and str(e).endswith("'end_pos'"): + return None + # Bug in Python 2.6, see #275 + if isinstance(e, OSError) and e.errno == 13: + return None + # Bug jedi#466 + if ( + isinstance(e, SyntaxError) and + "EOL while scanning string literal" in str(e) + ): + return None + # Bug jedi#482 + if isinstance(e, UnicodeEncodeError): + return None + # Bug jedi#485 + if ( + isinstance(e, ValueError) and + "invalid \\x escape" in str(e) + ): + return None + # Bug jedi#485 in Python 3 + if ( + isinstance(e, SyntaxError) and + "truncated \\xXX escape" in str(e) + ): + return None + # Bug jedi#465 + if ( + isinstance(e, SyntaxError) and + "encoding declaration in Unicode string" in str(e) + ): + return None + # Bug #337 / jedi#471 + if ( + isinstance(e, ImportError) and + "No module named" in str(e) + ): + return None + # Bug #365 / jedi#486 - fixed in Jedi 0.8.2 + if ( + isinstance(e, UnboundLocalError) and + "local variable 'path' referenced before assignment" in str(e) + ): + return None + # Bug #366 / jedi#491 + if ( + isinstance(e, ValueError) and + "__loader__ is None" in str(e) + ): + return None + # Bug #353 + if ( + isinstance(e, OSError) and + "No such file or directory" in str(e) + ): + return None + + from jedi import debug + + debug_info = [] + + def _debug(level, str_out): + if level == debug.NOTICE: + prefix = "[N]" + elif level == debug.WARNING: + prefix = "[W]" + else: + prefix = "[?]" + debug_info.append(u"{0} {1}".format(prefix, str_out)) + + jedi.set_debug_function(_debug, speed=False) + try: + script = jedi.Script(*args, **kwargs) + return getattr(script, name)() + except Exception as e: + source = kwargs.get('source') + sc_args = [] + sc_args.extend(repr(arg) for arg in args) + sc_args.extend("{0}={1}".format(k, "source" if k == "source" + else repr(v)) + for (k, v) in kwargs.items()) + + data = { + "traceback": traceback.format_exc(), + "jedi_debug_info": {'script_args': ", ".join(sc_args), + 'source': source, + 'method': name, + 'debug_info': debug_info} + } + raise rpc.Fault(message=str(e), + code=500, + data=data) + finally: + jedi.set_debug_function(None) diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/pydocutils.py b/emacs.d/elpa/elpy-20150502.740/elpy/pydocutils.py similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/elpy/pydocutils.py rename to emacs.d/elpa/elpy-20150502.740/elpy/pydocutils.py diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/refactor.py b/emacs.d/elpa/elpy-20150502.740/elpy/refactor.py similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/elpy/refactor.py rename to emacs.d/elpa/elpy-20150502.740/elpy/refactor.py diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/ropebackend.py b/emacs.d/elpa/elpy-20150502.740/elpy/ropebackend.py new file mode 100644 index 0000000..55a625d --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/ropebackend.py @@ -0,0 +1,326 @@ +"""Elpy backend using the Rope library. + +This backend uses the Rope library: + +http://rope.sourceforge.net/ + +""" + +import os +import time +import traceback + +import rope.contrib.codeassist +import rope.base.project +import rope.base.libutils +import rope.base.exceptions +import rope.contrib.findit + +from elpy import rpc +import elpy.pydocutils + +VALIDATE_EVERY_SECONDS = 5 +MAXFIXES = 5 + + +class RopeBackend(object): + """The Rope backend class. + + Implements the RPC calls we can pass on to Rope. Also subclasses + the native backend to provide methods Rope does not provide, if + any. + + """ + name = "rope" + + def __init__(self, project_root): + super(RopeBackend, self).__init__() + self.last_validation = 0 + if not os.path.exists(project_root): + raise rpc.Fault( + "rope does not support files without a local project root", + code=400 + ) + self.project_root = project_root + self.completions = {} + prefs = dict(ignored_resources=['*.pyc', '*~', '.ropeproject', + '.hg', '.svn', '_svn', '.git'], + python_files=['*.py'], + save_objectdb=False, + compress_objectdb=False, + automatic_soa=True, + soa_followed_calls=0, + perform_doa=True, + validate_objectdb=True, + max_history_items=32, + save_history=False, + compress_history=False, + indent_size=4, + extension_modules=[], + import_dynload_stdmods=True, + ignore_syntax_errors=False, + ignore_bad_imports=False) + self.project = rope.base.project.Project(self.project_root, + ropefolder=None, + **prefs) + + def get_resource(self, filename): + if filename is not None and os.path.exists(filename): + return rope.base.libutils.path_to_resource(self.project, + filename, + 'file') + else: + return None + + def validate(self): + """Validate the stored project. + + This should be called before every use of Rope. It will + revalidate the project, but do some call throttling. + + """ + now = time.time() + if now > self.last_validation + VALIDATE_EVERY_SECONDS: + try: + self.project.validate() + except rope.base.exceptions.ResourceNotFoundError: + pass + self.last_validation = now + + def call_rope(self, rope_function, filename, source, offset, + **kwargs): + self.validate() + resource = self.get_resource(filename) + try: + return rope_function(self.project, + source, offset, + resource, + maxfixes=MAXFIXES, + **kwargs) + except (rope.base.exceptions.BadIdentifierError, + rope.base.exceptions.ModuleSyntaxError, + rope.base.exceptions.ResourceNotFoundError, + rope.base.exceptions.NameNotFoundError, + IndentationError, + LookupError, + AttributeError): + return None + except Exception as e: + data = { + "traceback": traceback.format_exc(), + "rope_debug_info": { + "project_root": self.project_root, + "filename": filename, + "source": source, + "function_name": (rope_function.__module__ + + "." + + rope_function.__name__), + "function_args": ", ".join([ + "project", "source", str(offset), "resource", + "maxfixes={0}".format(MAXFIXES) + ] + [ + u"{}={}".format(k, v) + for (k, v) in kwargs.items() + ]) + } + } + raise rpc.Fault( + code=500, + message=str(e), + data=data + ) + + def rpc_get_completions(self, filename, source, offset): + proposals = self.call_rope( + rope.contrib.codeassist.code_assist, + filename, source, offset + ) + if proposals is None: + return [] + try: + starting_offset = rope.contrib.codeassist.starting_offset(source, + offset) + except (rope.base.exceptions.BadIdentifierError, + rope.base.exceptions.ModuleSyntaxError, + IndentationError, + LookupError, + AttributeError): + return [] + prefixlen = offset - starting_offset + self.completions = dict((proposal.name, proposal) + for proposal in proposals) + try: + return [{'name': proposal.name, + 'suffix': proposal.name[prefixlen:], + 'annotation': proposal.type, + 'meta': str(proposal)} + for proposal in proposals] + except rope.base.exceptions.ModuleSyntaxError: + # Bug#406 + return [] + + def rpc_get_completion_docstring(self, completion): + proposal = self.completions.get(completion) + if proposal is None: + return None + else: + return proposal.get_doc() + + def rpc_get_completion_location(self, completion): + proposal = self.completions.get(completion) + if proposal is None: + return None + else: + if not proposal.pyname: + return None + module, lineno = proposal.pyname.get_definition_location() + if module is None: + return None + resource = module.get_module().get_resource() + return (resource.real_path, lineno) + + def rpc_get_definition(self, filename, source, offset): + location = self.call_rope( + rope.contrib.findit.find_definition, + filename, source, offset + ) + if location is None: + return None + else: + return (location.resource.real_path, location.offset) + + def rpc_get_calltip(self, filename, source, offset): + offset = find_called_name_offset(source, offset) + if 0 < offset < len(source) and source[offset] == ')': + offset -= 1 + + calltip = self.call_rope( + rope.contrib.codeassist.get_calltip, + filename, source, offset, + remove_self=True + ) + if calltip is None: + return None + + calltip = calltip.replace(".__init__(", "(") + calltip = calltip.replace("(self)", "()") + calltip = calltip.replace("(self, ", "(") + # "elpy.tests.support.source_and_offset(source)" + # => + # "support.source_and_offset(source)" + try: + openpos = calltip.index("(") + period2 = calltip.rindex(".", 0, openpos) + period1 = calltip.rindex(".", 0, period2) + calltip = calltip[period1 + 1:] + except ValueError: + pass + return calltip + + def rpc_get_docstring(self, filename, source, offset): + return self.call_rope( + rope.contrib.codeassist.get_doc, + filename, source, offset + ) + + +def find_called_name_offset(source, orig_offset): + """Return the offset of a calling function. + + This only approximates movement. + + """ + offset = min(orig_offset, len(source) - 1) + paren_count = 0 + while True: + if offset <= 1: + return orig_offset + elif source[offset] == '(': + if paren_count == 0: + return offset - 1 + else: + paren_count -= 1 + elif source[offset] == ')': + paren_count += 1 + offset -= 1 + + +################################################################## +# A recurring problem in Rope for Elpy is that it searches the whole +# project root for Python files. If the user edits a file in their +# home directory, this can easily read a whole lot of files, making +# Rope practically useless. We change the file finding algorithm here +# to only recurse into directories with an __init__.py file in them. +def find_source_folders(self, folder): + for resource in folder.get_folders(): + if self._is_package(resource): + return [folder] + result = [] + for resource in folder.get_files(): + if resource.name.endswith('.py'): + result.append(folder) + break + for resource in folder.get_folders(): + if self._is_package(resource): + result.append(resource) + return result + +import rope.base.pycore +rope.base.pycore.PyCore._find_source_folders = find_source_folders + + +def get_files(self): + if self.files is None: + self.files = get_python_project_files(self.project) + return self.files + +rope.base.project._FileListCacher.get_files = get_files + + +def get_python_project_files(project): + for dirname, subdirs, files in os.walk(project.root.real_path): + for filename in files: + yield rope.base.libutils.path_to_resource( + project, os.path.join(dirname, filename), 'file') + subdirs[:] = [subdir for subdir in subdirs + if os.path.exists(os.path.join(dirname, subdir, + "__init__.py"))] + + +################################################################## +# Monkey patching a method in rope because it doesn't complete import +# statements. + +orig_code_completions = (rope.contrib.codeassist. + _PythonCodeAssist._code_completions) + + +def code_completions(self): + proposals = get_import_completions(self) + if proposals: + return proposals + else: + return orig_code_completions(self) + + +def get_import_completions(self): + if not self.word_finder.is_import_statement(self.offset): + return [] + modulename = self.word_finder.get_primary_at(self.offset) + # Rope can handle modules in packages + if "." in modulename: + return [] + return dict((name, FakeProposal(name)) + for name in elpy.pydocutils.get_modules() + if name.startswith(modulename)) + + +class FakeProposal(object): + def __init__(self, name): + self.name = name + self.type = "mock" + + def get_doc(self): + return None + +rope.contrib.codeassist._PythonCodeAssist._code_completions = code_completions diff --git a/emacs.d/elpa/elpy-1.7.1/elpy/rpc.py b/emacs.d/elpa/elpy-20150502.740/elpy/rpc.py similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/elpy/rpc.py rename to emacs.d/elpa/elpy-20150502.740/elpy/rpc.py diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/server.py b/emacs.d/elpa/elpy-20150502.740/elpy/server.py new file mode 100644 index 0000000..57e1265 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/server.py @@ -0,0 +1,275 @@ +"""Method implementations for the Elpy JSON-RPC server. + +This file implements the methods exported by the JSON-RPC server. It +handles backend selection and passes methods on to the selected +backend. + +""" +import io +import os +import pydoc + +from elpy.pydocutils import get_pydoc_completions +from elpy.rpc import JSONRPCServer, Fault +from elpy.impmagic import ImportMagic + + +try: + from elpy import jedibackend +except ImportError: # pragma: no cover + jedibackend = None + +try: + from elpy import ropebackend +except ImportError: # pragma: no cover + ropebackend = None + + +class ElpyRPCServer(JSONRPCServer): + """The RPC server for elpy. + + See the rpc_* methods for exported method documentation. + + """ + def __init__(self, *args, **kwargs): + super(ElpyRPCServer, self).__init__(*args, **kwargs) + self.backend = None + self.import_magic = ImportMagic() + self.project_root = None + + def _call_backend(self, method, default, *args, **kwargs): + """Call the backend method with args. + + If there is currently no backend, return default.""" + meth = getattr(self.backend, method, None) + if meth is None: + return default + else: + return meth(*args, **kwargs) + + def rpc_echo(self, *args): + """Return the arguments. + + This is a simple test method to see if the protocol is + working. + + """ + return args + + def rpc_init(self, options): + self.project_root = options["project_root"] + + if self.import_magic.is_enabled: + self.import_magic.build_index(self.project_root) + + if ropebackend and options["backend"] == "rope": + self.backend = ropebackend.RopeBackend(self.project_root) + elif jedibackend and options["backend"] == "jedi": + self.backend = jedibackend.JediBackend(self.project_root) + elif ropebackend: + self.backend = ropebackend.RopeBackend(self.project_root) + elif jedibackend: + self.backend = jedibackend.JediBackend(self.project_root) + else: + self.backend = None + + return { + 'backend': (self.backend.name if self.backend is not None + else None) + } + + def rpc_get_calltip(self, filename, source, offset): + """Get the calltip for the function at the offset. + + """ + return self._call_backend("rpc_get_calltip", None, filename, + get_source(source), offset) + + def rpc_get_completions(self, filename, source, offset): + """Get a list of completion candidates for the symbol at offset. + + """ + results = self._call_backend("rpc_get_completions", [], filename, + get_source(source), offset) + # Uniquify by name + results = list(dict((res['name'], res) for res in results) + .values()) + results.sort(key=lambda cand: _pysymbol_key(cand["name"])) + return results + + def rpc_get_completion_docstring(self, completion): + """Return documentation for a previously returned completion. + + """ + return self._call_backend("rpc_get_completion_docstring", + None, completion) + + def rpc_get_completion_location(self, completion): + """Return the location for a previously returned completion. + + This returns a list of [file name, line number]. + + """ + return self._call_backend("rpc_get_completion_location", None, + completion) + + def rpc_get_definition(self, filename, source, offset): + """Get the location of the definition for the symbol at the offset. + + """ + return self._call_backend("rpc_get_definition", None, filename, + get_source(source), offset) + + def rpc_get_docstring(self, filename, source, offset): + """Get the docstring for the symbol at the offset. + + """ + return self._call_backend("rpc_get_docstring", None, filename, + get_source(source), offset) + + def rpc_get_pydoc_completions(self, name=None): + """Return a list of possible strings to pass to pydoc. + + If name is given, the strings are under name. If not, top + level modules are returned. + + """ + return get_pydoc_completions(name) + + def rpc_get_pydoc_documentation(self, symbol): + """Get the Pydoc documentation for the given symbol. + + Uses pydoc and can return a string with backspace characters + for bold highlighting. + + """ + try: + docstring = pydoc.render_doc(str(symbol), + "Elpy Pydoc Documentation for %s", + False) + except (ImportError, pydoc.ErrorDuringImport): + return None + else: + if isinstance(docstring, bytes): + docstring = docstring.decode("utf-8", "replace") + return docstring + + def rpc_get_refactor_options(self, filename, start, end=None): + """Return a list of possible refactoring options. + + This list will be filtered depending on whether it's + applicable at the point START and possibly the region between + START and END. + + """ + try: + from elpy import refactor + except: + raise ImportError("Rope not installed, refactorings unavailable") + ref = refactor.Refactor(self.project_root, filename) + return ref.get_refactor_options(start, end) + + def rpc_refactor(self, filename, method, args): + """Return a list of changes from the refactoring action. + + A change is a dictionary describing the change. See + elpy.refactor.translate_changes for a description. + + """ + try: + from elpy import refactor + except: + raise ImportError("Rope not installed, refactorings unavailable") + if args is None: + args = () + ref = refactor.Refactor(self.project_root, filename) + return ref.get_changes(method, *args) + + def rpc_get_usages(self, filename, source, offset): + """Get usages for the symbol at point. + + """ + source = get_source(source) + if hasattr(self.backend, "rpc_get_usages"): + return self.backend.rpc_get_usages(filename, source, offset) + else: + raise Fault("get_usages not implemented by current backend", + code=400) + + def _ensure_import_magic(self): # pragma: no cover + if not self.import_magic.is_enabled: + raise Fault("fixup_imports not enabled; install importmagic module", + code=400) + if not self.import_magic.symbol_index: + raise Fault(self.import_magic.fail_message, code=200) # XXX code? + + def rpc_get_import_symbols(self, filename, source, symbol): + """Return a list of modules from which the given symbol can be imported. + + """ + self._ensure_import_magic() + return self.import_magic.get_import_symbols(symbol) + + def rpc_add_import(self, filename, source, statement): + """Add an import statement to the module. + + """ + self._ensure_import_magic() + source = get_source(source) + return self.import_magic.add_import(source, statement) + + def rpc_get_unresolved_symbols(self, filename, source): + """Return a list of unreferenced symbols in the module. + + """ + self._ensure_import_magic() + source = get_source(source) + return self.import_magic.get_unresolved_symbols(source) + + def rpc_remove_unreferenced_imports(self, filename, source): + """Remove unused import statements. + + """ + self._ensure_import_magic() + source = get_source(source) + return self.import_magic.remove_unreferenced_imports(source) + + +def get_source(fileobj): + """Translate fileobj into file contents. + + fileobj is either a string or a dict. If it's a string, that's the + file contents. If it's a string, then the filename key contains + the name of the file whose contents we are to use. + + If the dict contains a true value for the key delete_after_use, + the file should be deleted once read. + + """ + if not isinstance(fileobj, dict): + return fileobj + else: + try: + with io.open(fileobj["filename"], encoding="utf-8") as f: + return f.read() + finally: + if fileobj.get('delete_after_use'): + try: + os.remove(fileobj["filename"]) + except: # pragma: no cover + pass + + +def _pysymbol_key(name): + """Return a sortable key index for name. + + Sorting is case-insensitive, with the first underscore counting as + worse than any character, but subsequent underscores do not. This + means that dunder symbols (like __init__) are sorted after symbols + that start with an alphabetic character, but before those that + start with only a single underscore. + + """ + if name.startswith("_"): + name = "~" + name[1:] + return name.lower() diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/__init__.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/__init__.py new file mode 100644 index 0000000..9c9b567 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/__init__.py @@ -0,0 +1,8 @@ +"""Unit tests for elpy.""" + +try: + import unittest2 + import sys + sys.modules['unittest'] = unittest2 +except: + pass diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/compat.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/compat.py new file mode 100644 index 0000000..16595f6 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/compat.py @@ -0,0 +1,18 @@ +"""Python 2/3 compatibility definitions. + +These are used by the rest of Elpy to keep compatibility definitions +in one place. + +""" + +import sys + + +if sys.version_info >= (3, 0): + PYTHON3 = True + import builtins + from io import StringIO +else: + PYTHON3 = False + import __builtin__ as builtins # noqa + from StringIO import StringIO # noqa diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/support.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/support.py new file mode 100644 index 0000000..f6839a1 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/support.py @@ -0,0 +1,743 @@ +# coding: utf-8 + +"""Support classes and functions for the elpy test code. + +Elpy uses a bit of a peculiar test setup to avoid redundancy. For the +tests of the two backends, we provide generic test cases for generic +tests and for specific callback tests. + +These mixins can be included in the actual test classes. We can't add +these tests to a BackendTestCase subclass directly because the test +discovery would find them there and try to run them, which would fail. + +""" + +import os +import shutil +import tempfile +import unittest + +from elpy.tests import compat + + +class BackendTestCase(unittest.TestCase): + """Base class for backend tests. + + This class sets up a project root directory and provides an easy + way to create files within the project root. + + """ + + def setUp(self): + """Create the project root and make sure it gets cleaned up.""" + super(BackendTestCase, self).setUp() + self.project_root = tempfile.mkdtemp(prefix="elpy-test") + self.addCleanup(shutil.rmtree, self.project_root, True) + + def project_file(self, relname, contents): + """Create a file named relname within the project root. + + Write contents into that file. + + """ + full_name = os.path.join(self.project_root, relname) + try: + os.makedirs(os.path.dirname(full_name)) + except OSError: + pass + with open(full_name, "w") as f: + f.write(contents) + return full_name + + +class GenericRPCTests(object): + """Generic RPC test methods. + + This is a mixin to add tests that should be run for all RPC + methods that follow the generic (filename, source, offset) calling + conventions. + + """ + METHOD = None + + def rpc(self, filename, source, offset): + method = getattr(self.backend, self.METHOD) + return method(filename, source, offset) + + def test_should_not_fail_on_inexisting_file(self): + filename = self.project_root + "/doesnotexist.py" + self.rpc(filename, "", 0) + + def test_should_not_fail_on_empty_file(self): + filename = self.project_file("test.py", "") + self.rpc(filename, "", 0) + + def test_should_not_fail_if_file_is_none(self): + self.rpc(None, "", 0) + + def test_should_not_fail_for_module_syntax_errors(self): + source, offset = source_and_offset( + "class Foo(object):\n" + " def bar(self):\n" + " foo(_|_" + " bar(" + "\n" + " def a(self):\n" + " pass\n" + "\n" + " def b(self):\n" + " pass\n" + "\n" + " def b(self):\n" + " pass\n" + "\n" + " def b(self):\n" + " pass\n" + "\n" + " def b(self):\n" + " pass\n" + "\n" + " def b(self):\n" + " pass\n" + ) + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_bad_indentation(self): + # Bug in Rope: rope#80 + source, offset = source_and_offset( + "def foo():\n" + " print(23)_|_\n" + " print(17)\n") + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_relative_import(self): + # Bug in Rope: rope#81 and rope#82 + source, offset = source_and_offset( + "from .. import foo_|_" + ) + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_on_keyword(self): + source, offset = source_and_offset( + "_|_try:\n" + " pass\n" + "except:\n" + " pass\n") + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_with_bad_encoding(self): + # Bug in Rope: rope#83 + source, offset = source_and_offset( + u'# coding: utf-8X_|_\n' + ) + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_with_form_feed_characters(self): + # Bug in Jedi: jedi#424 + source, offset = source_and_offset( + "\f\n" + "class Test(object):_|_\n" + " pass" + ) + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_dictionaries_in_weird_places(self): + # Bug in Jedi: jedi#417 + source, offset = source_and_offset( + "import json\n" + "\n" + "def foo():\n" + " json.loads(_|_\n" + "\n" + " json.load.return_value = {'foo': [],\n" + " 'bar': True}\n" + "\n" + " c = Foo()\n" + ) + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_break_with_binary_characters_in_docstring(self): + # Bug in Jedi: jedi#427 + template = '''\ +class Foo(object): + def __init__(self): + """ + COMMUNITY instance that this conversion belongs to. + DISPERSY_VERSION is the dispersy conversion identifier (on the wire version; must be one byte). + COMMUNIY_VERSION is the community conversion identifier (on the wire version; must be one byte). + + COMMUNIY_VERSION may not be '\\x00' or '\\xff'. '\\x00' is used by the DefaultConversion until + a proper conversion instance can be made for the Community. '\\xff' is reserved for when + more than one byte is needed as a version indicator. + """ + pass + + +x = Foo() +x._|_ +''' + source, offset = source_and_offset(template) + filename = self.project_file("test.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_def_without_name(self): + # Bug jedi#429 + source, offset = source_and_offset( + "def_|_():\n" + " if True:\n" + " return True\n" + " else:\n" + " return False\n" + ) + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_on_lambda(self): + # Bug #272 / jedi#431 + source, offset = source_and_offset( + "map(lambda_|_" + ) + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_on_literals(self): + # Bug #314, #344 / jedi#466 + source = u'lit = u"""\\\n# -*- coding: utf-8 -*-\n"""\n' + offset = 0 + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_with_args_as_args(self): + # Bug #347 in rope_py3k + source, offset = source_and_offset( + "def my_function(*args):\n" + " ret_|_" + ) + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_unicode_chars_in_string(self): + # Bug #358 / jedi#482 + source = '''\ +# coding: utf-8 + +logging.info(u"Saving «{}»...".format(title)) +requests.get(u"https://web.archive.org/save/{}".format(url)) +''' + offset = 57 + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_bad_escape_sequence(self): + # Bug #360 / jedi#485 + source = r"v = '\x'" + offset = 8 + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_for_coding_declarations_in_strings(self): + # Bug #314 / jedi#465 / python#22221 + source = u'lit = """\\\n# -*- coding: utf-8 -*-\n"""' + offset = 8 + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + def test_should_not_fail_if_root_vanishes(self): + # Bug #353 + source, offset = source_and_offset( + "import foo\n" + "foo._|_" + ) + filename = self.project_file("project.py", source) + shutil.rmtree(self.project_root) + + self.rpc(filename, source, offset) + + # For some reason, this breaks a lot of other tests. Couldn't + # figure out why. + # + # def test_should_not_fail_for_sys_path(self): + # # Bug #365 / jedi#486 + # source, offset = source_and_offset( + # "import sys\n" + # "\n" + # "sys.path.index(_|_\n" + # ) + # filename = self.project_file("project.py", source) + # + # self.rpc(filename, source, offset) + + +class RPCGetCompletionsTests(GenericRPCTests): + METHOD = "rpc_get_completions" + + def test_should_complete_builtin(self): + source, offset = source_and_offset("o_|_") + + expected = ["object", "oct", "open", "or", "ord"] + actual = [cand['name'] for cand in + self.backend.rpc_get_completions("test.py", + source, offset)] + + for candidate in expected: + self.assertIn(candidate, actual) + + def test_should_complete_imports(self): + source, offset = source_and_offset("import json\n" + "json.J_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + self.assertEqual( + sorted([cand['suffix'] for cand in completions]), + sorted(["SONDecoder", "SONEncoder"])) + + def test_should_complete_top_level_modules_for_import(self): + source, offset = source_and_offset("import multi_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + if compat.PYTHON3: + expected = ["processing"] + else: + expected = ["file", "processing"] + self.assertEqual(sorted([cand['suffix'] for cand in completions]), + sorted(expected)) + + def test_should_complete_packages_for_import(self): + source, offset = source_and_offset("import elpy.tes_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + self.assertEqual([cand['suffix'] for cand in completions], + ["ts"]) + + def test_should_not_complete_for_import(self): + source, offset = source_and_offset("import foo.Conf_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + self.assertEqual([cand['suffix'] for cand in completions], + []) + + def test_should_not_fail_for_short_module(self): + source, offset = source_and_offset("from .. import foo_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + self.assertIsNotNone(completions) + + def test_should_complete_sys(self): + source, offset = source_and_offset("import sys\nsys._|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + self.assertIn('path', [cand['suffix'] for cand in completions]) + + def test_should_find_with_trailing_text(self): + source, offset = source_and_offset( + "import threading\nthreading.T_|_mumble mumble") + + expected = ["Thread", "ThreadError", "Timer"] + actual = [cand['name'] for cand in + self.backend.rpc_get_completions("test.py", source, offset)] + + for candidate in expected: + self.assertIn(candidate, actual) + + def test_should_find_completion_different_package(self): + # See issue #74 + self.project_file("project/__init__.py", "") + source1 = ("class Add:\n" + " def add(self, a, b):\n" + " return a + b\n") + self.project_file("project/add.py", source1) + source2, offset = source_and_offset( + "from project.add import Add\n" + "class Calculator:\n" + " def add(self, a, b):\n" + " c = Add()\n" + " c.ad_|_\n") + file2 = self.project_file("project/calculator.py", source2) + proposals = self.backend.rpc_get_completions(file2, + source2, + offset) + self.assertEqual(["add"], + [proposal["name"] for proposal in proposals]) + + +class RPCGetCompletionDocstringTests(object): + def test_should_return_docstring(self): + source, offset = source_and_offset("import json\n" + "json.J_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + completions.sort(key=lambda p: p["name"]) + prop = completions[0] + self.assertEqual(prop["name"], "JSONDecoder") + + docs = self.backend.rpc_get_completion_docstring("JSONDecoder") + + self.assertIn("Simple JSON", docs) + + def test_should_return_none_if_unknown(self): + docs = self.backend.rpc_get_completion_docstring("Foo") + + self.assertIsNone(docs) + + +class RPCGetCompletionLocationTests(object): + def test_should_return_location(self): + source, offset = source_and_offset("donaudampfschiff = 1\n" + "donau_|_") + filename = self.project_file("test.py", source) + completions = self.backend.rpc_get_completions(filename, + source, + offset) + prop = completions[0] + self.assertEqual(prop["name"], "donaudampfschiff") + + loc = self.backend.rpc_get_completion_location("donaudampfschiff") + + self.assertEqual((filename, 1), loc) + + def test_should_return_none_if_unknown(self): + docs = self.backend.rpc_get_completion_location("Foo") + + self.assertIsNone(docs) + + +class RPCGetDefinitionTests(GenericRPCTests): + METHOD = "rpc_get_definition" + + def test_should_return_definition_location_same_file(self): + source, offset = source_and_offset("import threading\n" + "def test_function(a, b):\n" + " return a + b\n" + "\n" + "test_func_|_tion(\n") + filename = self.project_file("test.py", source) + + location = self.backend.rpc_get_definition(filename, + source, + offset) + + self.assertEqual(location[0], filename) + # On def or on the function name + self.assertIn(location[1], (17, 21)) + + def test_should_return_location_in_same_file_if_not_saved(self): + source, offset = source_and_offset( + "import threading\n" + "\n" + "\n" + "def other_function():\n" + " test_f_|_unction(1, 2)\n" + "\n" + "\n" + "def test_function(a, b):\n" + " return a + b\n") + filename = self.project_file("test.py", "") + + location = self.backend.rpc_get_definition(filename, + source, + offset) + + self.assertEqual(location[0], filename) + # def or function name + self.assertIn(location[1], (67, 71)) + + def test_should_return_location_in_different_file(self): + source1 = ("def test_function(a, b):\n" + " return a + b\n") + file1 = self.project_file("test1.py", source1) + source2, offset = source_and_offset("from test1 import test_function\n" + "test_funct_|_ion(1, 2)\n") + file2 = self.project_file("test2.py", source2) + + definition = self.backend.rpc_get_definition(file2, + source2, + offset) + + self.assertEqual(definition[0], file1) + # Either on the def or on the function name + self.assertIn(definition[1], (0, 4)) + + def test_should_return_none_if_location_not_found(self): + source, offset = source_and_offset("test_f_|_unction()\n") + filename = self.project_file("test.py", source) + + definition = self.backend.rpc_get_definition(filename, + source, + offset) + + self.assertIsNone(definition) + + def test_should_return_none_if_outside_of_symbol(self): + source, offset = source_and_offset("test_function(_|_)\n") + filename = self.project_file("test.py", source) + + definition = self.backend.rpc_get_definition(filename, + source, + offset) + + self.assertIsNone(definition) + + def test_should_return_definition_location_different_package(self): + # See issue #74 + self.project_file("project/__init__.py", "") + source1 = ("class Add:\n" + " def add(self, a, b):\n" + " return a + b\n") + file1 = self.project_file("project/add.py", source1) + source2, offset = source_and_offset( + "from project.add import Add\n" + "class Calculator:\n" + " def add(self, a, b):\n" + " return Add_|_().add(a, b)\n") + file2 = self.project_file("project/calculator.py", source2) + + location = self.backend.rpc_get_definition(file2, + source2, + offset) + + self.assertEqual(location[0], file1) + # class or class name + self.assertIn(location[1], (0, 6)) + + def test_should_find_variable_definition(self): + source, offset = source_and_offset("SOME_VALUE = 1\n" + "\n" + "variable = _|_SOME_VALUE\n") + filename = self.project_file("test.py", source) + self.assertEqual(self.backend.rpc_get_definition(filename, + source, + offset), + (filename, 0)) + + +class RPCGetCalltipTests(GenericRPCTests): + METHOD = "rpc_get_calltip" + + def test_should_get_calltip(self): + source, offset = source_and_offset( + "import threading\nthreading.Thread(_|_") + filename = self.project_file("test.py", source) + calltip = self.backend.rpc_get_calltip(filename, + source, + offset) + + expected = self.THREAD_CALLTIP + + self.assertEqual(calltip, expected) + + def test_should_get_calltip_even_after_parens(self): + source, offset = source_and_offset( + "import threading\nthreading.Thread(foo()_|_") + filename = self.project_file("test.py", source) + + actual = self.backend.rpc_get_calltip(filename, + source, + offset) + + self.assertEqual(self.THREAD_CALLTIP, actual) + + def test_should_get_calltip_at_closing_paren(self): + source, offset = source_and_offset( + "import threading\nthreading.Thread(_|_)") + filename = self.project_file("test.py", source) + + actual = self.backend.rpc_get_calltip(filename, + source, + offset) + + self.assertEqual(self.THREAD_CALLTIP, actual) + + def test_should_return_none_for_bad_identifier(self): + source, offset = source_and_offset( + "froblgoo(_|_") + filename = self.project_file("test.py", source) + calltip = self.backend.rpc_get_calltip(filename, + source, + offset) + self.assertIsNone(calltip) + + def test_should_remove_self_argument(self): + source, offset = source_and_offset( + "d = dict()\n" + "d.keys(_|_") + filename = self.project_file("test.py", source) + + actual = self.backend.rpc_get_calltip(filename, + source, + offset) + + self.assertEqual(self.KEYS_CALLTIP, actual) + + def test_should_remove_package_prefix(self): + source, offset = source_and_offset( + "import decimal\n" + "d = decimal.Decimal('1.5')\n" + "d.radix(_|_") + filename = self.project_file("test.py", source) + + actual = self.backend.rpc_get_calltip(filename, + source, + offset) + + self.assertEqual(self.RADIX_CALLTIP, actual) + + def test_should_return_none_outside_of_all(self): + filename = self.project_file("test.py", "") + source, offset = source_and_offset("import thr_|_eading\n") + calltip = self.backend.rpc_get_calltip(filename, + source, offset) + self.assertIsNone(calltip) + + def test_should_find_calltip_different_package(self): + # See issue #74 + self.project_file("project/__init__.py", "") + source1 = ("class Add:\n" + " def add(self, a, b):\n" + " return a + b\n") + self.project_file("project/add.py", source1) + source2, offset = source_and_offset( + "from project.add import Add\n" + "class Calculator:\n" + " def add(self, a, b):\n" + " c = Add()\n" + " c.add(_|_\n") + file2 = self.project_file("project/calculator.py", source2) + + actual = self.backend.rpc_get_calltip(file2, + source2, + offset) + + self.assertEqual(self.ADD_CALLTIP, actual) + + +class RPCGetDocstringTests(GenericRPCTests): + METHOD = "rpc_get_docstring" + + def check_docstring(self, docstring): + + def first_line(s): + return s[:s.index("\n")] + + self.assertEqual(first_line(docstring), + self.THREAD_JOIN_DOCSTRING) + + def test_should_get_docstring(self): + source, offset = source_and_offset( + "import threading\nthreading.Thread.join_|_(") + filename = self.project_file("test.py", source) + docstring = self.backend.rpc_get_docstring(filename, + source, + offset) + self.check_docstring(docstring) + + def test_should_return_none_for_bad_identifier(self): + source, offset = source_and_offset( + "froblgoo_|_(\n") + filename = self.project_file("test.py", source) + docstring = self.backend.rpc_get_docstring(filename, + source, + offset) + self.assertIsNone(docstring) + + +class RPCGetUsagesTests(GenericRPCTests): + METHOD = "rpc_get_usages" + + def test_should_return_uses_in_same_file(self): + filename = self.project_file("test.py", "") + source, offset = source_and_offset( + "def foo(x):\n" + " return _|_x + x\n") + + usages = self.backend.rpc_get_usages(filename, + source, + offset) + + self.assertEqual(usages, + [{'name': 'x', + 'offset': 8, + 'filename': filename}, + {'name': 'x', + 'filename': filename, + 'offset': 23}, + {'name': u'x', + 'filename': filename, + 'offset': 27}]) + + def test_should_return_uses_in_other_file(self): + file1 = self.project_file("file1.py", "") + file2 = self.project_file("file2.py", "\n\n\n\n\nx = 5") + source, offset = source_and_offset( + "import file2\n" + "file2._|_x\n") + + usages = self.backend.rpc_get_usages(file1, + source, + offset) + + self.assertEqual(usages, + [{'name': 'x', + 'filename': file1, + 'offset': 19}, + {'name': 'x', + 'filename': file2, + 'offset': 5}]) + + def test_should_not_fail_without_symbol(self): + filename = self.project_file("file.py", "") + + usages = self.backend.rpc_get_usages(filename, + "", + 0) + + self.assertEqual(usages, []) + + +def source_and_offset(source): + """Return a source and offset from a source description. + + >>> source_and_offset("hello, _|_world") + ("hello, world", 7) + >>> source_and_offset("_|_hello, world") + ("hello, world", 0) + >>> source_and_offset("hello, world_|_") + ("hello, world", 12) + """ + offset = source.index("_|_") + return source[:offset] + source[offset + 3:], offset diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_impmagic.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_impmagic.py new file mode 100644 index 0000000..38d6ab5 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_impmagic.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +"""Tests for the elpy.impmagic module""" + +import re +import unittest + +from elpy import impmagic +from elpy.tests.support import BackendTestCase + +TEST_SOURCE = '''# test file + +import time +import logging + +os.getcwd() +time.sleep(1) +''' + + +class ImportMagicTestCase(BackendTestCase): + + def setUp(self): + if not impmagic.importmagic: + raise unittest.SkipTest + self.importmagic = impmagic.ImportMagic() + super(ImportMagicTestCase, self).setUp() + + def build_index(self): + self.project_file('mymod.py', 'class AnUncommonName:\n pass\n') + self.importmagic.build_index(self.project_root, + custom_path=[self.project_root], + blacklist_re=re.compile('^$')) + self.importmagic._thread.join() + + def test_get_symbols(self): + self.build_index() + candidates = self.importmagic.get_import_symbols('AnUncommonName') + self.assertEqual(candidates, ['from mymod import AnUncommonName']) + candidates = self.importmagic.get_import_symbols('mymod') + self.assertEqual(candidates, ['import mymod']) + + @unittest.skipIf(impmagic.importmagic.__version__ == '0.1.3', + "Import ordering is random, see #479") + def test_add_import(self): + self.build_index() + start, end, newblock = self.importmagic.add_import( + TEST_SOURCE, 'from mymod import AnUncommonName') + self.assertEqual(start, 2) + self.assertEqual(end, 5) + self.assertEqual(newblock.strip(), + 'import logging\nimport time\n\nfrom mymod import AnUncommonName') + + start, end, newblock = self.importmagic.add_import( + TEST_SOURCE, 'import mymod') + self.assertEqual(start, 2) + self.assertEqual(end, 5) + self.assertEqual(newblock.strip(), + 'import logging\nimport time\n\nimport mymod') + + def test_get_unresolved_symbols(self): + self.build_index() + symbols = self.importmagic.get_unresolved_symbols('x = a + b\ny = c.d') + self.assertEqual(sorted(symbols), ['a', 'b', 'c.d']) + + def test_remove_unreferenced_imports(self): + self.build_index() + start, end, newblock = \ + self.importmagic.remove_unreferenced_imports(TEST_SOURCE) + self.assertEqual(start, 2) + self.assertEqual(end, 5) + self.assertEqual(newblock.strip(), 'import time') diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_jedibackend.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_jedibackend.py new file mode 100644 index 0000000..38aa45a --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_jedibackend.py @@ -0,0 +1,265 @@ +"""Tests for the elpy.jedibackend module.""" + +import unittest + +import jedi +import mock + +from elpy import jedibackend +from elpy import rpc +from elpy.tests import compat +from elpy.tests.support import BackendTestCase +from elpy.tests.support import RPCGetCompletionsTests +from elpy.tests.support import RPCGetCompletionDocstringTests +from elpy.tests.support import RPCGetCompletionLocationTests +from elpy.tests.support import RPCGetDocstringTests +from elpy.tests.support import RPCGetDefinitionTests +from elpy.tests.support import RPCGetCalltipTests +from elpy.tests.support import RPCGetUsagesTests + + +class JediBackendTestCase(BackendTestCase): + def setUp(self): + super(JediBackendTestCase, self).setUp() + self.backend = jedibackend.JediBackend(self.project_root) + + +class TestInit(JediBackendTestCase): + def test_should_have_jedi_as_name(self): + self.assertEqual(self.backend.name, "jedi") + + +class TestRPCGetCompletions(RPCGetCompletionsTests, + JediBackendTestCase): + pass + + +class TestRPCGetCompletionDocstring(RPCGetCompletionDocstringTests, + JediBackendTestCase): + pass + + +class TestRPCGetCompletionLocation(RPCGetCompletionLocationTests, + JediBackendTestCase): + pass + + +class TestRPCGetDocstring(RPCGetDocstringTests, + JediBackendTestCase): + THREAD_JOIN_DOCSTRING = 'join(self, timeout = None)' + + def check_docstring(self, docstring): + lines = docstring.splitlines() + self.assertEqual(lines[0], 'Documentation for threading.Thread.join:') + self.assertEqual(lines[2], self.THREAD_JOIN_DOCSTRING) + + +class TestRPCGetDefinition(RPCGetDefinitionTests, + JediBackendTestCase): + @mock.patch("jedi.Script") + def test_should_not_fail_if_module_path_is_none(self, Script): + """Do not fail if loc.module_path is None. + + This can happen under some circumstances I am unsure about. + See #537 for the issue that reported this. + + """ + locations = [ + mock.Mock(module_path=None) + ] + script = Script.return_value + script.goto_definitions.return_value = locations + script.goto_assignments.return_value = locations + + location = self.rpc("", "", 0) + + self.assertIsNone(location) + + +class TestRPCGetCalltip(RPCGetCalltipTests, + JediBackendTestCase): + KEYS_CALLTIP = {'index': 0, + 'params': [''], + 'name': u'keys'} + RADIX_CALLTIP = {'index': None, + 'params': [], + 'name': u'radix'} + ADD_CALLTIP = {'index': 0, + 'params': [u'a', u'b'], + 'name': u'add'} + if compat.PYTHON3: + THREAD_CALLTIP = {"name": "Thread", + "params": ["group = None", + "target = None", + "name = None", + "args = ()", + "kwargs = None", + "daemon = None"], + "index": 0} + else: + THREAD_CALLTIP = {"name": "Thread", + "params": ["group = None", + "target = None", + "name = None", + "args = ()", + "kwargs = None", + "verbose = None"], + "index": 0} + + +class TestRPCGetUsages(RPCGetUsagesTests, + JediBackendTestCase): + def test_should_not_fail_for_missing_module(self): + # This causes use.module_path to be None + source = "import sys\n\nsys.path.\n" # insert()" + offset = 21 + filename = self.project_file("project.py", source) + + self.rpc(filename, source, offset) + + +class TestPosToLinecol(unittest.TestCase): + def test_should_handle_beginning_of_string(self): + self.assertEqual(jedibackend.pos_to_linecol("foo", 0), + (1, 0)) + + def test_should_handle_end_of_line(self): + self.assertEqual(jedibackend.pos_to_linecol("foo\nbar\nbaz\nqux", 9), + (3, 1)) + + def test_should_handle_end_of_string(self): + self.assertEqual(jedibackend.pos_to_linecol("foo\nbar\nbaz\nqux", 14), + (4, 2)) + + +class TestLinecolToPos(unittest.TestCase): + def test_should_handle_beginning_of_string(self): + self.assertEqual(jedibackend.linecol_to_pos("foo", 1, 0), + 0) + + def test_should_handle_end_of_string(self): + self.assertEqual(jedibackend.linecol_to_pos("foo\nbar\nbaz\nqux", + 3, 1), + 9) + + def test_should_return_offset(self): + self.assertEqual(jedibackend.linecol_to_pos("foo\nbar\nbaz\nqux", + 4, 2), + 14) + + def test_should_fail_for_line_past_text(self): + self.assertRaises(ValueError, + jedibackend.linecol_to_pos, "foo\n", 3, 1) + + def test_should_fail_for_column_past_text(self): + self.assertRaises(ValueError, + jedibackend.linecol_to_pos, "foo\n", 1, 10) + + +class TestRunWithDebug(unittest.TestCase): + @mock.patch('jedi.Script') + def test_should_call_method(self, Script): + Script.return_value.test_method.return_value = "test-result" + + result = jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3) + + Script.assert_called_with(1, 2, arg=3) + self.assertEqual(result, 'test-result') + + @mock.patch('jedi.Script') + def test_should_re_raise(self, Script): + Script.side_effect = RuntimeError + + with self.assertRaises(RuntimeError): + jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3, + re_raise=(RuntimeError,)) + + @mock.patch('jedi.Script') + @mock.patch('jedi.set_debug_function') + def test_should_keep_debug_info(self, set_debug_function, Script): + Script.side_effect = RuntimeError + + try: + jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3) + except rpc.Fault as e: + self.assertGreaterEqual(e.code, 400) + self.assertIsNotNone(e.data) + self.assertIn("traceback", e.data) + jedi_debug_info = e.data["jedi_debug_info"] + self.assertIsNotNone(jedi_debug_info) + self.assertEqual(jedi_debug_info["script_args"], + "1, 2, arg=3") + self.assertEqual(jedi_debug_info["source"], None) + self.assertEqual(jedi_debug_info["method"], "test_method") + self.assertEqual(jedi_debug_info["debug_info"], []) + else: + self.fail("Fault not thrown") + + @mock.patch('jedi.Script') + @mock.patch('jedi.set_debug_function') + def test_should_keep_error_text(self, set_debug_function, Script): + Script.side_effect = RuntimeError + + try: + jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3) + except rpc.Fault as e: + self.assertEqual(str(e), str(RuntimeError())) + self.assertEqual(e.message, str(RuntimeError())) + else: + self.fail("Fault not thrown") + + @mock.patch('jedi.Script') + @mock.patch('jedi.set_debug_function') + def test_should_handle_source_special(self, set_debug_function, Script): + Script.side_effect = RuntimeError + + try: + jedibackend.run_with_debug(jedi, 'test_method', source="foo") + except rpc.Fault as e: + self.assertEqual(e.data["jedi_debug_info"]["script_args"], + "source=source") + self.assertEqual(e.data["jedi_debug_info"]["source"], "foo") + else: + self.fail("Fault not thrown") + + @mock.patch('jedi.Script') + @mock.patch('jedi.set_debug_function') + def test_should_set_debug_info(self, set_debug_function, Script): + the_debug_function = [None] + + def my_set_debug_function(debug_function, **kwargs): + the_debug_function[0] = debug_function + + def my_script(*args, **kwargs): + the_debug_function[0](jedi.debug.NOTICE, "Notice") + the_debug_function[0](jedi.debug.WARNING, "Warning") + the_debug_function[0]("other", "Other") + raise RuntimeError + + set_debug_function.side_effect = my_set_debug_function + Script.return_value.test_method = my_script + + try: + jedibackend.run_with_debug(jedi, 'test_method', source="foo") + except rpc.Fault as e: + self.assertEqual(e.data["jedi_debug_info"]["debug_info"], + ["[N] Notice", + "[W] Warning", + "[?] Other"]) + else: + self.fail("Fault not thrown") + + @mock.patch('jedi.set_debug_function') + @mock.patch('jedi.Script') + def test_should_not_fail_with_bad_data(self, Script, set_debug_function): + import jedi.debug + + def set_debug(function, speed=True): + if function is not None: + function(jedi.debug.NOTICE, u"\xab") + + set_debug_function.side_effect = set_debug + Script.return_value.test_method.side_effect = Exception + + with self.assertRaises(rpc.Fault): + jedibackend.run_with_debug(jedi, 'test_method', 1, 2, arg=3) diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_pydocutils.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_pydocutils.py new file mode 100644 index 0000000..6e4eeb2 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_pydocutils.py @@ -0,0 +1,88 @@ +import os +import unittest +import shutil +import sys +import tempfile + +import mock + +import elpy.pydocutils + + +class TestGetPydocCompletions(unittest.TestCase): + def test_should_return_top_level_modules(self): + modules = elpy.pydocutils.get_pydoc_completions("") + self.assertIn('sys', modules) + self.assertIn('json', modules) + + def test_should_return_submodules(self): + modules = elpy.pydocutils.get_pydoc_completions("elpy") + self.assertIn("elpy.rpc", modules) + self.assertIn("elpy.server", modules) + modules = elpy.pydocutils.get_pydoc_completions("os") + self.assertIn("os.path", modules) + + def test_should_find_objects_in_module(self): + self.assertIn("elpy.tests.test_pydocutils.TestGetPydocCompletions", + elpy.pydocutils.get_pydoc_completions + ("elpy.tests.test_pydocutils")) + + def test_should_find_attributes_of_objects(self): + attribs = elpy.pydocutils.get_pydoc_completions( + "elpy.tests.test_pydocutils.TestGetPydocCompletions") + self.assertIn("elpy.tests.test_pydocutils.TestGetPydocCompletions." + "test_should_find_attributes_of_objects", + attribs) + + def test_should_return_none_for_inexisting_module(self): + self.assertEqual([], + elpy.pydocutils.get_pydoc_completions + ("does_not_exist")) + + def test_should_work_for_unicode_strings(self): + self.assertIsNotNone(elpy.pydocutils.get_pydoc_completions + (u"sys")) + + def test_should_find_partial_completions(self): + self.assertIn("multiprocessing", + elpy.pydocutils.get_pydoc_completions + ("multiprocess")) + self.assertIn("multiprocessing.util", + elpy.pydocutils.get_pydoc_completions + ("multiprocessing.ut")) + + def test_should_ignore_trailing_dot(self): + self.assertIn("elpy.pydocutils", + elpy.pydocutils.get_pydoc_completions + ("elpy.")) + + +class TestGetModules(unittest.TestCase): + def test_should_return_top_level_modules(self): + modules = elpy.pydocutils.get_modules() + self.assertIn('sys', modules) + self.assertIn('json', modules) + + def test_should_return_submodules(self): + modules = elpy.pydocutils.get_modules("elpy") + self.assertIn("rpc", modules) + self.assertIn("server", modules) + + @mock.patch.object(elpy.pydocutils, 'safeimport') + def test_should_catch_import_errors(self, safeimport): + def raise_function(message): + raise elpy.pydocutils.ErrorDuringImport(message, + (None, None, None)) + safeimport.side_effect = raise_function + self.assertEqual([], elpy.pydocutils.get_modules("foo.bar")) + + def test_should_not_fail_for_permission_denied(self): + tmpdir = tempfile.mkdtemp(prefix="test-elpy-get-modules-") + sys.path.append(tmpdir) + os.chmod(tmpdir, 0o000) + try: + elpy.pydocutils.get_modules() + finally: + os.chmod(tmpdir, 0o755) + shutil.rmtree(tmpdir) + sys.path.remove(tmpdir) diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_refactor.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_refactor.py new file mode 100644 index 0000000..6a4a2ac --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_refactor.py @@ -0,0 +1,542 @@ +import unittest +import tempfile +import shutil +import os +import mock + +from elpy import refactor +from textwrap import dedent + + +class RefactorTestCase(unittest.TestCase): + def setUp(self): + self.project_root = tempfile.mkdtemp(prefix="test-refactor-root") + self.addCleanup(shutil.rmtree, self.project_root, + ignore_errors=True) + + def create_file(self, name, contents=""): + filename = os.path.join(self.project_root, name) + contents = dedent(contents) + offset = contents.find("_|_") + if offset > -1: + contents = contents[:offset] + contents[offset + 3:] + with open(filename, "w") as f: + f.write(contents) + return filename, offset + + def assertSourceEqual(self, first, second, msg=None): + """Fail if the two objects are unequal, ignoring indentation.""" + self.assertEqual(dedent(first), dedent(second), msg=msg) + + +class TestGetRefactorOptions(RefactorTestCase): + def test_should_only_return_importsmodule_if_not_on_symbol(self): + filename, offset = self.create_file("foo.py", + """\ + import foo + _|_""") + ref = refactor.Refactor(self.project_root, filename) + options = ref.get_refactor_options(offset) + self.assertTrue(all(opt['category'] in ('Imports', + 'Module') + for opt in options)) + filename, offset = self.create_file("foo.py", + """\ + _|_ + import foo""") + ref = refactor.Refactor(self.project_root, filename) + options = ref.get_refactor_options(offset) + self.assertTrue(all(opt['category'] in ('Imports', + 'Module') + for opt in options)) + + def test_should_return_all_if_on_symbol(self): + filename, offset = self.create_file("foo.py", + "import _|_foo") + ref = refactor.Refactor(self.project_root, filename) + options = ref.get_refactor_options(offset) + self.assertTrue(all(opt['category'] in ('Imports', + 'Method', + 'Module', + 'Symbol') + for opt in options)) + + def test_should_return_only_region_if_endoffset(self): + filename, offset = self.create_file("foo.py", + "import foo") + ref = refactor.Refactor(self.project_root, filename) + options = ref.get_refactor_options(offset, 5) + self.assertTrue(all(opt['category'] == 'Region' + for opt in options)) + + @unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") + def test_should_treat_from_import_special(self): + filename, offset = self.create_file("foo.py", + """\ + import foo + _|_""") + ref = refactor.Refactor(self.project_root, filename) + options = ref.get_refactor_options(offset) + self.assertFalse(any(opt['name'] == "refactor_froms_to_imports" + for opt in options)) + filename, offset = self.create_file("foo.py", + "imp_|_ort foo") + ref = refactor.Refactor(self.project_root, filename) + options = ref.get_refactor_options(offset) + self.assertTrue(any(opt['name'] == "refactor_froms_to_imports" + for opt in options)) + + +class TestGetChanges(RefactorTestCase): + def test_should_fail_if_method_is_not_refactoring(self): + filename, offset = self.create_file("foo.py") + ref = refactor.Refactor(self.project_root, filename) + self.assertRaises(ValueError, ref.get_changes, "bad_name") + + def test_should_return_method_results(self): + filename, offset = self.create_file("foo.py") + ref = refactor.Refactor(self.project_root, filename) + with mock.patch.object(ref, 'refactor_extract_method') as test: + test.return_value = "Meep!" + self.assertEqual(ref.get_changes("refactor_extract_method", + 1, 2), + "Meep!") + test.assert_called_with(1, 2) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestIsOnSymbol(RefactorTestCase): + def test_should_find_symbol(self): + filename, offset = self.create_file("test.py", "__B_|_AR = 100") + r = refactor.Refactor(self.project_root, filename) + self.assertTrue(r._is_on_symbol(offset)) + + # Issue #111 + def test_should_find_symbol_with_underscores(self): + filename, offset = self.create_file("test.py", "_|___BAR = 100") + r = refactor.Refactor(self.project_root, filename) + self.assertTrue(r._is_on_symbol(offset)) + + def test_should_not_find_weird_places(self): + filename, offset = self.create_file("test.py", "hello = _|_ 1 + 1") + r = refactor.Refactor(self.project_root, filename) + self.assertFalse(r._is_on_symbol(offset)) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestFromsToImports(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + """\ + _|_from datetime import datetime + + d = datetime(2013, 4, 7) + """) + ref = refactor.Refactor(self.project_root, filename) + (change,) = ref.get_changes("refactor_froms_to_imports", offset) + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], filename) + self.assertSourceEqual(change['contents'], + """\ + import datetime + + d = datetime.datetime(2013, 4, 7) + """) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestOrganizeImports(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + """\ + import unittest, base64 + import datetime, json + + obj = json.dumps(23) + unittest.TestCase() + """) + ref = refactor.Refactor(self.project_root, filename) + (change,) = ref.get_changes("refactor_organize_imports") + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], filename) + self.assertSourceEqual(change['contents'], + """\ + import json + import unittest + + + obj = json.dumps(23) + unittest.TestCase() + """) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestModuleToPackage(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + "_|_import os\n") + ref = refactor.Refactor(self.project_root, filename) + changes = ref.refactor_module_to_package() + a, b, c = changes + # Not sure why the a change is there. It's a CHANGE that + # changes nothing... + self.assertEqual(a['diff'], '') + + self.assertEqual(b['action'], 'create') + self.assertEqual(b['type'], 'directory') + self.assertEqual(b['path'], os.path.join(self.project_root, "foo")) + + self.assertEqual(c['action'], 'move') + self.assertEqual(c['type'], 'file') + self.assertEqual(c['source'], os.path.join(self.project_root, + "foo.py")) + self.assertEqual(c['destination'], os.path.join(self.project_root, + "foo/__init__.py")) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestRenameAtPoint(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + """\ + class Foo(object): + def _|_foo(self): + return 5 + + def bar(self): + return self.foo() + """) + file2, offset2 = self.create_file( + "bar.py", + """\ + import foo + + + x = foo.Foo() + x.foo()""") + ref = refactor.Refactor(self.project_root, filename) + first, second = ref.refactor_rename_at_point(offset, "frob", + in_hierarchy=False, + docs=False) + if first['file'] == filename: + a, b = first, second + else: + a, b = second, first + self.assertEqual(a['action'], 'change') + self.assertEqual(a['file'], filename) + self.assertSourceEqual(a['contents'], + """\ + class Foo(object): + def frob(self): + return 5 + + def bar(self): + return self.frob() + """) + self.assertEqual(b['action'], 'change') + self.assertEqual(b['file'], file2) + self.assertSourceEqual(b['contents'], + """\ + import foo + + + x = foo.Foo() + x.frob()""") + + def test_should_refactor_in_hierarchy(self): + filename, offset = self.create_file( + "foo.py", + """\ + class Foo(object): + def _|_foo(self): + return 5 + + def bar(self): + return self.foo() + + class Bar(Foo): + def foo(self): + return 42 + + class Baz(object): + def foo(self): + return 42 + """) + file2, offset2 = self.create_file( + "bar.py", + """\ + import foo + + + x, y, z = foo.Foo(), foo.Bar(), foo.Baz() + x.foo() + y.foo() + z.foo()""") + ref = refactor.Refactor(self.project_root, filename) + first, second = ref.refactor_rename_at_point(offset, "frob", + in_hierarchy=True, + docs=False) + if first['file'] == filename: + a, b = first, second + else: + a, b = second, first + self.assertEqual(a['action'], 'change') + self.assertEqual(a['file'], filename) + self.assertSourceEqual(a['contents'], + """\ + class Foo(object): + def frob(self): + return 5 + + def bar(self): + return self.frob() + + class Bar(Foo): + def frob(self): + return 42 + + class Baz(object): + def foo(self): + return 42 + """) + self.assertEqual(b['action'], 'change') + self.assertEqual(b['file'], file2) + self.assertSourceEqual(b['contents'], + """\ + import foo + + + x, y, z = foo.Foo(), foo.Bar(), foo.Baz() + x.frob() + y.frob() + z.foo()""") + + def test_should_refactor_in_docstrings(self): + filename, offset = self.create_file( + "foo.py", + """\ + class Foo(object): + "Frobnicate the foo" + def _|_foo(self): + return 5 + + print("I'm an unrelated foo") + """) + ref = refactor.Refactor(self.project_root, filename) + (change,) = ref.refactor_rename_at_point(offset, "frob", + in_hierarchy=False, + docs=True) + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], filename) + self.assertSourceEqual(change['contents'], + """\ + class Foo(object): + "Frobnicate the frob" + def frob(self): + return 5 + + print("I'm an unrelated foo") + """) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestRenameCurrentModule(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + "_|_import os\n") + file2, offset = self.create_file( + "bar.py", + """\ + _|_import foo + foo.os + """) + dest = os.path.join(self.project_root, "frob.py") + ref = refactor.Refactor(self.project_root, filename) + a, b = ref.refactor_rename_current_module("frob") + + self.assertEqual(a['action'], 'change') + self.assertEqual(a['file'], file2) + self.assertEqual(a['contents'], + "import frob\n" + "frob.os\n") + + self.assertEqual(b['action'], 'move') + self.assertEqual(b['type'], 'file') + self.assertEqual(b['source'], filename) + self.assertEqual(b['destination'], dest) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestMoveModule(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + "_|_import os\n") + file2, offset = self.create_file( + "bar.py", + """\ + _|_import foo + foo.os + """) + dest = os.path.join(self.project_root, "frob") + os.mkdir(dest) + with open(os.path.join(dest, "__init__.py"), "w") as f: + f.write("") + ref = refactor.Refactor(self.project_root, filename) + a, b = ref.refactor_move_module(dest) + + self.assertEqual(a['action'], 'change') + self.assertEqual(a['file'], file2) + self.assertSourceEqual(a['contents'], + """\ + import frob.foo + frob.foo.os + """) + + self.assertEqual(b['action'], 'move') + self.assertEqual(b['type'], 'file') + self.assertEqual(b['source'], filename) + self.assertEqual(b['destination'], + os.path.join(dest, "foo.py")) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestCreateInline(RefactorTestCase): + def setUp(self): + super(TestCreateInline, self).setUp() + self.filename, self.offset = self.create_file( + "foo.py", + """\ + def add(a, b): + return a + b + + x = _|_add(2, 3) + y = add(17, 4) + """) + + def test_should_refactor_single_occurrenc(self): + ref = refactor.Refactor(self.project_root, self.filename) + (change,) = ref.refactor_create_inline(self.offset, True) + + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], self.filename) + self.assertSourceEqual(change['contents'], + """\ + def add(a, b): + return a + b + + x = 2 + 3 + y = add(17, 4) + """) + + def test_should_refactor_all_occurrencs(self): + ref = refactor.Refactor(self.project_root, self.filename) + (change,) = ref.refactor_create_inline(self.offset, False) + + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], self.filename) + self.assertSourceEqual(change['contents'], + """\ + x = 2 + 3 + y = 17 + 4 + """) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestExtractMethod(RefactorTestCase): + def setUp(self): + super(TestExtractMethod, self).setUp() + self.filename, self.offset = self.create_file( + "foo.py", + """\ + class Foo(object): + def spaghetti(self, a, b): + _|_x = a + 5 + y = b + 23 + return y + """) + + def test_should_refactor_local(self): + ref = refactor.Refactor(self.project_root, self.filename) + (change,) = ref.refactor_extract_method(self.offset, 104, + "calc", False) + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], self.filename) + expected = """\ + class Foo(object): + def spaghetti(self, a, b): + return self.calc(a, b) + + def calc(self, a, b): + x = a + 5 + y = b + 23 + return y + """ + expected2 = expected.replace("return self.calc(a, b)", + "return self.calc(b, a)") + expected2 = expected2.replace("def calc(self, a, b)", + "def calc(self, b, a)") + # This is silly, but it's what we got. + if change['contents'] == dedent(expected2): + self.assertSourceEqual(change['contents'], expected2) + else: + self.assertSourceEqual(change['contents'], expected) + + def test_should_refactor_global(self): + ref = refactor.Refactor(self.project_root, self.filename) + (change,) = ref.refactor_extract_method(self.offset, 104, + "calc", True) + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], self.filename) + expected = """\ + class Foo(object): + def spaghetti(self, a, b): + return calc(a, b) + + def calc(a, b): + x = a + 5 + y = b + 23 + return y + """ + expected2 = expected.replace("return calc(a, b)", + "return calc(b, a)") + expected2 = expected2.replace("def calc(a, b)", + "def calc(b, a)") + if change['contents'] == dedent(expected2): + self.assertSourceEqual(change['contents'], expected2) + else: + self.assertSourceEqual(change['contents'], expected) + + +@unittest.skipIf(not refactor.ROPE_AVAILABLE, "Requires Rope") +class TestUseFunction(RefactorTestCase): + def test_should_refactor(self): + filename, offset = self.create_file( + "foo.py", + """\ + def _|_add_and_multiply(a, b, c): + temp = a + b + return temp * c + + f = 1 + 2 + g = f * 3 + """) + + ref = refactor.Refactor(self.project_root, filename) + (change,) = ref.refactor_use_function(offset) + + self.assertEqual(change['action'], 'change') + self.assertEqual(change['file'], filename) + self.assertSourceEqual(change['contents'], + """\ + def add_and_multiply(a, b, c): + temp = a + b + return temp * c + + g = add_and_multiply(1, 2, 3) + """) diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_ropebackend.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_ropebackend.py new file mode 100644 index 0000000..e51c9c1 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_ropebackend.py @@ -0,0 +1,193 @@ +"""Tests for elpy.ropebackend.""" + +import os +import shutil +import tempfile + +import mock + +from elpy import ropebackend +from elpy import rpc +from elpy.tests import compat +from elpy.tests.support import BackendTestCase +from elpy.tests.support import RPCGetCompletionsTests +from elpy.tests.support import RPCGetCompletionDocstringTests +from elpy.tests.support import RPCGetCompletionLocationTests +from elpy.tests.support import RPCGetDefinitionTests +from elpy.tests.support import RPCGetCalltipTests +from elpy.tests.support import RPCGetDocstringTests + + +class RopeBackendTestCase(BackendTestCase): + def setUp(self): + super(RopeBackendTestCase, self).setUp() + self.backend = ropebackend.RopeBackend(self.project_root) + + +class ShouldCallValidateTest(object): + def test_should_call_validate(self): + with mock.patch.object(self.backend, 'validate') as validate: + self.rpc(None, "", 0) + + self.assertTrue(validate.called) + + +class TestInit(RopeBackendTestCase): + def test_should_have_rope_as_name(self): + self.assertEqual(self.backend.name, "rope") + + def test_should_patch_project_files(self): + self.project_file("foo.txt", "") + self.project_file("baddir/file.py", "") + + self.backend.project.validate() + + actual = [f.real_path for f in + self.backend.project.file_list.get_files()] + self.assertEqual([os.path.join(self.project_root, "foo.txt")], + actual) + + def test_should_fail_for_inexisting_project_root(self): + with self.assertRaises(rpc.Fault): + ropebackend.RopeBackend("/does/not/exist/") + + +class TestValidate(RopeBackendTestCase): + def test_should_call_validate_after_timeout(self): + with mock.patch("time.time") as t: + t.return_value = 10 + self.backend.validate() + with mock.patch.object(self.backend, 'project') as project: + t.return_value = 10 + ropebackend.VALIDATE_EVERY_SECONDS + 1 + self.backend.validate() + + self.assertTrue(project.validate.called) + + def test_should_not_call_validate_before_timeout(self): + with mock.patch("time.time") as t: + t.return_value = 10 + self.backend.validate() + with mock.patch.object(self.backend, 'project') as project: + t.return_value = 10 + ropebackend.VALIDATE_EVERY_SECONDS - 1 + self.backend.validate() + + self.assertFalse(project.validate.called) + + def test_should_not_fail_if_root_vanishes(self): + # Bug #353 + tmpdir = tempfile.mkdtemp(prefix="elpy-test-validate-") + try: + backend = ropebackend.RopeBackend(tmpdir) + finally: + shutil.rmtree(tmpdir) + backend.validate() + + +class TestRPCGetCompletions(RPCGetCompletionsTests, + RopeBackendTestCase): + pass + + +class TestRPCGetCompletionDocstring(RPCGetCompletionDocstringTests, + RopeBackendTestCase): + pass + + +class TestRPCGetCompletionLocation(RPCGetCompletionLocationTests, + RopeBackendTestCase): + pass + + +class TestRPCGetDefinition(RPCGetDefinitionTests, + ShouldCallValidateTest, + RopeBackendTestCase): + pass + + +class TestRPCGetCalltip(RPCGetCalltipTests, + ShouldCallValidateTest, + RopeBackendTestCase): + ADD_CALLTIP = 'Add.add(a, b)' + RADIX_CALLTIP = "Decimal.radix()" + if compat.PYTHON3: + THREAD_CALLTIP = ( + "threading.Thread(group=None, target=None, " + "name=None, args=(), kwargs=None, daemon=None, *)" + ) + KEYS_CALLTIP = "builtins.keys()" + else: + THREAD_CALLTIP = ( + "threading.Thread(group=None, target=None, " + "name=None, args=(), kwargs=None, verbose=None)" + ) + KEYS_CALLTIP = "__builtin__.keys()" + + +class TestRPCGetDocstring(RPCGetDocstringTests, + ShouldCallValidateTest, + RopeBackendTestCase): + THREAD_JOIN_DOCSTRING = 'Thread.join(self, timeout=None):' + + +class TestGetPythonProjectFiles(RopeBackendTestCase): + def test(self): + self.project_file("foo.txt", "") + self.project_file("gooddir/__init__.py", "") + self.project_file("gooddir/file.py", "") + self.project_file("baddir/file.py", "") + expected = set(os.path.join(self.project_root, name) + for name in ["foo.txt", "gooddir/__init__.py", + "gooddir/file.py"]) + project = self.backend.project + + actual = set(resource.real_path + for resource + in ropebackend.get_python_project_files(project)) + + self.assertEqual(expected, actual) + + +class TestPatchProjectFiles(RopeBackendTestCase): + def test(self): + self.project_file("foo.txt", "") + self.project_file("gooddir/__init__.py", "") + self.project_file("gooddir/file.py", "") + self.project_file("baddir/file.py", "") + expected = set(os.path.join(self.project_root, name) + for name in ["foo.txt", "gooddir/__init__.py", + "gooddir/file.py"]) + + actual = set(resource.real_path + for resource + in self.backend.project.get_files()) + self.assertEqual(expected, actual) + + +class TestCallRope(RopeBackendTestCase): + def test_should_return_value(self): + func = mock.MagicMock() + func.return_value = 23 + + actual = self.backend.call_rope( + func, "foo.py", "", 0 + ) + + self.assertEqual(23, actual) + + def test_should_raise_fault_with_data_on_exception(self): + func = mock.MagicMock() + func.side_effect = RuntimeError("Stuff!") + func.__module__ = "rope.test" + func.__name__ = "test_function" + + try: + self.backend.call_rope( + func, "foo.py", "", 0 + ) + except rpc.Fault as e: + self.assertEqual(500, e.code) + self.assertEqual("Stuff!", e.message) + self.assertIn("traceback", e.data) + self.assertIn("rope_debug_info", e.data) + self.assertEqual("rope.test.test_function", + e.data["rope_debug_info"]["function_name"]) diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_rpc.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_rpc.py new file mode 100644 index 0000000..0d35196 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_rpc.py @@ -0,0 +1,209 @@ +"""Tests for elpy.rpc.""" + +import json +import unittest +import sys + +from elpy import rpc +from elpy.tests.compat import StringIO + + +class TestFault(unittest.TestCase): + def test_should_have_code_and_data(self): + fault = rpc.Fault("Hello", code=250, data="Fnord") + self.assertEqual(str(fault), "Hello") + self.assertEqual(fault.code, 250) + self.assertEqual(fault.data, "Fnord") + + def test_should_have_defaults_for_code_and_data(self): + fault = rpc.Fault("Hello") + self.assertEqual(str(fault), "Hello") + self.assertEqual(fault.code, 500) + self.assertIsNone(fault.data) + + +class TestJSONRPCServer(unittest.TestCase): + def setUp(self): + self.stdin = StringIO() + self.stdout = StringIO() + self.rpc = rpc.JSONRPCServer(self.stdin, self.stdout) + + def write(self, s): + self.stdin.seek(0) + self.stdin.truncate() + self.stdout.seek(0) + self.stdout.truncate() + self.stdin.write(s) + self.stdin.seek(0) + + def read(self): + value = self.stdout.getvalue() + self.stdin.seek(0) + self.stdin.truncate() + self.stdout.seek(0) + self.stdout.truncate() + return value + + +class TestInit(TestJSONRPCServer): + def test_should_use_arguments(self): + self.assertEqual(self.rpc.stdin, self.stdin) + self.assertEqual(self.rpc.stdout, self.stdout) + + def test_should_default_to_sys(self): + testrpc = rpc.JSONRPCServer() + self.assertEqual(sys.stdin, testrpc.stdin) + self.assertEqual(sys.stdout, testrpc.stdout) + + +class TestReadJson(TestJSONRPCServer): + def test_should_read_json(self): + objlist = [{'foo': 'bar'}, + {'baz': 'qux', 'fnord': 'argl\nbargl'}, + "beep\r\nbeep\r\nbeep"] + self.write("".join([(json.dumps(obj) + "\n") + for obj in objlist])) + for obj in objlist: + self.assertEqual(self.rpc.read_json(), + obj) + + def test_should_raise_eof_on_eof(self): + self.assertRaises(EOFError, self.rpc.read_json) + + def test_should_fail_on_malformed_json(self): + self.write("malformed json\n") + self.assertRaises(ValueError, + self.rpc.read_json) + + +class TestWriteJson(TestJSONRPCServer): + def test_should_write_json_line(self): + objlist = [{'foo': 'bar'}, + {'baz': 'qux', 'fnord': 'argl\nbargl'}, + ] + for obj in objlist: + self.rpc.write_json(**obj) + self.assertEqual(json.loads(self.read()), + obj) + + +class TestHandleRequest(TestJSONRPCServer): + def test_should_fail_if_json_does_not_contain_a_method(self): + self.write(json.dumps(dict(params=[], + id=23))) + self.assertRaises(ValueError, + self.rpc.handle_request) + + def test_should_call_right_method(self): + self.write(json.dumps(dict(method='foo', + params=[1, 2, 3], + id=23))) + self.rpc.rpc_foo = lambda *params: params + self.rpc.handle_request() + self.assertEqual(json.loads(self.read()), + dict(id=23, + result=[1, 2, 3])) + + def test_should_pass_defaults_for_missing_parameters(self): + def test_method(*params): + self.args = params + + self.write(json.dumps(dict(method='foo'))) + self.rpc.rpc_foo = test_method + self.rpc.handle_request() + self.assertEqual(self.args, ()) + self.assertEqual(self.read(), "") + + def test_should_return_error_for_missing_method(self): + self.write(json.dumps(dict(method='foo', + id=23))) + self.rpc.handle_request() + result = json.loads(self.read()) + + self.assertEqual(result["id"], 23) + self.assertEqual(result["error"]["message"], + "Unknown method foo") + + def test_should_return_error_for_exception_in_method(self): + def test_method(): + raise ValueError("An error was raised") + + self.write(json.dumps(dict(method='foo', + id=23))) + self.rpc.rpc_foo = test_method + + self.rpc.handle_request() + result = json.loads(self.read()) + + self.assertEqual(result["id"], 23) + self.assertEqual(result["error"]["message"], "An error was raised") + self.assertIn("traceback", result["error"]["data"]) + + def test_should_not_include_traceback_for_faults(self): + def test_method(): + raise rpc.Fault("This is a fault") + + self.write(json.dumps(dict(method="foo", + id=23))) + self.rpc.rpc_foo = test_method + + self.rpc.handle_request() + result = json.loads(self.read()) + + self.assertEqual(result["id"], 23) + self.assertEqual(result["error"]["message"], "This is a fault") + self.assertNotIn("traceback", result["error"]) + + def test_should_add_data_for_faults(self): + def test_method(): + raise rpc.Fault("St. Andreas' Fault", + code=12345, data="Yippieh") + + self.write(json.dumps(dict(method="foo", id=23))) + self.rpc.rpc_foo = test_method + + self.rpc.handle_request() + result = json.loads(self.read()) + + self.assertEqual(result["error"]["data"], "Yippieh") + + def test_should_call_handle_for_unknown_method(self): + def test_handle(method_name, args): + return "It works" + self.write(json.dumps(dict(method="doesnotexist", + id=23))) + self.rpc.handle = test_handle + self.rpc.handle_request() + self.assertEqual(json.loads(self.read()), + dict(id=23, + result="It works")) + + +class TestServeForever(TestJSONRPCServer): + def handle_request(self): + self.hr_called += 1 + if self.hr_called > 10: + raise self.error() + + def setUp(self): + super(TestServeForever, self).setUp() + self.hr_called = 0 + self.error = KeyboardInterrupt + self.rpc.handle_request = self.handle_request + + def test_should_call_handle_request_repeatedly(self): + self.rpc.serve_forever() + self.assertEqual(self.hr_called, 11) + + def test_should_return_on_some_errors(self): + self.error = KeyboardInterrupt + self.rpc.serve_forever() + self.error = EOFError + self.rpc.serve_forever() + self.error = SystemExit + self.rpc.serve_forever() + + def test_should_fail_on_most_errors(self): + self.error = RuntimeError + self.assertRaises(RuntimeError, + self.rpc.serve_forever) diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_server.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_server.py new file mode 100644 index 0000000..ecc9c16 --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_server.py @@ -0,0 +1,413 @@ +# coding: utf-8 + +"""Tests for the elpy.server module""" + +import os +import tempfile +import unittest + +import mock + +from elpy import rpc +from elpy import server +from elpy.tests import compat +from elpy.tests.support import BackendTestCase +import elpy.refactor + + +class ServerTestCase(unittest.TestCase): + def setUp(self): + self.srv = server.ElpyRPCServer() + + +class BackendCallTestCase(ServerTestCase): + def assert_calls_backend(self, method): + with mock.patch("elpy.server.get_source") as get_source: + with mock.patch.object(self.srv, "backend") as backend: + get_source.return_value = "transformed source" + + getattr(self.srv, method)("filename", "source", "offset") + + get_source.assert_called_with("source") + getattr(backend, method).assert_called_with( + "filename", "transformed source", "offset" + ) + + +class TestInit(ServerTestCase): + def test_should_not_select_a_backend_by_default(self): + self.assertIsNone(self.srv.backend) + + +class TestRPCEcho(ServerTestCase): + def test_should_return_arguments(self): + self.assertEqual(("hello", "world"), + self.srv.rpc_echo("hello", "world")) + + +class TestRPCInit(ServerTestCase): + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_set_project_root(self, RopeBackend, JediBackend): + self.srv.rpc_init({"project_root": "/project/root", + "backend": "rope"}) + + self.assertEqual("/project/root", self.srv.project_root) + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_initialize_rope(self, RopeBackend, JediBackend): + self.srv.rpc_init({"project_root": "/project/root", + "backend": "rope"}) + + RopeBackend.assert_called_with("/project/root") + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_initialize_jedi(self, RopeBackend, JediBackend): + self.srv.rpc_init({"project_root": "/project/root", + "backend": "jedi"}) + + JediBackend.assert_called_with("/project/root") + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_use_rope_if_available_and_requested( + self, RopeBackend, JediBackend): + RopeBackend.return_value.name = "rope" + JediBackend.return_value.name = "jedi" + + self.srv.rpc_init({"project_root": "/project/root", + "backend": "rope"}) + + self.assertEqual("rope", self.srv.backend.name) + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_use_jedi_if_available_and_requested( + self, RopeBackend, JediBackend): + RopeBackend.return_value.name = "rope" + JediBackend.return_value.name = "jedi" + + self.srv.rpc_init({"project_root": "/project/root", + "backend": "jedi"}) + + self.assertEqual("jedi", self.srv.backend.name) + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_use_rope_if_available_and_nothing_requested( + self, RopeBackend, JediBackend): + RopeBackend.return_value.name = "rope" + JediBackend.return_value.name = "jedi" + + self.srv.rpc_init({"project_root": "/project/root", + "backend": None}) + + self.assertEqual("rope", self.srv.backend.name) + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_use_jedi_if_rope_not_available_and_nothing_requested( + self, RopeBackend, JediBackend): + RopeBackend.return_value.name = "rope" + JediBackend.return_value.name = "jedi" + old_rope = server.ropebackend + server.ropebackend = None + + try: + self.srv.rpc_init({"project_root": "/project/root", + "backend": None}) + finally: + server.ropebackend = old_rope + + self.assertEqual("jedi", self.srv.backend.name) + + @mock.patch("elpy.jedibackend.JediBackend") + @mock.patch("elpy.ropebackend.RopeBackend") + def test_should_use_none_if_nothing_available( + self, RopeBackend, JediBackend): + RopeBackend.return_value.name = "rope" + JediBackend.return_value.name = "jedi" + old_rope = server.ropebackend + old_jedi = server.jedibackend + server.ropebackend = None + server.jedibackend = None + + try: + self.srv.rpc_init({"project_root": "/project/root", + "backend": None}) + finally: + server.ropebackend = old_rope + server.jedibackend = old_jedi + + self.assertIsNone(self.srv.backend) + + +class TestRPCGetCalltip(BackendCallTestCase): + def test_should_call_backend(self): + self.assert_calls_backend("rpc_get_calltip") + + def test_should_handle_no_backend(self): + self.srv.backend = None + self.assertIsNone(self.srv.rpc_get_calltip("filname", "source", + "offset")) + + +class TestRPCGetCompletions(BackendCallTestCase): + def test_should_call_backend(self): + self.assert_calls_backend("rpc_get_completions") + + def test_should_handle_no_backend(self): + self.srv.backend = None + self.assertEqual([], + self.srv.rpc_get_completions("filname", "source", + "offset")) + + def test_should_sort_results(self): + with mock.patch.object(self.srv, 'backend') as backend: + backend.rpc_get_completions.return_value = [ + {'name': '_e'}, + {'name': '__d'}, + {'name': 'c'}, + {'name': 'B'}, + {'name': 'a'}, + ] + expected = list(reversed(backend.rpc_get_completions.return_value)) + + actual = self.srv.rpc_get_completions("filename", "source", + "offset") + + self.assertEqual(expected, actual) + + def test_should_uniquify_results(self): + with mock.patch.object(self.srv, 'backend') as backend: + backend.rpc_get_completions.return_value = [ + {'name': 'a'}, + {'name': 'a'}, + ] + expected = [{'name': 'a'}] + + actual = self.srv.rpc_get_completions("filename", "source", + "offset") + + self.assertEqual(expected, actual) + + +class TestRPCGetCompletionDocs(ServerTestCase): + def test_should_call_backend(self): + with mock.patch.object(self.srv, "backend") as backend: + self.srv.rpc_get_completion_docstring("completion") + + (backend.rpc_get_completion_docstring + .assert_called_with("completion")) + + def test_should_handle_no_backend(self): + self.srv.backend = None + self.assertIsNone(self.srv.rpc_get_completion_docstring("foo")) + + +class TestRPCGetCompletionLocation(ServerTestCase): + def test_should_call_backend(self): + with mock.patch.object(self.srv, "backend") as backend: + self.srv.rpc_get_completion_location("completion") + + (backend.rpc_get_completion_location + .assert_called_with("completion")) + + def test_should_handle_no_backend(self): + self.srv.backend = None + self.assertIsNone(self.srv.rpc_get_completion_location("foo")) + + +class TestRPCGetDefinition(BackendCallTestCase): + def test_should_call_backend(self): + self.assert_calls_backend("rpc_get_definition") + + def test_should_handle_no_backend(self): + self.srv.backend = None + self.assertIsNone(self.srv.rpc_get_definition("filname", "source", + "offset")) + + +class TestRPCGetDocstring(BackendCallTestCase): + def test_should_call_backend(self): + self.assert_calls_backend("rpc_get_docstring") + + def test_should_handle_no_backend(self): + self.srv.backend = None + self.assertIsNone(self.srv.rpc_get_docstring("filname", "source", + "offset")) + + +class TestRPCGetPydocCompletions(ServerTestCase): + @mock.patch.object(server, 'get_pydoc_completions') + def test_should_call_pydoc_completions(self, get_pydoc_completions): + srv = server.ElpyRPCServer() + srv.rpc_get_pydoc_completions() + get_pydoc_completions.assert_called_with(None) + srv.rpc_get_pydoc_completions("foo") + get_pydoc_completions.assert_called_with("foo") + + +class TestGetPydocDocumentation(ServerTestCase): + @mock.patch("pydoc.render_doc") + def test_should_find_documentation(self, render_doc): + render_doc.return_value = "expected" + + actual = self.srv.rpc_get_pydoc_documentation("open") + + render_doc.assert_called_with("open", + "Elpy Pydoc Documentation for %s", + False) + self.assertEqual("expected", actual) + + def test_should_return_none_for_unknown_module(self): + actual = self.srv.rpc_get_pydoc_documentation("frob.open") + + self.assertIsNone(actual) + + def test_should_return_valid_unicode(self): + import json + + docstring = self.srv.rpc_get_pydoc_documentation("tarfile") + + json.dumps(docstring) + + +class TestRPCGetRefactorOptions(BackendTestCase): + @mock.patch.object(compat.builtins, '__import__') + def test_should_fail_if_rope_is_not_available(self, import_): + import_.side_effect = ImportError + filename = self.project_file("foo.py", "") + srv = server.ElpyRPCServer() + self.assertRaises(ImportError, srv.rpc_get_refactor_options, + filename, 0) + + @mock.patch.object(elpy.refactor, 'Refactor') + def test_should_initialize_and_call_refactor_object(self, Refactor): + filename = self.project_file("foo.py", "import foo") + srv = server.ElpyRPCServer() + srv.project_root = self.project_root + + srv.rpc_get_refactor_options(filename, 5) + + Refactor.assert_called_with(self.project_root, filename) + Refactor.return_value.get_refactor_options.assert_called_with(5, None) + + +class TestRPCRefactor(BackendTestCase): + @mock.patch.object(compat.builtins, '__import__') + def test_should_fail_if_rope_is_not_available(self, import_): + import_.side_effect = ImportError + filename = self.project_file("foo.py", "") + srv = server.ElpyRPCServer() + self.assertRaises(ImportError, srv.rpc_refactor, + filename, 'foo', ()) + + @mock.patch.object(elpy.refactor, 'Refactor') + def test_should_initialize_and_call_refactor_object_with_args( + self, Refactor): + filename = self.project_file("foo.py", "import foo") + srv = server.ElpyRPCServer() + srv.project_root = self.project_root + + srv.rpc_refactor(filename, 'foo', (1, 2, 3)) + + Refactor.assert_called_with(self.project_root, filename) + Refactor.return_value.get_changes.assert_called_with('foo', 1, 2, 3) + + @mock.patch.object(elpy.refactor, 'Refactor') + def test_should_initialize_and_call_refactor_object_without_args( + self, Refactor): + filename = self.project_file("foo.py", "import foo") + srv = server.ElpyRPCServer() + srv.project_root = self.project_root + + srv.rpc_refactor(filename, 'foo', None) + + Refactor.assert_called_with(self.project_root, filename) + Refactor.return_value.get_changes.assert_called_with('foo') + + +class TestRPCGetUsages(BackendCallTestCase): + def test_should_call_backend(self): + self.assert_calls_backend("rpc_get_usages") + + def test_should_handle_no_backend(self): + self.srv.backend = None + with self.assertRaises(rpc.Fault): + self.assertIsNone(self.srv.rpc_get_usages("filname", "source", + "offset")) + + +class TestRPCImportMagic(ServerTestCase): + def test_should_call_importmagic(self): + with mock.patch.object(self.srv, "import_magic") as impmagic: + self.srv.rpc_get_import_symbols("filename", "source", "os") + impmagic.get_import_symbols.assert_called_with("os") + self.srv.rpc_add_import("filename", "source", "import os") + impmagic.add_import.assert_called_with("source", "import os") + self.srv.rpc_get_unresolved_symbols("filename", "source") + impmagic.get_unresolved_symbols.assert_called_with("source") + self.srv.rpc_remove_unreferenced_imports("filename", "source") + impmagic.remove_unreferenced_imports.assert_called_with("source") + + +class TestGetSource(unittest.TestCase): + def test_should_return_string_by_default(self): + self.assertEqual(server.get_source("foo"), + "foo") + + def test_should_return_file_contents(self): + fd, filename = tempfile.mkstemp(prefix="elpy-test-") + self.addCleanup(os.remove, filename) + with open(filename, "w") as f: + f.write("file contents") + + fileobj = {'filename': filename} + + self.assertEqual(server.get_source(fileobj), + "file contents") + + def test_should_clean_up_tempfile(self): + fd, filename = tempfile.mkstemp(prefix="elpy-test-") + with open(filename, "w") as f: + f.write("file contents") + + fileobj = {'filename': filename, + 'delete_after_use': True} + + self.assertEqual(server.get_source(fileobj), + "file contents") + self.assertFalse(os.path.exists(filename)) + + def test_should_support_utf8(self): + fd, filename = tempfile.mkstemp(prefix="elpy-test-") + self.addCleanup(os.remove, filename) + with open(filename, "wb") as f: + f.write(u"möp".encode("utf-8")) + + source = server.get_source({'filename': filename}) + + self.assertEqual(source, u"möp") + + +class TestPysymbolKey(BackendTestCase): + def keyLess(self, a, b): + self.assertLess(b, a) + self.assertLess(server._pysymbol_key(a), + server._pysymbol_key(b)) + + def test_should_be_case_insensitive(self): + self.keyLess("bar", "Foo") + + def test_should_sort_private_symbols_after_public_symbols(self): + self.keyLess("foo", "_bar") + + def test_should_sort_private_symbols_after_dunder_symbols(self): + self.assertLess(server._pysymbol_key("__foo__"), + server._pysymbol_key("_bar")) + + def test_should_sort_dunder_symbols_after_public_symbols(self): + self.keyLess("bar", "__foo") diff --git a/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_support.py b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_support.py new file mode 100644 index 0000000..0ed1d6d --- /dev/null +++ b/emacs.d/elpa/elpy-20150502.740/elpy/tests/test_support.py @@ -0,0 +1,19 @@ +"""Tests for elpy.tests.support. Yep, we test test code.""" + +import unittest + +from elpy.tests.support import source_and_offset + + +class TestSourceAndOffset(unittest.TestCase): + def test_should_return_source_and_offset(self): + self.assertEqual(source_and_offset("hello, _|_world"), + ("hello, world", 7)) + + def test_should_handle_beginning_of_string(self): + self.assertEqual(source_and_offset("_|_hello, world"), + ("hello, world", 0)) + + def test_should_handle_end_of_string(self): + self.assertEqual(source_and_offset("hello, world_|_"), + ("hello, world", 12)) diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/.yas-setup.el b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/.yas-setup.el similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/.yas-setup.el rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/.yas-setup.el diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__abs__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__abs__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__abs__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__abs__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__add__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__add__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__add__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__add__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__and__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__and__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__and__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__and__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__bool__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__bool__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__bool__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__bool__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__call__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__call__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__call__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__call__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__cmp__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__cmp__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__cmp__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__cmp__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__coerce__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__coerce__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__coerce__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__coerce__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__complex__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__complex__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__complex__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__complex__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__contains__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__contains__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__contains__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__contains__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__del__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__del__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__del__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__del__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__delattr__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__delattr__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__delattr__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__delattr__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__delete__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__delete__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__delete__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__delete__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__delitem__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__delitem__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__delitem__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__delitem__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__div__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__div__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__div__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__div__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__divmod__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__divmod__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__divmod__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__divmod__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__enter__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__enter__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__enter__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__enter__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__eq__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__eq__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__eq__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__eq__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__exit__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__exit__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__exit__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__exit__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__float__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__float__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__float__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__float__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__floordiv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__floordiv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__floordiv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__floordiv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ge__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ge__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ge__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ge__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__get__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__get__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__get__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__get__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__getattr__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__getattr__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__getattr__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__getattr__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__getattribute__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__getattribute__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__getattribute__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__getattribute__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__getitem__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__getitem__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__getitem__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__getitem__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__gt__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__gt__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__gt__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__gt__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__hash__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__hash__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__hash__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__hash__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__hex__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__hex__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__hex__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__hex__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__iadd__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__iadd__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__iadd__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__iadd__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__iand__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__iand__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__iand__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__iand__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__idiv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__idiv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__idiv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__idiv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ifloordiv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ifloordiv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ifloordiv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ifloordiv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ilshift__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ilshift__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ilshift__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ilshift__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__imod__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__imod__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__imod__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__imod__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__imul__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__imul__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__imul__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__imul__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__index__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__index__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__index__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__index__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__init__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__init__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__init__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__init__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__instancecheck__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__instancecheck__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__instancecheck__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__instancecheck__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__int__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__int__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__int__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__int__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__invert__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__invert__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__invert__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__invert__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ior__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ior__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ior__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ior__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ipow__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ipow__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ipow__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ipow__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__irshift__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__irshift__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__irshift__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__irshift__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__isub__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__isub__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__isub__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__isub__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__iter__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__iter__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__iter__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__iter__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__itruediv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__itruediv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__itruediv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__itruediv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ixor__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ixor__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ixor__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ixor__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__le__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__le__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__le__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__le__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__len__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__len__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__len__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__len__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__long__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__long__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__long__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__long__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__lshift__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__lshift__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__lshift__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__lshift__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__lt__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__lt__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__lt__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__lt__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__mod__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__mod__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__mod__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__mod__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__mul__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__mul__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__mul__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__mul__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ne__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ne__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ne__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ne__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__neg__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__neg__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__neg__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__neg__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__new__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__new__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__new__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__new__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__nonzero__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__nonzero__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__nonzero__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__nonzero__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__oct__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__oct__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__oct__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__oct__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__or__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__or__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__or__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__or__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__pos__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__pos__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__pos__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__pos__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__pow__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__pow__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__pow__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__pow__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__radd__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__radd__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__radd__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__radd__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rand__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rand__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rand__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rand__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rdivmod__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rdivmod__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rdivmod__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rdivmod__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__repr__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__repr__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__repr__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__repr__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__reversed__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__reversed__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__reversed__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__reversed__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rfloordiv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rfloordiv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rfloordiv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rfloordiv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rlshift__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rlshift__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rlshift__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rlshift__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rmod__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rmod__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rmod__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rmod__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rmul__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rmul__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rmul__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rmul__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ror__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ror__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__ror__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__ror__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rpow__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rpow__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rpow__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rpow__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rrshift__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rrshift__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rrshift__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rrshift__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rshift__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rshift__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rshift__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rshift__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rsub__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rsub__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rsub__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rsub__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rtruediv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rtruediv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rtruediv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rtruediv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rxor__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rxor__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__rxor__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__rxor__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__set__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__set__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__set__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__set__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__setattr__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__setattr__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__setattr__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__setattr__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__setitem__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__setitem__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__setitem__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__setitem__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__slots__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__slots__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__slots__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__slots__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__str__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__str__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__str__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__str__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__sub__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__sub__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__sub__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__sub__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__subclasscheck__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__subclasscheck__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__subclasscheck__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__subclasscheck__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__truediv__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__truediv__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__truediv__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__truediv__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__unicode__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__unicode__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__unicode__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__unicode__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__xor__ b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__xor__ similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/__xor__ rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/__xor__ diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/ase b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/ase similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/ase rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/ase diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/asne b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/asne similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/asne rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/asne diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/asr b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/asr similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/asr rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/asr diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/class b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/class similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/class rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/class diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/defs b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/defs similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/defs rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/defs diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/enc b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/enc similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/enc rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/enc diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/env b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/env similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/env rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/env diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/from b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/from similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/from rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/from diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/pdb b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/pdb similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/pdb rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/pdb diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/py3 b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/py3 similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/py3 rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/py3 diff --git a/emacs.d/elpa/elpy-1.7.1/snippets/python-mode/super b/emacs.d/elpa/elpy-20150502.740/snippets/python-mode/super similarity index 100% rename from emacs.d/elpa/elpy-1.7.1/snippets/python-mode/super rename to emacs.d/elpa/elpy-20150502.740/snippets/python-mode/super diff --git a/emacs.d/elpa/epl-20140823.609/epl-autoloads.el b/emacs.d/elpa/epl-20140823.609/epl-autoloads.el deleted file mode 100644 index 65ff813..0000000 --- a/emacs.d/elpa/epl-20140823.609/epl-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; epl-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("epl.el") (21570 23222 569606 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; epl-autoloads.el ends here diff --git a/emacs.d/elpa/epl-20140823.609/epl-pkg.el b/emacs.d/elpa/epl-20140823.609/epl-pkg.el deleted file mode 100644 index 9f748ca..0000000 --- a/emacs.d/elpa/epl-20140823.609/epl-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "epl" "20140823.609" "Emacs Package Library" '((cl-lib "0.3")) :url "http://github.com/cask/epl" :keywords '("convenience")) diff --git a/emacs.d/elpa/epl-20140823.609/epl.el b/emacs.d/elpa/epl-20140823.609/epl.el deleted file mode 100644 index c1f2d1e..0000000 --- a/emacs.d/elpa/epl-20140823.609/epl.el +++ /dev/null @@ -1,651 +0,0 @@ -;;; epl.el --- Emacs Package Library -*- lexical-binding: t; -*- - -;; Copyright (C) 2013, 2014 Sebastian Wiesner - -;; Author: Sebastian Wiesner -;; Maintainer: Johan Andersson -;; Sebastian Wiesner -;; Version: 20140823.609 -;; X-Original-Version: 0.7-cvs -;; Package-Requires: ((cl-lib "0.3")) -;; Keywords: convenience -;; URL: http://github.com/cask/epl - -;; This file is NOT part of GNU Emacs. - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; A package management library for Emacs, based on package.el. - -;; The purpose of this library is to wrap all the quirks and hassle of -;; package.el into a sane API. - -;; The following functions comprise the public interface of this library: - -;;; Package directory selection - -;; `epl-package-dir' gets the directory of packages. - -;; `epl-default-package-dir' gets the default package directory. - -;; `epl-change-package-dir' changes the directory of packages. - -;;; Package system management - -;; `epl-initialize' initializes the package system and activates all -;; packages. - -;; `epl-reset' resets the package system. - -;; `epl-refresh' refreshes all package archives. - -;; `epl-add-archive' adds a new package archive. - -;;; Package objects - -;; Struct `epl-requirement' describes a requirement of a package with `name' and -;; `version' slots. - -;; `epl-requirement-version-string' gets a requirement version as string. - -;; Struct `epl-package' describes an installed or installable package with a -;; `name' and some internal `description'. - -;; `epl-package-version' gets the version of a package. - -;; `epl-package-version-string' gets the version of a package as string. - -;; `epl-package-summary' gets the summary of a package. - -;; `epl-package-requirements' gets the requirements of a package. - -;; `epl-package-directory' gets the installation directory of a package. - -;; `epl-package-from-buffer' creates a package object for the package contained -;; in the current buffer. - -;; `epl-package-from-file' creates a package object for a package file, either -;; plain lisp or tarball. - -;; `epl-package-from-descriptor-file' creates a package object for a package -;; description (i.e. *-pkg.el) file. - -;;; Package database access - -;; `epl-package-installed-p' determines whether a package is installed, either -;; built-in or explicitly installed. - -;; `epl-package-outdated-p' determines whether a package is outdated, that is, -;; whether a package with a higher version number is available. - -;; `epl-built-in-packages', `epl-installed-packages', `epl-outdated-packages' -;; and `epl-available-packages' get all packages built-in, installed, outdated, -;; or available for installation respectively. - -;; `epl-find-built-in-package', `epl-find-installed-packages' and -;; `epl-find-available-packages' find built-in, installed and available packages -;; by name. - -;; `epl-find-upgrades' finds all upgradable packages. - -;; `epl-built-in-p' return true if package is built-in to Emacs. - -;;; Package operations - -;; `epl-install-file' installs a package file. - -;; `epl-package-install' installs a package. - -;; `epl-package-delete' deletes a package. - -;; `epl-upgrade' upgrades packages. - -;;; Code: - -(require 'cl-lib) -(require 'package) - -(defsubst epl--package-desc-p (package) - "Whether PACKAGE is a `package-desc' object. - -Like `package-desc-p', but return nil, if `package-desc-p' is not -defined as function." - (and (fboundp 'package-desc-p) (package-desc-p package))) - - -;;; Package directory -(defun epl-package-dir () - "Get the directory of packages." - package-user-dir) - -(defun epl-default-package-dir () - "Get the default directory of packages." - (eval (car (get 'package-user-dir 'standard-value)))) - -(defun epl-change-package-dir (directory) - "Change the directory of packages to DIRECTORY." - (setq package-user-dir directory) - (epl-initialize)) - - -;;; Package system management -(defvar epl--load-path-before-initialize nil - "Remember the load path for `epl-reset'.") - -(defun epl-initialize (&optional no-activate) - "Load Emacs Lisp packages and activate them. - -With NO-ACTIVATE non-nil, do not activate packages." - (setq epl--load-path-before-initialize load-path) - (package-initialize no-activate)) - -(defalias 'epl-refresh 'package-refresh-contents) - -(defun epl-add-archive (name url) - "Add a package archive with NAME and URL." - (add-to-list 'package-archives (cons name url))) - -(defun epl-reset () - "Reset the package system. - -Clear the list of installed and available packages, the list of -package archives and reset the package directory." - (setq package-alist nil - package-archives nil - package-archive-contents nil - load-path epl--load-path-before-initialize) - (when (boundp 'package-obsolete-alist) ; Legacy package.el - (setq package-obsolete-alist nil)) - (epl-change-package-dir (epl-default-package-dir))) - - -;;; Package structures -(cl-defstruct (epl-requirement - (:constructor epl-requirement-create)) - "Structure describing a requirement. - -Slots: - -`name' The name of the required package, as symbol. - -`version' The version of the required package, as version list." - name - version) - -(defun epl-requirement-version-string (requirement) - "The version of a REQUIREMENT, as string." - (package-version-join (epl-requirement-version requirement))) - -(cl-defstruct (epl-package (:constructor epl-package-create)) - "Structure representing a package. - -Slots: - -`name' The package name, as symbol. - -`description' The package description. - -The format package description varies between package.el -variants. For `package-desc' variants, it is simply the -corresponding `package-desc' object. For legacy variants, it is -a vector `[VERSION REQS DOCSTRING]'. - -Do not access `description' directly, but instead use the -`epl-package' accessors." - name - description) - -(defmacro epl-package-as-description (var &rest body) - "Cast VAR to a package description in BODY. - -VAR is a symbol, bound to an `epl-package' object. This macro -casts this object to the `description' object, and binds the -description to VAR in BODY." - (declare (indent 1)) - (unless (symbolp var) - (signal 'wrong-type-argument (list #'symbolp var))) - `(if (epl-package-p ,var) - (let ((,var (epl-package-description ,var))) - ,@body) - (signal 'wrong-type-argument (list #'epl-package-p ,var)))) - -(defsubst epl-package--package-desc-p (package) - "Whether the description of PACKAGE is a `package-desc'." - (epl--package-desc-p (epl-package-description package))) - -(defun epl-package-version (package) - "Get the version of PACKAGE, as version list." - (epl-package-as-description package - (cond - ((fboundp 'package-desc-version) (package-desc-version package)) - ;; Legacy - ((fboundp 'package-desc-vers) - (let ((version (package-desc-vers package))) - (if (listp version) version (version-to-list version)))) - (:else (error "Cannot get version from %S" package))))) - -(defun epl-package-version-string (package) - "Get the version from a PACKAGE, as string." - (package-version-join (epl-package-version package))) - -(defun epl-package-summary (package) - "Get the summary of PACKAGE, as string." - (epl-package-as-description package - (cond - ((fboundp 'package-desc-summary) (package-desc-summary package)) - ((fboundp 'package-desc-doc) (package-desc-doc package)) ; Legacy - (:else (error "Cannot get summary from %S" package))))) - -(defsubst epl-requirement--from-req (req) - "Create a `epl-requirement' from a `package-desc' REQ." - (let ((version (cadr req))) - (epl-requirement-create :name (car req) - :version (if (listp version) version - (version-to-list version))))) - -(defun epl-package-requirements (package) - "Get the requirements of PACKAGE. - -The requirements are a list of `epl-requirement' objects." - (epl-package-as-description package - (mapcar #'epl-requirement--from-req (package-desc-reqs package)))) - -(defun epl-package-directory (package) - "Get the directory PACKAGE is installed to. - -Return the absolute path of the installation directory of -PACKAGE, or nil, if PACKAGE is not installed." - (cond - ((fboundp 'package-desc-dir) - (package-desc-dir (epl-package-description package))) - ((fboundp 'package--dir) - (package--dir (symbol-name (epl-package-name package)) - (epl-package-version-string package))) - (:else (error "Cannot get package directory from %S" package)))) - -(defun epl-package-->= (pkg1 pkg2) - "Determine whether PKG1 is before PKG2 by version." - (not (version-list-< (epl-package-version pkg1) - (epl-package-version pkg2)))) - -(defun epl-package--from-package-desc (package-desc) - "Create an `epl-package' from a PACKAGE-DESC. - -PACKAGE-DESC is a `package-desc' object, from recent package.el -variants." - (if (and (fboundp 'package-desc-name) - (epl--package-desc-p package-desc)) - (epl-package-create :name (package-desc-name package-desc) - :description package-desc) - (signal 'wrong-type-argument (list 'epl--package-desc-p package-desc)))) - -(defun epl-package--parse-info (info) - "Parse a package.el INFO." - (if (epl--package-desc-p info) - (epl-package--from-package-desc info) - ;; For legacy package.el, info is a vector [NAME REQUIRES DESCRIPTION - ;; VERSION COMMENTARY]. We need to re-shape this vector into the - ;; `package-alist' format [VERSION REQUIRES DESCRIPTION] to attach it to the - ;; new `epl-package'. - (let ((name (intern (aref info 0))) - (info (vector (aref info 3) (aref info 1) (aref info 2)))) - (epl-package-create :name name :description info)))) - -(defun epl-package-from-buffer (&optional buffer) - "Create an `epl-package' object from BUFFER. - -BUFFER defaults to the current buffer." - (let ((info (with-current-buffer (or buffer (current-buffer)) - (package-buffer-info)))) - (epl-package--parse-info info))) - -(defun epl-package-from-lisp-file (file-name) - "Parse the package headers the file at FILE-NAME. - -Return an `epl-package' object with the header metadata." - (with-temp-buffer - (insert-file-contents file-name) - (epl-package-from-buffer (current-buffer)))) - -(defun epl-package-from-tar-file (file-name) - "Parse the package tarball at FILE-NAME. - -Return a `epl-package' object with the meta data of the tarball -package in FILE-NAME." - (condition-case nil - ;; In legacy package.el, `package-tar-file-info' takes the name of the tar - ;; file to parse as argument. In modern package.el, it has no arguments - ;; and works on the current buffer. Hence, we just try to call the legacy - ;; version, and if that fails because of a mismatch between formal and - ;; actual arguments, we use the modern approach. To avoid spurious - ;; signature warnings by the byte compiler, we suppress warnings when - ;; calling the function. - (epl-package--parse-info (with-no-warnings - (package-tar-file-info file-name))) - (wrong-number-of-arguments - (with-temp-buffer - (insert-file-contents-literally file-name) - ;; Switch to `tar-mode' to enable extraction of the file. Modern - ;; `package-tar-file-info' relies on `tar-mode', and signals an error if - ;; called in a buffer with a different mode. - (tar-mode) - (epl-package--parse-info (with-no-warnings - (package-tar-file-info))))))) - -(defun epl-package-from-file (file-name) - "Parse the package at FILE-NAME. - -Return an `epl-package' object with the meta data of the package -at FILE-NAME." - (if (string-match-p (rx ".tar" string-end) file-name) - (epl-package-from-tar-file file-name) - (epl-package-from-lisp-file file-name))) - -(defun epl-package--parse-descriptor-requirement (requirement) - "Parse a REQUIREMENT in a package descriptor." - ;; This function is only called on legacy package.el. On package-desc - ;; package.el, we just let package.el do the work. - (cl-destructuring-bind (name version-string) requirement - (list name (version-to-list version-string)))) - -(defun epl-package-from-descriptor-file (descriptor-file) - "Load a `epl-package' from a package DESCRIPTOR-FILE. - -A package descriptor is a file defining a new package. Its name -typically ends with -pkg.el." - (with-temp-buffer - (insert-file-contents descriptor-file) - (goto-char (point-min)) - (let ((sexp (read (current-buffer)))) - (unless (eq (car sexp) 'define-package) - (error "%S is no valid package descriptor" descriptor-file)) - (if (and (fboundp 'package-desc-from-define) - (fboundp 'package-desc-name)) - ;; In Emacs snapshot, we can conveniently call a function to parse the - ;; descriptor - (let ((desc (apply #'package-desc-from-define (cdr sexp)))) - (epl-package-create :name (package-desc-name desc) - :description desc)) - ;; In legacy package.el, we must manually deconstruct the descriptor, - ;; because the load function has eval's the descriptor and has a lot of - ;; global side-effects. - (cl-destructuring-bind - (name version-string summary requirements) (cdr sexp) - (epl-package-create - :name (intern name) - :description - (vector (version-to-list version-string) - (mapcar #'epl-package--parse-descriptor-requirement - ;; Strip the leading `quote' from the package list - (cadr requirements)) - summary))))))) - - -;;; Package database access -(defun epl-package-installed-p (package) - "Determine whether a PACKAGE is installed. - -PACKAGE is either a package name as symbol, or a package object." - (let ((name (if (epl-package-p package) - (epl-package-name package) - package)) - (version (when (epl-package-p package) - (epl-package-version package)))) - (package-installed-p name version))) - -(defun epl--parse-built-in-entry (entry) - "Parse an ENTRY from the list of built-in packages. - -Return the corresponding `epl-package' object." - (if (fboundp 'package--from-builtin) - ;; In package-desc package.el, convert the built-in package to a - ;; `package-desc' and convert that to an `epl-package' - (epl-package--from-package-desc (package--from-builtin entry)) - (epl-package-create :name (car entry) :description (cdr entry)))) - -(defun epl-built-in-packages () - "Get all built-in packages. - -Return a list of `epl-package' objects." - ;; This looks mighty strange, but it's the only way to force package.el to - ;; build the list of built-in packages. Without this, `package--builtins' - ;; might be empty. - (package-built-in-p 'foo) - (mapcar #'epl--parse-built-in-entry package--builtins)) - -(defun epl-find-built-in-package (name) - "Find a built-in package with NAME. - -NAME is a package name, as symbol. - -Return the built-in package as `epl-package' object, or nil if -there is no built-in package with NAME." - (when (package-built-in-p name) - ;; We must call `package-built-in-p' *before* inspecting - ;; `package--builtins', because otherwise `package--builtins' might be - ;; empty. - (epl--parse-built-in-entry (assq name package--builtins)))) - -(defun epl-package-outdated-p (package) - "Determine whether a PACKAGE is outdated. - -A package is outdated, if there is an available package with a -higher version. - -PACKAGE is either a package name as symbol, or a package object. -In the former case, test the installed or built-in package with -the highest version number, in the later case, test the package -object itself. - -Return t, if the package is outdated, or nil otherwise." - (let* ((package (if (epl-package-p package) - package - (or (car (epl-find-installed-packages package)) - (epl-find-built-in-package package)))) - (available (car (epl-find-available-packages - (epl-package-name package))))) - (and package available (version-list-< (epl-package-version package) - (epl-package-version available))))) - -(defun epl--parse-package-list-entry (entry) - "Parse a list of packages from ENTRY. - -ENTRY is a single entry in a package list, e.g. `package-alist', -`package-archive-contents', etc. Typically it is a cons cell, -but the exact format varies between package.el versions. This -function tries to parse all known variants. - -Return a list of `epl-package' objects parsed from ENTRY." - (let ((descriptions (cdr entry))) - (cond - ((listp descriptions) - (sort (mapcar #'epl-package--from-package-desc descriptions) - #'epl-package-->=)) - ;; Legacy package.el has just a single package in an entry, which is a - ;; standard description vector - ((vectorp descriptions) - (list (epl-package-create :name (car entry) - :description descriptions))) - (:else (error "Cannot parse entry %S" entry))))) - -(defun epl-installed-packages () - "Get all installed packages. - -Return a list of package objects." - (apply #'append (mapcar #'epl--parse-package-list-entry package-alist))) - -(defsubst epl--filter-outdated-packages (packages) - "Filter outdated packages from PACKAGES." - (let (res) - (dolist (package packages) - (when (epl-package-outdated-p package) - (push package res))) - (nreverse res))) - -(defun epl-outdated-packages () - "Get all outdated packages, as in `epl-package-outdated-p'. - -Return a list of package objects." - (epl--filter-outdated-packages (epl-installed-packages))) - -(defsubst epl--find-package-in-list (name list) - "Find a package by NAME in a package LIST. - -Return a list of corresponding `epl-package' objects." - (let ((entry (assq name list))) - (when entry - (epl--parse-package-list-entry entry)))) - -(defun epl-find-installed-package (name) - "Find the latest installed package by NAME. - -NAME is a package name, as symbol. - -Return the installed package with the highest version number as -`epl-package' object, or nil, if no package with NAME is -installed." - (car (epl-find-installed-packages name))) -(make-obsolete 'epl-find-installed-package 'epl-find-installed-packages "0.7") - -(defun epl-find-installed-packages (name) - "Find all installed packages by NAME. - -NAME is a package name, as symbol. - -Return a list of all installed packages with NAME, sorted by -version number in descending order. Return nil, if there are no -packages with NAME." - (epl--find-package-in-list name package-alist)) - -(defun epl-available-packages () - "Get all packages available for installation. - -Return a list of package objects." - (apply #'append (mapcar #'epl--parse-package-list-entry - package-archive-contents))) - -(defun epl-find-available-packages (name) - "Find available packages for NAME. - -NAME is a package name, as symbol. - -Return a list of available packages for NAME, sorted by version -number in descending order. Return nil, if there are no packages -for NAME." - (epl--find-package-in-list name package-archive-contents)) - -(cl-defstruct (epl-upgrade - (:constructor epl-upgrade-create)) - "Structure describing an upgradable package. -Slots: - -`installed' The installed package - -`available' The package available for installation." - installed - available) - -(defun epl-find-upgrades (&optional packages) - "Find all upgradable PACKAGES. - -PACKAGES is a list of package objects to upgrade, defaulting to -all installed packages. - -Return a list of `epl-upgrade' objects describing all upgradable -packages." - (let ((packages (or packages (epl-installed-packages))) - upgrades) - (dolist (pkg packages) - (let* ((version (epl-package-version pkg)) - (name (epl-package-name pkg)) - ;; Find the latest available package for NAME - (available-pkg (car (epl-find-available-packages name))) - (available-version (when available-pkg - (epl-package-version available-pkg)))) - (when (and available-version (version-list-< version available-version)) - (push (epl-upgrade-create :installed pkg - :available available-pkg) - upgrades)))) - (nreverse upgrades))) - -(defalias 'epl-built-in-p 'package-built-in-p) - - -;;; Package operations - -(defalias 'epl-install-file 'package-install-file) - -(defun epl-package-install (package &optional force) - "Install a PACKAGE. - -PACKAGE is a `epl-package' object. If FORCE is given and -non-nil, install PACKAGE, even if it is already installed." - (when (or force (not (epl-package-installed-p package))) - (if (epl-package--package-desc-p package) - (package-install (epl-package-description package)) - ;; The legacy API installs by name. We have no control over versioning, - ;; etc. - (package-install (epl-package-name package))))) - -(defun epl-package-delete (package) - "Delete a PACKAGE. - -PACKAGE is a `epl-package' object to delete." - ;; package-delete allows for packages being trashed instead of fully deleted. - ;; Let's prevent his silly behavior - (let ((delete-by-moving-to-trash nil)) - ;; The byte compiler will warn us that we are calling `package-delete' with - ;; the wrong number of arguments, since it can't infer that we guarantee to - ;; always call the correct version. Thus we suppress all warnings when - ;; calling `package-delete'. I wish there was a more granular way to - ;; disable just that specific warning, but it is what it is. - (if (epl-package--package-desc-p package) - (with-no-warnings - (package-delete (epl-package-description package))) - ;; The legacy API deletes by name (as string!) and version instead by - ;; descriptor. Hence `package-delete' takes two arguments. For some - ;; insane reason, the arguments are strings here! - (let ((name (symbol-name (epl-package-name package))) - (version (epl-package-version-string package))) - (with-no-warnings - (package-delete name version)) - ;; Legacy package.el does not remove the deleted package - ;; from the `package-alist', so we do it manually here. - (let ((pkg (assq (epl-package-name package) package-alist))) - (when pkg - (setq package-alist (delq pkg package-alist)))))))) - -(defun epl-upgrade (&optional packages preserve-obsolete) - "Upgrade PACKAGES. - -PACKAGES is a list of package objects to upgrade, defaulting to -all installed packages. - -The old versions of the updated packages are deleted, unless -PRESERVE-OBSOLETE is non-nil. - -Return a list of all performed upgrades, as a list of -`epl-upgrade' objects." - (let ((upgrades (epl-find-upgrades packages))) - (dolist (upgrade upgrades) - (epl-package-install (epl-upgrade-available upgrade) 'force) - (unless preserve-obsolete - (epl-package-delete (epl-upgrade-installed upgrade)))) - upgrades)) - -(provide 'epl) - -;;; epl.el ends here diff --git a/emacs.d/elpa/epl-20150326.1212/epl-autoloads.el b/emacs.d/elpa/epl-20150326.1212/epl-autoloads.el new file mode 100644 index 0000000..58e1d16 --- /dev/null +++ b/emacs.d/elpa/epl-20150326.1212/epl-autoloads.el @@ -0,0 +1,15 @@ +;;; epl-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil nil ("epl.el") (21837 24214 829363 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; epl-autoloads.el ends here diff --git a/emacs.d/elpa/epl-20150326.1212/epl-pkg.el b/emacs.d/elpa/epl-20150326.1212/epl-pkg.el new file mode 100644 index 0000000..7ef65a8 --- /dev/null +++ b/emacs.d/elpa/epl-20150326.1212/epl-pkg.el @@ -0,0 +1 @@ +(define-package "epl" "20150326.1212" "Emacs Package Library" '((cl-lib "0.3")) :url "http://github.com/cask/epl" :keywords '("convenience")) diff --git a/emacs.d/elpa/epl-20150326.1212/epl.el b/emacs.d/elpa/epl-20150326.1212/epl.el new file mode 100644 index 0000000..dbe41c0 --- /dev/null +++ b/emacs.d/elpa/epl-20150326.1212/epl.el @@ -0,0 +1,695 @@ +;;; epl.el --- Emacs Package Library -*- lexical-binding: t; -*- + +;; Copyright (C) 2013-2015 Sebastian Wiesner +;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2015 Free Software + +;; Author: Sebastian Wiesner +;; Maintainer: Johan Andersson +;; Sebastian Wiesner +;; Version: 0.7-cvs +;; Package-Version: 20150326.1212 +;; Package-Requires: ((cl-lib "0.3")) +;; Keywords: convenience +;; URL: http://github.com/cask/epl + +;; This file is NOT part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; A package management library for Emacs, based on package.el. + +;; The purpose of this library is to wrap all the quirks and hassle of +;; package.el into a sane API. + +;; The following functions comprise the public interface of this library: + +;;; Package directory selection + +;; `epl-package-dir' gets the directory of packages. + +;; `epl-default-package-dir' gets the default package directory. + +;; `epl-change-package-dir' changes the directory of packages. + +;;; Package system management + +;; `epl-initialize' initializes the package system and activates all +;; packages. + +;; `epl-reset' resets the package system. + +;; `epl-refresh' refreshes all package archives. + +;; `epl-add-archive' adds a new package archive. + +;;; Package objects + +;; Struct `epl-requirement' describes a requirement of a package with `name' and +;; `version' slots. + +;; `epl-requirement-version-string' gets a requirement version as string. + +;; Struct `epl-package' describes an installed or installable package with a +;; `name' and some internal `description'. + +;; `epl-package-version' gets the version of a package. + +;; `epl-package-version-string' gets the version of a package as string. + +;; `epl-package-summary' gets the summary of a package. + +;; `epl-package-requirements' gets the requirements of a package. + +;; `epl-package-directory' gets the installation directory of a package. + +;; `epl-package-from-buffer' creates a package object for the package contained +;; in the current buffer. + +;; `epl-package-from-file' creates a package object for a package file, either +;; plain lisp or tarball. + +;; `epl-package-from-descriptor-file' creates a package object for a package +;; description (i.e. *-pkg.el) file. + +;;; Package database access + +;; `epl-package-installed-p' determines whether a package is installed, either +;; built-in or explicitly installed. + +;; `epl-package-outdated-p' determines whether a package is outdated, that is, +;; whether a package with a higher version number is available. + +;; `epl-built-in-packages', `epl-installed-packages', `epl-outdated-packages' +;; and `epl-available-packages' get all packages built-in, installed, outdated, +;; or available for installation respectively. + +;; `epl-find-built-in-package', `epl-find-installed-packages' and +;; `epl-find-available-packages' find built-in, installed and available packages +;; by name. + +;; `epl-find-upgrades' finds all upgradable packages. + +;; `epl-built-in-p' return true if package is built-in to Emacs. + +;;; Package operations + +;; `epl-install-file' installs a package file. + +;; `epl-package-install' installs a package. + +;; `epl-package-delete' deletes a package. + +;; `epl-upgrade' upgrades packages. + +;;; Code: + +(require 'cl-lib) +(require 'package) + + +(unless (fboundp #'define-error) + ;; `define-error' for 24.3 and earlier, copied from subr.el + (defun define-error (name message &optional parent) + "Define NAME as a new error signal. +MESSAGE is a string that will be output to the echo area if such an error +is signaled without being caught by a `condition-case'. +PARENT is either a signal or a list of signals from which it inherits. +Defaults to `error'." + (unless parent (setq parent 'error)) + (let ((conditions + (if (consp parent) + (apply #'append + (mapcar (lambda (parent) + (cons parent + (or (get parent 'error-conditions) + (error "Unknown signal `%s'" parent)))) + parent)) + (cons parent (get parent 'error-conditions))))) + (put name 'error-conditions + (delete-dups (copy-sequence (cons name conditions)))) + (when message (put name 'error-message message))))) + +(defsubst epl--package-desc-p (package) + "Whether PACKAGE is a `package-desc' object. + +Like `package-desc-p', but return nil, if `package-desc-p' is not +defined as function." + (and (fboundp 'package-desc-p) (package-desc-p package))) + + +;;; EPL errors +(define-error 'epl-error "EPL error") + +(define-error 'epl-invalid-package "Invalid EPL package" 'epl-error) + +(define-error 'epl-invalid-package-file "Invalid EPL package file" + 'epl-invalid-package) + + +;;; Package directory +(defun epl-package-dir () + "Get the directory of packages." + package-user-dir) + +(defun epl-default-package-dir () + "Get the default directory of packages." + (eval (car (get 'package-user-dir 'standard-value)))) + +(defun epl-change-package-dir (directory) + "Change the directory of packages to DIRECTORY." + (setq package-user-dir directory) + (epl-initialize)) + + +;;; Package system management +(defvar epl--load-path-before-initialize nil + "Remember the load path for `epl-reset'.") + +(defun epl-initialize (&optional no-activate) + "Load Emacs Lisp packages and activate them. + +With NO-ACTIVATE non-nil, do not activate packages." + (setq epl--load-path-before-initialize load-path) + (package-initialize no-activate)) + +(defalias 'epl-refresh 'package-refresh-contents) + +(defun epl-add-archive (name url) + "Add a package archive with NAME and URL." + (add-to-list 'package-archives (cons name url))) + +(defun epl-reset () + "Reset the package system. + +Clear the list of installed and available packages, the list of +package archives and reset the package directory." + (setq package-alist nil + package-archives nil + package-archive-contents nil + load-path epl--load-path-before-initialize) + (when (boundp 'package-obsolete-alist) ; Legacy package.el + (setq package-obsolete-alist nil)) + (epl-change-package-dir (epl-default-package-dir))) + + +;;; Package structures +(cl-defstruct (epl-requirement + (:constructor epl-requirement-create)) + "Structure describing a requirement. + +Slots: + +`name' The name of the required package, as symbol. + +`version' The version of the required package, as version list." + name + version) + +(defun epl-requirement-version-string (requirement) + "The version of a REQUIREMENT, as string." + (package-version-join (epl-requirement-version requirement))) + +(cl-defstruct (epl-package (:constructor epl-package-create)) + "Structure representing a package. + +Slots: + +`name' The package name, as symbol. + +`description' The package description. + +The format package description varies between package.el +variants. For `package-desc' variants, it is simply the +corresponding `package-desc' object. For legacy variants, it is +a vector `[VERSION REQS DOCSTRING]'. + +Do not access `description' directly, but instead use the +`epl-package' accessors." + name + description) + +(defmacro epl-package-as-description (var &rest body) + "Cast VAR to a package description in BODY. + +VAR is a symbol, bound to an `epl-package' object. This macro +casts this object to the `description' object, and binds the +description to VAR in BODY." + (declare (indent 1)) + (unless (symbolp var) + (signal 'wrong-type-argument (list #'symbolp var))) + `(if (epl-package-p ,var) + (let ((,var (epl-package-description ,var))) + ,@body) + (signal 'wrong-type-argument (list #'epl-package-p ,var)))) + +(defsubst epl-package--package-desc-p (package) + "Whether the description of PACKAGE is a `package-desc'." + (epl--package-desc-p (epl-package-description package))) + +(defun epl-package-version (package) + "Get the version of PACKAGE, as version list." + (epl-package-as-description package + (cond + ((fboundp 'package-desc-version) (package-desc-version package)) + ;; Legacy + ((fboundp 'package-desc-vers) + (let ((version (package-desc-vers package))) + (if (listp version) version (version-to-list version)))) + (:else (error "Cannot get version from %S" package))))) + +(defun epl-package-version-string (package) + "Get the version from a PACKAGE, as string." + (package-version-join (epl-package-version package))) + +(defun epl-package-summary (package) + "Get the summary of PACKAGE, as string." + (epl-package-as-description package + (cond + ((fboundp 'package-desc-summary) (package-desc-summary package)) + ((fboundp 'package-desc-doc) (package-desc-doc package)) ; Legacy + (:else (error "Cannot get summary from %S" package))))) + +(defsubst epl-requirement--from-req (req) + "Create a `epl-requirement' from a `package-desc' REQ." + (let ((version (cadr req))) + (epl-requirement-create :name (car req) + :version (if (listp version) version + (version-to-list version))))) + +(defun epl-package-requirements (package) + "Get the requirements of PACKAGE. + +The requirements are a list of `epl-requirement' objects." + (epl-package-as-description package + (mapcar #'epl-requirement--from-req (package-desc-reqs package)))) + +(defun epl-package-directory (package) + "Get the directory PACKAGE is installed to. + +Return the absolute path of the installation directory of +PACKAGE, or nil, if PACKAGE is not installed." + (cond + ((fboundp 'package-desc-dir) + (package-desc-dir (epl-package-description package))) + ((fboundp 'package--dir) + (package--dir (symbol-name (epl-package-name package)) + (epl-package-version-string package))) + (:else (error "Cannot get package directory from %S" package)))) + +(defun epl-package-->= (pkg1 pkg2) + "Determine whether PKG1 is before PKG2 by version." + (not (version-list-< (epl-package-version pkg1) + (epl-package-version pkg2)))) + +(defun epl-package--from-package-desc (package-desc) + "Create an `epl-package' from a PACKAGE-DESC. + +PACKAGE-DESC is a `package-desc' object, from recent package.el +variants." + (if (and (fboundp 'package-desc-name) + (epl--package-desc-p package-desc)) + (epl-package-create :name (package-desc-name package-desc) + :description package-desc) + (signal 'wrong-type-argument (list 'epl--package-desc-p package-desc)))) + +(defun epl-package--parse-info (info) + "Parse a package.el INFO." + (if (epl--package-desc-p info) + (epl-package--from-package-desc info) + ;; For legacy package.el, info is a vector [NAME REQUIRES DESCRIPTION + ;; VERSION COMMENTARY]. We need to re-shape this vector into the + ;; `package-alist' format [VERSION REQUIRES DESCRIPTION] to attach it to the + ;; new `epl-package'. + (let ((name (intern (aref info 0))) + (info (vector (aref info 3) (aref info 1) (aref info 2)))) + (epl-package-create :name name :description info)))) + +(defun epl-package-from-buffer (&optional buffer) + "Create an `epl-package' object from BUFFER. + +BUFFER defaults to the current buffer. + +Signal `epl-invalid-package' if the buffer does not contain a +valid package file." + (let ((info (with-current-buffer (or buffer (current-buffer)) + (condition-case err + (package-buffer-info) + (error (signal 'epl-invalid-package (cdr err))))))) + (epl-package--parse-info info))) + +(defun epl-package-from-lisp-file (file-name) + "Parse the package headers the file at FILE-NAME. + +Return an `epl-package' object with the header metadata." + (with-temp-buffer + (insert-file-contents file-name) + (condition-case err + (epl-package-from-buffer (current-buffer)) + ;; Attach file names to invalid package errors + (epl-invalid-package + (signal 'epl-invalid-package-file (cons file-name (cdr err)))) + ;; Forward other errors + (error (signal (car err) (cdr err)))))) + +(defun epl-package-from-tar-file (file-name) + "Parse the package tarball at FILE-NAME. + +Return a `epl-package' object with the meta data of the tarball +package in FILE-NAME." + (condition-case nil + ;; In legacy package.el, `package-tar-file-info' takes the name of the tar + ;; file to parse as argument. In modern package.el, it has no arguments + ;; and works on the current buffer. Hence, we just try to call the legacy + ;; version, and if that fails because of a mismatch between formal and + ;; actual arguments, we use the modern approach. To avoid spurious + ;; signature warnings by the byte compiler, we suppress warnings when + ;; calling the function. + (epl-package--parse-info (with-no-warnings + (package-tar-file-info file-name))) + (wrong-number-of-arguments + (with-temp-buffer + (insert-file-contents-literally file-name) + ;; Switch to `tar-mode' to enable extraction of the file. Modern + ;; `package-tar-file-info' relies on `tar-mode', and signals an error if + ;; called in a buffer with a different mode. + (tar-mode) + (epl-package--parse-info (with-no-warnings + (package-tar-file-info))))))) + +(defun epl-package-from-file (file-name) + "Parse the package at FILE-NAME. + +Return an `epl-package' object with the meta data of the package +at FILE-NAME." + (if (string-match-p (rx ".tar" string-end) file-name) + (epl-package-from-tar-file file-name) + (epl-package-from-lisp-file file-name))) + +(defun epl-package--parse-descriptor-requirement (requirement) + "Parse a REQUIREMENT in a package descriptor." + ;; This function is only called on legacy package.el. On package-desc + ;; package.el, we just let package.el do the work. + (cl-destructuring-bind (name version-string) requirement + (list name (version-to-list version-string)))) + +(defun epl-package-from-descriptor-file (descriptor-file) + "Load a `epl-package' from a package DESCRIPTOR-FILE. + +A package descriptor is a file defining a new package. Its name +typically ends with -pkg.el." + (with-temp-buffer + (insert-file-contents descriptor-file) + (goto-char (point-min)) + (let ((sexp (read (current-buffer)))) + (unless (eq (car sexp) 'define-package) + (error "%S is no valid package descriptor" descriptor-file)) + (if (and (fboundp 'package-desc-from-define) + (fboundp 'package-desc-name)) + ;; In Emacs snapshot, we can conveniently call a function to parse the + ;; descriptor + (let ((desc (apply #'package-desc-from-define (cdr sexp)))) + (epl-package-create :name (package-desc-name desc) + :description desc)) + ;; In legacy package.el, we must manually deconstruct the descriptor, + ;; because the load function has eval's the descriptor and has a lot of + ;; global side-effects. + (cl-destructuring-bind + (name version-string summary requirements) (cdr sexp) + (epl-package-create + :name (intern name) + :description + (vector (version-to-list version-string) + (mapcar #'epl-package--parse-descriptor-requirement + ;; Strip the leading `quote' from the package list + (cadr requirements)) + summary))))))) + + +;;; Package database access +(defun epl-package-installed-p (package) + "Determine whether a PACKAGE is installed. + +PACKAGE is either a package name as symbol, or a package object." + (let ((name (if (epl-package-p package) + (epl-package-name package) + package)) + (version (when (epl-package-p package) + (epl-package-version package)))) + (package-installed-p name version))) + +(defun epl--parse-built-in-entry (entry) + "Parse an ENTRY from the list of built-in packages. + +Return the corresponding `epl-package' object." + (if (fboundp 'package--from-builtin) + ;; In package-desc package.el, convert the built-in package to a + ;; `package-desc' and convert that to an `epl-package' + (epl-package--from-package-desc (package--from-builtin entry)) + (epl-package-create :name (car entry) :description (cdr entry)))) + +(defun epl-built-in-packages () + "Get all built-in packages. + +Return a list of `epl-package' objects." + ;; This looks mighty strange, but it's the only way to force package.el to + ;; build the list of built-in packages. Without this, `package--builtins' + ;; might be empty. + (package-built-in-p 'foo) + (mapcar #'epl--parse-built-in-entry package--builtins)) + +(defun epl-find-built-in-package (name) + "Find a built-in package with NAME. + +NAME is a package name, as symbol. + +Return the built-in package as `epl-package' object, or nil if +there is no built-in package with NAME." + (when (package-built-in-p name) + ;; We must call `package-built-in-p' *before* inspecting + ;; `package--builtins', because otherwise `package--builtins' might be + ;; empty. + (epl--parse-built-in-entry (assq name package--builtins)))) + +(defun epl-package-outdated-p (package) + "Determine whether a PACKAGE is outdated. + +A package is outdated, if there is an available package with a +higher version. + +PACKAGE is either a package name as symbol, or a package object. +In the former case, test the installed or built-in package with +the highest version number, in the later case, test the package +object itself. + +Return t, if the package is outdated, or nil otherwise." + (let* ((package (if (epl-package-p package) + package + (or (car (epl-find-installed-packages package)) + (epl-find-built-in-package package)))) + (available (car (epl-find-available-packages + (epl-package-name package))))) + (and package available (version-list-< (epl-package-version package) + (epl-package-version available))))) + +(defun epl--parse-package-list-entry (entry) + "Parse a list of packages from ENTRY. + +ENTRY is a single entry in a package list, e.g. `package-alist', +`package-archive-contents', etc. Typically it is a cons cell, +but the exact format varies between package.el versions. This +function tries to parse all known variants. + +Return a list of `epl-package' objects parsed from ENTRY." + (let ((descriptions (cdr entry))) + (cond + ((listp descriptions) + (sort (mapcar #'epl-package--from-package-desc descriptions) + #'epl-package-->=)) + ;; Legacy package.el has just a single package in an entry, which is a + ;; standard description vector + ((vectorp descriptions) + (list (epl-package-create :name (car entry) + :description descriptions))) + (:else (error "Cannot parse entry %S" entry))))) + +(defun epl-installed-packages () + "Get all installed packages. + +Return a list of package objects." + (apply #'append (mapcar #'epl--parse-package-list-entry package-alist))) + +(defsubst epl--filter-outdated-packages (packages) + "Filter outdated packages from PACKAGES." + (let (res) + (dolist (package packages) + (when (epl-package-outdated-p package) + (push package res))) + (nreverse res))) + +(defun epl-outdated-packages () + "Get all outdated packages, as in `epl-package-outdated-p'. + +Return a list of package objects." + (epl--filter-outdated-packages (epl-installed-packages))) + +(defsubst epl--find-package-in-list (name list) + "Find a package by NAME in a package LIST. + +Return a list of corresponding `epl-package' objects." + (let ((entry (assq name list))) + (when entry + (epl--parse-package-list-entry entry)))) + +(defun epl-find-installed-package (name) + "Find the latest installed package by NAME. + +NAME is a package name, as symbol. + +Return the installed package with the highest version number as +`epl-package' object, or nil, if no package with NAME is +installed." + (car (epl-find-installed-packages name))) +(make-obsolete 'epl-find-installed-package 'epl-find-installed-packages "0.7") + +(defun epl-find-installed-packages (name) + "Find all installed packages by NAME. + +NAME is a package name, as symbol. + +Return a list of all installed packages with NAME, sorted by +version number in descending order. Return nil, if there are no +packages with NAME." + (epl--find-package-in-list name package-alist)) + +(defun epl-available-packages () + "Get all packages available for installation. + +Return a list of package objects." + (apply #'append (mapcar #'epl--parse-package-list-entry + package-archive-contents))) + +(defun epl-find-available-packages (name) + "Find available packages for NAME. + +NAME is a package name, as symbol. + +Return a list of available packages for NAME, sorted by version +number in descending order. Return nil, if there are no packages +for NAME." + (epl--find-package-in-list name package-archive-contents)) + +(cl-defstruct (epl-upgrade + (:constructor epl-upgrade-create)) + "Structure describing an upgradable package. +Slots: + +`installed' The installed package + +`available' The package available for installation." + installed + available) + +(defun epl-find-upgrades (&optional packages) + "Find all upgradable PACKAGES. + +PACKAGES is a list of package objects to upgrade, defaulting to +all installed packages. + +Return a list of `epl-upgrade' objects describing all upgradable +packages." + (let ((packages (or packages (epl-installed-packages))) + upgrades) + (dolist (pkg packages) + (let* ((version (epl-package-version pkg)) + (name (epl-package-name pkg)) + ;; Find the latest available package for NAME + (available-pkg (car (epl-find-available-packages name))) + (available-version (when available-pkg + (epl-package-version available-pkg)))) + (when (and available-version (version-list-< version available-version)) + (push (epl-upgrade-create :installed pkg + :available available-pkg) + upgrades)))) + (nreverse upgrades))) + +(defalias 'epl-built-in-p 'package-built-in-p) + + +;;; Package operations + +(defalias 'epl-install-file 'package-install-file) + +(defun epl-package-install (package &optional force) + "Install a PACKAGE. + +PACKAGE is a `epl-package' object. If FORCE is given and +non-nil, install PACKAGE, even if it is already installed." + (when (or force (not (epl-package-installed-p package))) + (if (epl-package--package-desc-p package) + (package-install (epl-package-description package)) + ;; The legacy API installs by name. We have no control over versioning, + ;; etc. + (package-install (epl-package-name package))))) + +(defun epl-package-delete (package) + "Delete a PACKAGE. + +PACKAGE is a `epl-package' object to delete." + ;; package-delete allows for packages being trashed instead of fully deleted. + ;; Let's prevent his silly behavior + (let ((delete-by-moving-to-trash nil)) + ;; The byte compiler will warn us that we are calling `package-delete' with + ;; the wrong number of arguments, since it can't infer that we guarantee to + ;; always call the correct version. Thus we suppress all warnings when + ;; calling `package-delete'. I wish there was a more granular way to + ;; disable just that specific warning, but it is what it is. + (if (epl-package--package-desc-p package) + (with-no-warnings + (package-delete (epl-package-description package))) + ;; The legacy API deletes by name (as string!) and version instead by + ;; descriptor. Hence `package-delete' takes two arguments. For some + ;; insane reason, the arguments are strings here! + (let ((name (symbol-name (epl-package-name package))) + (version (epl-package-version-string package))) + (with-no-warnings + (package-delete name version)) + ;; Legacy package.el does not remove the deleted package + ;; from the `package-alist', so we do it manually here. + (let ((pkg (assq (epl-package-name package) package-alist))) + (when pkg + (setq package-alist (delq pkg package-alist)))))))) + +(defun epl-upgrade (&optional packages preserve-obsolete) + "Upgrade PACKAGES. + +PACKAGES is a list of package objects to upgrade, defaulting to +all installed packages. + +The old versions of the updated packages are deleted, unless +PRESERVE-OBSOLETE is non-nil. + +Return a list of all performed upgrades, as a list of +`epl-upgrade' objects." + (let ((upgrades (epl-find-upgrades packages))) + (dolist (upgrade upgrades) + (epl-package-install (epl-upgrade-available upgrade) 'force) + (unless preserve-obsolete + (epl-package-delete (epl-upgrade-installed upgrade)))) + upgrades)) + +(provide 'epl) + +;;; epl.el ends here diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-autoloads.el b/emacs.d/elpa/erlang-20141104.17/erlang-autoloads.el deleted file mode 100644 index 17b510c..0000000 --- a/emacs.d/elpa/erlang-20141104.17/erlang-autoloads.el +++ /dev/null @@ -1,144 +0,0 @@ -;;; erlang-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "erlang" "erlang.el" (21726 22636 0 0)) -;;; Generated autoloads from erlang.el - -(autoload 'erlang-mode "erlang" "\ -Major mode for editing Erlang source files in Emacs. -It knows about syntax and comment, it can indent code, it is capable -of fontifying the source file, the TAGS commands are aware of Erlang -modules, and the Erlang man pages can be accessed. - -Should this module, \"erlang.el\", be installed properly, Erlang mode -is activated whenever an Erlang source or header file is loaded into -Emacs. To indicate this, the mode line should contain the word -\"Erlang\". - -The main feature of Erlang mode is indentation, press TAB and the -current line will be indented correctly. - -Comments starting with only one `%' are indented to the column stored -in the variable `comment-column'. Comments starting with two `%':s -are indented with the same indentation as code. Comments starting -with at least three `%':s are indented to the first column. - -However, Erlang mode contains much more, this is a list of the most -useful commands: - TAB - Indent the line. - C-c C-q - Indent current function. - M-; - Create a comment at the end of the line. - M-q - Fill a comment, i.e. wrap lines so that they (hopefully) - will look better. - M-a - Goto the beginning of an Erlang clause. - M-C-a - Ditto for function. - M-e - Goto the end of an Erlang clause. - M-C-e - Ditto for function. - M-h - Mark current Erlang clause. - M-C-h - Ditto for function. - C-c C-z - Start, or switch to, an inferior Erlang shell. - C-c C-k - Compile current file. - C-x ` - Next error. - , - Electric comma. - ; - Electric semicolon. - -Erlang mode check the name of the file against the module name when -saving, whenever a mismatch occurs Erlang mode offers to modify the -source. - -The variable `erlang-electric-commands' controls the electric -commands. To deactivate all of them, set it to nil. - -There exists a large number of commands and variables in the Erlang -module. Please press `M-x apropos RET erlang RET' to see a complete -list. Press `C-h f name-of-function RET' and `C-h v name-of-variable -RET'to see the full description of functions and variables, -respectively. - -On entry to this mode the contents of the hook `erlang-mode-hook' is -executed. - -Please see the beginning of the file `erlang.el' for more information -and examples of hooks. - -Other commands: -\\{erlang-mode-map} - -\(fn)" t nil) - -(dolist (r '("\\.erl$" "\\.app\\.src$" "\\.escript" "\\.hrl$" "\\.xrl$" "\\.yrl" "/ebin/.+\\.app")) (add-to-list 'auto-mode-alist (cons r 'erlang-mode))) - -(autoload 'erlang-find-tag "erlang" "\ -Like `find-tag'. Capable of retrieving Erlang modules. - -Tags can be given on the forms `tag', `module:', `module:tag'. - -\(fn MODTAGNAME &optional NEXT-P REGEXP-P)" t nil) - -(autoload 'erlang-find-tag-other-window "erlang" "\ -Like `find-tag-other-window' but aware of Erlang modules. - -\(fn TAGNAME &optional NEXT-P REGEXP-P)" t nil) - -(autoload 'erlang-shell "erlang" "\ -Start a new Erlang shell. - -The variable `erlang-shell-function' decides which method to use, -default is to start a new Erlang host. It is possible that, in the -future, a new shell on an already running host will be started. - -\(fn)" t nil) - (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -(autoload 'erlang-compile "erlang" "\ -Compile Erlang module in current buffer. - -\(fn)" t nil) - -(autoload 'inferior-erlang "erlang" "\ -Run an inferior Erlang. -With prefix command, prompt for command to start Erlang with. - -This is just like running Erlang in a normal shell, except that -an Emacs buffer is used for input and output. -\\ -The command line history can be accessed with \\[comint-previous-input] and \\[comint-next-input]. -The history is saved between sessions. - -Entry to this mode calls the functions in the variables -`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. - -The following commands imitate the usual Unix interrupt and -editing control characters: -\\{erlang-shell-mode-map} - -\(fn &optional COMMAND)" t nil) - -;;;*** - -;;;### (autoloads nil "erlang-start" "erlang-start.el" (21726 22636 -;;;;;; 0 0)) -;;; Generated autoloads from erlang-start.el - -(let ((a '("\\.erl\\'" . erlang-mode)) (b '("\\.hrl\\'" . erlang-mode))) (or (assoc (car a) auto-mode-alist) (setq auto-mode-alist (cons a auto-mode-alist))) (or (assoc (car b) auto-mode-alist) (setq auto-mode-alist (cons b auto-mode-alist)))) - -(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode)) - -(let ((erl-ext '(".jam" ".vee" ".beam"))) (while erl-ext (let ((cie completion-ignored-extensions)) (while (and cie (not (string-equal (car cie) (car erl-ext)))) (setq cie (cdr cie))) (if (null cie) (setq completion-ignored-extensions (cons (car erl-ext) completion-ignored-extensions)))) (setq erl-ext (cdr erl-ext)))) - -;;;*** - -;;;### (autoloads nil nil ("erlang-eunit.el" "erlang-flymake.el" -;;;;;; "erlang-pkg.el" "erlang-skels-old.el" "erlang-skels.el" "erlang_appwiz.el") -;;;;;; (21726 22636 81178 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; erlang-autoloads.el ends here diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-pkg.el b/emacs.d/elpa/erlang-20141104.17/erlang-pkg.el deleted file mode 100644 index d0248c9..0000000 --- a/emacs.d/elpa/erlang-20141104.17/erlang-pkg.el +++ /dev/null @@ -1,4 +0,0 @@ -(define-package "erlang" "20141104.17" "Erlang major mode" 'nil) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/erlang-20141104.17/erlang.el b/emacs.d/elpa/erlang-20141104.17/erlang.el deleted file mode 100644 index c56759e..0000000 --- a/emacs.d/elpa/erlang-20141104.17/erlang.el +++ /dev/null @@ -1,5753 +0,0 @@ -;;; erlang.el --- Major modes for editing and running Erlang - -;; Copyright (C) 2004 Free Software Foundation, Inc. -;; Author: Anders Lindgren -;; Keywords: erlang, languages, processes -;; Date: 2011-12-11 - -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 1996-2014. All Rights Reserved. -;; -;; The contents of this file are subject to the Erlang Public License, -;; Version 1.1, (the "License"); you may not use this file except in -;; compliance with the License. You should have received a copy of the -;; Erlang Public License along with this software. If not, it can be -;; retrieved online at http://www.erlang.org/. -;; -;; Software distributed under the License is distributed on an "AS IS" -;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -;; the License for the specific language governing rights and limitations -;; under the License. -;; -;; %CopyrightEnd% -;; - -;; Lars Thorsén's modifications of 2000-06-07 included. -;; The original version of this package was written by Robert Virding. -;; -;;; Commentary: - -;; Introduction: -;; ------------ -;; -;; This package provides support for the programming language Erlang. -;; The package provides an editing mode with lots of bells and -;; whistles, compilation support, and it makes it possible for the -;; user to start Erlang shells that run inside Emacs. -;; -;; See the Erlang distribution for full documentation of this package. - -;; Installation: -;; ------------ -;; -;; Place this file in Emacs load path, byte-compile it, and add the -;; following line to the appropriate init file: -;; -;; (require 'erlang-start) -;; -;; The full documentation contains much more extensive description of -;; the installation procedure. - -;; Reporting Bugs: -;; -------------- -;; -;; Please send bug reports to the following email address: -;; erlang-bugs@erlang.org -;; or if you have a patch suggestion to: -;; erlang-patches@erlang.org -;; Please state as exactly as possible: -;; - Version number of Erlang Mode (see the menu), Emacs, Erlang, -;; and of any other relevant software. -;; - What the expected result was. -;; - What you did, preferably in a repeatable step-by-step form. -;; - A description of the unexpected result. -;; - Relevant pieces of Erlang code causing the problem. -;; - Personal Emacs customisations, if any. -;; -;; Should the Emacs generate an error, please set the Emacs variable -;; `debug-on-error' to `t'. Repeat the error and enclose the debug -;; information in your bug-report. -;; -;; To set the variable you can use the following command: -;; M-x set-variable RET debug-on-error RET t RET -;;; Code: - -(eval-when-compile (require 'cl)) - -;; Variables: - -(defconst erlang-version "2.7" - "The version number of Erlang mode.") - -(defvar erlang-root-dir nil - "The directory where the Erlang system is installed. -The name should not contain the trailing slash. - -Should this variable be nil, no manual pages will show up in the -Erlang mode menu.") - -(eval-and-compile - (defconst erlang-emacs-major-version - (if (boundp 'emacs-major-version) - emacs-major-version - (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) - (erlang-string-to-int (substring emacs-version - (match-beginning 1) (match-end 1)))) - "Major version number of Emacs.")) - -(eval-and-compile - (defconst erlang-emacs-minor-version - (if (boundp 'emacs-minor-version) - emacs-minor-version - (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) - (erlang-string-to-int (substring emacs-version - (match-beginning 2) (match-end 2)))) - "Minor version number of Emacs.")) - -(defconst erlang-xemacs-p (string-match "Lucid\\|XEmacs" emacs-version) - "Non-nil when running under XEmacs or Lucid Emacs.") - -(defvar erlang-xemacs-popup-menu '("Erlang Mode Commands" . nil) - "Common popup menu for all buffers in Erlang mode. - -This variable is destructively modified every time the Erlang menu -is modified. The effect is that all changes take effect in all -buffers in Erlang mode, just like under GNU Emacs. - -Never EVER set this variable!") - -(defvar erlang-menu-items '(erlang-menu-base-items - erlang-menu-skel-items - erlang-menu-shell-items - erlang-menu-compile-items - erlang-menu-man-items - erlang-menu-personal-items - erlang-menu-version-items) - "*List of menu item list to combine to create Erlang mode menu. - -External programs which temporarily add menu items to the Erlang mode -menu may use this variable. Please use the function `add-hook' to add -items. - -Please call the function `erlang-menu-init' after every change to this -variable.") - -(defvar erlang-menu-base-items - '(("Indent" - (("Indent Line" erlang-indent-command) - ("Indent Region " erlang-indent-region - (if erlang-xemacs-p (mark) mark-active)) - ("Indent Clause" erlang-indent-clause) - ("Indent Function" erlang-indent-function) - ("Indent Buffer" erlang-indent-current-buffer))) - ("Edit" - (("Fill Comment" erlang-fill-paragraph) - ("Comment Region" comment-region - (if erlang-xemacs-p (mark) mark-active)) - ("Uncomment Region" erlang-uncomment-region - (if erlang-xemacs-p (mark) mark-active)) - nil - ("Beginning of Function" erlang-beginning-of-function) - ("End of Function" erlang-end-of-function) - ("Mark Function" erlang-mark-function) - nil - ("Beginning of Clause" erlang-beginning-of-clause) - ("End of Clause" erlang-end-of-clause) - ("Mark Clause" erlang-mark-clause) - nil - ("New Clause" erlang-generate-new-clause) - ("Clone Arguments" erlang-clone-arguments) - nil - ("Align Arrows" erlang-align-arrows))) - ("Syntax Highlighting" - (("Level 4" erlang-font-lock-level-4) - ("Level 3" erlang-font-lock-level-3) - ("Level 2" erlang-font-lock-level-2) - ("Level 1" erlang-font-lock-level-1) - ("Off" erlang-font-lock-level-0))) - ("TAGS" - (("Find Tag" find-tag) - ("Find Next Tag" erlang-find-next-tag) - ;("Find Regexp" find-tag-regexp) - ("Complete Word" erlang-complete-tag) - ("Tags Apropos" tags-apropos) - ("Search Files" tags-search)))) - "Description of menu used in Erlang mode. - -This variable must be a list. The elements are either nil representing -a horizontal line or a list with two or three elements. The first is -the name of the menu item, the second is the function to call, or a -submenu, on the same same form as ITEMS. The third optional argument -is an expression which is evaluated every time the menu is displayed. -Should the expression evaluate to nil the menu item is ghosted. - -Example: - '((\"Func1\" function-one) - (\"SubItem\" - ((\"Yellow\" function-yellow) - (\"Blue\" function-blue))) - nil - (\"Region Function\" spook-function midnight-variable)) - -Call the function `erlang-menu-init' after modifying this variable.") - -(defvar erlang-menu-shell-items - '(nil - ("Shell" - (("Start New Shell" erlang-shell) - ("Display Shell" erlang-shell-display)))) - "Description of the Shell menu used by Erlang mode. - -Please see the documentation of `erlang-menu-base-items'.") - -(defvar erlang-menu-compile-items - '(("Compile" - (("Compile Buffer" erlang-compile) - ("Display Result" erlang-compile-display) - ("Next Error" erlang-next-error)))) - "Description of the Compile menu used by Erlang mode. - -Please see the documentation of `erlang-menu-base-items'.") - -(defvar erlang-menu-version-items - '(nil - ("Version" erlang-version)) - "Description of the version menu used in Erlang mode.") - -(defvar erlang-menu-personal-items nil - "Description of personal menu items used in Erlang mode. - -Please see the variable `erlang-menu-base-items' for a description -of the format.") - -(defvar erlang-menu-man-items nil - "The menu containing man pages. - -The format of the menu should be compatible with `erlang-menu-base-items'. -This variable is added to the list of Erlang menus stored in -`erlang-menu-items'.") - -(defvar erlang-menu-skel-items '() - "Description of the menu containing the skeleton entries. -The menu is in the form described by the variable `erlang-menu-base-items'.") - -(defvar erlang-mode-hook nil - "*Functions to run when Erlang mode is activated. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customise Erlang -mode for all users on the system. - -The functions added to this hook are run every time Erlang mode is -started. See also `erlang-load-hook', a hook which is run once, -when Erlang mode is loaded into Emacs, and `erlang-shell-mode-hook' -which is run every time a new inferior Erlang shell is started. - -To use a hook, create an Emacs lisp function to perform your actions -and add the function to the hook by calling `add-hook'. - -The following example binds the key sequence C-c C-c to the command -`erlang-compile' (normally bound to C-c C-k). The example also -activates Font Lock mode to fontify the buffer and adds a menu -containing all functions defined in the current buffer. - -To use the example, copy the following lines to your `~/.emacs' file: - - (add-hook 'erlang-mode-hook 'my-erlang-mode-hook) - - (defun my-erlang-mode-hook () - (local-set-key \"\\C-c\\C-c\" 'erlang-compile) - (if window-system - (progn - (setq font-lock-maximum-decoration t) - (font-lock-mode 1))) - (if (and window-system (fboundp 'imenu-add-to-menubar)) - (imenu-add-to-menubar \"Imenu\")))") - -(defvar erlang-load-hook nil - "*Functions to run when Erlang mode is loaded. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customize Erlang -mode for all users on the system. - -The difference between this hook and `erlang-mode-hook' and -`erlang-shell-mode-hook' is that the functions in this hook -is only called once, when the Erlang mode is loaded into Emacs -the first time. - -Natural actions for the functions added to this hook are actions which -only should be performed once, and actions which should be performed -before starting Erlang mode. For example, a number of variables are -used by Erlang mode before `erlang-mode-hook' is run. - -The following example sets the variable `erlang-root-dir' so that the -manual pages can be retrieved (note that you must set the value of -`erlang-root-dir' to match the location of Erlang on your system): - - (add-hook 'erlang-load-hook 'my-erlang-load-hook) - - (defun my-erlang-load-hook () - (setq erlang-root-dir \"/usr/local/erlang\"))") - -(defvar erlang-new-file-hook nil - "Functions to run when a new Erlang source file is being edited. - -A useful function is `tempo-template-erlang-normal-header'. -\(This function only exists when the `tempo' package is available.)") - -(defvar erlang-check-module-name 'ask - "*Non-nil means check that module name and file name agrees when saving. - -If the value of this variable is the atom `ask', the user is -prompted. If the value is t the source is silently changed.") - -(defvar erlang-electric-commands - '(erlang-electric-comma - erlang-electric-semicolon - erlang-electric-gt) - "*List of activated electric commands. - -The list should contain the electric commands which should be active. -Currently, the available electric commands are: - `erlang-electric-comma' - `erlang-electric-semicolon' - `erlang-electric-gt' - `erlang-electric-newline' - -Should the variable be bound to t, all electric commands -are activated. - -To deactivate all electric commands, set this variable to nil.") - -(defvar erlang-electric-newline-inhibit t - "*Set to non-nil to inhibit newline after electric command. - -This is useful since a lot of people press return after executing an -electric command. - -In order to work, the command must also be in the -list `erlang-electric-newline-inhibit-list'. - -Note that commands in this list are required to set the variable -`erlang-electric-newline-inhibit' to nil when the newline shouldn't be -inhibited.") - -(defvar erlang-electric-newline-inhibit-list - '(erlang-electric-semicolon - erlang-electric-comma - erlang-electric-gt) - "*Commands which can inhibit the next newline.") - -(defvar erlang-electric-semicolon-insert-blank-lines nil - "*Number of blank lines inserted before header, or nil. - -This variable controls the behaviour of `erlang-electric-semicolon' -when a new function header is generated. When nil, no blank line is -inserted between the current line and the new header. When bound to a -number it represents the number of blank lines which should be -inserted.") - -(defvar erlang-electric-semicolon-criteria - '(erlang-next-lines-empty-p - erlang-at-keyword-end-p - erlang-at-end-of-function-p) - "*List of functions controlling `erlang-electric-semicolon'. -The functions in this list are called, in order, whenever a semicolon -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-comma-criteria - '(erlang-stop-when-inside-argument-list - erlang-stop-when-at-guard - erlang-next-lines-empty-p - erlang-at-keyword-end-p - erlang-at-end-of-clause-p - erlang-at-end-of-function-p) - "*List of functions controlling `erlang-electric-comma'. -The functions in this list are called, in order, whenever a comma -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-arrow-criteria - '(erlang-stop-when-in-type-spec - erlang-next-lines-empty-p - erlang-at-end-of-function-p) - "*List of functions controlling the arrow aspect of `erlang-electric-gt'. -The functions in this list are called, in order, whenever a `>' -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-newline-criteria - '(t) - "*List of functions controlling `erlang-electric-newline'. - -The electric newline commands indents the next line. Should the -current line begin with a comment the comment start is copied to -the newly created line. - -The functions in this list are called, in order, whenever a comma -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- trigger the electric command. - -If every function in the list is called with no determination made, -then no prototype is inserted. Should the atom t be a member of the -list, it is treated as a function triggering the electric command. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-next-lines-empty-threshold 2 - "*Number of blank lines required to activate an electric command. - -Actually, this value controls the behaviour of the function -`erlang-next-lines-empty-p' which normally is a member of the -criteria lists controlling the electric commands. (Please see -the variables `erlang-electric-semicolon-criteria' and -`erlang-electric-comma-criteria'.) - -The variable is bound to a threshold value, a number, representing the -number of lines which must be empty. - -Setting this variable to zero, electric commands will always be -triggered by `erlang-next-lines-empty-p', unless inhibited by other -rules. - -Should this variable be nil, `erlang-next-lines-empty-p' will never -trigger an electric command. The same effect would be reached if the -function `erlang-next-lines-empty-p' would be removed from the criteria -lists. - -Note that even if `erlang-next-lines-empty-p' should not trigger an -electric command, other functions in the criteria list could.") - -(defvar erlang-new-clause-with-arguments nil - "*Non-nil means that the arguments are cloned when a clause is generated. - -A new function header can be generated by calls to the function -`erlang-generate-new-clause' and by use of the electric semicolon.") - -(defvar erlang-compile-use-outdir t - "*When nil, go to the directory containing source file when compiling. - -This is a workaround for a bug in the `outdir' option of compile. If the -outdir is not in the current load path, Erlang doesn't load the object -module after it has been compiled. - -To activate the workaround, place the following in your `~/.emacs' file: - (setq erlang-compile-use-outdir nil)") - -(defvar erlang-indent-level 4 - "*Indentation of Erlang calls/clauses within blocks.") -(put 'erlang-indent-level 'safe-local-variable 'integerp) - -(defvar erlang-indent-guard 2 - "*Indentation of Erlang guards.") -(put 'erlang-indent-guard 'safe-local-variable 'integerp) - -(defvar erlang-argument-indent 2 - "*Indentation of the first argument in a function call. -When nil, indent to the column after the `(' of the -function.") -(put 'erlang-argument-indent 'safe-local-variable '(lambda (val) (or (null val) (integerp val)))) - -(defvar erlang-tab-always-indent t - "*Non-nil means TAB in Erlang mode should always re-indent the current line, -regardless of where in the line point is when the TAB command is used.") - -(defvar erlang-man-inhibit (eq system-type 'windows-nt) - "Inhibit the creation of the Erlang Manual Pages menu. - -The Windows distribution of Erlang does not include man pages, hence -there is no attempt to create the menu.") - -(defvar erlang-man-dirs - '(("Man - Commands" "/man/man1" t) - ("Man - Modules" "/man/man3" t) - ("Man - Files" "/man/man4" t) - ("Man - Applications" "/man/man6" t)) - "*The man directories displayed in the Erlang menu. - -Each item in the list should be a list with three elements, the first -the name of the menu, the second the directory, and the last a flag. -Should the flag the nil, the directory is absolute, should it be non-nil -the directory is relative to the variable `erlang-root-dir'.") - -(defvar erlang-man-max-menu-size 35 - "*The maximum number of menu items in one menu allowed.") - -(defvar erlang-man-display-function 'erlang-man-display - "*Function used to display man page. - -The function is called with one argument, the name of the file -containing the man page. Use this variable when the default -function, `erlang-man-display', does not work on your system.") - -(defvar erlang-compile-extra-opts '() - "*Additional options to the compilation command. -This is an elisp list of options. Each option can be either: -- an atom -- a dotted pair -- a string -Example: '(bin_opt_info (i . \"/path1/include\") (i . \"/path2/include\"))") - -(defvar erlang-compile-command-function-alist - '((".erl\\'" . inferior-erlang-compute-erl-compile-command) - (".xrl\\'" . inferior-erlang-compute-leex-compile-command) - (".yrl\\'" . inferior-erlang-compute-yecc-compile-command) - ("." . inferior-erlang-compute-erl-compile-command)) - "*Alist of filename patterns vs corresponding compilation functions. -Each element looks like (REGEXP . FUNCTION). Compiling a file whose name -matches REGEXP specifies FUNCTION to use to compute the compilation -command. The FUNCTION will be called with two arguments: module name and -default compilation options, like output directory. The FUNCTION -is expected to return a string.") - -(defvar erlang-leex-compile-opts '() - "*Options to pass to leex when compiling xrl files. -This is an elisp list of options. Each option can be either: -- an atom -- a dotted pair -- a string") - -(defvar erlang-yecc-compile-opts '() - "*Options to pass to yecc when compiling yrl files. -This is an elisp list of options. Each option can be either: -- an atom -- a dotted pair -- a string") - -(eval-and-compile - (defvar erlang-regexp-modern-p - (if (> erlang-emacs-major-version 21) t nil) - "Non-nil when this version of Emacs uses a modern version of regexp. -Supporting \_< and \_> This is determined by checking the version of Emacs used.")) - -(eval-and-compile - (defconst erlang-atom-quoted-regexp - "'\\(?:[^\\']\\|\\(?:\\\\.\\)\\)*'" - "Regexp describing a single-quoted atom")) - -(eval-and-compile - (defconst erlang-atom-regular-regexp - (if erlang-regexp-modern-p - "\\_<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\_>" - "\\<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\>") - "Regexp describing a regular (non-quoted) atom")) - -(eval-and-compile - (defconst erlang-atom-regexp - (concat "\\(" erlang-atom-quoted-regexp "\\|" - erlang-atom-regular-regexp "\\)") - "Regexp describing an Erlang atom.")) - -(eval-and-compile - (defconst erlang-atom-regexp-matches 1 - "Number of regexp parenthesis pairs in `erlang-atom-regexp'. - -This is used to determine parenthesis matches in complex regexps which -contains `erlang-atom-regexp'.")) - - -(eval-and-compile - (defconst erlang-variable-regexp - (if erlang-regexp-modern-p - "\\_<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\_>" - "\\<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\>") - "Regexp which should match an Erlang variable. - -The regexp must be surrounded with a pair of regexp parentheses.")) - -(eval-and-compile - (defconst erlang-variable-regexp-matches 1 - "Number of regexp parenthesis pairs in `erlang-variable-regexp'. - -This is used to determine matches in complex regexps which contains -`erlang-variable-regexp'.")) - - -(eval-and-compile - (defun erlang-regexp-opt (strings &optional paren) - "Like `regexp-opt', except if PAREN is `symbols', then the -resulting regexp is surrounded by \\_< and \\_>." - (if (eq paren 'symbols) - (if erlang-regexp-modern-p - (concat "\\_<" (regexp-opt strings t) "\\_>") - (concat "\\<" (regexp-opt strings t) "\\>")) - (regexp-opt strings paren)))) - - -(eval-and-compile - (defvar erlang-keywords - '("after" - "begin" - "catch" - "case" - "cond" - "end" - "fun" - "if" - "let" - "of" - "receive" - "try" - "when") - "Erlang reserved keywords")) - -(eval-and-compile - (defconst erlang-keywords-regexp (erlang-regexp-opt erlang-keywords 'symbols))) - -(eval-and-compile - (defvar erlang-operators - '("and" - "andalso" - "band" - "bnot" - "bor" - "bsl" - "bsr" - "bxor" - "div" - "not" - "or" - "orelse" - "rem" - "xor") - "Erlang operators")) -;; What about these? -;; '+' '-' '*' '/' '>', '>=', '<', '=<', '=:=', '==', '=/=', '/=' - -(eval-and-compile - (defconst erlang-operators-regexp (erlang-regexp-opt erlang-operators 'symbols))) - - -(eval-and-compile - (defvar erlang-guards - '("is_atom" - "is_binary" - "is_bitstring" - "is_boolean" - "is_float" - "is_function" - "is_integer" - "is_list" - "is_map" - "is_number" - "is_pid" - "is_port" - "is_record" - "is_reference" - "is_tuple" - "atom" - "binary" - "bitstring" - "boolean" - ;;"float" ; Not included to avoid clashes with the bif float/1 - "function" - "integer" - "list" - "number" - "pid" - "port" - "record" - "reference" - "tuple") - "Erlang guards")) - -(eval-and-compile - (defconst erlang-guards-regexp (erlang-regexp-opt erlang-guards 'symbols))) - -(eval-and-compile - (defvar erlang-predefined-types - '("any" - "arity" - "boolean" - "byte" - "char" - "cons" - "deep_string" - "iodata" - "iolist" - "maybe_improper_list" - "module" - "mfa" - "nil" - "neg_integer" - "none" - "non_neg_integer" - "nonempty_list" - "nonempty_improper_list" - "nonempty_maybe_improper_list" - "nonempty_string" - "no_return" - "pos_integer" - "string" - "term" - "timeout" - "map") - "Erlang type specs types")) - -(eval-and-compile - (defconst erlang-predefined-types-regexp - (erlang-regexp-opt erlang-predefined-types 'symbols))) - - -(eval-and-compile - (defvar erlang-int-bifs - '("abs" - "apply" - "atom_to_binary" - "atom_to_list" - "binary_to_atom" - "binary_to_existing_atom" - "binary_to_float" - "binary_to_integer" - "binary_to_list" - "binary_to_term" - "binary_part" - "bit_size" - "bitsize" - "bitstring_to_list" - "byte_size" - "check_old_code" - "check_process_code" - "date" - "delete_module" - "demonitor" - "disconnect_node" - "element" - "erase" - "error" - "exit" - "float" - "float_to_binary" - "float_to_list" - "garbage_collect" - "get" - "get_keys" - "group_leader" - "halt" - "hd" - "integer_to_list" - "integer_to_binary" - "iolist_size" - "iolist_to_binary" - "is_alive" - "is_atom" - "is_binary" - "is_bitstring" - "is_boolean" - "is_float" - "is_function" - "is_integer" - "is_list" - "is_map" - "is_number" - "is_pid" - "is_port" - "is_process_alive" - "is_record" - "is_reference" - "is_tuple" - "length" - "link" - "list_to_atom" - "list_to_binary" - "list_to_bitstring" - "list_to_existing_atom" - "list_to_float" - "list_to_integer" - "list_to_pid" - "list_to_tuple" - "load_module" - "make_ref" - "map_size" - "max" - "min" - "module_loaded" - "monitor" - "monitor_node" - "node" - "nodes" - "now" - "open_port" - "pid_to_list" - "port_close" - "port_command" - "port_connect" - "port_control" - "pre_loaded" - "process_flag" - "process_info" - "processes" - "purge_module" - "put" - "register" - "registered" - "round" - "self" - "setelement" - "size" - "spawn" - "spawn_link" - "spawn_monitor" - "spawn_opt" - "split_binary" - "statistics" - "term_to_binary" - "time" - "throw" - "tl" - "trunc" - "tuple_size" - "tuple_to_list" - "unlink" - "unregister" - "whereis") - "Erlang built-in functions (BIFs)")) - -(eval-and-compile - (defconst erlang-int-bif-regexp (erlang-regexp-opt erlang-int-bifs 'symbols))) - - -(eval-and-compile - (defvar erlang-ext-bifs - '("adler32" - "adler32_combine" - "alloc_info" - "alloc_sizes" - "append" - "append_element" - "await_proc_exit" - "await_sched_wall_time_modifications" - "bump_reductions" - "call_on_load_function" - "cancel_timer" - "crasher" - "crc32" - "crc32_combine" - "decode_packet" - "delay_trap" - "delete_element" - "dexit" - "dgroup_leader" - "display" - "display_nl" - "display_string" - "dist_exit" - "dlink" - "dmonitor_node" - "dmonitor_p" - "dsend" - "dt_append_vm_tag_data" - "dt_get_tag" - "dt_get_tag_data" - "dt_prepend_vm_tag_data" - "dt_put_tag" - "dt_restore_tag" - "dt_spread_tag" - "dunlink" - "external_size" - "finish_after_on_load" - "finish_loading" - "flush_monitor_message" - "format_cpu_topology" - "fun_info" - "fun_info_mfa" - "fun_to_list" - "function_exported" - "garbage_collect_message_area" - "gather_gc_info_result" - "gather_sched_wall_time_result" - "get_cookie" - "get_module_info" - "get_stacktrace" - "hash" - "hibernate" - "insert_element" - "is_builtin" - "load_nif" - "loaded" - "localtime" - "localtime_to_universaltime" - "make_fun" - "make_tuple" - "match_spec_test" - "md5" - "md5_final" - "md5_init" - "md5_update" - "memory" - "module_info" - "monitor_node" - "nif_error" - "phash" - "phash2" - "port_call" - "port_get_data" - "port_info" - "port_set_data" - "port_to_list" - "ports" - "posixtime_to_universaltime" - "prepare_loading" - "process_display" - "raise" - "read_timer" - "ref_to_list" - "resume_process" - "send" - "send_after" - "send_nosuspend" - "seq_trace" - "seq_trace_info" - "seq_trace_print" - "set_cookie" - "set_cpu_topology" - "setnode" - "spawn_opt" - "start_timer" - "subtract" - "suspend_process" - "system_flag" - "system_info" - "system_monitor" - "system_profile" - "trace" - "trace_delivered" - "trace_info" - "trace_pattern" - "universaltime" - "universaltime_to_localtime" - "universaltime_to_posixtime" - "yield") - "Erlang built-in functions (BIFs) that needs erlang: prefix")) - -(eval-and-compile - (defconst erlang-ext-bif-regexp - (erlang-regexp-opt (append erlang-int-bifs erlang-ext-bifs) 'symbols))) - - -(defvar erlang-defun-prompt-regexp (concat "^" erlang-atom-regexp "\\s *(") - "Regexp which should match beginning of a clause.") - -(defvar erlang-file-name-extension-regexp "\\.[eh]rl$" - "*Regexp which should match an Erlang file name. - -This regexp is used when an Erlang module name is extracted from the -name of an Erlang source file. - -The regexp should only match the section of the file name which should -be excluded from the module name. - -To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\". -The matches all except the extension. This is useful if the Erlang -tags system should interpret tags on the form `module:tag' for -files written in other languages than Erlang.") - -(defvar erlang-inferior-shell-split-window t - "*If non-nil, when starting an inferior shell, split windows. -If nil, the inferior shell replaces the window. This is the traditional -behaviour.") - -(defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist) - "Non-nil means use `compilation-minor-mode' in Erlang shell.") - -(defvar erlang-mode-map - (let ((map (make-sparse-keymap))) - (unless (boundp 'indent-line-function) - (define-key map "\t" 'erlang-indent-command)) - (define-key map ";" 'erlang-electric-semicolon) - (define-key map "," 'erlang-electric-comma) - (define-key map "<" 'erlang-electric-lt) - (define-key map ">" 'erlang-electric-gt) - (define-key map "\C-m" 'erlang-electric-newline) - (if (not (boundp 'delete-key-deletes-forward)) - (define-key map "\177" 'backward-delete-char-untabify) - (define-key map [(backspace)] 'backward-delete-char-untabify)) - ;;(unless (boundp 'fill-paragraph-function) - (define-key map "\M-q" 'erlang-fill-paragraph) - (unless (boundp 'beginning-of-defun-function) - (define-key map "\M-\C-a" 'erlang-beginning-of-function) - (define-key map "\M-\C-e" 'erlang-end-of-function) - (define-key map '(meta control h) 'erlang-mark-function)) ; Xemacs - (define-key map "\M-\t" 'erlang-complete-tag) - (define-key map "\C-c\M-\t" 'tempo-complete-tag) - (define-key map "\M-+" 'erlang-find-next-tag) - (define-key map "\C-c\M-a" 'erlang-beginning-of-clause) - (define-key map "\C-c\M-b" 'tempo-backward-mark) - (define-key map "\C-c\M-e" 'erlang-end-of-clause) - (define-key map "\C-c\M-f" 'tempo-forward-mark) - (define-key map "\C-c\M-h" 'erlang-mark-clause) - (define-key map "\C-c\C-c" 'comment-region) - (define-key map "\C-c\C-j" 'erlang-generate-new-clause) - (define-key map "\C-c\C-k" 'erlang-compile) - (define-key map "\C-c\C-l" 'erlang-compile-display) - (define-key map "\C-c\C-s" 'erlang-show-syntactic-information) - (define-key map "\C-c\C-q" 'erlang-indent-function) - (define-key map "\C-c\C-u" 'erlang-uncomment-region) - (define-key map "\C-c\C-y" 'erlang-clone-arguments) - (define-key map "\C-c\C-a" 'erlang-align-arrows) - (define-key map "\C-c\C-z" 'erlang-shell-display) - (unless inferior-erlang-use-cmm - (define-key map "\C-x`" 'erlang-next-error)) - map) - "*Keymap used in Erlang mode.") -(defvar erlang-mode-abbrev-table nil - "Abbrev table in use in Erlang-mode buffers.") -(defvar erlang-mode-syntax-table nil - "Syntax table in use in Erlang-mode buffers.") - - - -(defvar erlang-skel-file "erlang-skels" - "The type of erlang-skeletons that should be used, default - uses edoc type, for the old type, standard comments, - set \"erlang-skels-old\" in your .emacs and restart. - - Or define your own and set the variable to that file.") - -;; Tempo skeleton templates: -(load erlang-skel-file) - -;; Font-lock variables - -;; The next few variables define different Erlang font-lock patterns. -;; They could be appended to form a custom font-lock appearance. -;; -;; The function `erlang-font-lock-set-face' could be used to change -;; the face of a pattern. -;; -;; Note that Erlang strings and atoms are highlighted with using -;; syntactic analysis. - -(defvar erlang-font-lock-keywords-function-header - (list - (list (concat "^" erlang-atom-regexp "\\s-*(") - 1 'font-lock-function-name-face t)) - "Font lock keyword highlighting a function header.") - -(defface erlang-font-lock-exported-function-name-face - '((default (:inherit font-lock-function-name-face))) - "Face used for highlighting exported functions.") - -(defvar erlang-font-lock-exported-function-name-face - 'erlang-font-lock-exported-function-name-face) - -(defvar erlang-inhibit-exported-function-name-face nil - "Inhibit separate face for exported functions") - -(defvar erlang-font-lock-keywords-exported-function-header - (list - (list #'erlang-match-next-exported-function - 1 'erlang-font-lock-exported-function-name-face t)) - "Font lock keyword highlighting an exported function header.") - -(defvar erlang-font-lock-keywords-int-bifs - (list - (list (concat erlang-int-bif-regexp "\\s-*(") - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting built in functions.") - -(defvar erlang-font-lock-keywords-ext-bifs - (list - (list (concat "\\<\\(erlang\\)\\s-*:\\s-*" erlang-ext-bif-regexp "\\s-*(") - '(1 'font-lock-builtin-face) - '(2 'font-lock-builtin-face))) - "Font lock keyword highlighting built in functions.") - -(defvar erlang-font-lock-keywords-int-function-calls - (list - (list (concat erlang-atom-regexp "\\s-*(") - 1 'font-lock-type-face)) - "Font lock keyword highlighting an internal function call.") - -(defvar erlang-font-lock-keywords-ext-function-calls - (list - (list (concat erlang-atom-regexp "\\s-*:\\s-*" - erlang-atom-regexp "\\s-*(") - '(1 'font-lock-type-face) - '(2 'font-lock-type-face))) - "Font lock keyword highlighting an external function call.") - -(defvar erlang-font-lock-keywords-fun-n - (list - (list (concat "\\(" erlang-atom-regexp "/[0-9]+\\)") - 1 'font-lock-type-face)) - "Font lock keyword highlighting a fun descriptor in F/N format.") - -(defvar erlang-font-lock-keywords-operators - (list - (list erlang-operators-regexp - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting Erlang operators.") - -(defvar erlang-font-lock-keywords-dollar - (list - (list "\\(\\$\\([^\\]\\|\\\\\\([^0-7^\n]\\|[0-7]+\\|\\^[a-zA-Z]\\)\\)\\)" - 1 'font-lock-constant-face)) - "Font lock keyword highlighting numbers in ASCII form (e.g. $A).") - -(defvar erlang-font-lock-keywords-arrow - (list - (list "->\\(\\s \\|$\\)" 1 'font-lock-function-name-face)) - "Font lock keyword highlighting clause arrow.") - -(defvar erlang-font-lock-keywords-lc - (list - (list "\\(<-\\|<=\\|||\\)\\(\\s \\|$\\)" 1 'font-lock-keyword-face)) - "Font lock keyword highlighting list comprehension operators.") - -(defvar erlang-font-lock-keywords-keywords - (list - (list erlang-keywords-regexp 1 'font-lock-keyword-face)) - "Font lock keyword highlighting Erlang keywords.") - -(defvar erlang-font-lock-keywords-attr - (list - (list (concat "^\\(-" erlang-atom-regexp "\\)\\(\\s-\\|\\.\\|(\\)") - 1 (if (boundp 'font-lock-preprocessor-face) - 'font-lock-preprocessor-face - 'font-lock-constant-face))) - "Font lock keyword highlighting attributes.") - -(defvar erlang-font-lock-keywords-quotes - (list - (list "`\\([-+a-zA-Z0-9_:*][-+a-zA-Z0-9_:*]+\\)'" - 1 - 'font-lock-keyword-face - t)) - "Font lock keyword highlighting words in single quotes in comments. - -This is not the highlighting of Erlang strings and atoms, which -are highlighted by syntactic analysis.") - -(defvar erlang-font-lock-keywords-guards - (list - (list (concat "[^:]" erlang-guards-regexp "\\s-*(") - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting guards.") - -(defvar erlang-font-lock-keywords-predefined-types - (list - (list (concat "[^:]" erlang-predefined-types-regexp "\\s-*(") - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting predefined types.") - - -(defvar erlang-font-lock-keywords-macros - (list - (list (concat "?\\s-*\\(" erlang-atom-regexp - "\\|" erlang-variable-regexp "\\)") - 1 'font-lock-constant-face) - (list (concat "^\\(-\\(?:define\\|ifn?def\\)\\)\\s-*(\\s-*\\(" erlang-atom-regexp - "\\|" erlang-variable-regexp "\\)") - (if (boundp 'font-lock-preprocessor-face) - (list 1 'font-lock-preprocessor-face t) - (list 1 'font-lock-constant-face t)) - (list 3 'font-lock-type-face t t)) - (list "^-e\\(lse\\|ndif\\)\\>" 0 'font-lock-preprocessor-face t)) - "Font lock keyword highlighting macros. -This must be placed in front of `erlang-font-lock-keywords-vars'.") - -(defvar erlang-font-lock-keywords-records - (list - (list (concat "#\\s *" erlang-atom-regexp) - 1 'font-lock-type-face) - ;; Don't highlight numerical constants. - (list (if erlang-regexp-modern-p - "\\_<[0-9]+#\\([0-9a-zA-Z]+\\)" - "\\<[0-9]+#\\([0-9a-zA-Z]+\\)") - 1 nil t) - (list (concat "^-record\\s-*(\\s-*" erlang-atom-regexp) - 1 'font-lock-type-face)) - "Font lock keyword highlighting Erlang records. -This must be placed in front of `erlang-font-lock-keywords-vars'.") - -(defvar erlang-font-lock-keywords-vars - (list - (list (concat "[^#]" erlang-variable-regexp) ; no numerical constants - 1 'font-lock-variable-name-face)) - "Font lock keyword highlighting Erlang variables. -Must be preceded by `erlang-font-lock-keywords-macros' to work properly.") - -(defvar erlang-font-lock-descr-string - "Font-lock keywords used by Erlang Mode. - -There exists three levels of Font Lock keywords for Erlang: - `erlang-font-lock-keywords-1' - Function headers and reserved keywords. - `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'. - `erlang-font-lock-keywords-3' - Variables, macros and records. - `erlang-font-lock-keywords-4' - Exported functions, Function names, - Funs, LCs (not Atoms). - -To use a specific level, please set the variable -`font-lock-maximum-decoration' to the appropriate level. Note that the -variable must be set before Erlang mode is activated. - -Example: - (setq font-lock-maximum-decoration 2)") - -(defvar erlang-font-lock-keywords-1 - (append erlang-font-lock-keywords-function-header - erlang-font-lock-keywords-dollar - erlang-font-lock-keywords-arrow - erlang-font-lock-keywords-keywords - ) - ;; DocStringOrig: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords-2 - (append erlang-font-lock-keywords-1 - erlang-font-lock-keywords-int-bifs - erlang-font-lock-keywords-ext-bifs - erlang-font-lock-keywords-attr - erlang-font-lock-keywords-quotes - erlang-font-lock-keywords-guards - ) - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords-3 - (append erlang-font-lock-keywords-2 - erlang-font-lock-keywords-operators - erlang-font-lock-keywords-macros - erlang-font-lock-keywords-records - erlang-font-lock-keywords-vars - erlang-font-lock-keywords-predefined-types - ) - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords-4 - (append erlang-font-lock-keywords-3 - erlang-font-lock-keywords-exported-function-header - erlang-font-lock-keywords-int-function-calls - erlang-font-lock-keywords-ext-function-calls - erlang-font-lock-keywords-fun-n - erlang-font-lock-keywords-lc - ) - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords erlang-font-lock-keywords-4 - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-syntax-table nil - "Syntax table used by Font Lock mode. - -The difference between this and the standard Erlang Mode -syntax table is that `_' is treated as part of words by -this syntax table. - -Unfortunately, XEmacs hasn't got support for a special Font -Lock syntax table. The effect is that `apply' in the atom -`foo_apply' will be highlighted as a bif.") - - -;;; Avoid errors while compiling this file. - -;; `eval-when-compile' is not defined in Emacs 18. We define it as a -;; no-op. -(or (fboundp 'eval-when-compile) - (defmacro eval-when-compile (&rest rest) nil)) - -;; These umm...functions are new in Emacs 20. And, yes, until version -;; 19.27 Emacs backquotes were this ugly. - -(or (fboundp 'unless) - (defmacro unless (condition &rest body) - "(unless CONDITION BODY...): If CONDITION is false, do BODY, else return nil." - `((if (, condition) nil ,@body)))) - -(or (fboundp 'when) - (defmacro when (condition &rest body) - "(when CONDITION BODY...): If CONDITION is true, do BODY, else return nil." - `((if (, condition) (progn ,@body) nil)))) - -(or (fboundp 'char-before) - (defmacro char-before (&optional pos) - "Return the character in the current buffer just before POS." - `( (char-after (1- (or ,pos (point))))))) - -;; defvar some obsolete variables, which we still support for -;; backwards compatibility reasons. -(eval-when-compile - (defvar comment-indent-hook) - (defvar dabbrev-case-fold-search) - (defvar tempo-match-finder) - (defvar compilation-menu-map) - (defvar next-error-last-buffer)) - -(eval-when-compile - (if (or (featurep 'bytecomp) - (featurep 'byte-compile)) - (progn - (cond ((string-match "Lucid\\|XEmacs" emacs-version) - (put 'comment-indent-hook 'byte-obsolete-variable nil) - ;; Do not warn for unused variables - ;; when compiling under XEmacs. - (setq byte-compile-warnings - '(free-vars unresolved callargs redefine)))) - (require 'comint) - (require 'tempo) - (require 'compile)))) - - -(defun erlang-version () - "Return the current version of Erlang mode." - (interactive) - (if (interactive-p) - (message "Erlang mode version %s, written by Anders Lindgren" - erlang-version)) - erlang-version) - - -;;;###autoload -(defun erlang-mode () - "Major mode for editing Erlang source files in Emacs. -It knows about syntax and comment, it can indent code, it is capable -of fontifying the source file, the TAGS commands are aware of Erlang -modules, and the Erlang man pages can be accessed. - -Should this module, \"erlang.el\", be installed properly, Erlang mode -is activated whenever an Erlang source or header file is loaded into -Emacs. To indicate this, the mode line should contain the word -\"Erlang\". - -The main feature of Erlang mode is indentation, press TAB and the -current line will be indented correctly. - -Comments starting with only one `%' are indented to the column stored -in the variable `comment-column'. Comments starting with two `%':s -are indented with the same indentation as code. Comments starting -with at least three `%':s are indented to the first column. - -However, Erlang mode contains much more, this is a list of the most -useful commands: - TAB - Indent the line. - C-c C-q - Indent current function. - M-; - Create a comment at the end of the line. - M-q - Fill a comment, i.e. wrap lines so that they (hopefully) - will look better. - M-a - Goto the beginning of an Erlang clause. - M-C-a - Ditto for function. - M-e - Goto the end of an Erlang clause. - M-C-e - Ditto for function. - M-h - Mark current Erlang clause. - M-C-h - Ditto for function. - C-c C-z - Start, or switch to, an inferior Erlang shell. - C-c C-k - Compile current file. - C-x ` - Next error. - , - Electric comma. - ; - Electric semicolon. - -Erlang mode check the name of the file against the module name when -saving, whenever a mismatch occurs Erlang mode offers to modify the -source. - -The variable `erlang-electric-commands' controls the electric -commands. To deactivate all of them, set it to nil. - -There exists a large number of commands and variables in the Erlang -module. Please press `M-x apropos RET erlang RET' to see a complete -list. Press `C-h f name-of-function RET' and `C-h v name-of-variable -RET'to see the full description of functions and variables, -respectively. - -On entry to this mode the contents of the hook `erlang-mode-hook' is -executed. - -Please see the beginning of the file `erlang.el' for more information -and examples of hooks. - -Other commands: -\\{erlang-mode-map}" - (interactive) - (kill-all-local-variables) - (setq major-mode 'erlang-mode) - (setq mode-name "Erlang") - (erlang-syntax-table-init) - (use-local-map erlang-mode-map) - (erlang-electric-init) - (erlang-menu-init) - (erlang-mode-variables) - (erlang-check-module-name-init) - (erlang-man-init) - (erlang-tags-init) - (erlang-font-lock-init) - (erlang-skel-init) - (tempo-use-tag-list 'erlang-tempo-tags) - (run-hooks 'erlang-mode-hook) - (if (zerop (buffer-size)) - (run-hooks 'erlang-new-file-hook)) - ;; Doesn't exist in Emacs v21.4; required by Emacs v23. - (if (boundp 'after-change-major-mode-hook) - (run-hooks 'after-change-major-mode-hook))) - -;;;###autoload -(dolist (r '("\\.erl$" "\\.app\\.src$" "\\.escript" - "\\.hrl$" "\\.xrl$" "\\.yrl" "/ebin/.+\\.app")) - (add-to-list 'auto-mode-alist (cons r 'erlang-mode))) - -(defun erlang-syntax-table-init () - (if (null erlang-mode-syntax-table) - (let ((table (make-syntax-table))) - (modify-syntax-entry ?\n ">" table) - (modify-syntax-entry ?\" "\"" table) - (modify-syntax-entry ?# "." table) -;; (modify-syntax-entry ?$ "\\" table) ;; Creates problems with indention afterwards -;; (modify-syntax-entry ?$ "'" table) ;; Creates syntax highlighting and indention problems - (modify-syntax-entry ?$ "/" table) ;; Misses the corner case "string that ends with $" - ;; we have to live with that for now..it is the best alternative - ;; that can be worked around with "string hat ends with \$" - (modify-syntax-entry ?% "<" table) - (modify-syntax-entry ?& "." table) - (modify-syntax-entry ?\' "\"" table) - (modify-syntax-entry ?* "." table) - (modify-syntax-entry ?+ "." table) - (modify-syntax-entry ?- "." table) - (modify-syntax-entry ?/ "." table) - (modify-syntax-entry ?: "." table) - (modify-syntax-entry ?< "." table) - (modify-syntax-entry ?= "." table) - (modify-syntax-entry ?> "." table) - (modify-syntax-entry ?\\ "\\" table) - (modify-syntax-entry ?_ "_" table) - (modify-syntax-entry ?| "." table) - (modify-syntax-entry ?^ "'" table) - - ;; Pseudo bit-syntax: Latin1 double angle quotes as parens. - ;;(modify-syntax-entry ?\253 "(?\273" table) - ;;(modify-syntax-entry ?\273 ")?\253" table) - - (setq erlang-mode-syntax-table table))) - - (set-syntax-table erlang-mode-syntax-table)) - - -(defun erlang-electric-init () - ;; Set up electric character functions to work with - ;; delsel/pending-del mode. Also, set up text properties for bit - ;; syntax handling. - (mapc #'(lambda (cmd) - (put cmd 'delete-selection t) ;for delsel (Emacs) - (put cmd 'pending-delete t)) ;for pending-del (XEmacs) - '(erlang-electric-semicolon - erlang-electric-comma - erlang-electric-gt)) - - (put 'bitsyntax-open-outer 'syntax-table '(4 . ?>)) - (put 'bitsyntax-open-outer 'rear-nonsticky '(category)) - (put 'bitsyntax-open-inner 'rear-nonsticky '(category)) - (put 'bitsyntax-close-inner 'rear-nonsticky '(category)) - (put 'bitsyntax-close-outer 'syntax-table '(5 . ?<)) - (put 'bitsyntax-close-outer 'rear-nonsticky '(category)) - (make-local-variable 'parse-sexp-lookup-properties) - (setq parse-sexp-lookup-properties 't)) - - -(defun erlang-mode-variables () - (or erlang-mode-abbrev-table - (define-abbrev-table 'erlang-mode-abbrev-table ())) - (setq local-abbrev-table erlang-mode-abbrev-table) - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "^$\\|" page-delimiter)) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate paragraph-start) - (make-local-variable 'paragraph-ignore-fill-prefix) - (setq paragraph-ignore-fill-prefix t) - (make-local-variable 'require-final-newline) - (setq require-final-newline t) - (make-local-variable 'defun-prompt-regexp) - (setq defun-prompt-regexp erlang-defun-prompt-regexp) - (make-local-variable 'comment-start) - (setq comment-start "%") - (make-local-variable 'comment-start-skip) - (setq comment-start-skip "%+\\s *") - (make-local-variable 'comment-column) - (setq comment-column 48) - (make-local-variable 'indent-line-function) - (setq indent-line-function 'erlang-indent-command) - (make-local-variable 'indent-region-function) - (setq indent-region-function 'erlang-indent-region) - (set (make-local-variable 'comment-indent-function) 'erlang-comment-indent) - (if (<= erlang-emacs-major-version 18) - (set (make-local-variable 'comment-indent-hook) 'erlang-comment-indent)) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'dabbrev-case-fold-search) nil) - (set (make-local-variable 'imenu-prev-index-position-function) - 'erlang-beginning-of-function) - (set (make-local-variable 'imenu-extract-index-name-function) - 'erlang-get-function-name-and-arity) - (set (make-local-variable 'tempo-match-finder) - "[^-a-zA-Z0-9_]\\([-a-zA-Z0-9_]*\\)\\=") - (set (make-local-variable 'beginning-of-defun-function) - 'erlang-beginning-of-function) - (set (make-local-variable 'end-of-defun-function) 'erlang-end-of-function) - (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) - (set (make-local-variable 'fill-paragraph-function) 'erlang-fill-paragraph) - (set (make-local-variable 'comment-add) 1) - (set (make-local-variable 'outline-regexp) "[[:lower:]0-9_]+ *(.*) *-> *$") - (set (make-local-variable 'outline-level) (lambda () 1)) - (set (make-local-variable 'add-log-current-defun-function) - 'erlang-current-defun)) - -(defun erlang-font-lock-init () - "Initialize Font Lock for Erlang mode." - (or erlang-font-lock-syntax-table - (setq erlang-font-lock-syntax-table - (let ((table (copy-syntax-table erlang-mode-syntax-table))) - (modify-syntax-entry ?_ "w" table) - table))) - (set (make-local-variable 'font-lock-syntax-table) - erlang-font-lock-syntax-table) - (set (make-local-variable 'font-lock-beginning-of-syntax-function) - 'erlang-beginning-of-clause) - (make-local-variable 'font-lock-keywords) - (let ((level (cond ((boundp 'font-lock-maximum-decoration) - (symbol-value 'font-lock-maximum-decoration)) - ((boundp 'font-lock-use-maximal-decoration) - (symbol-value 'font-lock-use-maximal-decoration)) - (t nil)))) - (if (consp level) - (setq level (cdr-safe (or (assq 'erlang-mode level) - (assq t level))))) - ;; `level' can here be: - ;; A number - The fontification level - ;; nil - Use the default - ;; t - Use maximum - (cond ((eq level nil) - (set 'font-lock-keywords erlang-font-lock-keywords)) - ((eq level 1) - (set 'font-lock-keywords erlang-font-lock-keywords-1)) - ((eq level 2) - (set 'font-lock-keywords erlang-font-lock-keywords-2)) - ((eq level 3) - (set 'font-lock-keywords erlang-font-lock-keywords-3)) - (t - (set 'font-lock-keywords erlang-font-lock-keywords-4)))) - - ;; Modern font-locks can handle the above much more elegantly: - (set (make-local-variable 'font-lock-defaults) - '((erlang-font-lock-keywords erlang-font-lock-keywords-1 - erlang-font-lock-keywords-2 - erlang-font-lock-keywords-3 - erlang-font-lock-keywords-4) - nil nil ((?_ . "w")) erlang-beginning-of-clause - (font-lock-mark-block-function . erlang-mark-clause) - (font-lock-syntactic-keywords - ;; A dollar sign right before the double quote that ends a - ;; string is not a character escape. - ;; - ;; And a "string" consists of a double quote not escaped by a - ;; dollar sign, any number of non-backslash non-newline - ;; characters or escaped backslashes, a dollar sign - ;; (otherwise we wouldn't care) and a double quote. This - ;; doesn't match multi-line strings, but this is probably - ;; the best we can get, since while font-locking we don't - ;; know whether matching started inside a string: limiting - ;; search to a single line keeps things sane. - . (("\\(?:^\\|[^$]\\)\"\\(?:[^\"\n]\\|\\\\\"\\)*\\(\\$\\)\"" 1 "w") - ;; Likewise for atoms - ("\\(?:^\\|[^$]\\)'\\(?:[^'\n]\\|\\\\'\\)*\\(\\$\\)'" 1 "w") - ;; And the dollar sign in $\" or $\' escapes two - ;; characters, not just one. - ("\\(\\$\\)\\\\[\"']" 1 "'")))))) - - - -;; Useful when defining your own keywords. -(defun erlang-font-lock-set-face (ks &rest faces) - "Replace the face components in a list of keywords. - -The first argument, KS, is a list of keywords. The rest of the -arguments are expressions to replace the face information with. The -first expression replaces the face of the first keyword, the second -expression the second keyword etc. - -Should an expression be nil, the face of the corresponding keyword is -not changed. - -Should fewer expressions than keywords be given, the last expression -is used for all remaining keywords. - -Normally, the expressions are just atoms representing the new face. -They could however be more complex, returning different faces in -different situations. - -This function only handles keywords with elements on the forms: - (REGEXP NUMBER FACE) - (REGEXP NUMBER FACE OVERWRITE) - -This could be used when defining your own special font-lock setup, e.g: - -\(setq my-font-lock-keywords - (append erlang-font-lock-keywords-function-header - erlang-font-lock-keywords-dollar - (erlang-font-lock-set-face - erlang-font-lock-keywords-macros 'my-neon-green-face) - (erlang-font-lock-set-face - erlang-font-lock-keywords-lc 'my-deep-red 'my-light-red) - erlang-font-lock-keywords-attr)) - -For a more elaborate example, please see the beginning of the file -`erlang.el'." - (let ((res '())) - (while ks - (let* ((regexp (car (car ks))) - (number (car (cdr (car ks)))) - (new-face (if (and faces (car faces)) - (car faces) - (car (cdr (cdr (car ks)))))) - (overwrite (car (cdr (cdr (cdr (car ks)))))) - (new-keyword (list regexp number new-face))) - (if overwrite (nconc new-keyword (list overwrite))) - (setq res (cons new-keyword res)) - (setq ks (cdr ks)) - (if (and faces (cdr faces)) - (setq faces (cdr faces))))) - (nreverse res))) - - -(defun erlang-font-lock-level-0 () - ;; DocStringOrig: font-cmd - "Unfontify current buffer." - (interactive) - (font-lock-mode 0)) - - -(defun erlang-font-lock-level-1 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 1. -This highlights function headers, reserved keywords, strings and comments." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-1) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-font-lock-level-2 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 2. -This highlights level 1 features (see `erlang-font-lock-level-1') -plus bifs, guards and `single quotes'." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-2) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-font-lock-level-3 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 3. -This highlights level 2 features (see `erlang-font-lock-level-2') -plus variables, macros and records." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-3) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - -(defun erlang-font-lock-level-4 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 4. -This highlights level 3 features (see `erlang-font-lock-level-2') -plus variables, macros and records." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-4) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-menu-init () - "Init menus for Erlang mode. - -The variable `erlang-menu-items' contain a description of the Erlang -mode menu. Normally, the list contains atoms, representing variables -bound to pieces of the menu. - -Personal extensions could be added to `erlang-menu-personal-items'. - -This function should be called if any variable describing the -menu configuration is changed." - (erlang-menu-install "Erlang" erlang-menu-items erlang-mode-map t)) - - -(defun erlang-menu-install (name items keymap &optional popup) - "Install a menu in Emacs or XEmacs based on an abstract description. - -NAME is the name of the menu. - -ITEMS is a list. The elements are either nil representing a horizontal -line or a list with two or three elements. The first is the name of -the menu item, the second the function to call, or a submenu, on the -same same form as ITEMS. The third optional element is an expression -which is evaluated every time the menu is displayed. Should the -expression evaluate to nil the menu item is ghosted. - -KEYMAP is the keymap to add to menu to. (When using XEmacs, the menu -will only be visible when this menu is the global, the local, or an -activate minor mode keymap.) - -If POPUP is non-nil, the menu is bound to the XEmacs `mode-popup-menu' -variable, i.e. it will popup when pressing the right mouse button. - -Please see the variable `erlang-menu-base-items'." - (cond (erlang-xemacs-p - (let ((menu (erlang-menu-xemacs name items keymap))) - ;; We add the menu to the global menubar. - ;;(funcall (symbol-function 'set-buffer-menubar) - ;; (symbol-value 'current-menubar)) - (funcall (symbol-function 'add-submenu) nil menu) - (setcdr erlang-xemacs-popup-menu (cdr menu)) - (if (and popup (boundp 'mode-popup-menu)) - (funcall (symbol-function 'set) - 'mode-popup-menu erlang-xemacs-popup-menu)))) - ((>= erlang-emacs-major-version 19) - (define-key keymap (vector 'menu-bar (intern name)) - (erlang-menu-make-keymap name items))) - (t nil))) - - -(defun erlang-menu-make-keymap (name items) - "Build a menu for Emacs 19." - (let ((menumap (funcall (symbol-function 'make-sparse-keymap) - name)) - (count 0) - id def first second third) - (setq items (reverse items)) - (while items - ;; Replace any occurrence of atoms by their value. - (while (and items (atom (car items)) (not (null (car items)))) - (if (and (boundp (car items)) - (listp (symbol-value (car items)))) - (setq items (append (reverse (symbol-value (car items))) - (cdr items))) - (setq items (cdr items)))) - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (setq third (car-safe (cdr-safe (cdr-safe (car items))))) - (cond ((null first) - (setq count (+ count 1)) - (setq id (intern (format "separator-%d" count))) - (setq def '("--" . nil))) - ((and (consp second) (eq (car second) 'lambda)) - (setq count (+ count 1)) - (setq id (intern (format "lambda-%d" count))) - (setq def (cons first second))) - ((symbolp second) - (setq id second) - (setq def (cons first second))) - (t - (setq count (+ count 1)) - (setq id (intern (format "submenu-%d" count))) - (setq def (erlang-menu-make-keymap first second)))) - (define-key menumap (vector id) def) - (if third - (put id 'menu-enable third)) - (setq items (cdr items))) - (cons name menumap))) - - -(defun erlang-menu-xemacs (name items &optional keymap) - "Build a menu for XEmacs." - (let ((res '()) - first second third entry) - (while items - ;; Replace any occurrence of atoms by their value. - (while (and items (atom (car items)) (not (null (car items)))) - (if (and (boundp (car items)) - (listp (symbol-value (car items)))) - (setq items (append (reverse (symbol-value (car items))) - (cdr items))) - (setq items (cdr items)))) - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (setq third (car-safe (cdr-safe (cdr-safe (car items))))) - (cond ((null first) - (setq res (cons "------" res))) - ((symbolp second) - (setq res (cons (vector first second (or third t)) res))) - ((and (consp second) (eq (car second) 'lambda)) - (setq res (cons (vector first (list 'call-interactively second) - (or third t)) res))) - (t - (setq res (cons (cons first - (cdr (erlang-menu-xemacs - first second))) - res)))) - (setq items (cdr items))) - (setq res (reverse res)) - ;; When adding a menu to a minor-mode keymap under Emacs, - ;; it disappears when the mode is disabled. The expression - ;; generated below imitates this behaviour. - ;; (This could be expressed much clearer using backquotes, - ;; but I don't want to pull in every package.) - (if keymap - (let ((expr (list 'or - (list 'eq keymap 'global-map) - (list 'eq keymap (list 'current-local-map)) - (list 'symbol-value - (list 'car-safe - (list 'rassq - keymap - 'minor-mode-map-alist)))))) - (setq res (cons ':included (cons expr res))))) - (cons name res))) - - -(defun erlang-menu-substitute (items alist) - "Substitute functions in menu described by ITEMS. - -The menu ITEMS is updated destructively. - -ALIST is list of pairs where the car is the old function and cdr the new." - (let (first second pair) - (while items - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (cond ((null first)) - ((symbolp second) - (setq pair (and second (assq second alist))) - (if pair - (setcar (cdr (car items)) (cdr pair)))) - ((and (consp second) (eq (car second) 'lambda))) - (t - (erlang-menu-substitute second alist))) - (setq items (cdr items))))) - - -(defun erlang-menu-add-above (entry above items) - "Add menu ENTRY above menu entry ABOVE in menu ITEMS. -Do nothing if the items already should be in the menu. -Should ABOVE not be in the list, the entry is added at -the bottom of the menu. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged. - -The equality test is performed by `eq'. - -Example: (erlang-menu-add-above 'my-erlang-menu-items - 'erlang-menu-man-items)" - (erlang-menu-add-below entry above items t)) - - -(defun erlang-menu-add-below (entry below items &optional above-p) - "Add menu ENTRY below menu items BELOW in the Erlang menu. -Do nothing if the items already should be in the menu. -Should BELOW not be in the list, items is added at the bottom -of the menu. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged. - -The equality test is performed by `eq'. - -Example: - -\(setq erlang-menu-items - (erlang-menu-add-below 'my-erlang-menu-items - 'erlang-menu-base-items - erlang-menu-items))" - (if (memq entry items) - items ; Return the original menu. - (let ((head '()) - (done nil) - res) - (while (not done) - (cond ((null items) - (setq res (append head (list entry))) - (setq done t)) - ((eq below (car items)) - (setq res - (if above-p - (append head (cons entry items)) - (append head (cons (car items) - (cons entry (cdr items)))))) - (setq done t)) - (t - (setq head (append head (list (car items)))) - (setq items (cdr items))))) - res))) - -(defun erlang-menu-delete (entry items) - "Delete ENTRY from menu ITEMS. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged." - (delq entry items)) - -;; Man code: - -(defun erlang-man-init () - "Add menus containing the manual pages of the Erlang. - -The variable `erlang-man-dirs' contains entries describing -the location of the manual pages." - (interactive) - (if erlang-man-inhibit - () - (setq erlang-menu-man-items - '(nil - ("Man - Function" erlang-man-function))) - (if erlang-man-dirs - (setq erlang-menu-man-items - (append erlang-menu-man-items - (erlang-man-make-top-menu erlang-man-dirs)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-man-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init))) - - -(defun erlang-man-uninstall () - "Remove the man pages from the Erlang mode." - (interactive) - (setq erlang-menu-items - (erlang-menu-delete 'erlang-menu-man-items erlang-menu-items)) - (erlang-menu-init)) - - -;; The man menu is a hierarchal structure, with the manual sections -;; at the top, described by `erlang-man-dirs'. The next level could -;; either be the manual pages if not to many, otherwise it is an index -;; menu whose submenus will contain up to `erlang-man-max-menu-size' -;; manual pages. - -(defun erlang-man-make-top-menu (dir-list) - "Create one menu entry per element of DIR-LIST. -The format is described in the documentation of `erlang-man-dirs'." - (let ((menu '()) - dir) - (while dir-list - (setq dir (cond ((nth 2 (car dir-list)) - ;; Relative to `erlang-root-dir'. - (and (stringp erlang-root-dir) - (concat erlang-root-dir (nth 1 (car dir-list))))) - (t - ;; Absolute - (nth 1 (car dir-list))))) - (if (and dir - (file-readable-p dir)) - (setq menu (cons (list (car (car dir-list)) - (erlang-man-make-middle-menu - (erlang-man-get-files dir))) - menu))) - (setq dir-list (cdr dir-list))) - ;; Should no menus be found, generate a menu item which - ;; will display a help text, when selected. - (if menu - (nreverse menu) - '(("Man Pages" - (("Error! Why?" erlang-man-describe-error))))))) - - -;; Should the menu be to long, let's split it into a number of -;; smaller menus. Warning, this code contains beautiful -;; destructive operations! -(defun erlang-man-make-middle-menu (filelist) - "Create the second level menu from FILELIST. - -Should the list be longer than `erlang-man-max-menu-size', a tree of -menus is created." - (if (<= (length filelist) erlang-man-max-menu-size) - (erlang-man-make-menu filelist) - (let ((menu '()) - (filelist (copy-sequence filelist)) - segment submenu pair) - (while filelist - (setq pair (nthcdr (- erlang-man-max-menu-size 1) filelist)) - (setq segment filelist) - (if (null pair) - (setq filelist nil) - (setq filelist (cdr pair)) - (setcdr pair nil)) - (setq submenu (erlang-man-make-menu segment)) - (setq menu (cons (list (concat (car (car submenu)) - " -- " - (car (car (reverse submenu)))) - submenu) - menu))) - (nreverse menu)))) - - -(defun erlang-man-make-menu (filelist) - "Make a leaf menu based on FILELIST." - (let ((menu '()) - item) - (while filelist - (setq item (erlang-man-make-menu-item (car filelist))) - (if item - (setq menu (cons item menu))) - (setq filelist (cdr filelist))) - (nreverse menu))) - - -(defun erlang-man-make-menu-item (file) - "Create a menu item containing the name of the man page." - (and (string-match ".+/\\([^/]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file) - (let ((page (substring file (match-beginning 1) (match-end 1)))) - (list (capitalize page) - (list 'lambda '() - '(interactive) - (list 'funcall 'erlang-man-display-function - file)))))) - - -(defun erlang-man-get-files (dir) - "Return files in directory DIR." - (directory-files dir t ".+\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?\\'")) - - -(defun erlang-man-module (&optional module) - "Find manual page for MODULE, defaults to module of function under point. -This function is aware of imported functions." - (interactive - (list (let* ((mod (car-safe (erlang-get-function-under-point))) - (input (read-string - (format "Manual entry for module%s: " - (if (or (null mod) (string= mod "")) - "" - (format " (default %s)" mod)))))) - (if (string= input "") - mod - input)))) - (or module (setq module (car (erlang-get-function-under-point)))) - (if (or (null module) (string= module "")) - (error "No Erlang module name given")) - (let ((dir-list erlang-man-dirs) - (pat (concat "/" (regexp-quote module) "\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$")) - (file nil) - file-list) - (while (and dir-list (null file)) - (setq file-list (erlang-man-get-files - (if (nth 2 (car dir-list)) - (concat erlang-root-dir (nth 1 (car dir-list))) - (nth 1 (car dir-list))))) - (while (and file-list (null file)) - (if (string-match pat (car file-list)) - (setq file (car file-list))) - (setq file-list (cdr file-list))) - (setq dir-list (cdr dir-list))) - (if file - (funcall erlang-man-display-function file) - (error "No manual page for module %s found" module)))) - - -;; Warning, the function `erlang-man-function' is a hack! -;; It links itself into the man code in a non-clean way. I have -;; chosen to keep it since it provides a very useful functionality -;; which is not possible to achieve using a clean approach. -;; / AndersL - -(defvar erlang-man-function-name nil - "Name of function for last `erlang-man-function' call. -Used for communication between `erlang-man-function' and the -patch to `Man-notify-when-ready'.") - -(defun erlang-man-function (&optional name) - "Find manual page for NAME, where NAME is module:function. -The entry for `function' is displayed. - -This function is aware of imported functions." - (interactive - (list (let* ((mod-func (erlang-get-function-under-point)) - (mod (car-safe mod-func)) - (func (nth 1 mod-func)) - (input (read-string - (format - "Manual entry for `module:func' or `module'%s: " - (if (or (null mod) (string= mod "")) - "" - (format " (default %s:%s)" mod func)))))) - (if (string= input "") - (if (and mod func) - (concat mod ":" func) - mod) - input)))) - ;; Emacs 18 doesn't provide `man'... - (condition-case nil - (require 'man) - (error nil)) - (let ((modname nil) - (funcname nil)) - (cond ((null name) - (let ((mod-func (erlang-get-function-under-point))) - (setq modname (car-safe mod-func)) - (setq funcname (nth 1 mod-func)))) - ((string-match ":" name) - (setq modname (substring name 0 (match-beginning 0))) - (setq funcname (substring name (match-end 0) nil))) - ((stringp name) - (setq modname name))) - (if (or (null modname) (string= modname "")) - (error "No Erlang module name given")) - (cond ((fboundp 'Man-notify-when-ready) - ;; Emacs 19: The man command could possibly start an - ;; asynchronous process, i.e. we must hook ourselves into - ;; the system to be activated when the man-process - ;; terminates. - (if (null funcname) - () - (erlang-man-patch-notify) - (setq erlang-man-function-name funcname)) - (condition-case nil - (erlang-man-module modname) - (error (setq erlang-man-function-name nil)))) - (t - (erlang-man-module modname) - (if funcname - (erlang-man-find-function - (or (get-buffer "*Manual Entry*") ; Emacs 18 - (current-buffer)) ; XEmacs - funcname)))))) - - -;; Should the defadvice be at the top level, the package `advice' would -;; be required. Now it is only required when this functionality -;; is used. (Emacs 19 specific.) -(defun erlang-man-patch-notify () - "Patch the function `Man-notify-when-ready' to search for function. -The variable `erlang-man-function-name' is assumed to be bound to -the function name, or to nil. - -The reason for patching a function is that under Emacs 19, the man -command is executed asynchronously." - (condition-case nil - (require 'advice) - ;; This should never happened since this is only called when - ;; running under Emacs 19. - (error (error (concat "This command needs the package `advice', " - "please upgrade your Emacs.")))) - (require 'man) - (defadvice Man-notify-when-ready - (after erlang-Man-notify-when-ready activate) - "Set point at the documentation of the function name in -`erlang-man-function-name' when the man page is displayed." - (if erlang-man-function-name - (erlang-man-find-function (ad-get-arg 0) erlang-man-function-name)) - (setq erlang-man-function-name nil))) - - -(defun erlang-man-find-function (buf func) - "Find manual page for function in `erlang-man-function-name' in buffer BUF." - (if func - (let ((win (get-buffer-window buf))) - (if win - (progn - (set-buffer buf) - (goto-char (point-min)) - (if (re-search-forward - (concat "^[ \t]+" func " ?(") - (point-max) t) - (progn - (forward-word -1) - (set-window-point win (point))) - (message "Could not find function `%s'" func))))))) - - -(defun erlang-man-display (file) - "Display FILE as a `man' file. -This is the default manual page display function. -The variables `erlang-man-display-function' contains the function -to be used." - ;; Emacs 18 doesn't `provide' man. - (condition-case nil - (require 'man) - (error nil)) - (if file - (let ((process-environment (copy-sequence process-environment))) - (if (string-match "\\(.*\\)/man[^/]*/\\([^.]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file) - (let ((dir (substring file (match-beginning 1) (match-end 1))) - (page (substring file (match-beginning 2) (match-end 2)))) - (if (fboundp 'setenv) - (setenv "MANPATH" dir) - ;; Emacs 18 - (setq process-environment (cons (concat "MANPATH=" dir) - process-environment))) - (cond ((not (and (not erlang-xemacs-p) - (= erlang-emacs-major-version 19) - (< erlang-emacs-minor-version 29))) - (manual-entry page)) - (t - ;; Emacs 19.28 and earlier versions of 19: - ;; The manual-entry command unconditionally prompts - ;; the user :-( - (funcall (symbol-function 'Man-getpage-in-background) - page)))) - (error "Can't find man page for %s\n" file))))) - - -(defun erlang-man-describe-error () - "Describe why the manual pages weren't found." - (interactive) - (with-output-to-temp-buffer "*Erlang Man Error*" - (princ "Normally, this menu should contain Erlang manual pages. - -In order to find the manual pages, the variable `erlang-root-dir' -should be bound to the name of the directory containing the Erlang -installation. The name should not include the final slash. - -Practically, you should add a line on the following form to -your ~/.emacs, or ask your system administrator to add it to -the site init file: - (setq erlang-root-dir \"/the/erlang/root/dir/goes/here\") - -For example: - (setq erlang-root-dir \"/usr/local/erlang\") - -After installing the line, kill and restart Emacs, or restart Erlang -mode with the command `M-x erlang-mode RET'."))) - -;; Skeleton code: - -;; This code is based on the package `tempo' which is part of modern -;; Emacsen. (GNU Emacs 19.25 (?) and XEmacs 19.14.) - -(defun erlang-skel-init () - "Generate the skeleton functions and menu items. -The variable `erlang-skel' contains the name and descriptions of -all skeletons. - -The skeleton routines are based on the `tempo' package. Should this -package not be present, this function does nothing." - (interactive) - (condition-case nil - (require 'tempo) - (error t)) - (if (featurep 'tempo) - (let ((skel erlang-skel) - (menu '())) - (while skel - (cond ((null (car skel)) - (setq menu (cons nil menu))) - (t - (funcall (symbol-function 'tempo-define-template) - (concat "erlang-" (nth 1 (car skel))) - ;; The tempo template used contains an `include' - ;; function call only, hence changes to the - ;; variables describing the templates take effect - ;; immdiately. - (list (list 'erlang-skel-include (nth 2 (car skel)))) - (nth 1 (car skel)) - (car (car skel)) - 'erlang-tempo-tags) - (setq menu (cons (erlang-skel-make-menu-item - (car skel)) menu)))) - (setq skel (cdr skel))) - (setq erlang-menu-skel-items - (list nil (list "Skeletons" (nreverse menu)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-skel-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init)))) - -(defun erlang-skel-make-menu-item (skel) - (let ((func (intern (concat "tempo-template-erlang-" (nth 1 skel))))) - (cond ((null (nth 3 skel)) - (list (car skel) func)) - (t - (list (car skel) - (list 'lambda '() - '(interactive) - (list 'funcall - (list 'quote (nth 3 skel)) - (list 'quote func)))))))) - -;; Functions designed to be added to the skeleton menu. -;; (Not normally used) -(defun erlang-skel-insert (func) - "Insert skeleton generated by FUNC and goto first tempo mark." - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - -(defun erlang-skel-header (func) - "Insert the header generated by FUNC at the beginning of the buffer." - (goto-char (point-min)) - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - - -;; Functions used inside the skeleton descriptions. -(defun erlang-skel-skip-blank () - (skip-chars-backward " \t") - nil) - -(defun erlang-skel-include (&rest args) - "Include a template inside another template. - -Example of use, assuming that `erlang-skel-func' is defined: - - (defvar foo-skeleton '(\"%%% New function:\" - (erlang-skel-include erlang-skel-func))) - -Technically, this function returns the `tempo' attribute`(l ...)' which -can contain other `tempo' attributes. Please see the function -`tempo-define-template' for a description of the `(l ...)' attribute." - (let ((res '()) - entry) - (while args - (setq entry (car args)) - (while entry - (setq res (cons (car entry) res)) - (setq entry (cdr entry))) - (setq args (cdr args))) - (cons 'l (nreverse res)))) - -(defvar erlang-skel-separator-length 70) - -(defun erlang-skel-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- erlang-skel-separator-length percent) ?-) - "\n"))) - -(defun erlang-skel-double-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- erlang-skel-separator-length percent) ?=) - "\n"))) - -(defun erlang-skel-dd-mmm-yyyy () - "Return the current date as a string in \"DD Mon YYYY\" form. -The first character of DD is space if the value is less than 10." - (let ((date (current-time-string))) - (format "%2d %s %s" - (erlang-string-to-int (substring date 8 10)) - (substring date 4 7) - (substring date -4)))) - -;; Indentation code: - -(defun erlang-indent-command (&optional whole-exp) - "Indent current line as Erlang code. -With argument, indent any additional lines of the same clause -rigidly along with this one." - (interactive "P") - (if whole-exp - ;; If arg, always indent this line as Erlang - ;; and shift remaining lines of clause the same amount. - (let ((shift-amt (erlang-indent-line)) - beg end) - (save-excursion - (if erlang-tab-always-indent - (beginning-of-line)) - (setq beg (point)) - (erlang-end-of-clause 1) - (setq end (point)) - (goto-char beg) - (forward-line 1) - (setq beg (point))) - (if (> end beg) - (indent-code-rigidly beg end shift-amt "\n"))) - (if (and (not erlang-tab-always-indent) - (save-excursion - (skip-chars-backward " \t") - (not (bolp)))) - (insert-tab) - (erlang-indent-line)))) - - -(defun erlang-indent-line () - "Indent current line as Erlang code. -Return the amount the indentation changed by." - (let ((pos (- (point-max) (point))) - indent beg - shift-amt) - (beginning-of-line 1) - (setq beg (point)) - (skip-chars-forward " \t") - (cond ((looking-at "%") - (setq indent (funcall comment-indent-function)) - (setq shift-amt (- indent (current-column)))) - (t - (setq indent (erlang-calculate-indent)) - (cond ((null indent) - (setq indent (current-indentation))) - ((eq indent t) - ;; This should never occur here. - (error "Erlang mode error")) - ;;((= (char-syntax (following-char)) ?\)) - ;; (setq indent (1- indent))) - ) - (setq shift-amt (- indent (current-column))))) - (if (zerop shift-amt) - nil - (delete-region beg (point)) - (indent-to indent)) - ;; If initial point was within line's indentation, position - ;; after the indentation. Else stay at same point in text. - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos))) - shift-amt)) - - -(defun erlang-indent-region (beg end) - "Indent region of Erlang code. - -This is automagically called by the user level function `indent-region'." - (interactive "r") - (save-excursion - (let ((case-fold-search nil) - (continue t) - (from-end (- (point-max) end)) - indent-point;; The beginning of the current line - indent;; The indent amount - state) - (goto-char beg) - (beginning-of-line) - (setq indent-point (point)) - (erlang-beginning-of-clause) - ;; Parse the Erlang code from the beginning of the clause to - ;; the beginning of the region. - (while (< (point) indent-point) - (setq state (erlang-partial-parse (point) indent-point state))) - ;; Indent every line in the region - (while continue - (goto-char indent-point) - (skip-chars-forward " \t") - (cond ((looking-at "%") - ;; Do not use our stack to help the user to customize - ;; comment indentation. - (setq indent (funcall comment-indent-function))) - ((looking-at "$") - ;; Don't indent empty lines. - (setq indent 0)) - (t - (setq indent - (save-excursion - (erlang-calculate-stack-indent (point) state))) - (cond ((null indent) - (setq indent (current-indentation))) - ((eq indent t) - ;; This should never occur here. - (error "Erlang mode error")) - ;;((= (char-syntax (following-char)) ?\)) - ;; (setq indent (1- indent))) - ))) - (if (zerop (- indent (current-column))) - nil - (delete-region indent-point (point)) - (indent-to indent)) - ;; Find the next line in the region - (goto-char indent-point) - (save-excursion - (forward-line 1) - (setq indent-point (point))) - (if (>= from-end (- (point-max) indent-point)) - (setq continue nil) - (while (< (point) indent-point) - (setq state (erlang-partial-parse - (point) indent-point state)))))))) - - -(defun erlang-indent-current-buffer () - "Indent current buffer as Erlang code." - (interactive) - (save-excursion - (save-restriction - (widen) - (erlang-indent-region (point-min) (point-max))))) - - -(defun erlang-indent-function () - "Indent current Erlang function." - (interactive) - (save-excursion - (let ((end (progn (erlang-end-of-function 1) (point))) - (beg (progn (erlang-beginning-of-function 1) (point)))) - (erlang-indent-region beg end)))) - - -(defun erlang-indent-clause () - "Indent current Erlang clause." - (interactive) - (save-excursion - (let ((end (progn (erlang-end-of-clause 1) (point))) - (beg (progn (erlang-beginning-of-clause 1) (point)))) - (erlang-indent-region beg end)))) - - -(defmacro erlang-push (x stack) (list 'setq stack (list 'cons x stack))) -(defmacro erlang-pop (stack) (list 'setq stack (list 'cdr stack))) -;; Would much prefer to make caddr a macro but this clashes. -(defun erlang-caddr (x) (car (cdr (cdr x)))) - - -(defun erlang-calculate-indent (&optional parse-start) - "Compute appropriate indentation for current line as Erlang code. -Return nil if line starts inside string, t if in a comment." - (save-excursion - (let ((indent-point (point)) - (case-fold-search nil) - (state nil)) - (if parse-start - (goto-char parse-start) - (erlang-beginning-of-clause)) - (while (< (point) indent-point) - (setq state (erlang-partial-parse (point) indent-point state))) - (erlang-calculate-stack-indent indent-point state)))) - -(defun erlang-show-syntactic-information () - "Show syntactic information for current line." - - (interactive) - - (save-excursion - (let ((starting-point (point)) - (case-fold-search nil) - (state nil)) - (erlang-beginning-of-clause) - (while (< (point) starting-point) - (setq state (erlang-partial-parse (point) starting-point state))) - (message "%S" state)))) - - -(defun erlang-partial-parse (from to &optional state) - "Parse Erlang syntax starting at FROM until TO, with an optional STATE. -Value is list (stack token-start token-type in-what)." - (goto-char from) ; Start at the beginning - (erlang-skip-blank to) - (let ((cs (char-syntax (following-char))) - (stack (car state)) - (token (point)) - in-what) - (cond - - ;; Done: Return previous state. - ((>= token to) - (setq token (nth 1 state)) - (setq cs (nth 2 state)) - (setq in-what (nth 3 state))) - - ;; Word constituent: check and handle keywords. - ((= cs ?w) - (cond ((looking-at "\\(end\\|after\\)[^_a-zA-Z0-9]") - ;; Must pop top icr layer, `after' will push a new - ;; layer next. - (progn - (while (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (if (and stack (memq (car (car stack)) '(icr begin fun try))) - (erlang-pop stack)))) - ((looking-at "catch\\b.*of") - t) - ((looking-at "catch\\b\\s *\\($\\|%\\|.*->\\)") - ;; Must pop top icr layer, `catch' in try/catch - ;;will push a new layer next. - (progn - (while (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (if (and stack (memq (car (car stack)) '(icr begin try))) - (erlang-pop stack)))) - ) - (cond ((looking-at "\\(if\\|case\\|receive\\)[^_a-zA-Z0-9]") - ;; Must push a new icr (if/case/receive) layer. - (erlang-push (list 'icr token (current-column)) stack)) - ((looking-at "\\(try\\|after\\)[^_a-zA-Z0-9]") - ;; Must handle separately, try catch or try X of -> catch - ;; same for `after', it could be - ;; receive after Time -> X end, or - ;; try after X end - (erlang-push (list 'try token (current-column)) stack)) - ((looking-at "\\(of\\)[^_a-zA-Z0-9]") - ;; Must handle separately, try X of -> catch - (if (and stack (eq (car (car stack)) 'try)) - (let ((try-column (nth 2 (car stack))) - (try-pos (nth 1 (car stack)))) - (erlang-pop stack) - (erlang-push (list 'icr try-pos try-column) stack)))) - - ((looking-at "\\(fun\\)[^_a-zA-Z0-9]") - ;; Push a new layer if we are defining a `fun' - ;; expression, not when we are refering an existing - ;; function. 'fun's defines are only indented one level now. - (if (save-excursion - (goto-char (match-end 1)) - (erlang-skip-blank to) - ;; Use erlang-variable-regexp here to look for an - ;; optional variable name to match EEP37 named funs. - (if (looking-at erlang-variable-regexp) - (progn - (goto-char (match-end 0)) - (erlang-skip-blank to))) - (eq (following-char) ?\()) - (erlang-push (list 'fun token (current-column)) stack))) - ((looking-at "\\(begin\\)[^_a-zA-Z0-9]") - (erlang-push (list 'begin token (current-column)) stack)) - ;; Normal when case - ;;((looking-at "when\\s ") - ;;((looking-at "when\\s *\\($\\|%\\)") - ((looking-at "when[^_a-zA-Z0-9]") - (erlang-push (list 'when token (current-column)) stack)) - ((looking-at "catch\\b.*of") - t) - ((looking-at "catch\\b\\s *\\($\\|%\\|.*->\\)") - (erlang-push (list 'icr token (current-column)) stack)) - ;;(erlang-push (list '-> token (current-column)) stack)) - ;;((looking-at "^of$") - ;; (erlang-push (list 'icr token (current-column)) stack) - ;;(erlang-push (list '-> token (current-column)) stack)) - ) - (forward-sexp 1)) - ;; String: Try to skip over it. (Catch error if not complete.) - ((= cs ?\") - (condition-case nil - (progn - (forward-sexp 1) - (if (> (point) to) - (progn - (setq in-what 'string) - (goto-char to)))) - (error - (setq in-what 'string) - (goto-char to)))) - - ;; Expression prefix e.i. $ or ^ (Note ^ can be in the character - ;; literal $^ or part of string and $ outside of a string denotes - ;; a character literal) - ((= cs ?') - (cond - ((= (following-char) ?\") ;; $ or ^ was the last char in a string - (forward-char 1)) - (t - ;; Maybe a character literal, quote the next char to avoid - ;; situations as $" being seen as the begining of a string. - ;; Note the quoting something in the middle of a string is harmless. - (quote (following-char)) - (forward-char 1)))) - - ;; Symbol constituent or punctuation - - ((memq cs '(?. ?_)) - (cond - - ;; Clause end - ((= (following-char) ?\;) - (if (eq (car (car (last stack))) 'spec) - (while (memq (car (car stack)) '(when ::)) - (erlang-pop stack))) - (if (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (forward-char 1)) - - ;; Parameter separator - ((looking-at ",") - (forward-char 1) - (if (and stack (eq (car (car stack)) '::)) - ;; Type or spec - (erlang-pop stack))) - - ;; Function end - ((looking-at "\\.\\(\\s \\|\n\\|\\s<\\)") - (setq stack nil) - (forward-char 1)) - - ;; Function head - ((looking-at "->") - (if (and stack (eq (car (car stack)) 'when)) - (erlang-pop stack)) - (erlang-push (list '-> token (current-column)) stack) - (forward-char 2)) - - ;; List-comprehension divider - ((looking-at "||") - (erlang-push (list '|| token (current-column)) stack) - (forward-char 2)) - - ;; Bit-syntax open paren - ((looking-at "<<") - (erlang-push (list '<< token (current-column)) stack) - (forward-char 2)) - - ;; Bbit-syntax close paren - ((looking-at ">>") - (while (memq (car (car stack)) '(|| ->)) - (erlang-pop stack)) - (cond ((eq (car (car stack)) '<<) - (erlang-pop stack)) - ((memq (car (car stack)) '(icr begin fun)) - (error "Missing `end'")) - (t - (error "Unbalanced parentheses"))) - (forward-char 2)) - - ;; Macro - ((= (following-char) ??) - ;; Skip over the ? - (forward-char 1) - ) - - ;; Type spec's - ((looking-at "-type\\s \\|-opaque\\s ") - (if stack - (forward-char 1) - (erlang-push (list 'icr token (current-column)) stack) - (forward-char 6))) - ((looking-at "-spec\\s ") - (if stack - (forward-char 1) - (forward-char 6) - (skip-chars-forward "^(\n") - (erlang-push (list 'spec (point) (current-column)) stack) - )) - - ;; Type spec delimiter - ((looking-at "::") - (erlang-push (list ':: token (current-column)) stack) - (forward-char 2)) - - ;; Don't follow through in the clause below - ;; '|' don't need spaces around it - ((looking-at "|") - (forward-char 1)) - - ;; Other punctuation: Skip over it and any following punctuation - ((= cs ?.) - ;; Skip over all characters in the operand. - (skip-syntax-forward ".")) - - ;; Other char: Skip over it. - (t - (forward-char 1)))) - - ;; Open parenthesis - ((= cs ?\() - (erlang-push (list '\( token (current-column)) stack) - (forward-char 1)) - - ;; Close parenthesis - ((= cs ?\)) - (while (memq (car (car stack)) '(|| -> :: when)) - (erlang-pop stack)) - (cond ((eq (car (car stack)) '\() - (erlang-pop stack) - (if (and (eq (car (car stack)) 'fun) - (or (eq (car (car (last stack))) 'spec) - (eq (car (car (cdr stack))) '::))) ;; -type() - ;; Inside fun type def ') closes fun definition - (erlang-pop stack))) - ((eq (car (car stack)) 'icr) - (erlang-pop stack) - ;; Normal catch not try-catch might have caused icr - ;; and then incr should be removed and is not an error. - (if (eq (car (car stack)) '\() - (erlang-pop stack) - (error "Missing `end'") - )) - ((eq (car (car stack)) 'begin) - (error "Missing `end'")) - (t - (error "Unbalanced parenthesis")) - ) - (forward-char 1)) - - ;; Character quote: Skip it and the quoted char. - ((= cs ?/) - (forward-char 2)) - - ;; Character escape: Skip it and the escape sequence. - ((= cs ?\\) - (forward-char 1) - (skip-syntax-forward "w")) - - ;; Everything else - (t - (forward-char 1))) - (list stack token cs in-what))) - -(defun erlang-calculate-stack-indent (indent-point state) - "From the given last position and state (stack) calculate indentation. -Return nil if inside string, t if in a comment." - (let* ((stack (and state (car state))) - (token (nth 1 state)) - (stack-top (and stack (car stack)))) - (cond ((null state) ;No state - 0) - ((nth 3 state) - ;; Return nil or t. - (eq (nth 3 state) 'comment)) - ((null stack) - (if (looking-at "when[^_a-zA-Z0-9]") - erlang-indent-guard - 0)) - ((eq (car stack-top) '\() - ;; Element of list, tuple or part of an expression, - (cond ((null erlang-argument-indent) - ;; indent to next column. - (1+ (nth 2 stack-top))) - ((= (char-syntax (following-char)) ?\)) - (goto-char (nth 1 stack-top)) - (cond ((looking-at "[({]\\s *\\($\\|%\\)") - ;; Line ends with parenthesis. - (let ((previous (erlang-indent-find-preceding-expr)) - (stack-pos (nth 2 stack-top))) - (if (>= previous stack-pos) stack-pos - (- (+ previous erlang-argument-indent) 1)))) - (t - (nth 2 stack-top)))) - ((= (following-char) ?,) - ;; a comma at the start of the line: line up with opening parenthesis. - (nth 2 stack-top)) - (t - (goto-char (nth 1 stack-top)) - (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)") - ;; Line ends with parenthesis. - (erlang-indent-parenthesis (nth 2 stack-top))) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (1+ (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column))))) - (erlang-indent-standard indent-point token base 't))))) - ;; - ((eq (car stack-top) '<<) - ;; Element of binary (possible comprehension) expression, - (cond ((null erlang-argument-indent) - ;; indent to next column. - (+ 2 (nth 2 stack-top))) - ((looking-at "\\(>>\\)[^_a-zA-Z0-9]") - (nth 2 stack-top)) - (t - (goto-char (nth 1 stack-top)) - ;; Indent to the same column as the first - ;; argument. - (goto-char (+ 2 (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column)))) - - ((memq (car stack-top) '(icr fun spec)) - ;; The default indentation is the column of the option - ;; directly following the keyword. (This does not apply to - ;; `case'.) Should no option be on the same line, the - ;; indentation is the indentation of the keyword + - ;; `erlang-indent-level'. - ;; - ;; `after' should be indented to the same level as the - ;; corresponding receive. - (cond ((looking-at "\\(after\\|of\\)\\($\\|[^_a-zA-Z0-9]\\)") - (nth 2 stack-top)) - ((looking-at "when[^_a-zA-Z0-9]") - ;; Handling one when part - (+ (nth 2 stack-top) erlang-indent-level erlang-indent-guard)) - (t - (save-excursion - (goto-char (nth 1 stack-top)) - (if (looking-at "case[^_a-zA-Z0-9]") - (+ (nth 2 stack-top) erlang-indent-level) - (skip-chars-forward "a-z") - (skip-chars-forward " \t") - (if (memq (following-char) '(?% ?\n)) - (+ (nth 2 stack-top) erlang-indent-level) - (current-column)))))) - ) - ((and (eq (car stack-top) '||) (looking-at "\\(]\\|>>\\)[^_a-zA-Z0-9]")) - (nth 2 (car (cdr stack)))) - ;; Real indentation, where operators create extra indentation etc. - ((memq (car stack-top) '(-> || try begin)) - (if (looking-at "\\(of\\)[^_a-zA-Z0-9]") - (nth 2 stack-top) - (goto-char (nth 1 stack-top)) - ;; Check if there is more code after the '->' on the - ;; same line. If so use this indentation as base, else - ;; use parent indentation + 2 * level as base. - (let ((off erlang-indent-level) - (skip 2)) - (cond ((null (cdr stack))) ; Top level in function. - ((eq (car stack-top) 'begin) - (setq skip 5)) - ((eq (car stack-top) 'try) - (setq skip 5)) - ((eq (car stack-top) '->) - ;; If in fun definition use standard indent level not double - ;;(if (not (eq (car (car (cdr stack))) 'fun)) - ;; Removed it made multi clause fun's look to bad - (setq off (* 2 erlang-indent-level)))) ;; ) - (let ((base (erlang-indent-find-base stack indent-point off skip))) - ;; Special cases - (goto-char indent-point) - (cond ((looking-at "\\(end\\|after\\)\\($\\|[^_a-zA-Z0-9]\\)") - (if (eq (car stack-top) '->) - (erlang-pop stack)) - (if stack - (erlang-caddr (car stack)) - 0)) - ((looking-at "catch\\b\\($\\|[^_a-zA-Z0-9]\\)") - ;; Are we in a try - (let ((start (if (eq (car stack-top) '->) - (car (cdr stack)) - stack-top))) - (if (null start) nil - (goto-char (nth 1 start))) - (cond ((looking-at "try\\($\\|[^_a-zA-Z0-9]\\)") - (progn - (if (eq (car stack-top) '->) - (erlang-pop stack)) - (if stack - (erlang-caddr (car stack)) - 0))) - (t (erlang-indent-standard indent-point token base 'nil))))) ;; old catch - (t - (erlang-indent-standard indent-point token base 'nil) - )))) - )) - ((eq (car stack-top) 'when) - (goto-char (nth 1 stack-top)) - (if (looking-at "when\\s *\\($\\|%\\)") - (progn - (erlang-pop stack) - (if (and stack (memq (nth 0 (car stack)) '(icr fun))) - (progn - (goto-char (nth 1 (car stack))) - (+ (nth 2 (car stack)) erlang-indent-guard - ;; receive XYZ or receive - ;; XYZ - ;; This if thing does not seem to be needed - ;;(if (looking-at "[a-z]+\\s *\\($\\|%\\)") - ;; erlang-indent-level - ;; (* 2 erlang-indent-level)))) - (* 2 erlang-indent-level))) - ;;erlang-indent-level)) - (+ erlang-indent-level erlang-indent-guard))) - ;; "when" is followed by code, let's indent to the same - ;; column. - (forward-char 4) ; Skip "when" - (skip-chars-forward " \t") - (current-column))) - ;; Type and Spec indentation - ((eq (car stack-top) '::) - (if (looking-at "}") - ;; Closing record definition with types - ;; pop stack and recurse - (erlang-calculate-stack-indent indent-point - (cons (erlang-pop stack) (cdr state))) - (cond ((null erlang-argument-indent) - ;; indent to next column. - (+ 2 (nth 2 stack-top))) - ((looking-at "::[^_a-zA-Z0-9]") - (nth 2 stack-top)) - (t - (let ((start-alternativ (if (looking-at "|") 2 0))) - (goto-char (nth 1 stack-top)) - (- (cond ((looking-at "::\\s *\\($\\|%\\)") - ;; Line ends with :: - (if (eq (car (car (last stack))) 'spec) - (+ (erlang-indent-find-preceding-expr 1) - erlang-argument-indent) - (+ (erlang-indent-find-preceding-expr 2) - erlang-argument-indent))) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (+ 2 (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column))) start-alternativ)))))) - ))) - -(defun erlang-indent-standard (indent-point token base inside-parenthesis) - "Standard indent when in blocks or tuple or arguments. - Look at last thing to see in what state we are, move relative to the base." - (goto-char token) - (cond ((looking-at "||\\|,\\|->\\||") - base) - ((erlang-at-keyword) - (+ (current-column) erlang-indent-level)) - ((or (= (char-syntax (following-char)) ?.) - (erlang-at-operator)) - (+ base erlang-indent-level)) - (t - (goto-char indent-point) - (cond ((memq (following-char) '(?\( )) - ;; Function application. - (+ (erlang-indent-find-preceding-expr) - erlang-argument-indent)) - ;; Empty line, or end; treat it as the end of - ;; the block. (Here we have a choice: should - ;; the user be forced to reindent continued - ;; lines, or should the "end" be reindented?) - - ;; Avoid treating comments a continued line. - ((= (following-char) ?%) - base) - ;; Continued line (e.g. line beginning - ;; with an operator.) - (t - (if (or (erlang-at-operator) (not inside-parenthesis)) - (+ base erlang-indent-level) - base)))))) - -(defun erlang-indent-find-base (stack indent-point &optional offset skip) - "Find the base column for current stack." - (or skip (setq skip 2)) - (or offset (setq offset erlang-indent-level)) - (save-excursion - (let* ((stack-top (car stack))) - (goto-char (nth 1 stack-top)) - (if (< skip (- (point-max) (point))) - (progn - (forward-char skip) - (if (looking-at "\\s *\\($\\|%\\)") - (progn - (if (memq (car stack-top) '(-> ||)) - (erlang-pop stack)) - ;; Take parent identation + offset, - ;; else just erlang-indent-level if no parent - (if stack - (+ (erlang-caddr (car stack)) - offset) - erlang-indent-level)) - (erlang-skip-blank indent-point) - (current-column))) - (+ (current-column) skip))))) - - -;; Does not handle `begin' .. `end'. -(defun erlang-indent-find-preceding-expr (&optional arg) - "Return the first column of the preceding expression. -This assumes that the preceding expression is either simple -\(i.e. an atom) or parenthesized." - (save-excursion - (or arg (setq arg 1)) - (ignore-errors (forward-sexp (- arg))) - (let ((col (current-column))) - (skip-chars-backward " \t") - ;; Special hack to handle: (note line break) - ;; [#myrecord{ - ;; foo = foo}] - ;; where the call (forward-sexp -1) will fail when point is at the `#'. - (or - (ignore-errors - ;; Needed to match the colon in "'foo':'bar'". - (cond ((eq (preceding-char) ?:) - (backward-char 1) - (forward-sexp -1) - (current-column)) - ((eq (preceding-char) ?#) - ;; We may now be at: - ;; - either a construction of a new record - ;; - or update of a record, in which case we want - ;; the column of the expression to be updated. - ;; - ;; To see which of the two cases we are at, we first - ;; move an expression backwards, check for keywords, - ;; then immediately an expression forwards. Moving - ;; backwards skips past tokens like `,' or `->', but - ;; when moving forwards again, we won't skip past such - ;; tokens. We use this: if, after having moved - ;; forwards, we're back where we started, then it was - ;; a record update. - ;; The check for keywords is to detect cases like: - ;; case Something of #record_construction{...} - (backward-char 1) - (let ((record-start (point)) - (record-start-col (current-column))) - (forward-sexp -1) - (let ((preceding-expr-col (current-column)) - ;; white space definition according to erl_scan - (white-space "\000-\040\200-\240")) - (if (erlang-at-keyword) - ;; The (forward-sexp -1) call moved past a keyword - (1+ record-start-col) - (forward-sexp 1) - (skip-chars-forward white-space record-start) - ;; Are we back where we started? If so, it was an update. - (if (= (point) record-start) - preceding-expr-col - (goto-char record-start) - (1+ (current-column))))))) - (t col))) - col)))) - -(defun erlang-indent-parenthesis (stack-position) - (let ((previous (erlang-indent-find-preceding-expr))) - (if (> previous stack-position) - (+ stack-position erlang-argument-indent) - (+ previous erlang-argument-indent)))) - -(defun erlang-skip-blank (&optional lim) - "Skip over whitespace and comments until limit reached." - (or lim (setq lim (point-max))) - (let (stop) - (while (and (not stop) (< (point) lim)) - (cond ((= (following-char) ?%) - (skip-chars-forward "^\n" lim)) - ((= (following-char) ?\n) - (skip-chars-forward "\n" lim)) - ((looking-at "\\s ") - (if (re-search-forward "\\S " lim 'move) - (forward-char -1))) - (t - (setq stop t)))) - stop)) - -(defun erlang-at-keyword () - "Are we looking at an Erlang keyword which will increase indentation?" - (looking-at (concat "\\(when\\|if\\|fun\\|case\\|begin\\|" - "of\\|receive\\|after\\|catch\\|try\\)\\b"))) - -(defun erlang-at-operator () - "Are we looking at an Erlang operator?" - (looking-at - "\\(bnot\\|div\\|mod\\|band\\|bor\\|bxor\\|bsl\\|bsr\\)\\b")) - -(defun erlang-comment-indent () - "Compute Erlang comment indentation. - -Used both by `indent-for-comment' and the Erlang specific indentation -commands." - (cond ((looking-at "%%%") 0) - ((looking-at "%%") - (or (erlang-calculate-indent) - (current-indentation))) - (t - (save-excursion - (skip-chars-backward " \t") - (max (if (bolp) 0 (1+ (current-column))) - comment-column))))) - -;;; Erlang movement commands - -;; All commands below work as movement commands. I.e. if the point is -;; at the end of the clause, and the command `erlang-end-of-clause' is -;; executed, the point is moved to the end of the NEXT clause. (This -;; mimics the behaviour of `end-of-defun'.) -;; -;; Personally I would like to rewrite them to be "pure", and add a set -;; of movement functions, like `erlang-next-clause', -;; `erlang-previous-clause', and the same for functions. -;; -;; The current implementation makes it hopeless to use the functions as -;; subroutines in more complex commands. /andersl - -(defun erlang-beginning-of-clause (&optional arg) - "Move backward to previous start of clause. -With argument, do this that many times. -Return t unless search stops due to end of buffer." - (interactive "p") - (or arg (setq arg 1)) - (if (< arg 0) - ;; Step back to the end of the previous line, unless we are at - ;; the beginning of the buffer. The reason for this move is - ;; that the regexp below includes the last character of the - ;; previous line. - (if (bobp) - (or (looking-at "\n") - (forward-char 1)) - (forward-char -1) - (if (looking-at "\\`\n") - (forward-char 1)))) - ;; The regexp matches a function header that isn't - ;; included in a string. - (and (re-search-forward "\\(\\`\\|\\`\n\\|[^\\]\n\\)\\(-?[a-z]\\|'\\|-\\)" - nil 'move (- arg)) - (let ((beg (match-beginning 2))) - (and beg (goto-char beg)) - t))) - -(defun erlang-end-of-clause (&optional arg) - "Move to the end of the current clause. -With argument, do this that many times." - (interactive "p") - (or arg (setq arg 1)) - (while (and (looking-at "[ \t]*[%\n]") - (zerop (forward-line 1)))) - ;; Move to the next clause. - (erlang-beginning-of-clause (- arg)) - (beginning-of-line);; Just to be sure... - (let ((continue t)) - (while (and (not (bobp)) continue) - (forward-line -1) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - nil - (end-of-line) - (setq continue nil))))) - -(defun erlang-mark-clause () - "Put mark at end of clause, point at beginning." - (interactive) - (push-mark (point)) - (erlang-end-of-clause 1) - ;; Sets the region. In Emacs 19 and XEmacs, we want to activate - ;; the region. - (condition-case nil - (push-mark (point) nil t) - (error (push-mark (point)))) - (erlang-beginning-of-clause 1) - ;; The above function deactivates the mark. - (if (boundp 'deactivate-mark) - (funcall (symbol-function 'set) 'deactivate-mark nil))) - -(defun erlang-beginning-of-function (&optional arg) - "Move backward to previous start of function. -With positive argument, do this that many times. -With negative argument, search forward. - -Return t unless search stops due to end of buffer." - (interactive "p") - (or arg (setq arg 1)) - (cond - ;; Search backward - ((> arg 0) - (while (and (> arg 0) - (and (erlang-beginning-of-clause 1) - (let ((start (point)) - (name (erlang-name-of-function)) - (arity (erlang-get-function-arity))) - ;; Note: "arity" is nil for e.g. "-import", hence - ;; two "-import" clauses are not considered to - ;; be part of the same function. - (while (and (erlang-beginning-of-clause 1) - (string-equal name - (erlang-name-of-function)) - arity - (equal arity - (erlang-get-function-arity))) - (setq start (point))) - (goto-char start) - t))) - (setq arg (1- arg)))) - ;; Search forward - ((< arg 0) - (end-of-line) - (erlang-beginning-of-clause 1) - ;; Step -arg functions forward. - (while (and (< arg 0) - ;; Step one function forward, or stop if the end of - ;; the buffer was reached. Return t if we found the - ;; function. - (let ((name (erlang-name-of-function)) - (arity (erlang-get-function-arity)) - (found (erlang-beginning-of-clause -1))) - (while (and found - (string-equal name (erlang-name-of-function)) - arity - (equal arity - (erlang-get-function-arity))) - (setq found (erlang-beginning-of-clause -1))) - found)) - (setq arg (1+ arg))))) - (zerop arg)) - - -(defun erlang-end-of-function (&optional arg) - "Move forward to next end of function. - -With argument, do this that many times. -With negative argument go towards the beginning of the buffer." - (interactive "p") - (or arg (setq arg 1)) - (let ((first t)) - ;; Forward - (while (and (> arg 0) (< (point) (point-max))) - (let ((pos (point))) - (while (progn - (if (and first - (progn - (forward-char 1) - (erlang-beginning-of-clause 1))) - nil - (or (bobp) (forward-char -1)) - (erlang-beginning-of-clause -1)) - (setq first nil) - (erlang-pass-over-function) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - (forward-line 1)) - (<= (point) pos)))) - (setq arg (1- arg))) - ;; Backward - (while (< arg 0) - (let ((pos (point))) - (erlang-beginning-of-clause 1) - (erlang-pass-over-function) - (forward-line 1) - (if (>= (point) pos) - (if (erlang-beginning-of-function 2) - (progn - (erlang-pass-over-function) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - (forward-line 1))) - (goto-char (point-min))))) - (setq arg (1+ arg))))) - -(eval-and-compile - (if (default-boundp 'beginning-of-defun-function) - (defalias 'erlang-mark-function 'mark-defun) - (defun erlang-mark-function () - "Put mark at end of function, point at beginning." - (interactive) - (push-mark (point)) - (erlang-end-of-function 1) - ;; Sets the region. In Emacs 19 and XEmacs, we want to activate - ;; the region. - (condition-case nil - (push-mark (point) nil t) - (error (push-mark (point)))) - (erlang-beginning-of-function 1) - ;; The above function deactivates the mark. - (if (boundp 'deactivate-mark) - (funcall (symbol-function 'set) 'deactivate-mark nil))))) - -(defun erlang-pass-over-function () - (while (progn - (erlang-skip-blank) - (and (not (looking-at "\\.\\(\\s \\|\n\\|\\s<\\)")) - (not (eobp)))) - (forward-sexp 1)) - (if (not (eobp)) - (forward-char 1))) - -(defun erlang-name-of-function () - (save-excursion - ;; Skip over attribute leader. - (if (looking-at "-[ \t]*") - (re-search-forward "-[ \t]*" nil 'move)) - (let ((start (point))) - (forward-sexp 1) - (buffer-substring start (point))))) - - -;;; Miscellaneous - -(defun erlang-fill-paragraph (&optional justify) - "Like \\[fill-paragraph], but handle Erlang comments. -If any of the current line is a comment, fill the comment or the -paragraph of it that point is in, preserving the comment's indentation -and initial `%':s." - (interactive "P") - (let ((has-comment nil) - ;; If has-comment, the appropriate fill-prefix for the comment. - comment-fill-prefix) - ;; Figure out what kind of comment we are looking at. - (save-excursion - (beginning-of-line) - (cond - ;; Find the command prefix. - ((looking-at (concat "\\s *" comment-start-skip)) - (setq has-comment t) - (setq comment-fill-prefix (buffer-substring (match-beginning 0) - (match-end 0)))) - ;; A line with some code, followed by a comment? Remember that the - ;; % which starts the comment shouldn't be part of a string or - ;; character. - ((progn - (while (not (looking-at "%\\|$")) - (skip-chars-forward "^%\n\"\\\\") - (cond - ((eq (char-after (point)) ?\\) (forward-char 2)) - ((eq (char-after (point)) ?\") (forward-sexp 1)))) - (looking-at comment-start-skip)) - (setq has-comment t) - (setq comment-fill-prefix - (concat (make-string (current-column) ? ) - (buffer-substring (match-beginning 0) (match-end 0))))))) - (if (not has-comment) - (fill-paragraph justify) - ;; Narrow to include only the comment, and then fill the region. - (save-restriction - (narrow-to-region - ;; Find the first line we should include in the region to fill. - (save-excursion - (while (and (zerop (forward-line -1)) - (looking-at "^\\s *%"))) - ;; We may have gone to far. Go forward again. - (or (looking-at "^\\s *%") - (forward-line 1)) - (point)) - ;; Find the beginning of the first line past the region to fill. - (save-excursion - (while (progn (forward-line 1) - (looking-at "^\\s *%"))) - (point))) - ;; Lines with only % on them can be paragraph boundaries. - (let ((paragraph-start (concat paragraph-start "\\|^[ \t%]*$")) - (paragraph-separate (concat paragraph-start "\\|^[ \t%]*$")) - (fill-prefix comment-fill-prefix)) - (fill-paragraph justify)))))) - - -(defun erlang-uncomment-region (beg end) - "Uncomment all commented lines in the region." - (interactive "r") - (uncomment-region beg end)) - - -(defun erlang-generate-new-clause () - "Create additional Erlang clause header. - -Parses the source file for the name of the current Erlang function. -Create the header containing the name, A pair of parentheses, -and an arrow. The space between the function name and the -first parenthesis is preserved. The point is placed between -the parentheses." - (interactive) - (let ((name (save-excursion - (and (erlang-beginning-of-clause) - (erlang-get-function-name t)))) - (arrow (save-excursion - (and (erlang-beginning-of-clause) - (erlang-get-function-arrow))))) - (if (or (null arrow) (null name)) - (error "Can't find name of current Erlang function")) - (if (and (bolp) (eolp)) - nil - (end-of-line) - (newline)) - (insert name) - (save-excursion - (insert ") " arrow)) - (if erlang-new-clause-with-arguments - (erlang-clone-arguments)))) - - -(defun erlang-clone-arguments () - "Insert, at the point, the argument list of the previous clause. - -The mark is set at the beginning of the inserted text, the point -at the end." - (interactive) - (let ((args (save-excursion - (beginning-of-line) - (and (erlang-beginning-of-clause) - (erlang-get-function-arguments)))) - (p (point))) - (if (null args) - (error "Can't clone argument list")) - (insert args) - (set-mark p))) - -;;; Information retrieval functions. - -(defun erlang-buffer-substring (beg end) - "Like `buffer-substring-no-properties'. -Although, this function works on all versions of Emacs." - (if (fboundp 'buffer-substring-no-properties) - (funcall (symbol-function 'buffer-substring-no-properties) beg end) - (buffer-substring beg end))) - - -(defun erlang-get-module () - "Return the name of the module as specified by `-module'. - -Return nil if file contains no `-module' attribute." - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (let ((md (match-data))) - (unwind-protect - (if (re-search-forward - (eval-when-compile - (concat "^-module\\s *(\\s *\\(\\(" - erlang-atom-regexp - "\\)?\\)\\s *)\\s *\\.")) - (point-max) t) - (erlang-remove-quotes - (erlang-buffer-substring (match-beginning 1) - (match-end 1))) - nil) - (store-match-data md)))))) - - -(defun erlang-get-module-from-file-name (&optional file) - "Extract the module name from a file name. - -First, the directory part is removed. Second, the part of the file name -matching `erlang-file-name-extension-regexp' is removed. - -Should the match fail, nil is returned. - -By modifying `erlang-file-name-extension-regexp' to match files other -than Erlang source files, Erlang specific functions could be applied on -non-Erlang files. Most notably; the support for Erlang modules in the -tags system could be used by files written in other languages." - (or file (setq file buffer-file-name)) - (if (null file) - nil - (setq file (file-name-nondirectory file)) - (if (string-match erlang-file-name-extension-regexp file) - (substring file 0 (match-beginning 0)) - nil))) - - -;; Used by `erlang-get-export' and `erlang-get-import'. - -(defun erlang-get-function-arity-list () - "Parse list of `function/arity' as used by `-import' and `-export'. - -Point must be before the opening bracket. When the -function returns the point will be placed after the closing bracket. - -The function does not return an error if the list is incorrectly -formatted. - -Return list of (function . arity). The order of the returned list -corresponds to the order of the parsed Erlang list." - (let ((res '())) - (erlang-skip-blank) - (forward-char 1) - (if (not (eq (preceding-char) ?\[)) - '() ; Not looking at an Erlang list. - (while ; Note: `while' has no body. - (progn - (erlang-skip-blank) - (and (looking-at (eval-when-compile - (concat erlang-atom-regexp "/\\([0-9]+\\)\\>"))) - (progn - (setq res (cons - (cons - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 1) (match-end 1))) - (erlang-string-to-int - (erlang-buffer-substring - (match-beginning - (+ 1 erlang-atom-regexp-matches)) - (match-end - (+ 1 erlang-atom-regexp-matches))))) - res)) - (goto-char (match-end 0)) - (erlang-skip-blank) - (forward-char 1) - ;; Test if there are more exported functions. - (eq (preceding-char) ?,)))))) - (nreverse res))) - - -;;; Note that `-export' and the open parenthesis must be written on -;;; the same line. - -(defun erlang-get-export () - "Return a list of `(function . arity)' as specified by `-export'." - (save-excursion - (goto-char (point-min)) - (let ((md (match-data)) - (res '())) - (unwind-protect - (progn - (while (re-search-forward "^-export\\s *(" (point-max) t) - (erlang-skip-blank) - (setq res (nconc res (erlang-get-function-arity-list)))) - res) - (store-match-data md))))) - - -(defun erlang-get-import () - "Parse an Erlang source file for imported functions. - -Return an alist with module name as car part and list of conses containing -function and arity as cdr part." - (save-excursion - (goto-char (point-min)) - (let ((md (match-data)) - (res '())) - (unwind-protect - (progn - (while (re-search-forward "^-import\\s *(" (point-max) t) - (erlang-skip-blank) - (if (looking-at erlang-atom-regexp) - (let ((module (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 0) - (match-end 0))))) - (goto-char (match-end 0)) - (erlang-skip-blank) - (if (eq (following-char) ?,) - (progn - (forward-char 1) - (erlang-skip-blank) - (let ((funcs (erlang-get-function-arity-list)) - (pair (assoc module res))) - (if pair - (setcdr pair (nconc (cdr pair) funcs)) - (setq res (cons (cons module funcs) - res))))))))) - (nreverse res)) - (store-match-data md))))) - - -(defun erlang-get-function-name (&optional arg) - "Return name of current function, or nil. - -If optional argument is non-nil, everything up to and including -the first `(' is returned. - -Normally used in conjunction with `erlang-beginning-of-clause', e.g.: - (save-excursion - (if (not (eobp)) (forward-char 1)) - (and (erlang-beginning-of-clause) - (erlang-get-function-name t)))" - (let ((n (if arg 0 1))) - (and (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *("))) - (erlang-buffer-substring (match-beginning n) (match-end n))))) - - -(defun erlang-get-function-arrow () - "Return arrow of current function, could be \"->\" or nil. - -Normally used in conjunction with `erlang-beginning-of-clause', e.g.: - (save-excursion - (if (not (eobp)) (forward-char 1)) - (and (erlang-beginning-of-clause) - (erlang-get-function-arrow)))" - (and - (save-excursion - (re-search-forward "->" (point-max) t) - (erlang-buffer-substring (- (point) 2) (+ (point) 1))))) - -(defun erlang-get-function-arity () - "Return the number of arguments of function at point, or nil." - (and (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *("))) - (save-excursion - (goto-char (match-end 0)) - (condition-case nil - (let ((res 0) - (cont t)) - (while cont - (cond ((eobp) - (setq res nil) - (setq cont nil)) - ((looking-at "\\s *)") - (setq cont nil)) - ((looking-at "\\s *\\($\\|%\\)") - (forward-line 1)) - ((looking-at "\\s *<<[^>]*?>>") - (when (zerop res) - (setq res (+ 1 res))) - (goto-char (match-end 0))) - ((looking-at "\\s *,") - (setq res (+ 1 res)) - (goto-char (match-end 0))) - (t - (when (zerop res) - (setq res (+ 1 res))) - (forward-sexp 1)))) - res) - (error nil))))) - -(defun erlang-get-function-name-and-arity () - "Return the name and arity of the function at point, or nil. -The return value is a string of the form \"foo/1\"." - (let ((name (erlang-get-function-name)) - (arity (erlang-get-function-arity))) - (and name arity (format "%s/%d" name arity)))) - -(defun erlang-get-function-arguments () - "Return arguments of current function, or nil." - (if (not (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *(")))) - nil - (save-excursion - (condition-case nil - (let ((start (match-end 0))) - (goto-char (- start 1)) - (forward-sexp) - (erlang-buffer-substring start (- (point) 1))) - (error nil))))) - - -(defun erlang-get-function-under-point () - "Return the module and function under the point, or nil. - -Should no explicit module name be present at the point, the -list of imported functions is searched. - -The following could be returned: - (\"module\" \"function\") -- Both module and function name found. - (nil \"function\") -- No module name was found. - nil -- No function name found - -In the future the list may contain more elements." - (save-excursion - (let ((md (match-data)) - (res nil)) - (if (eq (char-syntax (following-char)) ? ) - (skip-chars-backward " \t")) - (skip-chars-backward "a-zA-Z0-9_:'") - (cond ((looking-at (eval-when-compile - (concat erlang-atom-regexp ":" erlang-atom-regexp))) - (setq res (list - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 1) (match-end 1))) - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning (1+ erlang-atom-regexp-matches)) - (match-end (1+ erlang-atom-regexp-matches))))))) - ((looking-at erlang-atom-regexp) - (let ((fk (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 0) (match-end 0)))) - (mod nil) - (imports (erlang-get-import))) - (while (and imports (null mod)) - (if (assoc fk (cdr (car imports))) - (setq mod (car (car imports))) - (setq imports (cdr imports)))) - (setq res (list mod fk))))) - (store-match-data md) - res))) - - -;; TODO: Escape single quotes inside the string without -;; replace-regexp-in-string. -(defun erlang-add-quotes-if-needed (str) - "Return STR, possibly with quotes." - (let ((case-fold-search nil)) ; force string matching to be case sensitive - (if (and (stringp str) - (not (string-match (eval-when-compile - (concat "\\`" erlang-atom-regexp "\\'")) str))) - (progn (if (fboundp 'replace-regexp-in-string) - (setq str (replace-regexp-in-string "'" "\\'" str t t ))) - (concat "'" str "'")) - str))) - - -(defun erlang-remove-quotes (str) - "Return STR without quotes, if present." - (let ((md (match-data))) - (prog1 - (if (string-match "\\`'\\(.*\\)'\\'" str) - (substring str 1 -1) - str) - (store-match-data md)))) - -(defun erlang-match-next-exported-function (max) - "Returns non-nil if there is an exported function in the current -buffer between point and MAX." - (block nil - (while (and (not erlang-inhibit-exported-function-name-face) - (erlang-match-next-function max)) - (when (erlang-last-match-exported-p) - (return (match-data)))))) - -(defun erlang-match-next-function (max) - "Searches forward in current buffer for the next erlang function, -bounded by position MAX." - (re-search-forward erlang-defun-prompt-regexp max 'move-point)) - -(defun erlang-last-match-exported-p () - "Returns non-nil if match-data describes the name and arity of an -exported function." - (save-excursion - (save-match-data - (goto-char (match-beginning 1)) - (erlang-function-exported-p - (erlang-remove-quotes (erlang-get-function-name)) - (erlang-get-function-arity))))) - -(defun erlang-function-exported-p (name arity) - "Returns non-nil if function of name and arity is exported in current buffer." - (save-excursion - (let* ((old-match-data (match-data)) - (exports (erlang-get-export))) - (store-match-data old-match-data) - (member (cons name arity) exports)))) - - -;;; Check module name - -;; The function `write-file', bound to C-x C-w, calls -;; `set-visited-file-name' which clears the hook. :-( -;; To make sure that the hook always is present, we advise -;; `set-visited-file-name'. -(defun erlang-check-module-name-init () - "Initialize the functionality to compare file and module names. - -Unless we have `before-save-hook', we redefine the function -`set-visited-file-name' since it clears the variable -`local-write-file-hooks'. The original function definition is -stored in `erlang-orig-set-visited-file-name'." - (if (boundp 'before-save-hook) - ;; If we have that, `make-local-hook' is obsolete. - (add-hook 'before-save-hook 'erlang-check-module-name nil t) - (require 'advice) - (unless (ad-advised-definition-p 'set-visited-file-name) - (defadvice set-visited-file-name (after erlang-set-visited-file-name - activate) - (if (eq major-mode 'erlang-mode) - (add-hook 'local-write-file-hooks 'erlang-check-module-name)))) - (add-hook 'local-write-file-hooks 'erlang-check-module-name))) - - -(defun erlang-check-module-name () - "If the module name doesn't match file name, ask for permission to change. - -The variable `erlang-check-module-name' controls the behaviour of this -function. It it is nil, this function does nothing. If it is t, the -source is silently changed. If it is set to the atom `ask', the user -is prompted. - -This function is normally placed in the hook `local-write-file-hooks'." - (if erlang-check-module-name - (let ((mn (erlang-add-quotes-if-needed - (erlang-get-module))) - (fn (erlang-add-quotes-if-needed - (erlang-get-module-from-file-name (buffer-file-name))))) - (if (and (stringp mn) (stringp fn)) - (or (string-equal mn fn) - (if (or (eq erlang-check-module-name t) - (y-or-n-p - "Module does not match file name. Modify source? ")) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (if (re-search-forward - (eval-when-compile - (concat "^-module\\s *(\\s *\\(\\(" - erlang-atom-regexp - "\\)?\\)\\s *)\\s *\\.")) - (point-max) t) - (progn - (goto-char (match-beginning 1)) - (delete-region (match-beginning 1) - (match-end 1)) - (insert fn)))))))))) - ;; Must return nil since it is added to `local-write-file-hook'. - nil) - - -;;; Electric functions. - -(defun erlang-electric-semicolon (&optional arg) - "Insert a semicolon character and possibly a prototype for the next line. - -The variable `erlang-electric-semicolon-criteria' states a criterion, -when fulfilled a newline is inserted, the next line is indented and a -prototype for the next line is inserted. Normally the prototype -consists of \" ->\". Should the semicolon end the clause a new clause -header is generated. - -The variable `erlang-electric-semicolon-insert-blank-lines' controls -the number of blank lines inserted between the current line and new -function header. - -Behaves just like the normal semicolon when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line." - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-semicolon - erlang-electric-commands))) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-semicolon-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (erlang-indent-line) - (end-of-line) - (newline) - (if (condition-case nil - (progn (erlang-indent-line) t) - (error (if (bolp) (delete-backward-char 1)))) - (if (not (bolp)) - (save-excursion - (insert " ->")) - (condition-case nil - (progn - (erlang-generate-new-clause) - (if erlang-electric-semicolon-insert-blank-lines - (save-excursion - (beginning-of-line) - (newline - erlang-electric-semicolon-insert-blank-lines)))) - (error (if (bolp) (delete-backward-char 1)))))))) - - -(defun erlang-electric-comma (&optional arg) - "Insert a comma character and possibly a new indented line. -The variable `erlang-electric-comma-criteria' states a criterion, -when fulfilled a newline is inserted and the next line is indented. - -Behaves just like the normal comma when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line." - (interactive "P") - - (self-insert-command (prefix-numeric-value arg)) - - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-comma erlang-electric-commands))) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-comma-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (erlang-indent-line) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-backward-char 1)))))) - -(defun erlang-electric-lt (&optional arg) - "Insert a less-than sign, and optionally mark it as an open paren." - - (interactive "p") - - (self-insert-command arg) - - ;; Was this the second char in bit-syntax open (`<<')? - (unless (<= (point) 2) - (save-excursion - (backward-char 2) - (when (and (eq (char-after (point)) ?<) - (not (eq (get-text-property (point) 'category) - 'bitsyntax-open-inner))) - ;; Then mark the two chars... - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-open-outer) - (forward-char 1) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-open-inner) - ;;...and unmark any subsequent less-than chars. - (forward-char 1) - (while (eq (char-after (point)) ?<) - (remove-text-properties (point) (1+ (point)) - '(category nil)) - (forward-char 1)))))) - -(defun erlang-after-bitsyntax-close () - "Return t if point is immediately after a bit-syntax close parenthesis (`>>')." - (and (>= (point) 3) - (save-excursion - (backward-char 2) - (and (eq (char-after (point)) ?>) - (not (eq (get-text-property (point) 'category) - 'bitsyntax-close-outer)))))) - -(defun erlang-after-arrow () - "Return true if point is immediately after a function arrow (`->')." - (and (>= (point) 2) - (and - (save-excursion - (backward-char) - (eq (char-before (point)) ?-)) - (or (not (listp erlang-electric-commands)) - (memq 'erlang-electric-gt - erlang-electric-commands)) - (not (erlang-in-literal)) - (looking-at "\\s *\\(%.*\\)?$") - (erlang-test-criteria-list erlang-electric-arrow-criteria)))) - - -(defun erlang-electric-gt (&optional arg) - "Insert a greater-than sign, and optionally mark it as a close paren." - - (interactive "p") - - (self-insert-command arg) - - (cond - ;; Did we just write a bit-syntax close (`>>')? - ((erlang-after-bitsyntax-close) - (save-excursion - ;; Then mark the two chars... - (backward-char 2) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-close-inner) - (forward-char) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-close-outer) - ;;...and unmark any subsequent greater-than chars. - (forward-char) - (while (eq (char-after (point)) ?>) - (remove-text-properties (point) (1+ (point)) - '(category nil)) - (forward-char)))) - - ;; Did we just write a function arrow (`->')? - ((erlang-after-arrow) - (let ((erlang-electric-newline-inhibit t)) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-backward-char 1)))))) - - ;; Then it's just a plain greater-than. - (t - nil))) - - -(defun erlang-electric-arrow\ off (&optional arg) - "Insert a '>'-sign and possibly a new indented line. - -This command is only `electric' when the `>' is part of an `->' arrow. -The variable `erlang-electric-arrow-criteria' states a sequence of -criteria, which decides when a newline should be inserted and the next -line indented. - -It behaves just like the normal greater than sign when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line. - -After being split/merged into `erlang-after-arrow' and -`erlang-electric-gt', it is now unused and disabled." - (interactive "P") - (let ((prec (preceding-char))) - (self-insert-command (prefix-numeric-value arg)) - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-arrow - erlang-electric-commands))) - (not (eq prec ?-)) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-arrow-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-backward-char 1))))))) - - -(defun erlang-electric-newline (&optional arg) - "Break line at point and indent, continuing comment if within one. -The variable `erlang-electric-newline-criteria' states a criterion, -when fulfilled a newline is inserted and the next line is indented. - -Should the current line begin with a comment, and the variable -`comment-multi-line' be non-nil, a new comment start is inserted. - -Should the previous command be another electric command we assume that -the user pressed newline out of old habit, hence we will do nothing." - (interactive "P") - (cond ((and (not arg) - erlang-electric-newline-inhibit - (memq last-command erlang-electric-newline-inhibit-list)) - ()) ; Do nothing! - ((or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-newline - erlang-electric-commands))) - (null (erlang-test-criteria-list - erlang-electric-newline-criteria))) - (newline (prefix-numeric-value arg))) - (t - (if (and comment-multi-line - (save-excursion - (beginning-of-line) - (looking-at (concat "\\s *" comment-start-skip)))) - (let ((str (buffer-substring - (or (match-end 1) (match-beginning 0)) - (min (match-end 0) (point))))) - (newline) - (undo-boundary) - (insert str)) - (newline) - (undo-boundary) - (indent-according-to-mode))))) - - -(defun erlang-test-criteria-list (criteria) - "Given a list of criterion functions, test if criteria are fulfilled. - -Each element in the criteria list can a function returning nil, t or -the atom `stop'. t means that the criterion is fulfilled, `stop' means -that it isn't fulfilled and that the search should stop, -and nil means continue searching. - -Should the list contain the atom t the criterion is assumed to be -fulfilled, unless preceded by a function returning `stop', of course. - -Should the argument be the atom t instead of a list, the criterion is -assumed to be trivially true. - -Should all functions return nil, the criteria are assumed not to be -fulfilled. - -Return t if criteria fulfilled, nil otherwise." - (if (eq criteria t) - t - (save-excursion - (let ((answer nil)) - (while (and criteria (null answer)) - (if (eq (car criteria) t) - (setq answer t) - (setq answer (funcall (car criteria)))) - (setq criteria (cdr criteria))) - (if (and answer (not (eq answer 'stop))) - t - nil))))) - - -(defun erlang-in-literal (&optional lim) - "Test if point is in string, quoted atom or comment. - -Return one of the three atoms `atom', `string', and `comment'. -Should the point be inside none of the above mentioned types of -context, nil is returned." - (save-excursion - (let* ((lim (or lim (save-excursion - (erlang-beginning-of-clause) - (point)))) - (state (if (fboundp 'syntax-ppss) ; post Emacs 21.3 - (funcall (symbol-function 'syntax-ppss)) - (parse-partial-sexp lim (point))))) - (cond - ((eq (nth 3 state) ?') 'atom) - ((nth 3 state) 'string) - ((nth 4 state) 'comment) - (t nil))))) - - -(defun erlang-at-end-of-function-p () - "Test if point is at end of an Erlang function. - -This function is designed to be a member of a criteria list." - (eq (save-excursion (erlang-skip-blank) (point)) - (save-excursion - (erlang-beginning-of-function -1) (point)))) - - -(defun erlang-at-end-of-clause-p () - "Test if point is at end of an Erlang clause. - -This function is designed to be a member of a criteria list." - (eq (save-excursion (erlang-skip-blank) (point)) - (save-excursion - (erlang-beginning-of-clause -1) (point)))) - - -(defun erlang-stop-when-inside-argument-list () - "Return `stop' if inside parenthesis list, nil otherwise. - -Knows about the list comprehension syntax. When the point is -after `||', `stop' is not returned. - -This function is designed to be a member of a criteria list." - (save-excursion - (condition-case nil - (let ((orig-point (point)) - (state nil)) - (up-list -1) - (if (not (eq (following-char) ?\[)) - 'stop - ;; Do not return `stop' when inside a list comprehension - ;; construction. (The point must be after `||'). - (while (< (point) orig-point) - (setq state (erlang-partial-parse (point) orig-point state))) - (if (and (car state) (eq (car (car (car state))) '||)) - nil - 'stop))) - (error - nil)))) - - -(defun erlang-stop-when-at-guard () - "Return `stop' when at function guards. - -This function is designed to be a member of a criteria list." - (save-excursion - (beginning-of-line) - (if (and (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *("))) - (not (looking-at - (eval-when-compile - (concat "^" erlang-atom-regexp ".*->"))))) - 'stop - nil))) - - -(defun erlang-stop-when-in-type-spec () - "Return `stop' when in a type spec line. - -This function is designed to be a member of a criteria list." - (save-excursion - (beginning-of-line) - (when (save-match-data (looking-at "-\\(spec\\|type\\)")) - 'stop))) - - -(defun erlang-next-lines-empty-p () - "Return non-nil if next lines are empty. - -The variable `erlang-next-lines-empty-threshold' contains the number -of lines required to be empty. - -A line containing only spaces and tabs is considered empty. - -This function is designed to be a member of a criteria list." - (and erlang-next-lines-empty-threshold - (save-excursion - (let ((left erlang-next-lines-empty-threshold) - (cont t)) - (while (and cont (> left 0)) - (forward-line 1) - (setq cont (looking-at "\\s *$")) - (setq left (- left 1))) - cont)))) - - -(defun erlang-at-keyword-end-p () - "Test if next readable token is the keyword end. - -This function is designed to be a member of a criteria list." - (save-excursion - (erlang-skip-blank) - (looking-at "end[^_a-zA-Z0-9]"))) - - -;; Erlang tags support which is aware of erlang modules. -;; -;; Not yet implemented under XEmacs. (Hint: The Emacs 19 etags -;; package works under XEmacs.) - -(eval-when-compile - (if (or (featurep 'bytecomp) - (featurep 'byte-compile)) - (progn - (require 'etags)))) - - -;; Variables: - -(defvar erlang-tags-function-alist - '((find-tag . erlang-find-tag) - (find-tag-other-window . erlang-find-tag-other-window) - (find-tag-regexp . erlang-find-tag-regexp) - (find-tag-other-frame . erlang-find-tag-other-frame)) - "Alist of old tags commands and the replacement functions.") - -(defvar erlang-tags-installed nil - "Non-nil when the Erlang tags system is installed.") -(defvar erlang-tags-file-list '() - "List of files in tag list. Used when finding tag on form `module:'.") -(defvar erlang-tags-completion-table nil - "Like `tags-completion-table', this table contains `tag' and `module:tag'.") -(defvar erlang-tags-buffer-installed-p nil - "Non-nil when Erlang module recognising functions installed.") -(defvar erlang-tags-buffer-list '() - "Temporary list of buffers.") -(defvar erlang-tags-orig-completion-table nil - "Temporary storage for `tags-completion-table'.") -(defvar erlang-tags-orig-tag-order nil - "Temporary storage for `find-tag-tag-order'.") -(defvar erlang-tags-orig-regexp-tag-order nil - "Temporary storage for `find-tag-regexp-tag-order'.") -(defvar erlang-tags-orig-search-function nil - "Temporary storage for `find-tag-search-function'.") -(defvar erlang-tags-orig-regexp-search-function nil - "Temporary storage for `find-tag-regexp-search-function'.") -(defvar erlang-tags-orig-format-hooks nil - "Temporary storage for `tags-table-format-hooks'.") ;v19 -(defvar erlang-tags-orig-format-functions nil - "Temporary storage for `tags-table-format-functions'.") ;v > 19 - -(defun erlang-tags-init () - "Install an alternate version of tags, aware of Erlang modules. - -After calling this function, the tags functions are aware of -Erlang modules. Tags can be entered on the for `module:tag' as well -as on the old form `tag'. - -In the completion list, `module:tag' and `module:' shows up. - -Call this function from an appropriate init file, or add it to -Erlang mode hook with the commands: - (add-hook 'erlang-mode-hook 'erlang-tags-init) - (add-hook 'erlang-shell-mode-hook 'erlang-tags-init) - -This function only works under Emacs 18 and Emacs 19. Currently, It -is not implemented under XEmacs. (Hint: The Emacs 19 etags module -works under XEmacs.)" - (interactive) - (cond ((= erlang-emacs-major-version 18) - (require 'tags) - (erlang-tags-define-keys (current-local-map)) - (setq erlang-tags-installed t)) - (t - (require 'etags) - ;; Test on a function available in the Emacs 19 version - ;; of tags but not in the XEmacs version. - (if (not (fboundp 'find-tag-noselect)) - () - (erlang-tags-define-keys (current-local-map)) - (setq erlang-tags-installed t))))) - - -;; Set all keys bound to `find-tag' et.al. in the global map and the -;; menu to `erlang-find-tag' et.al. in `map'. -;; -;; The function `substitute-key-definition' does not work properly -;; in all version of Emacs. - -(defun erlang-tags-define-keys (map) - "Bind tags commands to keymap MAP aware of Erlang modules." - (let ((alist erlang-tags-function-alist)) - (while alist - (let* ((old (car (car alist))) - (new (cdr (car alist))) - (keys (append (where-is-internal old global-map)))) - (while keys - (define-key map (car keys) new) - (setq keys (cdr keys)))) - (setq alist (cdr alist)))) - ;; Update the menu. - (erlang-menu-substitute erlang-menu-base-items erlang-tags-function-alist) - (erlang-menu-init)) - - -;; There exists a variable `find-tag-default-function'. It is not used -;; since `complete-tag' uses it to get current word under point. In that -;; situation we don't want the module to be prepended. - -(defun erlang-find-tag-default () - "Return the default tag. -Search `-import' list of imported functions. -Single quotes are been stripped away." - (let ((mod-func (erlang-get-function-under-point))) - (cond ((null mod-func) - nil) - ((null (car mod-func)) - (nth 1 mod-func)) - (t - (concat (car mod-func) ":" (nth 1 mod-func)))))) - - -;; Return `t' since it is used inside `tags-loop-form'. -;;;###autoload -(defun erlang-find-tag (modtagname &optional next-p regexp-p) - "Like `find-tag'. Capable of retrieving Erlang modules. - -Tags can be given on the forms `tag', `module:', `module:tag'." - (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) - (switch-to-buffer (erlang-find-tag-noselect modtagname next-p regexp-p)) - t) - - -;; Code mainly from `find-tag-other-window' in `etags.el'. -;;;###autoload -(defun erlang-find-tag-other-window (tagname &optional next-p regexp-p) - "Like `find-tag-other-window' but aware of Erlang modules." - (interactive (erlang-tag-interactive - "Find `module:tag' or `tag' other window: ")) - - ;; This is to deal with the case where the tag is found in the - ;; selected window's buffer; without this, point is moved in both - ;; windows. To prevent this, we save the selected window's point - ;; before doing find-tag-noselect, and restore it afterwards. - (let* ((window-point (window-point (selected-window))) - (tagbuf (erlang-find-tag-noselect tagname next-p regexp-p)) - (tagpoint (progn (set-buffer tagbuf) (point)))) - (set-window-point (prog1 - (selected-window) - (switch-to-buffer-other-window tagbuf) - ;; We have to set this new window's point; it - ;; might already have been displaying a - ;; different portion of tagbuf, in which case - ;; switch-to-buffer-other-window doesn't set - ;; the window's point from the buffer. - (set-window-point (selected-window) tagpoint)) - window-point))) - - -(defun erlang-find-tag-other-frame (tagname &optional next-p) - "Like `find-tag-other-frame' but aware of Erlang modules." - (interactive (erlang-tag-interactive - "Find `module:tag' or `tag' other frame: ")) - (let ((pop-up-frames t)) - (erlang-find-tag-other-window tagname next-p))) - - -(defun erlang-find-tag-regexp (regexp &optional next-p other-window) - "Like `find-tag-regexp' but aware of Erlang modules." - (interactive (if (fboundp 'find-tag-regexp) - (erlang-tag-interactive - "Find `module:regexp' or `regexp': ") - (error "This version of Emacs can't find tags by regexps"))) - (funcall (if other-window - 'erlang-find-tag-other-window - 'erlang-find-tag) - regexp next-p t)) - - -;; Just like C-u M-. This could be added to the menu. -(defun erlang-find-next-tag () - "Find next tag, like \\[find-tag] with prefix arg." - (interactive) - (let ((current-prefix-arg '(4))) - (if erlang-tags-installed - (call-interactively 'erlang-find-tag) - (call-interactively 'find-tag)))) - - -;; Mimics `find-tag-noselect' found in `etags.el', but uses `find-tag' to -;; be compatible with `tags.el'. -;; -;; Handles three cases: -;; * `module:' Loop over all possible file names. Stop if a file-name -;; without extension and directory matches the module. -;; -;; * `module:tag' -;; Emacs 19: Replace test functions with functions aware of -;; Erlang modules. Tricky because the etags system wasn't -;; built for these kind of operations... -;; -;; Emacs 18: We loop over `find-tag' until we find a file -;; whose module matches the requested module. The -;; drawback is that a lot of files could be loaded into -;; Emacs. -;; -;; * `tag' Just give it to `find-tag'. - -(defun erlang-find-tag-noselect (modtagname &optional next-p regexp-p) - "Like `find-tag-noselect' but aware of Erlang modules." - (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) - (or modtagname - (setq modtagname (symbol-value 'last-tag))) - (funcall (symbol-function 'set) 'last-tag modtagname) - ;; `tags.el' uses this variable to record how M-, would - ;; know where to restart a tags command. - (if (boundp 'tags-loop-form) - (funcall (symbol-function 'set) - 'tags-loop-form '(erlang-find-tag nil t))) - (save-window-excursion - (cond - ((string-match ":$" modtagname) - ;; Only the module name was given. Read all files whose file name - ;; match. - (let ((modname (substring modtagname 0 (match-beginning 0))) - (file nil)) - (if (not next-p) - (save-excursion - (visit-tags-table-buffer) - (setq erlang-tags-file-list - (funcall (symbol-function 'tags-table-files))))) - (while (null file) - (or erlang-tags-file-list - (save-excursion - (if (and (featurep 'etags) - (funcall - (symbol-function 'visit-tags-table-buffer) 'same) - (funcall - (symbol-function 'visit-tags-table-buffer) t)) - (setq erlang-tags-file-list - (funcall (symbol-function 'tags-table-files))) - (error "No %stags containing %s" (if next-p "more " "") - modtagname)))) - (if erlang-tags-file-list - (let ((this-module (erlang-get-module-from-file-name - (car erlang-tags-file-list)))) - (if (and (stringp this-module) - (string= modname this-module)) - (setq file (car erlang-tags-file-list))) - (setq erlang-tags-file-list (cdr erlang-tags-file-list))))) - (set-buffer (or (get-file-buffer file) - (find-file-noselect file))))) - - ((string-match ":" modtagname) - (if (boundp 'find-tag-tag-order) - ;; Method one: Add module-recognising functions to the - ;; list of order functions. However, the tags system - ;; from Emacs 18, and derives thereof (read: XEmacs) - ;; hasn't got this feature. - (progn - (erlang-tags-install-module-check) - (unwind-protect - (funcall (symbol-function 'find-tag) - modtagname next-p regexp-p) - (erlang-tags-remove-module-check))) - ;; Method two: Call the tags system until a file matching - ;; the module is found. This could result in that many - ;; files are read. (e.g. The tag "foo:file" will take a - ;; while to process.) - (let* ((modname (substring modtagname 0 (match-beginning 0))) - (tagname (substring modtagname (match-end 0) nil)) - (last-tag tagname) - file) - (while - (progn - (funcall (symbol-function 'find-tag) tagname next-p regexp-p) - (setq next-p t) - ;; Determine the module form the file name. (The - ;; alternative, to check `-module', would make this - ;; code useless for non-Erlang programs.) - (setq file (erlang-get-module-from-file-name buffer-file-name)) - (not (and (stringp file) - (string= modname file)))))))) - (t - (funcall (symbol-function 'find-tag) modtagname next-p regexp-p))) - (current-buffer))) ; Return the new buffer. - - -;; Process interactive arguments for erlang-find-tag-*. -;; -;; Negative arguments work only for `etags', not `tags'. This is not -;; a problem since negative arguments means step back into the -;; history list, a feature not implemented in `tags'. - -(defun erlang-tag-interactive (prompt) - (condition-case nil - (require 'etags) - (error - (require 'tags))) - (if current-prefix-arg - (list nil (if (< (prefix-numeric-value current-prefix-arg) 0) - '- - t)) - (let* ((default (erlang-find-tag-default)) - (prompt (if default - (format "%s(default %s) " prompt default) - prompt)) - (spec (if (featurep 'etags) - (completing-read prompt 'erlang-tags-complete-tag) - (read-string prompt)))) - (list (if (equal spec "") - (or default (error "There is no default tag")) - spec))))) - - -;; Search tag functions which are aware of Erlang modules. The tactic -;; is to store new search functions into the local variables of the -;; TAGS buffers. The variables are restored directly after the -;; search. The situation is complicated by the fact that new TAGS -;; files can be loaded during the search. -;; - -(defun erlang-tags-install-module-check () - "Install our own tag search functions." - ;; Make sure our functions are installed in TAGS files loaded - ;; into Emacs while searching. - (cond - ((>= erlang-emacs-major-version 20) - (setq erlang-tags-orig-format-functions - (symbol-value 'tags-table-format-functions)) - (funcall (symbol-function 'set) 'tags-table-format-functions - (cons 'erlang-tags-recognize-tags-table - erlang-tags-orig-format-functions)) - (setq erlang-tags-buffer-list '()) - ) - (t - (setq erlang-tags-orig-format-hooks - (symbol-value 'tags-table-format-hooks)) - (funcall (symbol-function 'set) 'tags-table-format-hooks - (cons 'erlang-tags-recognize-tags-table - erlang-tags-orig-format-hooks)) - (setq erlang-tags-buffer-list '()) - )) - - ;; Install our functions in the TAGS files already resident. - (save-excursion - (let ((files (symbol-value 'tags-table-computed-list))) - (while files - (if (stringp (car files)) - (if (get-file-buffer (car files)) - (progn - (set-buffer (get-file-buffer (car files))) - (erlang-tags-install-local)))) - (setq files (cdr files)))))) - - -(defun erlang-tags-install-local () - "Install our tag search functions in current buffer." - (if erlang-tags-buffer-installed-p - () - ;; Mark this buffer as "installed" and record. - (set (make-local-variable 'erlang-tags-buffer-installed-p) t) - (setq erlang-tags-buffer-list - (cons (current-buffer) erlang-tags-buffer-list)) - - ;; Save the original values. - (set (make-local-variable 'erlang-tags-orig-tag-order) - (symbol-value 'find-tag-tag-order)) - (set (make-local-variable 'erlang-tags-orig-regexp-tag-order) - (symbol-value 'find-tag-regexp-tag-order)) - (set (make-local-variable 'erlang-tags-orig-search-function) - (symbol-value 'find-tag-search-function)) - (set (make-local-variable 'erlang-tags-orig-regexp-search-function) - (symbol-value 'find-tag-regexp-search-function)) - - ;; Install our own functions. - (set (make-local-variable 'find-tag-search-function) - 'erlang-tags-search-forward) - (set (make-local-variable 'find-tag-regexp-search-function) - 'erlang-tags-regexp-search-forward) - (set (make-local-variable 'find-tag-tag-order) - '(erlang-tag-match-module-p)) - (set (make-local-variable 'find-tag-regexp-tag-order) - '(erlang-tag-match-module-regexp-p)))) - - -(defun erlang-tags-remove-module-check () - "Remove our own tags search functions." - (cond - ((>= erlang-emacs-major-version 20) - (funcall (symbol-function 'set) - 'tags-table-format-functions - erlang-tags-orig-format-functions) - ) - (t - (funcall (symbol-function 'set) - 'tags-table-format-hooks - erlang-tags-orig-format-hooks) - )) - - ;; Remove our functions from the TAGS files. (Note that - ;; `tags-table-computed-list' need not be the same list as when - ;; the search was started.) - (save-excursion - (let ((buffers erlang-tags-buffer-list)) - (while buffers - (if (buffer-name (car buffers)) - (progn - (set-buffer (car buffers)) - (erlang-tags-remove-local))) - (setq buffers (cdr buffers)))))) - - -(defun erlang-tags-remove-local () - "Remove our tag search functions from current buffer." - (if (null erlang-tags-buffer-installed-p) - () - (funcall (symbol-function 'set) 'erlang-tags-buffer-installed-p nil) - (funcall (symbol-function 'set) - 'find-tag-tag-order erlang-tags-orig-tag-order) - (funcall (symbol-function 'set) - 'find-tag-regexp-tag-order erlang-tags-orig-regexp-tag-order) - (funcall (symbol-function 'set) - 'find-tag-search-function erlang-tags-orig-search-function) - (funcall (symbol-function 'set) - 'find-tag-regexp-search-function - erlang-tags-orig-regexp-search-function))) - - -(defun erlang-tags-recognize-tags-table () - "Install our functions in all loaded TAGS files. - -This function is added to `tags-table-format-hooks/functions' when searching -for a tag on the form `module:tag'." - (if (null (funcall (symbol-function 'etags-recognize-tags-table))) - nil - (erlang-tags-install-local) - t)) - - -(defun erlang-tags-search-forward (tag &optional bound noerror count) - "Forward search function, aware of Erlang module prefix." - (if (string-match ":" tag) - (setq tag (substring tag (match-end 0) nil))) - ;; Avoid unintended recursion. - (if (eq erlang-tags-orig-search-function 'erlang-tags-search-forward) - (search-forward tag bound noerror count) - (funcall erlang-tags-orig-search-function tag bound noerror count))) - - -(defun erlang-tags-regexp-search-forward (tag &optional bound noerror count) - "Forward regexp search function, aware of Erlang module prefix." - (if (string-match ":" tag) - (setq tag (substring tag (match-end 0) nil))) - (if (eq erlang-tags-orig-regexp-search-function - 'erlang-tags-regexp-search-forward) - (re-search-forward tag bound noerror count) - (funcall erlang-tags-orig-regexp-search-function - tag bound noerror count))) - - -;; t if point is at a tag line that matches TAG, containing -;; module information. Assumes that all other order functions -;; are stored in `erlang-tags-orig-[regex]-tag-order'. - -(defun erlang-tag-match-module-p (tag) - (erlang-tag-match-module-common-p tag erlang-tags-orig-tag-order)) - -(defun erlang-tag-match-module-regexp-p (tag) - (erlang-tag-match-module-common-p tag erlang-tags-orig-regexp-tag-order)) - -(defun erlang-tag-match-module-common-p (tag order) - (let ((mod nil) - (found nil)) - (if (string-match ":" tag) - (progn - (setq mod (substring tag 0 (match-beginning 0))) - (setq tag (substring tag (match-end 0) nil)))) - (while (and order (not found)) - (setq found - (and (not (memq (car order) - '(erlang-tag-match-module-p - erlang-tag-match-module-regexp-p))) - (funcall (car order) tag))) - (setq order (cdr order))) - (and found - (or (null mod) - (string= mod (erlang-get-module-from-file-name - (file-of-tag))))))) - - -;;; Tags completion, Emacs 19 `etags' specific. -;;; -;;; The basic idea is to create a second completion table `erlang-tags- -;;; completion-table' containing all normal tags plus tags on the form -;;; `module:tag'. - - -(defun erlang-complete-tag () - "Perform tags completion on the text around point. -Completes to the set of names listed in the current tags table. - -Should the Erlang tags system be installed this command knows -about Erlang modules." - (interactive) - (condition-case nil - (require 'etags) - (error nil)) - (cond ((and erlang-tags-installed - (fboundp 'complete-tag)) ; Emacs 19 - (let ((orig-tags-complete-tag (symbol-function 'tags-complete-tag))) - (fset 'tags-complete-tag - (symbol-function 'erlang-tags-complete-tag)) - (unwind-protect - (funcall (symbol-function 'complete-tag)) - (fset 'tags-complete-tag orig-tags-complete-tag)))) - ((fboundp 'complete-tag) ; Emacs 19 - (funcall (symbol-function 'complete-tag))) - ((fboundp 'tag-complete-symbol) ; XEmacs - (funcall (symbol-function 'tag-complete-symbol))) - (t - (error "This version of Emacs can't complete tags")))) - - -;; Based on `tags-complete-tag', but this one uses -;; `erlang-tags-completion-table' instead of `tags-completion-table'. -;; -;; This is the entry-point called by system function `completing-read'. -(defun erlang-tags-complete-tag (string predicate what) - (save-excursion - ;; If we need to ask for the tag table, allow that. - (let ((enable-recursive-minibuffers t)) - (visit-tags-table-buffer)) - (if (eq what t) - (all-completions string (erlang-tags-completion-table) predicate) - (try-completion string (erlang-tags-completion-table) predicate)))) - - -;; `tags-completion-table' calls itself recursively, make it -;; call our own wedge instead. Note that the recursive call -;; is very rare; it only occurs when a tags-file contains -;; `include'-statements. -(defun erlang-tags-completion-table () - "Build completion table. Tags on the form `tag' or `module:tag'." - (setq erlang-tags-orig-completion-table - (symbol-function 'tags-completion-table)) - (fset 'tags-completion-table - (symbol-function 'erlang-tags-completion-table-1)) - (unwind-protect - (erlang-tags-completion-table-1) - (fset 'tags-completion-table - erlang-tags-orig-completion-table))) - - -(defun erlang-tags-completion-table-1 () - (make-local-variable 'erlang-tags-completion-table) - (or erlang-tags-completion-table - (let ((tags-completion-table nil) - (tags-completion-table-function - 'erlang-etags-tags-completion-table)) - (funcall erlang-tags-orig-completion-table) - (setq erlang-tags-completion-table tags-completion-table)))) - - -;; Based on `etags-tags-completion-table'. The difference is that we -;; add three symbols to the vector, the tag, module: and module:tag. -;; The module is extracted from the file name of a tag. (This one -;; only works if we are looking at an `etags' file. However, this is -;; the only format supported by Emacs, so far.) -(defun erlang-etags-tags-completion-table () - (let ((table (make-vector 511 0)) - (file nil)) - (save-excursion - (goto-char (point-min)) - ;; This monster regexp matches an etags tag line. - ;; \1 is the string to match; - ;; \2 is not interesting; - ;; \3 is the guessed tag name; XXX guess should be better eg DEFUN - ;; \4 is not interesting; - ;; \5 is the explicitly-specified tag name. - ;; \6 is the line to start searching at; - ;; \7 is the char to start searching at. - (while (progn - (while (and - (eq (following-char) ?\f) - (looking-at "\f\n\\([^,\n]*\\),.*\n")) - (setq file (buffer-substring - (match-beginning 1) (match-end 1))) - (goto-char (match-end 0))) - (re-search-forward - "\ -^\\(\\([^\177]+[^-a-zA-Z0-9_$\177]+\\)?\\([-a-zA-Z0-9_$?:]+\\)\ -\[^-a-zA-Z0-9_$?:\177]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\ -\\([0-9]+\\)?,\\([0-9]+\\)?\n" - nil t)) - (let ((tag (if (match-beginning 5) - ;; There is an explicit tag name. - (buffer-substring (match-beginning 5) (match-end 5)) - ;; No explicit tag name. Best guess. - (buffer-substring (match-beginning 3) (match-end 3)))) - (module (and file - (erlang-get-module-from-file-name file)))) - (intern tag table) - (if (stringp module) - (progn - (intern (concat module ":" tag) table) - ;; Only the first one will be stored in the table. - (intern (concat module ":") table)))))) - table)) - -;;; -;;; Prepare for other methods to run an Erlang slave process. -;;; - -(defvar erlang-shell-function 'inferior-erlang - "Command to execute start a new Erlang shell. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-shell-display-function 'inferior-erlang-run-or-select - "Command to execute to display Erlang shell. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-compile-function 'inferior-erlang-compile - "Command to execute to compile current buffer. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-compile-erlang-function "c" - "Erlang function to call to compile an erlang file.") - -(defvar erlang-compile-display-function 'inferior-erlang-run-or-select - "Command to execute to view last compilation. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-next-error-function 'inferior-erlang-next-error - "Command to execute to go to the next error. - -Change this variable to use your favorite Erlang compilation -package. Not used in Emacs 21.") - - -;;;###autoload -(defun erlang-shell () - "Start a new Erlang shell. - -The variable `erlang-shell-function' decides which method to use, -default is to start a new Erlang host. It is possible that, in the -future, a new shell on an already running host will be started." - (interactive) - (call-interactively erlang-shell-function)) - - -;;;###autoload (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -;; It is customary for Emacs packages to supply a function on this -;; form, even though it violates the `erlang-*' name convention. -(defalias 'run-erlang 'erlang-shell) - - -(defun erlang-shell-display () - "Display an Erlang shell, or start a new." - (interactive) - (call-interactively erlang-shell-display-function)) - - -;;;###autoload -(defun erlang-compile () - "Compile Erlang module in current buffer." - (interactive) - (call-interactively erlang-compile-function)) - - -(defun erlang-compile-display () - "Display compilation output." - (interactive) - (call-interactively erlang-compile-display-function)) - - -(defun erlang-next-error () - "Display next error message from the latest compilation." - (interactive) - (call-interactively erlang-next-error-function)) - - - -;;; -;;; Erlang Shell Mode -- Major mode used for Erlang shells. -;;; - -;; This mode is designed to be implementation independent, -;; e.g. it does not assume that we are running an inferior -;; Erlang, there exists a lot of other possibilities. - - -(defvar erlang-shell-buffer-name "*erlang*" - "The name of the Erlang link shell buffer.") - -(defvar erlang-shell-mode-map nil - "Keymap used by Erlang shells.") - - -(defvar erlang-shell-mode-hook nil - "*User functions to run when an Erlang shell is started. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customise Erlang -mode for all users on the system. - -The function added to this hook is run every time a new Erlang -shell is started. - -See also `erlang-load-hook', a hook which is run once, when Erlang -mode is loaded, and `erlang-mode-hook' which is run every time a new -Erlang source file is loaded into Emacs.") - - -(defvar erlang-input-ring-file-name "~/.erlang_history" - "*When non-nil, file name used to store Erlang shell history information.") - - -(defun erlang-shell-mode () - "Major mode for interacting with an Erlang shell. - -We assume that we already are in Comint mode. - -The following special commands are available: -\\{erlang-shell-mode-map}" - (interactive) - (setq major-mode 'erlang-shell-mode) - (setq mode-name "Erlang Shell") - (erlang-mode-variables) - (if erlang-shell-mode-map - nil - (setq erlang-shell-mode-map (copy-keymap comint-mode-map)) - (erlang-shell-mode-commands erlang-shell-mode-map)) - (use-local-map erlang-shell-mode-map) - (unless inferior-erlang-use-cmm - ;; This was originally not a marker, but it needs to be, at least - ;; in Emacs 21, and should be backwards-compatible. Otherwise, - ;; would need to test whether compilation-parsing-end is a marker - ;; after requiring `compile'. - (set (make-local-variable 'compilation-parsing-end) (copy-marker 1)) - (set (make-local-variable 'compilation-error-list) nil) - (set (make-local-variable 'compilation-old-error-list) nil)) - ;; Needed when compiling directly from the Erlang shell. - (setq compilation-last-buffer (current-buffer)) - (setq comint-prompt-regexp "^[^>=]*> *") - (setq comint-eol-on-send t) - (setq comint-input-ignoredups t) - (setq comint-scroll-show-maximum-output t) - (setq comint-scroll-to-bottom-on-output t) - ;; In Emacs 19.30, `add-hook' has got a `local' flag, use it. If - ;; the call fails, just call the normal `add-hook'. - (condition-case nil - (progn - (add-hook 'comint-output-filter-functions - 'inferior-erlang-strip-delete nil t) - (add-hook 'comint-output-filter-functions - 'inferior-erlang-strip-ctrl-m nil t)) - (error - (funcall (symbol-function 'make-local-hook) - 'comint-output-filter-functions) ; obsolete as of Emacs 21.1 - (add-hook 'comint-output-filter-functions 'inferior-erlang-strip-delete) - (add-hook 'comint-output-filter-functions 'inferior-erlang-strip-ctrl-m))) - ;; Some older versions of comint don't have an input ring. - (if (fboundp 'comint-read-input-ring) - (progn - (setq comint-input-ring-file-name erlang-input-ring-file-name) - (comint-read-input-ring t) - (make-local-variable 'kill-buffer-hook) - (add-hook 'kill-buffer-hook 'comint-write-input-ring))) - ;; At least in Emacs 21, we need to be in `compilation-minor-mode' - ;; for `next-error' to work. We can avoid it clobbering the shell - ;; keys thus. - (when inferior-erlang-use-cmm - (compilation-minor-mode 1) - (set (make-local-variable 'minor-mode-overriding-map-alist) - `((compilation-minor-mode - . ,(let ((map (make-sparse-keymap))) - ;; It would be useful to put keymap properties on the - ;; error lines so that we could use RET and mouse-2 - ;; on them directly. - (when (boundp 'compilation-skip-threshold) ; new compile.el - (define-key map [mouse-2] #'erlang-mouse-2-command) - (define-key map "\C-m" #'erlang-RET-command)) - (if (boundp 'compilation-menu-map) - (define-key map [menu-bar compilation] - (cons "Errors" compilation-menu-map))) - map))))) - (run-hooks 'erlang-shell-mode-hook)) - - -(defun erlang-mouse-2-command (event) - "Command bound to `mouse-2' in inferior Erlang buffer. -Selects Comint or Compilation mode command as appropriate." - (interactive "e") - (if (save-window-excursion - (save-excursion - (mouse-set-point event) - (consp (get-text-property (line-beginning-position) 'message)))) - (call-interactively (lookup-key compilation-mode-map [mouse-2])) - (call-interactively (lookup-key comint-mode-map [mouse-2])))) - -(defun erlang-RET-command () - "Command bound to `RET' in inferior Erlang buffer. -Selects Comint or Compilation mode command as appropriate." - (interactive) - (if (consp (get-text-property (line-beginning-position) 'message)) - (call-interactively (lookup-key compilation-mode-map "\C-m")) - (call-interactively (lookup-key comint-mode-map "\C-m")))) - -(defun erlang-shell-mode-commands (map) - (define-key map "\M-\t" 'erlang-complete-tag) - (define-key map "\C-a" 'comint-bol) ; Normally the other way around. - (define-key map "\C-c\C-a" 'beginning-of-line) - (define-key map "\C-d" nil) ; Was `comint-delchar-or-maybe-eof' - (define-key map "\M-\C-m" 'compile-goto-error) - (unless inferior-erlang-use-cmm - (define-key map "\C-x`" 'erlang-next-error))) - -;;; -;;; Inferior Erlang -- Run an Erlang shell as a subprocess. -;;; - -(defvar inferior-erlang-display-buffer-any-frame nil - "*When nil, `inferior-erlang-display-buffer' use only selected frame. -When t, all frames are searched. When 'raise, the frame is raised.") - -(defvar inferior-erlang-shell-type 'newshell - "The type of Erlang shell to use. - -When this variable is set to the atom `oldshell', the old shell is used. -When set to `newshell' the new shell is used. Should the variable be -nil, the default shell is used. - -This variable influence the setting of other variables.") - -(defvar inferior-erlang-machine "erl" - "*The name of the Erlang shell.") - -(defvar inferior-erlang-machine-options '() - "*The options used when activating the Erlang shell. - -This must be a list of strings.") - -(defvar inferior-erlang-process-name "inferior-erlang" - "The name of the inferior Erlang process.") - -(defvar inferior-erlang-buffer-name erlang-shell-buffer-name - "The name of the inferior Erlang buffer.") - -(defvar inferior-erlang-prompt-timeout 60 - "*Number of seconds before `inferior-erlang-wait-prompt' timeouts. - -The time specified is waited after every output made by the inferior -Erlang shell. When this variable is t, we assume that we always have -a prompt. When nil, we will wait forever, or until \\[keyboard-quit].") - -(defvar inferior-erlang-process nil - "Process of last invoked inferior Erlang, or nil.") - -(defvar inferior-erlang-buffer nil - "Buffer of last invoked inferior Erlang, or nil.") - -;; Enable uniquifying Erlang shell buffers based on directory name. -(eval-after-load "uniquify" - '(add-to-list 'uniquify-list-buffers-directory-modes 'erlang-shell-mode)) - -;;;###autoload -(defun inferior-erlang (&optional command) - "Run an inferior Erlang. -With prefix command, prompt for command to start Erlang with. - -This is just like running Erlang in a normal shell, except that -an Emacs buffer is used for input and output. -\\ -The command line history can be accessed with \\[comint-previous-input] and \\[comint-next-input]. -The history is saved between sessions. - -Entry to this mode calls the functions in the variables -`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. - -The following commands imitate the usual Unix interrupt and -editing control characters: -\\{erlang-shell-mode-map}" - (interactive - (when current-prefix-arg - (list (if (fboundp 'read-shell-command) - ;; `read-shell-command' is a new function in Emacs 23. - (read-shell-command "Erlang command: ") - (read-string "Erlang command: "))))) - (require 'comint) - (let (cmd opts) - (if command - (setq cmd "sh" - opts (list "-c" command)) - (setq cmd inferior-erlang-machine - opts inferior-erlang-machine-options) - (cond ((eq inferior-erlang-shell-type 'oldshell) - (setq opts (cons "-oldshell" opts))) - ((eq inferior-erlang-shell-type 'newshell) - (setq opts (append '("-newshell" "-env" "TERM" "vt100") opts))))) - - ;; Using create-file-buffer and list-buffers-directory in this way - ;; makes uniquify give each buffer a unique name based on the - ;; directory. - (let ((fake-file-name (expand-file-name inferior-erlang-buffer-name default-directory))) - (setq inferior-erlang-buffer (create-file-buffer fake-file-name)) - (apply 'make-comint-in-buffer - inferior-erlang-process-name - inferior-erlang-buffer - cmd - nil opts) - (with-current-buffer inferior-erlang-buffer - (setq list-buffers-directory fake-file-name)))) - - (setq inferior-erlang-process - (get-buffer-process inferior-erlang-buffer)) - (if (> 21 erlang-emacs-major-version) ; funcalls to avoid compiler warnings - (funcall (symbol-function 'set-process-query-on-exit-flag) - inferior-erlang-process nil) - (funcall (symbol-function 'process-kill-without-query) inferior-erlang-process)) - (if erlang-inferior-shell-split-window - (switch-to-buffer-other-window inferior-erlang-buffer) - (switch-to-buffer inferior-erlang-buffer)) - (if (and (not (eq system-type 'windows-nt)) - (eq inferior-erlang-shell-type 'newshell)) - (setq comint-process-echoes t)) - (erlang-shell-mode)) - - -(defun inferior-erlang-run-or-select () - "Switch to an inferior Erlang buffer, possibly starting new process." - (interactive) - (if (null (inferior-erlang-running-p)) - (inferior-erlang) - (inferior-erlang-display-buffer t))) - - -(defun inferior-erlang-display-buffer (&optional select) - "Make the inferior Erlang process visible. -The window is returned. - -Should `inferior-erlang-display-buffer-any-frame' be nil the buffer is -displayed in the current frame. Should it be non-nil, and the buffer -already is visible in any other frame, no new window will be created. -Should it be the atom 'raise, the frame containing the window will -be raised. - -Should the optional argument SELECT be non-nil, the window is -selected. Should the window be in another frame, that frame is raised. - -Note, should the mouse pointer be places outside the raised frame, that -frame will become deselected before the next command." - (interactive) - (or (inferior-erlang-running-p) - (error "No inferior Erlang process is running")) - (let ((win (inferior-erlang-window - inferior-erlang-display-buffer-any-frame)) - (frames-p (fboundp 'selected-frame))) - (if (null win) - (let ((old-win (selected-window))) - (save-excursion - (switch-to-buffer-other-window inferior-erlang-buffer) - (setq win (selected-window))) - (select-window old-win)) - (if (and window-system - frames-p - (or select - (eq inferior-erlang-display-buffer-any-frame 'raise)) - (not (eq (selected-frame) (window-frame win)))) - (raise-frame (window-frame win)))) - (if select - (select-window win)) - (sit-for 0) - win)) - - -(defun inferior-erlang-running-p () - "Non-nil when an inferior Erlang is running." - (and inferior-erlang-process - (memq (process-status inferior-erlang-process) '(run open)) - inferior-erlang-buffer - (buffer-name inferior-erlang-buffer))) - - -(defun inferior-erlang-window (&optional all-frames) - "Return the window containing the inferior Erlang, or nil." - (and (inferior-erlang-running-p) - (if (and all-frames (>= erlang-emacs-major-version 19)) - (get-buffer-window inferior-erlang-buffer t) - (get-buffer-window inferior-erlang-buffer)))) - - -(defun inferior-erlang-wait-prompt () - "Wait until the inferior Erlang shell prompt appears." - (if (eq inferior-erlang-prompt-timeout t) - () - (or (inferior-erlang-running-p) - (error "No inferior Erlang shell is running")) - (save-excursion - (set-buffer inferior-erlang-buffer) - (let ((msg nil)) - (while (save-excursion - (goto-char (process-mark inferior-erlang-process)) - (forward-line 0) - (not (looking-at comint-prompt-regexp))) - (if msg - () - (setq msg t) - (message "Waiting for Erlang shell prompt (press C-g to abort).")) - (or (accept-process-output inferior-erlang-process - inferior-erlang-prompt-timeout) - (error "No Erlang shell prompt before timeout"))) - (if msg (message "")))))) - -(defun inferior-erlang-send-empty-cmd-unless-already-at-prompt () - "If not already at a prompt, try to send an empty cmd to get a prompt. -The empty command resembles hitting RET. This is useful in some -situations, for instance if a crash or error report from sasl -has been printed after the last prompt." - (save-excursion - (set-buffer inferior-erlang-buffer) - (if (> (point-max) 1) - ;; make sure we get a prompt if buffer contains data - (if (save-excursion - (goto-char (process-mark inferior-erlang-process)) - (forward-line 0) - (not (looking-at comint-prompt-regexp))) - (inferior-erlang-send-command ""))))) - -(autoload 'comint-send-input "comint") - -(defun inferior-erlang-send-command (cmd &optional hist) - "Send command CMD to the inferior Erlang. - -The contents of the current command line (if any) will -be placed at the next prompt. - -If optional second argument is non-nil the command is inserted into -the history list. - -Return the position after the newly inserted command." - (or (inferior-erlang-running-p) - (error "No inferior Erlang process is running")) - (let ((old-buffer (current-buffer)) - (insert-point (marker-position (process-mark inferior-erlang-process))) - (insert-length (if comint-process-echoes - 0 - (1+ (length cmd))))) - (set-buffer inferior-erlang-buffer) - (goto-char insert-point) - (insert cmd) - ;; Strange things happened if `comint-eol-on-send' is declared - ;; in the `let' expression above, but setq:d here. The - ;; `set-buffer' statement obviously makes the buffer local - ;; instance of `comint-eol-on-send' shadow this one. - ;; I'm considering this a bug in Elisp. - ;; - ;; This was previously cautioned against in the Lisp manual. It - ;; has been sorted out in Emacs 21. -- fx - (let ((comint-eol-on-send nil) - (comint-input-filter (if hist comint-input-filter 'ignore))) - (if (and (not erlang-xemacs-p) - (>= emacs-major-version 22)) - (comint-send-input nil t) - (comint-send-input))) - ;; Adjust all windows whose points are incorrect. - (if (null comint-process-echoes) - (walk-windows - (function - (lambda (window) - (if (and (eq (window-buffer window) inferior-erlang-buffer) - (= (window-point window) insert-point)) - (set-window-point window - (+ insert-point insert-length))))) - nil t)) - (set-buffer old-buffer) - (+ insert-point insert-length))) - - -(defun inferior-erlang-strip-delete (&optional s) - "Remove `^H' (delete) and the characters it was supposed to remove." - (interactive) - (if (and (boundp 'comint-last-input-end) - (boundp 'comint-last-output-start)) - (save-excursion - (goto-char - (if (interactive-p) - (symbol-value 'comint-last-input-end) - (symbol-value 'comint-last-output-start))) - (while (progn (skip-chars-forward "^\C-h") - (not (eq (point) (point-max)))) - (delete-char 1) - (or (bolp) - (backward-delete-char 1)))))) - - -;; Basically `comint-strip-ctrl-m', with a few extra checks. -(defun inferior-erlang-strip-ctrl-m (&optional string) - "Strip trailing `^M' characters from the current output group." - (interactive) - (if (and (boundp 'comint-last-input-end) - (boundp 'comint-last-output-start)) - (let ((pmark (process-mark (get-buffer-process (current-buffer))))) - (save-excursion - (goto-char - (if (interactive-p) - (symbol-value 'comint-last-input-end) - (symbol-value 'comint-last-output-start))) - (while (re-search-forward "\r+$" pmark t) - (replace-match "" t t)))))) - - -(defun inferior-erlang-compile (arg) - "Compile the file in the current buffer. - -With prefix arg, compiles for debug. - -Should Erlang return `{error, nofile}' it could not load the object -module after completing the compilation. This is due to a bug in the -compile command `c' when using the option `outdir'. - -There exists two workarounds for this bug: - - 1) Place the directory in the Erlang load path. - - 2) Set the Emacs variable `erlang-compile-use-outdir' to nil. - To do so, place the following line in your `~/.emacs'-file: - (setq erlang-compile-use-outdir nil)" - (interactive "P") - (save-some-buffers) - (inferior-erlang-prepare-for-input) - (let* ((dir (inferior-erlang-compile-outdir)) -;;; (file (file-name-nondirectory (buffer-file-name))) - (noext (substring (erlang-local-buffer-file-name) 0 -4)) - (opts (append (list (cons 'outdir dir)) - (if current-prefix-arg - (list 'debug_info 'export_all)) - erlang-compile-extra-opts)) - end) - (save-excursion - (set-buffer inferior-erlang-buffer) - (compilation-forget-errors)) - (setq end (inferior-erlang-send-command - (inferior-erlang-compute-compile-command noext opts) - nil)) - (sit-for 0) - (inferior-erlang-wait-prompt) - (save-excursion - (set-buffer inferior-erlang-buffer) - (setq compilation-error-list nil) - (set-marker compilation-parsing-end end)) - (setq compilation-last-buffer inferior-erlang-buffer))) - -(defun inferior-erlang-prepare-for-input (&optional no-display) - "Create an inferior erlang buffer if needed and ready it for input. -The buffer is displayed, according to `inferior-erlang-display-buffer' -unless the optional NO-DISPLAY is non-nil." - (or (inferior-erlang-running-p) - (save-excursion - (inferior-erlang))) - (or (inferior-erlang-running-p) - (error "Error starting inferior Erlang shell")) - (if (not no-display) - (inferior-erlang-display-buffer)) - (inferior-erlang-send-empty-cmd-unless-already-at-prompt) - (sit-for 0) - (inferior-erlang-wait-prompt)) - -(defun inferior-erlang-compile-outdir () - "Return the directory to compile the current buffer into." - (let* ((buffer-dir (directory-file-name - (file-name-directory (erlang-local-buffer-file-name)))) - (parent-dir (directory-file-name - (file-name-directory buffer-dir))) - (ebin-dir (concat (file-name-as-directory parent-dir) "ebin")) - (buffer-dir-base-name (file-name-nondirectory - (expand-file-name - (concat (file-name-as-directory buffer-dir) - "."))))) - (if (and (string= buffer-dir-base-name "src") - (file-directory-p ebin-dir)) - (file-name-as-directory ebin-dir) - (file-name-as-directory buffer-dir)))) - -(defun inferior-erlang-compute-compile-command (module-name opts) - (let ((ccfn erlang-compile-command-function-alist) - (res (inferior-erlang-compute-erl-compile-command module-name opts)) - ccfn-entry - done) - (if (not (null (erlang-local-buffer-file-name))) - (while (and (not done) (not (null ccfn))) - (setq ccfn-entry (car ccfn)) - (setq ccfn (cdr ccfn)) - (if (string-match (car ccfn-entry) (erlang-local-buffer-file-name)) - (let ((c-fn (cdr ccfn-entry))) - (setq done t) - (if (not (null c-fn)) - (setq result (funcall c-fn module-name opts))))))) - result)) - -(defun inferior-erlang-compute-erl-compile-command (module-name opts) - (let* ((out-dir-opt (assoc 'outdir opts)) - (out-dir (cdr out-dir-opt))) - (if erlang-compile-use-outdir - (format "%s(\"%s\"%s)." - erlang-compile-erlang-function - module-name - (inferior-erlang-format-comma-opts opts)) - (let (;; Hopefully, noone else will ever use these... - (tmpvar "Tmp7236") - (tmpvar2 "Tmp8742")) - (format - (concat - "f(%s), {ok, %s} = file:get_cwd(), " - "file:set_cwd(\"%s\"), " - "%s = %s(\"%s\"%s), file:set_cwd(%s), f(%s), %s.") - tmpvar2 tmpvar - out-dir - tmpvar2 - erlang-compile-erlang-function - module-name (inferior-erlang-format-comma-opts - (remq out-dir-opt opts)) - tmpvar tmpvar tmpvar2))))) - -(defun inferior-erlang-compute-leex-compile-command (module-name opts) - (let ((file-name (erlang-local-buffer-file-name)) - (erl-compile-expr (inferior-erlang-remove-any-trailing-dot - (inferior-erlang-compute-erl-compile-command - module-name opts)))) - (format (concat "f(LErr1__), f(LErr2__), " - "case case leex:file(\"%s\", [%s]) of" - " ok -> ok;" - " {ok,_} -> ok;" - " {ok,_,_} -> ok;" - " LErr1__ -> LErr1__ " - "end of" - " ok -> %s;" - " LErr2__ -> LErr2__ " - "end.") - file-name - (inferior-erlang-format-comma-opts erlang-leex-compile-opts) - erl-compile-expr))) - -(defun inferior-erlang-compute-yecc-compile-command (module-name opts) - (let ((file-name (erlang-local-buffer-file-name)) - (erl-compile-expr (inferior-erlang-remove-any-trailing-dot - (inferior-erlang-compute-erl-compile-command - module-name opts)))) - (format (concat "f(YErr1__), f(YErr2__), " - "case case yecc:file(\"%s\", [%s]) of" - " {ok,_} -> ok;" - " {ok,_,_} -> ok;" - " YErr1__ -> YErr1__ " - "end of" - " ok -> %s;" - " YErr2__ -> YErr2__ " - "end.") - file-name - (inferior-erlang-format-comma-opts erlang-yecc-compile-opts) - erl-compile-expr))) - -(defun inferior-erlang-remove-any-trailing-dot (str) - (if (string= (substring str -1) ".") - (substring str 0 (1- (length str))) - str)) - -(defun inferior-erlang-format-comma-opts (opts) - (if (null opts) - "" - (concat ", " (inferior-erlang-format-opts opts)))) - -(defun inferior-erlang-format-opts (opts) - (concat "[" (inferior-erlang-string-join (mapcar 'inferior-erlang-format-opt - opts) - ", ") - "]")) - -(defun inferior-erlang-format-opt (opt) - (cond ((stringp opt) (concat "\"" opt "\"")) - ((atom opt) (format "%s" opt)) - ((consp opt) (concat "{" (inferior-erlang-string-join - (mapcar 'inferior-erlang-format-opt - (list (car opt) (cdr opt))) - ", ") - "}")) - (t (error (format "Unexpected opt %s" opt))))) - -(defun inferior-erlang-string-join (strs sep) - (let ((result (or (car strs) ""))) - (setq strs (cdr strs)) - (while strs - (setq result (concat result sep (car strs))) - (setq strs (cdr strs))) - result)) - -(defun erlang-local-buffer-file-name () - ;; When editing a file remotely via tramp, - ;; the buffer's file name may be for example - ;; "/ssh:host.example.com:/some/path/x.erl" - ;; - ;; If I try to compile such a file using C-c C-k, an - ;; erlang shell on the remote host is automatically - ;; started if needed, but for it to successfully compile - ;; the file, the c(...) command that is sent must contain - ;; the file name "/some/path/x.erl" without the - ;; tramp-prefix "/ssh:host.example.com:". - (cond ((null (buffer-file-name)) - nil) - ((erlang-tramp-remote-file-p) - (erlang-tramp-get-localname)) - (t - (buffer-file-name)))) - -(defun erlang-tramp-remote-file-p () - (and (fboundp 'tramp-tramp-file-p) - (tramp-tramp-file-p (buffer-file-name)))) - -(defun erlang-tramp-get-localname () - (let ((tramp-info (tramp-dissect-file-name (buffer-file-name)))) - (if (fboundp 'tramp-file-name-localname) - (tramp-file-name-localname tramp-info) - ;; In old versions of tramp, it was `tramp-file-name-path' - ;; instead of the newer `tramp-file-name-localname' - (tramp-file-name-path tramp-info)))) - -;; `next-error' only accepts buffers with major mode `compilation-mode' -;; or with the minor mode `compilation-minor-mode' activated. -;; (To activate the minor mode is out of the question, since it will -;; ruin the inferior Erlang keymap.) -;; This is done differently in Emacs 21. -(defun inferior-erlang-next-error (&optional argp) - "Just like `next-error'. -Capable of finding error messages in an inferior Erlang buffer." - (interactive "P") - (let ((done nil) - (buf (or (and (boundp 'next-error-last-buffer) - next-error-last-buffer) - (and (boundp 'compilation-last-buffer) - compilation-last-buffer)))) - (if (and (bufferp buf) - (save-excursion - (set-buffer buf) - (and (eq major-mode 'erlang-shell-mode) - (setq major-mode 'compilation-mode)))) - (unwind-protect - (progn - (setq done t) - (next-error argp)) - (save-excursion - (set-buffer buf) - (setq major-mode 'erlang-shell-mode)))) - (or done - (next-error argp)))) - - -(defun inferior-erlang-change-directory (&optional dir) - "Make the inferior Erlang change directory. -The default is to go to the directory of the current buffer." - (interactive) - (or dir (setq dir (file-name-directory (erlang-local-buffer-file-name)))) - (or (inferior-erlang-running-p) - (error "No inferior Erlang is running")) - (inferior-erlang-display-buffer) - (inferior-erlang-send-empty-cmd-unless-already-at-prompt) - (inferior-erlang-wait-prompt) - (inferior-erlang-send-command (format "cd('%s')." dir) nil)) - -(defun erlang-align-arrows (start end) - "Align arrows (\"->\") in function clauses from START to END. -When called interactively, aligns arrows after function clauses inside -the region. - -With a prefix argument, aligns all arrows, not just those in function -clauses. - -Example: - -sum(L) -> sum(L, 0). -sum([H|T], Sum) -> sum(T, Sum + H); -sum([], Sum) -> Sum. - -becomes: - -sum(L) -> sum(L, 0). -sum([H|T], Sum) -> sum(T, Sum + H); -sum([], Sum) -> Sum." - (interactive "r") - (save-excursion - (let (;; regexp for matching arrows. without a prefix argument, - ;; the regexp matches function heads. With a prefix, it - ;; matches any arrow. - (re (if current-prefix-arg - "^.*\\(\\)->" - (eval-when-compile - (concat "^" erlang-atom-regexp ".*\\(\\)->")))) - ;; part of regexp matching directly before the arrow - (arrow-match-pos (if current-prefix-arg - 1 - (1+ erlang-atom-regexp-matches))) - ;; accumulator for positions where arrows are found, ordered - ;; by buffer position (from greatest to smallest) - (arrow-positions '()) - ;; accumulator for longest distance from start of line to arrow - (most-indent 0) - ;; marker to track the end of the region we're aligning - (end-marker (progn (goto-char end) - (point-marker)))) - ;; Pass 1: Find the arrow positions, adjust the whitespace - ;; before each arrow to one space, and find the greatest - ;; indentation level. - (goto-char start) - (while (re-search-forward re end-marker t) - (goto-char (match-beginning arrow-match-pos)) - (just-one-space) ; adjust whitespace - (setq arrow-positions (cons (point) arrow-positions)) - (setq most-indent (max most-indent (erlang-column-number)))) - (set-marker end-marker nil) ; free the marker - ;; Pass 2: Insert extra padding so that all arrow indentation is - ;; equal. This is done last-to-first by buffer position, so that - ;; inserting spaces before one arrow doesn't change the - ;; positions of the next ones. - (mapc (lambda (arrow-pos) - (goto-char arrow-pos) - (let* ((pad (- most-indent (erlang-column-number)))) - (when (> pad 0) - (insert-char ?\ pad)))) - arrow-positions)))) - -(defun erlang-column-number () - "Return the column number of the current position in the buffer. -Tab characters are counted by their visual width." - (string-width (buffer-substring (line-beginning-position) (point)))) - -(defun erlang-current-defun () - "`add-log-current-defun-function' for Erlang." - (save-excursion - (erlang-beginning-of-function) - (if (looking-at "[a-z0-9_]+") - (match-string 0)))) - -;; Aliases for backward compatibility with older versions of Erlang Mode. -;; -;; Unfortuantely, older versions of Emacs doesn't have `defalias' and -;; `make-obsolete' so we have to define our own `obsolete' function. - -(defun erlang-obsolete (sym newdef) - "Make the obsolete function SYM refer to the defined function NEWDEF. - -Simplified version of a combination `defalias' and `make-obsolete', -it assumes that NEWDEF is loaded." - (defalias sym (symbol-function newdef)) - (if (fboundp 'make-obsolete) - (make-obsolete sym newdef))) - - -(erlang-obsolete 'calculate-erlang-indent 'erlang-calculate-indent) -(erlang-obsolete 'calculate-erlang-stack-indent - 'erlang-calculate-stack-indent) -(erlang-obsolete 'at-erlang-keyword 'erlang-at-keyword) -(erlang-obsolete 'at-erlang-operator 'erlang-at-operator) -(erlang-obsolete 'beginning-of-erlang-clause 'erlang-beginning-of-clause) -(erlang-obsolete 'end-of-erlang-clause 'erlang-end-of-clause) -(erlang-obsolete 'mark-erlang-clause 'erlang-mark-clause) -(erlang-obsolete 'beginning-of-erlang-function 'erlang-beginning-of-function) -(erlang-obsolete 'end-of-erlang-function 'erlang-end-of-function) -(erlang-obsolete 'mark-erlang-function 'erlang-mark-function) -(erlang-obsolete 'pass-over-erlang-clause 'erlang-pass-over-function) -(erlang-obsolete 'name-of-erlang-function 'erlang-name-of-function) - - -;; Fixme: shouldn't redefine `set-visited-file-name' anyhow -- see above. -(defconst erlang-unload-hook - (list (lambda () - (defalias 'set-visited-file-name - 'erlang-orig-set-visited-file-name) - (when (featurep 'advice) - (ad-unadvise 'Man-notify-when-ready) - (ad-unadvise 'set-visited-file-name))))) - - -(defun erlang-string-to-int (string) - (if (fboundp 'string-to-number) - (string-to-number string) - (funcall (symbol-function 'string-to-int) string))) - -;; The end... - -(provide 'erlang) - -(run-hooks 'erlang-load-hook) - -;; Local variables: -;; coding: iso-8859-1 -;; End: - -;;; erlang.el ends here diff --git a/emacs.d/elpa/erlang-20150319.456/erlang-autoloads.el b/emacs.d/elpa/erlang-20150319.456/erlang-autoloads.el new file mode 100644 index 0000000..c5817f1 --- /dev/null +++ b/emacs.d/elpa/erlang-20150319.456/erlang-autoloads.el @@ -0,0 +1,144 @@ +;;; erlang-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "erlang" "erlang.el" (21837 24214 0 0)) +;;; Generated autoloads from erlang.el + +(autoload 'erlang-mode "erlang" "\ +Major mode for editing Erlang source files in Emacs. +It knows about syntax and comment, it can indent code, it is capable +of fontifying the source file, the TAGS commands are aware of Erlang +modules, and the Erlang man pages can be accessed. + +Should this module, \"erlang.el\", be installed properly, Erlang mode +is activated whenever an Erlang source or header file is loaded into +Emacs. To indicate this, the mode line should contain the word +\"Erlang\". + +The main feature of Erlang mode is indentation, press TAB and the +current line will be indented correctly. + +Comments starting with only one `%' are indented to the column stored +in the variable `comment-column'. Comments starting with two `%':s +are indented with the same indentation as code. Comments starting +with at least three `%':s are indented to the first column. + +However, Erlang mode contains much more, this is a list of the most +useful commands: + TAB - Indent the line. + C-c C-q - Indent current function. + M-; - Create a comment at the end of the line. + M-q - Fill a comment, i.e. wrap lines so that they (hopefully) + will look better. + M-a - Goto the beginning of an Erlang clause. + M-C-a - Ditto for function. + M-e - Goto the end of an Erlang clause. + M-C-e - Ditto for function. + M-h - Mark current Erlang clause. + M-C-h - Ditto for function. + C-c C-z - Start, or switch to, an inferior Erlang shell. + C-c C-k - Compile current file. + C-x ` - Next error. + , - Electric comma. + ; - Electric semicolon. + +Erlang mode check the name of the file against the module name when +saving, whenever a mismatch occurs Erlang mode offers to modify the +source. + +The variable `erlang-electric-commands' controls the electric +commands. To deactivate all of them, set it to nil. + +There exists a large number of commands and variables in the Erlang +module. Please press `M-x apropos RET erlang RET' to see a complete +list. Press `C-h f name-of-function RET' and `C-h v name-of-variable +RET'to see the full description of functions and variables, +respectively. + +On entry to this mode the contents of the hook `erlang-mode-hook' is +executed. + +Please see the beginning of the file `erlang.el' for more information +and examples of hooks. + +Other commands: +\\{erlang-mode-map} + +\(fn)" t nil) + +(dolist (r '("\\.erl$" "\\.app\\.src$" "\\.escript" "\\.hrl$" "\\.xrl$" "\\.yrl" "/ebin/.+\\.app")) (add-to-list 'auto-mode-alist (cons r 'erlang-mode))) + +(autoload 'erlang-find-tag "erlang" "\ +Like `find-tag'. Capable of retrieving Erlang modules. + +Tags can be given on the forms `tag', `module:', `module:tag'. + +\(fn MODTAGNAME &optional NEXT-P REGEXP-P)" t nil) + +(autoload 'erlang-find-tag-other-window "erlang" "\ +Like `find-tag-other-window' but aware of Erlang modules. + +\(fn TAGNAME &optional NEXT-P REGEXP-P)" t nil) + +(autoload 'erlang-shell "erlang" "\ +Start a new Erlang shell. + +The variable `erlang-shell-function' decides which method to use, +default is to start a new Erlang host. It is possible that, in the +future, a new shell on an already running host will be started. + +\(fn)" t nil) + (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) + +(autoload 'erlang-compile "erlang" "\ +Compile Erlang module in current buffer. + +\(fn)" t nil) + +(autoload 'inferior-erlang "erlang" "\ +Run an inferior Erlang. +With prefix command, prompt for command to start Erlang with. + +This is just like running Erlang in a normal shell, except that +an Emacs buffer is used for input and output. +\\ +The command line history can be accessed with \\[comint-previous-input] and \\[comint-next-input]. +The history is saved between sessions. + +Entry to this mode calls the functions in the variables +`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. + +The following commands imitate the usual Unix interrupt and +editing control characters: +\\{erlang-shell-mode-map} + +\(fn &optional COMMAND)" t nil) + +;;;*** + +;;;### (autoloads nil "erlang-start" "erlang-start.el" (21837 24214 +;;;;;; 0 0)) +;;; Generated autoloads from erlang-start.el + +(let ((a '("\\.erl\\'" . erlang-mode)) (b '("\\.hrl\\'" . erlang-mode))) (or (assoc (car a) auto-mode-alist) (setq auto-mode-alist (cons a auto-mode-alist))) (or (assoc (car b) auto-mode-alist) (setq auto-mode-alist (cons b auto-mode-alist)))) + +(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode)) + +(let ((erl-ext '(".jam" ".vee" ".beam"))) (while erl-ext (let ((cie completion-ignored-extensions)) (while (and cie (not (string-equal (car cie) (car erl-ext)))) (setq cie (cdr cie))) (if (null cie) (setq completion-ignored-extensions (cons (car erl-ext) completion-ignored-extensions)))) (setq erl-ext (cdr erl-ext)))) + +;;;*** + +;;;### (autoloads nil nil ("erlang-eunit.el" "erlang-flymake.el" +;;;;;; "erlang-pkg.el" "erlang-skels-old.el" "erlang-skels.el" "erlang_appwiz.el") +;;;;;; (21837 24214 353646 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; erlang-autoloads.el ends here diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-eunit.el b/emacs.d/elpa/erlang-20150319.456/erlang-eunit.el similarity index 100% rename from emacs.d/elpa/erlang-20141104.17/erlang-eunit.el rename to emacs.d/elpa/erlang-20150319.456/erlang-eunit.el diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-flymake.el b/emacs.d/elpa/erlang-20150319.456/erlang-flymake.el similarity index 100% rename from emacs.d/elpa/erlang-20141104.17/erlang-flymake.el rename to emacs.d/elpa/erlang-20150319.456/erlang-flymake.el diff --git a/emacs.d/elpa/erlang-20150319.456/erlang-pkg.el b/emacs.d/elpa/erlang-20150319.456/erlang-pkg.el new file mode 100644 index 0000000..7cee827 --- /dev/null +++ b/emacs.d/elpa/erlang-20150319.456/erlang-pkg.el @@ -0,0 +1,4 @@ +(define-package "erlang" "20150319.456" "Erlang major mode" 'nil) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-skels-old.el b/emacs.d/elpa/erlang-20150319.456/erlang-skels-old.el similarity index 100% rename from emacs.d/elpa/erlang-20141104.17/erlang-skels-old.el rename to emacs.d/elpa/erlang-20150319.456/erlang-skels-old.el diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-skels.el b/emacs.d/elpa/erlang-20150319.456/erlang-skels.el similarity index 100% rename from emacs.d/elpa/erlang-20141104.17/erlang-skels.el rename to emacs.d/elpa/erlang-20150319.456/erlang-skels.el diff --git a/emacs.d/elpa/erlang-20141104.17/erlang-start.el b/emacs.d/elpa/erlang-20150319.456/erlang-start.el similarity index 100% rename from emacs.d/elpa/erlang-20141104.17/erlang-start.el rename to emacs.d/elpa/erlang-20150319.456/erlang-start.el diff --git a/emacs.d/elpa/erlang-20150319.456/erlang.el b/emacs.d/elpa/erlang-20150319.456/erlang.el new file mode 100644 index 0000000..0c003ba --- /dev/null +++ b/emacs.d/elpa/erlang-20150319.456/erlang.el @@ -0,0 +1,5796 @@ +;;; erlang.el --- Major modes for editing and running Erlang + +;; Copyright (C) 2004 Free Software Foundation, Inc. +;; Author: Anders Lindgren +;; Keywords: erlang, languages, processes +;; Date: 2011-12-11 + +;; %CopyrightBegin% +;; +;; Copyright Ericsson AB 1996-2014. All Rights Reserved. +;; +;; The contents of this file are subject to the Erlang Public License, +;; Version 1.1, (the "License"); you may not use this file except in +;; compliance with the License. You should have received a copy of the +;; Erlang Public License along with this software. If not, it can be +;; retrieved online at http://www.erlang.org/. +;; +;; Software distributed under the License is distributed on an "AS IS" +;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +;; the License for the specific language governing rights and limitations +;; under the License. +;; +;; %CopyrightEnd% +;; + +;; Lars Thorsén's modifications of 2000-06-07 included. +;; The original version of this package was written by Robert Virding. +;; +;;; Commentary: + +;; Introduction: +;; ------------ +;; +;; This package provides support for the programming language Erlang. +;; The package provides an editing mode with lots of bells and +;; whistles, compilation support, and it makes it possible for the +;; user to start Erlang shells that run inside Emacs. +;; +;; See the Erlang distribution for full documentation of this package. + +;; Installation: +;; ------------ +;; +;; Place this file in Emacs load path, byte-compile it, and add the +;; following line to the appropriate init file: +;; +;; (require 'erlang-start) +;; +;; The full documentation contains much more extensive description of +;; the installation procedure. + +;; Reporting Bugs: +;; -------------- +;; +;; Please send bug reports to the following email address: +;; erlang-bugs@erlang.org +;; or if you have a patch suggestion to: +;; erlang-patches@erlang.org +;; Please state as exactly as possible: +;; - Version number of Erlang Mode (see the menu), Emacs, Erlang, +;; and of any other relevant software. +;; - What the expected result was. +;; - What you did, preferably in a repeatable step-by-step form. +;; - A description of the unexpected result. +;; - Relevant pieces of Erlang code causing the problem. +;; - Personal Emacs customisations, if any. +;; +;; Should the Emacs generate an error, please set the Emacs variable +;; `debug-on-error' to `t'. Repeat the error and enclose the debug +;; information in your bug-report. +;; +;; To set the variable you can use the following command: +;; M-x set-variable RET debug-on-error RET t RET +;;; Code: + +(eval-when-compile (require 'cl)) + +;; Variables: + +(defconst erlang-version "2.7" + "The version number of Erlang mode.") + +(defvar erlang-root-dir nil + "The directory where the Erlang system is installed. +The name should not contain the trailing slash. + +Should this variable be nil, no manual pages will show up in the +Erlang mode menu.") + +(eval-and-compile + (defconst erlang-emacs-major-version + (if (boundp 'emacs-major-version) + emacs-major-version + (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) + (erlang-string-to-int (substring emacs-version + (match-beginning 1) (match-end 1)))) + "Major version number of Emacs.")) + +(eval-and-compile + (defconst erlang-emacs-minor-version + (if (boundp 'emacs-minor-version) + emacs-minor-version + (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) + (erlang-string-to-int (substring emacs-version + (match-beginning 2) (match-end 2)))) + "Minor version number of Emacs.")) + +(defconst erlang-xemacs-p (string-match "Lucid\\|XEmacs" emacs-version) + "Non-nil when running under XEmacs or Lucid Emacs.") + +(defvar erlang-xemacs-popup-menu '("Erlang Mode Commands" . nil) + "Common popup menu for all buffers in Erlang mode. + +This variable is destructively modified every time the Erlang menu +is modified. The effect is that all changes take effect in all +buffers in Erlang mode, just like under GNU Emacs. + +Never EVER set this variable!") + +(defvar erlang-menu-items '(erlang-menu-base-items + erlang-menu-skel-items + erlang-menu-shell-items + erlang-menu-compile-items + erlang-menu-man-items + erlang-menu-personal-items + erlang-menu-version-items) + "*List of menu item list to combine to create Erlang mode menu. + +External programs which temporarily add menu items to the Erlang mode +menu may use this variable. Please use the function `add-hook' to add +items. + +Please call the function `erlang-menu-init' after every change to this +variable.") + +(defvar erlang-menu-base-items + '(("Indent" + (("Indent Line" erlang-indent-command) + ("Indent Region " erlang-indent-region + (if erlang-xemacs-p (mark) mark-active)) + ("Indent Clause" erlang-indent-clause) + ("Indent Function" erlang-indent-function) + ("Indent Buffer" erlang-indent-current-buffer))) + ("Edit" + (("Fill Comment" erlang-fill-paragraph) + ("Comment Region" comment-region + (if erlang-xemacs-p (mark) mark-active)) + ("Uncomment Region" erlang-uncomment-region + (if erlang-xemacs-p (mark) mark-active)) + nil + ("Beginning of Function" erlang-beginning-of-function) + ("End of Function" erlang-end-of-function) + ("Mark Function" erlang-mark-function) + nil + ("Beginning of Clause" erlang-beginning-of-clause) + ("End of Clause" erlang-end-of-clause) + ("Mark Clause" erlang-mark-clause) + nil + ("New Clause" erlang-generate-new-clause) + ("Clone Arguments" erlang-clone-arguments) + nil + ("Align Arrows" erlang-align-arrows))) + ("Syntax Highlighting" + (("Level 4" erlang-font-lock-level-4) + ("Level 3" erlang-font-lock-level-3) + ("Level 2" erlang-font-lock-level-2) + ("Level 1" erlang-font-lock-level-1) + ("Off" erlang-font-lock-level-0))) + ("TAGS" + (("Find Tag" find-tag) + ("Find Next Tag" erlang-find-next-tag) + ;("Find Regexp" find-tag-regexp) + ("Complete Word" erlang-complete-tag) + ("Tags Apropos" tags-apropos) + ("Search Files" tags-search)))) + "Description of menu used in Erlang mode. + +This variable must be a list. The elements are either nil representing +a horizontal line or a list with two or three elements. The first is +the name of the menu item, the second is the function to call, or a +submenu, on the same same form as ITEMS. The third optional argument +is an expression which is evaluated every time the menu is displayed. +Should the expression evaluate to nil the menu item is ghosted. + +Example: + '((\"Func1\" function-one) + (\"SubItem\" + ((\"Yellow\" function-yellow) + (\"Blue\" function-blue))) + nil + (\"Region Function\" spook-function midnight-variable)) + +Call the function `erlang-menu-init' after modifying this variable.") + +(defvar erlang-menu-shell-items + '(nil + ("Shell" + (("Start New Shell" erlang-shell) + ("Display Shell" erlang-shell-display)))) + "Description of the Shell menu used by Erlang mode. + +Please see the documentation of `erlang-menu-base-items'.") + +(defvar erlang-menu-compile-items + '(("Compile" + (("Compile Buffer" erlang-compile) + ("Display Result" erlang-compile-display) + ("Next Error" erlang-next-error)))) + "Description of the Compile menu used by Erlang mode. + +Please see the documentation of `erlang-menu-base-items'.") + +(defvar erlang-menu-version-items + '(nil + ("Version" erlang-version)) + "Description of the version menu used in Erlang mode.") + +(defvar erlang-menu-personal-items nil + "Description of personal menu items used in Erlang mode. + +Please see the variable `erlang-menu-base-items' for a description +of the format.") + +(defvar erlang-menu-man-items nil + "The menu containing man pages. + +The format of the menu should be compatible with `erlang-menu-base-items'. +This variable is added to the list of Erlang menus stored in +`erlang-menu-items'.") + +(defvar erlang-menu-skel-items '() + "Description of the menu containing the skeleton entries. +The menu is in the form described by the variable `erlang-menu-base-items'.") + +(defvar erlang-mode-hook nil + "*Functions to run when Erlang mode is activated. + +This hook is used to change the behaviour of Erlang mode. It is +normally used by the user to personalise the programming environment. +When used in a site init file, it could be used to customise Erlang +mode for all users on the system. + +The functions added to this hook are run every time Erlang mode is +started. See also `erlang-load-hook', a hook which is run once, +when Erlang mode is loaded into Emacs, and `erlang-shell-mode-hook' +which is run every time a new inferior Erlang shell is started. + +To use a hook, create an Emacs lisp function to perform your actions +and add the function to the hook by calling `add-hook'. + +The following example binds the key sequence C-c C-c to the command +`erlang-compile' (normally bound to C-c C-k). The example also +activates Font Lock mode to fontify the buffer and adds a menu +containing all functions defined in the current buffer. + +To use the example, copy the following lines to your `~/.emacs' file: + + (add-hook 'erlang-mode-hook 'my-erlang-mode-hook) + + (defun my-erlang-mode-hook () + (local-set-key \"\\C-c\\C-c\" 'erlang-compile) + (if window-system + (progn + (setq font-lock-maximum-decoration t) + (font-lock-mode 1))) + (if (and window-system (fboundp 'imenu-add-to-menubar)) + (imenu-add-to-menubar \"Imenu\")))") + +(defvar erlang-load-hook nil + "*Functions to run when Erlang mode is loaded. + +This hook is used to change the behaviour of Erlang mode. It is +normally used by the user to personalise the programming environment. +When used in a site init file, it could be used to customize Erlang +mode for all users on the system. + +The difference between this hook and `erlang-mode-hook' and +`erlang-shell-mode-hook' is that the functions in this hook +is only called once, when the Erlang mode is loaded into Emacs +the first time. + +Natural actions for the functions added to this hook are actions which +only should be performed once, and actions which should be performed +before starting Erlang mode. For example, a number of variables are +used by Erlang mode before `erlang-mode-hook' is run. + +The following example sets the variable `erlang-root-dir' so that the +manual pages can be retrieved (note that you must set the value of +`erlang-root-dir' to match the location of Erlang on your system): + + (add-hook 'erlang-load-hook 'my-erlang-load-hook) + + (defun my-erlang-load-hook () + (setq erlang-root-dir \"/usr/local/erlang\"))") + +(defvar erlang-new-file-hook nil + "Functions to run when a new Erlang source file is being edited. + +A useful function is `tempo-template-erlang-normal-header'. +\(This function only exists when the `tempo' package is available.)") + +(defvar erlang-check-module-name 'ask + "*Non-nil means check that module name and file name agrees when saving. + +If the value of this variable is the atom `ask', the user is +prompted. If the value is t the source is silently changed.") + +(defvar erlang-electric-commands + '(erlang-electric-comma + erlang-electric-semicolon + erlang-electric-gt) + "*List of activated electric commands. + +The list should contain the electric commands which should be active. +Currently, the available electric commands are: + `erlang-electric-comma' + `erlang-electric-semicolon' + `erlang-electric-gt' + `erlang-electric-newline' + +Should the variable be bound to t, all electric commands +are activated. + +To deactivate all electric commands, set this variable to nil.") + +(defvar erlang-electric-newline-inhibit t + "*Set to non-nil to inhibit newline after electric command. + +This is useful since a lot of people press return after executing an +electric command. + +In order to work, the command must also be in the +list `erlang-electric-newline-inhibit-list'. + +Note that commands in this list are required to set the variable +`erlang-electric-newline-inhibit' to nil when the newline shouldn't be +inhibited.") + +(defvar erlang-electric-newline-inhibit-list + '(erlang-electric-semicolon + erlang-electric-comma + erlang-electric-gt) + "*Commands which can inhibit the next newline.") + +(defvar erlang-electric-semicolon-insert-blank-lines nil + "*Number of blank lines inserted before header, or nil. + +This variable controls the behaviour of `erlang-electric-semicolon' +when a new function header is generated. When nil, no blank line is +inserted between the current line and the new header. When bound to a +number it represents the number of blank lines which should be +inserted.") + +(defvar erlang-electric-semicolon-criteria + '(erlang-next-lines-empty-p + erlang-at-keyword-end-p + erlang-at-end-of-function-p) + "*List of functions controlling `erlang-electric-semicolon'. +The functions in this list are called, in order, whenever a semicolon +is typed. Each function in the list is called with no arguments, +and should return one of the following values: + + nil -- no determination made, continue checking + 'stop -- do not create prototype for next line + (anything else) -- insert prototype, and stop checking + +If every function in the list is called with no determination made, +then no prototype is inserted. + +The test is performed by the function `erlang-test-criteria-list'.") + +(defvar erlang-electric-comma-criteria + '(erlang-stop-when-inside-argument-list + erlang-stop-when-at-guard + erlang-next-lines-empty-p + erlang-at-keyword-end-p + erlang-at-end-of-clause-p + erlang-at-end-of-function-p) + "*List of functions controlling `erlang-electric-comma'. +The functions in this list are called, in order, whenever a comma +is typed. Each function in the list is called with no arguments, +and should return one of the following values: + + nil -- no determination made, continue checking + 'stop -- do not create prototype for next line + (anything else) -- insert prototype, and stop checking + +If every function in the list is called with no determination made, +then no prototype is inserted. + +The test is performed by the function `erlang-test-criteria-list'.") + +(defvar erlang-electric-arrow-criteria + '(erlang-stop-when-in-type-spec + erlang-next-lines-empty-p + erlang-at-end-of-function-p) + "*List of functions controlling the arrow aspect of `erlang-electric-gt'. +The functions in this list are called, in order, whenever a `>' +is typed. Each function in the list is called with no arguments, +and should return one of the following values: + + nil -- no determination made, continue checking + 'stop -- do not create prototype for next line + (anything else) -- insert prototype, and stop checking + +If every function in the list is called with no determination made, +then no prototype is inserted. + +The test is performed by the function `erlang-test-criteria-list'.") + +(defvar erlang-electric-newline-criteria + '(t) + "*List of functions controlling `erlang-electric-newline'. + +The electric newline commands indents the next line. Should the +current line begin with a comment the comment start is copied to +the newly created line. + +The functions in this list are called, in order, whenever a comma +is typed. Each function in the list is called with no arguments, +and should return one of the following values: + + nil -- no determination made, continue checking + 'stop -- do not create prototype for next line + (anything else) -- trigger the electric command. + +If every function in the list is called with no determination made, +then no prototype is inserted. Should the atom t be a member of the +list, it is treated as a function triggering the electric command. + +The test is performed by the function `erlang-test-criteria-list'.") + +(defvar erlang-next-lines-empty-threshold 2 + "*Number of blank lines required to activate an electric command. + +Actually, this value controls the behaviour of the function +`erlang-next-lines-empty-p' which normally is a member of the +criteria lists controlling the electric commands. (Please see +the variables `erlang-electric-semicolon-criteria' and +`erlang-electric-comma-criteria'.) + +The variable is bound to a threshold value, a number, representing the +number of lines which must be empty. + +Setting this variable to zero, electric commands will always be +triggered by `erlang-next-lines-empty-p', unless inhibited by other +rules. + +Should this variable be nil, `erlang-next-lines-empty-p' will never +trigger an electric command. The same effect would be reached if the +function `erlang-next-lines-empty-p' would be removed from the criteria +lists. + +Note that even if `erlang-next-lines-empty-p' should not trigger an +electric command, other functions in the criteria list could.") + +(defvar erlang-new-clause-with-arguments nil + "*Non-nil means that the arguments are cloned when a clause is generated. + +A new function header can be generated by calls to the function +`erlang-generate-new-clause' and by use of the electric semicolon.") + +(defvar erlang-compile-use-outdir t + "*When nil, go to the directory containing source file when compiling. + +This is a workaround for a bug in the `outdir' option of compile. If the +outdir is not in the current load path, Erlang doesn't load the object +module after it has been compiled. + +To activate the workaround, place the following in your `~/.emacs' file: + (setq erlang-compile-use-outdir nil)") + +(defvar erlang-indent-level 4 + "*Indentation of Erlang calls/clauses within blocks.") +(put 'erlang-indent-level 'safe-local-variable 'integerp) + +(defvar erlang-indent-guard 2 + "*Indentation of Erlang guards.") +(put 'erlang-indent-guard 'safe-local-variable 'integerp) + +(defvar erlang-argument-indent 2 + "*Indentation of the first argument in a function call. +When nil, indent to the column after the `(' of the +function.") +(put 'erlang-argument-indent 'safe-local-variable '(lambda (val) (or (null val) (integerp val)))) + +(defvar erlang-tab-always-indent t + "*Non-nil means TAB in Erlang mode should always re-indent the current line, +regardless of where in the line point is when the TAB command is used.") + +(defvar erlang-man-inhibit (eq system-type 'windows-nt) + "Inhibit the creation of the Erlang Manual Pages menu. + +The Windows distribution of Erlang does not include man pages, hence +there is no attempt to create the menu.") + +(defvar erlang-man-dirs + '(("Man - Commands" "/man/man1" t) + ("Man - Modules" "/man/man3" t) + ("Man - Files" "/man/man4" t) + ("Man - Applications" "/man/man6" t)) + "*The man directories displayed in the Erlang menu. + +Each item in the list should be a list with three elements, the first +the name of the menu, the second the directory, and the last a flag. +Should the flag the nil, the directory is absolute, should it be non-nil +the directory is relative to the variable `erlang-root-dir'.") + +(defvar erlang-man-max-menu-size 35 + "*The maximum number of menu items in one menu allowed.") + +(defvar erlang-man-display-function 'erlang-man-display + "*Function used to display man page. + +The function is called with one argument, the name of the file +containing the man page. Use this variable when the default +function, `erlang-man-display', does not work on your system.") + +(defvar erlang-compile-extra-opts '() + "*Additional options to the compilation command. +This is an elisp list of options. Each option can be either: +- an atom +- a dotted pair +- a string +Example: '(bin_opt_info (i . \"/path1/include\") (i . \"/path2/include\"))") + +(defvar erlang-compile-command-function-alist + '((".erl\\'" . inferior-erlang-compute-erl-compile-command) + (".xrl\\'" . inferior-erlang-compute-leex-compile-command) + (".yrl\\'" . inferior-erlang-compute-yecc-compile-command) + ("." . inferior-erlang-compute-erl-compile-command)) + "*Alist of filename patterns vs corresponding compilation functions. +Each element looks like (REGEXP . FUNCTION). Compiling a file whose name +matches REGEXP specifies FUNCTION to use to compute the compilation +command. The FUNCTION will be called with two arguments: module name and +default compilation options, like output directory. The FUNCTION +is expected to return a string.") + +(defvar erlang-leex-compile-opts '() + "*Options to pass to leex when compiling xrl files. +This is an elisp list of options. Each option can be either: +- an atom +- a dotted pair +- a string") + +(defvar erlang-yecc-compile-opts '() + "*Options to pass to yecc when compiling yrl files. +This is an elisp list of options. Each option can be either: +- an atom +- a dotted pair +- a string") + +(eval-and-compile + (defvar erlang-regexp-modern-p + (if (> erlang-emacs-major-version 21) t nil) + "Non-nil when this version of Emacs uses a modern version of regexp. +Supporting \_< and \_> This is determined by checking the version of Emacs used.")) + +(eval-and-compile + (defconst erlang-atom-quoted-regexp + "'\\(?:[^\\']\\|\\(?:\\\\.\\)\\)*'" + "Regexp describing a single-quoted atom")) + +(eval-and-compile + (defconst erlang-atom-regular-regexp + (if erlang-regexp-modern-p + "\\_<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\_>" + "\\<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\>") + "Regexp describing a regular (non-quoted) atom")) + +(eval-and-compile + (defconst erlang-atom-regexp + (concat "\\(" erlang-atom-quoted-regexp "\\|" + erlang-atom-regular-regexp "\\)") + "Regexp describing an Erlang atom.")) + +(eval-and-compile + (defconst erlang-atom-regexp-matches 1 + "Number of regexp parenthesis pairs in `erlang-atom-regexp'. + +This is used to determine parenthesis matches in complex regexps which +contains `erlang-atom-regexp'.")) + + +(eval-and-compile + (defconst erlang-variable-regexp + (if erlang-regexp-modern-p + "\\_<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\_>" + "\\<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\>") + "Regexp which should match an Erlang variable. + +The regexp must be surrounded with a pair of regexp parentheses.")) + +(eval-and-compile + (defconst erlang-variable-regexp-matches 1 + "Number of regexp parenthesis pairs in `erlang-variable-regexp'. + +This is used to determine matches in complex regexps which contains +`erlang-variable-regexp'.")) + + +(eval-and-compile + (defun erlang-regexp-opt (strings &optional paren) + "Like `regexp-opt', except if PAREN is `symbols', then the +resulting regexp is surrounded by \\_< and \\_>." + (if (eq paren 'symbols) + (if erlang-regexp-modern-p + (concat "\\_<" (regexp-opt strings t) "\\_>") + (concat "\\<" (regexp-opt strings t) "\\>")) + (regexp-opt strings paren)))) + + +(eval-and-compile + (defvar erlang-keywords + '("after" + "begin" + "catch" + "case" + "cond" + "end" + "fun" + "if" + "let" + "of" + "receive" + "try" + "when") + "Erlang reserved keywords")) + +(eval-and-compile + (defconst erlang-keywords-regexp (erlang-regexp-opt erlang-keywords 'symbols))) + +(eval-and-compile + (defvar erlang-operators + '("and" + "andalso" + "band" + "bnot" + "bor" + "bsl" + "bsr" + "bxor" + "div" + "not" + "or" + "orelse" + "rem" + "xor") + "Erlang operators")) +;; What about these? +;; '+' '-' '*' '/' '>', '>=', '<', '=<', '=:=', '==', '=/=', '/=' + +(eval-and-compile + (defconst erlang-operators-regexp (erlang-regexp-opt erlang-operators 'symbols))) + + +(eval-and-compile + (defvar erlang-guards + '("is_atom" + "is_binary" + "is_bitstring" + "is_boolean" + "is_float" + "is_function" + "is_integer" + "is_list" + "is_map" + "is_number" + "is_pid" + "is_port" + "is_record" + "is_reference" + "is_tuple" + "atom" + "binary" + "bitstring" + "boolean" + ;;"float" ; Not included to avoid clashes with the bif float/1 + "function" + "integer" + "list" + "number" + "pid" + "port" + "record" + "reference" + "tuple") + "Erlang guards")) + +(eval-and-compile + (defconst erlang-guards-regexp (erlang-regexp-opt erlang-guards 'symbols))) + +(eval-and-compile + (defvar erlang-predefined-types + '("any" + "arity" + "boolean" + "byte" + "char" + "cons" + "deep_string" + "iodata" + "iolist" + "maybe_improper_list" + "module" + "mfa" + "nil" + "neg_integer" + "none" + "non_neg_integer" + "nonempty_list" + "nonempty_improper_list" + "nonempty_maybe_improper_list" + "nonempty_string" + "no_return" + "pos_integer" + "string" + "term" + "timeout" + "map") + "Erlang type specs types")) + +(eval-and-compile + (defconst erlang-predefined-types-regexp + (erlang-regexp-opt erlang-predefined-types 'symbols))) + + +(eval-and-compile + (defvar erlang-int-bifs + '("abs" + "apply" + "atom_to_binary" + "atom_to_list" + "binary_to_atom" + "binary_to_existing_atom" + "binary_to_float" + "binary_to_integer" + "binary_to_list" + "binary_to_term" + "binary_part" + "bit_size" + "bitsize" + "bitstring_to_list" + "byte_size" + "check_old_code" + "check_process_code" + "date" + "delete_module" + "demonitor" + "disconnect_node" + "element" + "erase" + "error" + "exit" + "float" + "float_to_binary" + "float_to_list" + "garbage_collect" + "get" + "get_keys" + "group_leader" + "halt" + "hd" + "integer_to_list" + "integer_to_binary" + "iolist_size" + "iolist_to_binary" + "is_alive" + "is_atom" + "is_binary" + "is_bitstring" + "is_boolean" + "is_float" + "is_function" + "is_integer" + "is_list" + "is_map" + "is_number" + "is_pid" + "is_port" + "is_process_alive" + "is_record" + "is_reference" + "is_tuple" + "length" + "link" + "list_to_atom" + "list_to_binary" + "list_to_bitstring" + "list_to_existing_atom" + "list_to_float" + "list_to_integer" + "list_to_pid" + "list_to_tuple" + "load_module" + "make_ref" + "map_size" + "max" + "min" + "module_loaded" + "monitor" + "monitor_node" + "node" + "nodes" + "now" + "open_port" + "pid_to_list" + "port_close" + "port_command" + "port_connect" + "port_control" + "pre_loaded" + "process_flag" + "process_info" + "processes" + "purge_module" + "put" + "register" + "registered" + "round" + "self" + "setelement" + "size" + "spawn" + "spawn_link" + "spawn_monitor" + "spawn_opt" + "split_binary" + "statistics" + "term_to_binary" + "time" + "throw" + "tl" + "trunc" + "tuple_size" + "tuple_to_list" + "unlink" + "unregister" + "whereis") + "Erlang built-in functions (BIFs)")) + +(eval-and-compile + (defconst erlang-int-bif-regexp (erlang-regexp-opt erlang-int-bifs 'symbols))) + + +(eval-and-compile + (defvar erlang-ext-bifs + '("adler32" + "adler32_combine" + "alloc_info" + "alloc_sizes" + "append" + "append_element" + "await_proc_exit" + "await_sched_wall_time_modifications" + "bump_reductions" + "call_on_load_function" + "cancel_timer" + "crasher" + "crc32" + "crc32_combine" + "decode_packet" + "delay_trap" + "delete_element" + "dexit" + "dgroup_leader" + "display" + "display_nl" + "display_string" + "dist_exit" + "dlink" + "dmonitor_node" + "dmonitor_p" + "dsend" + "dt_append_vm_tag_data" + "dt_get_tag" + "dt_get_tag_data" + "dt_prepend_vm_tag_data" + "dt_put_tag" + "dt_restore_tag" + "dt_spread_tag" + "dunlink" + "external_size" + "finish_after_on_load" + "finish_loading" + "flush_monitor_message" + "format_cpu_topology" + "fun_info" + "fun_info_mfa" + "fun_to_list" + "function_exported" + "garbage_collect_message_area" + "gather_gc_info_result" + "gather_sched_wall_time_result" + "get_cookie" + "get_module_info" + "get_stacktrace" + "hash" + "hibernate" + "insert_element" + "is_builtin" + "load_nif" + "loaded" + "localtime" + "localtime_to_universaltime" + "make_fun" + "make_tuple" + "match_spec_test" + "md5" + "md5_final" + "md5_init" + "md5_update" + "memory" + "module_info" + "monitor_node" + "nif_error" + "phash" + "phash2" + "port_call" + "port_get_data" + "port_info" + "port_set_data" + "port_to_list" + "ports" + "posixtime_to_universaltime" + "prepare_loading" + "process_display" + "raise" + "read_timer" + "ref_to_list" + "resume_process" + "send" + "send_after" + "send_nosuspend" + "seq_trace" + "seq_trace_info" + "seq_trace_print" + "set_cookie" + "set_cpu_topology" + "setnode" + "spawn_opt" + "start_timer" + "subtract" + "suspend_process" + "system_flag" + "system_info" + "system_monitor" + "system_profile" + "trace" + "trace_delivered" + "trace_info" + "trace_pattern" + "universaltime" + "universaltime_to_localtime" + "universaltime_to_posixtime" + "yield") + "Erlang built-in functions (BIFs) that needs erlang: prefix")) + +(eval-and-compile + (defconst erlang-ext-bif-regexp + (erlang-regexp-opt (append erlang-int-bifs erlang-ext-bifs) 'symbols))) + + +(defvar erlang-defun-prompt-regexp (concat "^" erlang-atom-regexp "\\s *(") + "Regexp which should match beginning of a clause.") + +(defvar erlang-file-name-extension-regexp "\\.[eh]rl$" + "*Regexp which should match an Erlang file name. + +This regexp is used when an Erlang module name is extracted from the +name of an Erlang source file. + +The regexp should only match the section of the file name which should +be excluded from the module name. + +To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\". +The matches all except the extension. This is useful if the Erlang +tags system should interpret tags on the form `module:tag' for +files written in other languages than Erlang.") + +(defvar erlang-inferior-shell-split-window t + "*If non-nil, when starting an inferior shell, split windows. +If nil, the inferior shell replaces the window. This is the traditional +behaviour.") + +(defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist) + "Non-nil means use `compilation-minor-mode' in Erlang shell.") + +(defvar erlang-mode-map + (let ((map (make-sparse-keymap))) + (unless (boundp 'indent-line-function) + (define-key map "\t" 'erlang-indent-command)) + (define-key map ";" 'erlang-electric-semicolon) + (define-key map "," 'erlang-electric-comma) + (define-key map "<" 'erlang-electric-lt) + (define-key map ">" 'erlang-electric-gt) + (define-key map "\C-m" 'erlang-electric-newline) + (if (not (boundp 'delete-key-deletes-forward)) + (define-key map "\177" 'backward-delete-char-untabify) + (define-key map [(backspace)] 'backward-delete-char-untabify)) + ;;(unless (boundp 'fill-paragraph-function) + (define-key map "\M-q" 'erlang-fill-paragraph) + (unless (boundp 'beginning-of-defun-function) + (define-key map "\M-\C-a" 'erlang-beginning-of-function) + (define-key map "\M-\C-e" 'erlang-end-of-function) + (define-key map '(meta control h) 'erlang-mark-function)) ; Xemacs + (define-key map "\M-\t" 'erlang-complete-tag) + (define-key map "\C-c\M-\t" 'tempo-complete-tag) + (define-key map "\M-+" 'erlang-find-next-tag) + (define-key map "\C-c\M-a" 'erlang-beginning-of-clause) + (define-key map "\C-c\M-b" 'tempo-backward-mark) + (define-key map "\C-c\M-e" 'erlang-end-of-clause) + (define-key map "\C-c\M-f" 'tempo-forward-mark) + (define-key map "\C-c\M-h" 'erlang-mark-clause) + (define-key map "\C-c\C-c" 'comment-region) + (define-key map "\C-c\C-j" 'erlang-generate-new-clause) + (define-key map "\C-c\C-k" 'erlang-compile) + (define-key map "\C-c\C-l" 'erlang-compile-display) + (define-key map "\C-c\C-s" 'erlang-show-syntactic-information) + (define-key map "\C-c\C-q" 'erlang-indent-function) + (define-key map "\C-c\C-u" 'erlang-uncomment-region) + (define-key map "\C-c\C-y" 'erlang-clone-arguments) + (define-key map "\C-c\C-a" 'erlang-align-arrows) + (define-key map "\C-c\C-z" 'erlang-shell-display) + (unless inferior-erlang-use-cmm + (define-key map "\C-x`" 'erlang-next-error)) + map) + "*Keymap used in Erlang mode.") +(defvar erlang-mode-abbrev-table nil + "Abbrev table in use in Erlang-mode buffers.") +(defvar erlang-mode-syntax-table nil + "Syntax table in use in Erlang-mode buffers.") + + + +(defvar erlang-skel-file "erlang-skels" + "The type of erlang-skeletons that should be used, default + uses edoc type, for the old type, standard comments, + set \"erlang-skels-old\" in your .emacs and restart. + + Or define your own and set the variable to that file.") + +;; Tempo skeleton templates: +(load erlang-skel-file) + +;; Font-lock variables + +;; The next few variables define different Erlang font-lock patterns. +;; They could be appended to form a custom font-lock appearance. +;; +;; The function `erlang-font-lock-set-face' could be used to change +;; the face of a pattern. +;; +;; Note that Erlang strings and atoms are highlighted with using +;; syntactic analysis. + +(defvar erlang-font-lock-keywords-function-header + (list + (list (concat "^" erlang-atom-regexp "\\s-*(") + 1 'font-lock-function-name-face t)) + "Font lock keyword highlighting a function header.") + +(defface erlang-font-lock-exported-function-name-face + '((default (:inherit font-lock-function-name-face))) + "Face used for highlighting exported functions.") + +(defvar erlang-font-lock-exported-function-name-face + 'erlang-font-lock-exported-function-name-face) + +(defvar erlang-inhibit-exported-function-name-face nil + "Inhibit separate face for exported functions") + +(defvar erlang-font-lock-keywords-exported-function-header + (list + (list #'erlang-match-next-exported-function + 1 'erlang-font-lock-exported-function-name-face t)) + "Font lock keyword highlighting an exported function header.") + +(defvar erlang-font-lock-keywords-int-bifs + (list + (list (concat erlang-int-bif-regexp "\\s-*(") + 1 'font-lock-builtin-face)) + "Font lock keyword highlighting built in functions.") + +(defvar erlang-font-lock-keywords-ext-bifs + (list + (list (concat "\\<\\(erlang\\)\\s-*:\\s-*" erlang-ext-bif-regexp "\\s-*(") + '(1 'font-lock-builtin-face) + '(2 'font-lock-builtin-face))) + "Font lock keyword highlighting built in functions.") + +(defvar erlang-font-lock-keywords-int-function-calls + (list + (list (concat erlang-atom-regexp "\\s-*(") + 1 'font-lock-type-face)) + "Font lock keyword highlighting an internal function call.") + +(defvar erlang-font-lock-keywords-ext-function-calls + (list + (list (concat erlang-atom-regexp "\\s-*:\\s-*" + erlang-atom-regexp "\\s-*(") + '(1 'font-lock-type-face) + '(2 'font-lock-type-face))) + "Font lock keyword highlighting an external function call.") + +(defvar erlang-font-lock-keywords-fun-n + (list + (list (concat "\\(" erlang-atom-regexp "/[0-9]+\\)") + 1 'font-lock-type-face)) + "Font lock keyword highlighting a fun descriptor in F/N format.") + +(defvar erlang-font-lock-keywords-operators + (list + (list erlang-operators-regexp + 1 'font-lock-builtin-face)) + "Font lock keyword highlighting Erlang operators.") + +(defvar erlang-font-lock-keywords-dollar + (list + (list "\\(\\$\\([^\\]\\|\\\\\\([^0-7^\n]\\|[0-7]+\\|\\^[a-zA-Z]\\)\\)\\)" + 1 'font-lock-constant-face)) + "Font lock keyword highlighting numbers in ASCII form (e.g. $A).") + +(defvar erlang-font-lock-keywords-arrow + (list + (list "->\\(\\s \\|$\\)" 1 'font-lock-function-name-face)) + "Font lock keyword highlighting clause arrow.") + +(defvar erlang-font-lock-keywords-lc + (list + (list "\\(<-\\|<=\\|||\\)\\(\\s \\|$\\)" 1 'font-lock-keyword-face)) + "Font lock keyword highlighting list comprehension operators.") + +(defvar erlang-font-lock-keywords-keywords + (list + (list erlang-keywords-regexp 1 'font-lock-keyword-face)) + "Font lock keyword highlighting Erlang keywords.") + +(defvar erlang-font-lock-keywords-attr + (list + (list (concat "^\\(-" erlang-atom-regexp "\\)\\(\\s-\\|\\.\\|(\\)") + 1 (if (boundp 'font-lock-preprocessor-face) + 'font-lock-preprocessor-face + 'font-lock-constant-face))) + "Font lock keyword highlighting attributes.") + +(defvar erlang-font-lock-keywords-quotes + (list + (list "`\\([-+a-zA-Z0-9_:*][-+a-zA-Z0-9_:*]+\\)'" + 1 + 'font-lock-keyword-face + t)) + "Font lock keyword highlighting words in single quotes in comments. + +This is not the highlighting of Erlang strings and atoms, which +are highlighted by syntactic analysis.") + +(defvar erlang-font-lock-keywords-guards + (list + (list (concat "[^:]" erlang-guards-regexp "\\s-*(") + 1 'font-lock-builtin-face)) + "Font lock keyword highlighting guards.") + +(defvar erlang-font-lock-keywords-predefined-types + (list + (list (concat "[^:]" erlang-predefined-types-regexp "\\s-*(") + 1 'font-lock-builtin-face)) + "Font lock keyword highlighting predefined types.") + + +(defvar erlang-font-lock-keywords-macros + (list + (list (concat "?\\s-*\\(" erlang-atom-regexp + "\\|" erlang-variable-regexp "\\)") + 1 'font-lock-constant-face) + (list (concat "^\\(-\\(?:define\\|ifn?def\\)\\)\\s-*(\\s-*\\(" erlang-atom-regexp + "\\|" erlang-variable-regexp "\\)") + (if (boundp 'font-lock-preprocessor-face) + (list 1 'font-lock-preprocessor-face t) + (list 1 'font-lock-constant-face t)) + (list 3 'font-lock-type-face t t)) + (list "^-e\\(lse\\|ndif\\)\\>" 0 'font-lock-preprocessor-face t)) + "Font lock keyword highlighting macros. +This must be placed in front of `erlang-font-lock-keywords-vars'.") + +(defvar erlang-font-lock-keywords-records + (list + (list (concat "#\\s *" erlang-atom-regexp) + 1 'font-lock-type-face) + ;; Don't highlight numerical constants. + (list (if erlang-regexp-modern-p + "\\_<[0-9]+#\\([0-9a-zA-Z]+\\)" + "\\<[0-9]+#\\([0-9a-zA-Z]+\\)") + 1 nil t) + (list (concat "^-record\\s-*(\\s-*" erlang-atom-regexp) + 1 'font-lock-type-face)) + "Font lock keyword highlighting Erlang records. +This must be placed in front of `erlang-font-lock-keywords-vars'.") + +(defvar erlang-font-lock-keywords-vars + (list + (list (concat "[^#]" erlang-variable-regexp) ; no numerical constants + 1 'font-lock-variable-name-face)) + "Font lock keyword highlighting Erlang variables. +Must be preceded by `erlang-font-lock-keywords-macros' to work properly.") + +(defvar erlang-font-lock-descr-string + "Font-lock keywords used by Erlang Mode. + +There exists three levels of Font Lock keywords for Erlang: + `erlang-font-lock-keywords-1' - Function headers and reserved keywords. + `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'. + `erlang-font-lock-keywords-3' - Variables, macros and records. + `erlang-font-lock-keywords-4' - Exported functions, Function names, + Funs, LCs (not Atoms). + +To use a specific level, please set the variable +`font-lock-maximum-decoration' to the appropriate level. Note that the +variable must be set before Erlang mode is activated. + +Example: + (setq font-lock-maximum-decoration 2)") + +(defvar erlang-font-lock-keywords-1 + (append erlang-font-lock-keywords-function-header + erlang-font-lock-keywords-dollar + erlang-font-lock-keywords-arrow + erlang-font-lock-keywords-keywords + ) + ;; DocStringOrig: erlang-font-lock-keywords + erlang-font-lock-descr-string) + +(defvar erlang-font-lock-keywords-2 + (append erlang-font-lock-keywords-1 + erlang-font-lock-keywords-int-bifs + erlang-font-lock-keywords-ext-bifs + erlang-font-lock-keywords-attr + erlang-font-lock-keywords-quotes + erlang-font-lock-keywords-guards + ) + ;; DocStringCopy: erlang-font-lock-keywords + erlang-font-lock-descr-string) + +(defvar erlang-font-lock-keywords-3 + (append erlang-font-lock-keywords-2 + erlang-font-lock-keywords-operators + erlang-font-lock-keywords-macros + erlang-font-lock-keywords-records + erlang-font-lock-keywords-vars + erlang-font-lock-keywords-predefined-types + ) + ;; DocStringCopy: erlang-font-lock-keywords + erlang-font-lock-descr-string) + +(defvar erlang-font-lock-keywords-4 + (append erlang-font-lock-keywords-3 + erlang-font-lock-keywords-exported-function-header + erlang-font-lock-keywords-int-function-calls + erlang-font-lock-keywords-ext-function-calls + erlang-font-lock-keywords-fun-n + erlang-font-lock-keywords-lc + ) + ;; DocStringCopy: erlang-font-lock-keywords + erlang-font-lock-descr-string) + +(defvar erlang-font-lock-keywords erlang-font-lock-keywords-4 + ;; DocStringCopy: erlang-font-lock-keywords + erlang-font-lock-descr-string) + +(defvar erlang-font-lock-syntax-table nil + "Syntax table used by Font Lock mode. + +The difference between this and the standard Erlang Mode +syntax table is that `_' is treated as part of words by +this syntax table. + +Unfortunately, XEmacs hasn't got support for a special Font +Lock syntax table. The effect is that `apply' in the atom +`foo_apply' will be highlighted as a bif.") + + +;;; Avoid errors while compiling this file. + +;; `eval-when-compile' is not defined in Emacs 18. We define it as a +;; no-op. +(or (fboundp 'eval-when-compile) + (defmacro eval-when-compile (&rest rest) nil)) + +;; These umm...functions are new in Emacs 20. And, yes, until version +;; 19.27 Emacs backquotes were this ugly. + +(or (fboundp 'unless) + (defmacro unless (condition &rest body) + "(unless CONDITION BODY...): If CONDITION is false, do BODY, else return nil." + `((if (, condition) nil ,@body)))) + +(or (fboundp 'when) + (defmacro when (condition &rest body) + "(when CONDITION BODY...): If CONDITION is true, do BODY, else return nil." + `((if (, condition) (progn ,@body) nil)))) + +(or (fboundp 'char-before) + (defmacro char-before (&optional pos) + "Return the character in the current buffer just before POS." + `( (char-after (1- (or ,pos (point))))))) + +;; defvar some obsolete variables, which we still support for +;; backwards compatibility reasons. +(eval-when-compile + (defvar comment-indent-hook) + (defvar dabbrev-case-fold-search) + (defvar tempo-match-finder) + (defvar compilation-menu-map) + (defvar next-error-last-buffer)) + +(eval-when-compile + (if (or (featurep 'bytecomp) + (featurep 'byte-compile)) + (progn + (cond ((string-match "Lucid\\|XEmacs" emacs-version) + (put 'comment-indent-hook 'byte-obsolete-variable nil) + ;; Do not warn for unused variables + ;; when compiling under XEmacs. + (setq byte-compile-warnings + '(free-vars unresolved callargs redefine)))) + (require 'comint) + (require 'tempo) + (require 'compile)))) + + +(defun erlang-version () + "Return the current version of Erlang mode." + (interactive) + (if (interactive-p) + (message "Erlang mode version %s, written by Anders Lindgren" + erlang-version)) + erlang-version) + + +;;;###autoload +(defun erlang-mode () + "Major mode for editing Erlang source files in Emacs. +It knows about syntax and comment, it can indent code, it is capable +of fontifying the source file, the TAGS commands are aware of Erlang +modules, and the Erlang man pages can be accessed. + +Should this module, \"erlang.el\", be installed properly, Erlang mode +is activated whenever an Erlang source or header file is loaded into +Emacs. To indicate this, the mode line should contain the word +\"Erlang\". + +The main feature of Erlang mode is indentation, press TAB and the +current line will be indented correctly. + +Comments starting with only one `%' are indented to the column stored +in the variable `comment-column'. Comments starting with two `%':s +are indented with the same indentation as code. Comments starting +with at least three `%':s are indented to the first column. + +However, Erlang mode contains much more, this is a list of the most +useful commands: + TAB - Indent the line. + C-c C-q - Indent current function. + M-; - Create a comment at the end of the line. + M-q - Fill a comment, i.e. wrap lines so that they (hopefully) + will look better. + M-a - Goto the beginning of an Erlang clause. + M-C-a - Ditto for function. + M-e - Goto the end of an Erlang clause. + M-C-e - Ditto for function. + M-h - Mark current Erlang clause. + M-C-h - Ditto for function. + C-c C-z - Start, or switch to, an inferior Erlang shell. + C-c C-k - Compile current file. + C-x ` - Next error. + , - Electric comma. + ; - Electric semicolon. + +Erlang mode check the name of the file against the module name when +saving, whenever a mismatch occurs Erlang mode offers to modify the +source. + +The variable `erlang-electric-commands' controls the electric +commands. To deactivate all of them, set it to nil. + +There exists a large number of commands and variables in the Erlang +module. Please press `M-x apropos RET erlang RET' to see a complete +list. Press `C-h f name-of-function RET' and `C-h v name-of-variable +RET'to see the full description of functions and variables, +respectively. + +On entry to this mode the contents of the hook `erlang-mode-hook' is +executed. + +Please see the beginning of the file `erlang.el' for more information +and examples of hooks. + +Other commands: +\\{erlang-mode-map}" + (interactive) + (kill-all-local-variables) + (setq major-mode 'erlang-mode) + (setq mode-name "Erlang") + (erlang-syntax-table-init) + (use-local-map erlang-mode-map) + (erlang-electric-init) + (erlang-menu-init) + (erlang-mode-variables) + (erlang-check-module-name-init) + (erlang-man-init) + (erlang-tags-init) + (erlang-font-lock-init) + (erlang-skel-init) + (tempo-use-tag-list 'erlang-tempo-tags) + (run-hooks 'erlang-mode-hook) + (if (zerop (buffer-size)) + (run-hooks 'erlang-new-file-hook)) + ;; Doesn't exist in Emacs v21.4; required by Emacs v23. + (if (boundp 'after-change-major-mode-hook) + (run-hooks 'after-change-major-mode-hook))) + +;;;###autoload +(dolist (r '("\\.erl$" "\\.app\\.src$" "\\.escript" + "\\.hrl$" "\\.xrl$" "\\.yrl" "/ebin/.+\\.app")) + (add-to-list 'auto-mode-alist (cons r 'erlang-mode))) + +(defun erlang-syntax-table-init () + (if (null erlang-mode-syntax-table) + (let ((table (make-syntax-table))) + (modify-syntax-entry ?\n ">" table) + (modify-syntax-entry ?\" "\"" table) + (modify-syntax-entry ?# "." table) +;; (modify-syntax-entry ?$ "\\" table) ;; Creates problems with indention afterwards +;; (modify-syntax-entry ?$ "'" table) ;; Creates syntax highlighting and indention problems + (modify-syntax-entry ?$ "/" table) ;; Misses the corner case "string that ends with $" + ;; we have to live with that for now..it is the best alternative + ;; that can be worked around with "string hat ends with \$" + (modify-syntax-entry ?% "<" table) + (modify-syntax-entry ?& "." table) + (modify-syntax-entry ?\' "\"" table) + (modify-syntax-entry ?* "." table) + (modify-syntax-entry ?+ "." table) + (modify-syntax-entry ?- "." table) + (modify-syntax-entry ?/ "." table) + (modify-syntax-entry ?: "." table) + (modify-syntax-entry ?< "." table) + (modify-syntax-entry ?= "." table) + (modify-syntax-entry ?> "." table) + (modify-syntax-entry ?\\ "\\" table) + (modify-syntax-entry ?_ "_" table) + (modify-syntax-entry ?| "." table) + (modify-syntax-entry ?^ "'" table) + + ;; Pseudo bit-syntax: Latin1 double angle quotes as parens. + ;;(modify-syntax-entry ?\253 "(?\273" table) + ;;(modify-syntax-entry ?\273 ")?\253" table) + + (setq erlang-mode-syntax-table table))) + + (set-syntax-table erlang-mode-syntax-table)) + + +(defun erlang-electric-init () + ;; Set up electric character functions to work with + ;; delsel/pending-del mode. Also, set up text properties for bit + ;; syntax handling. + (mapc #'(lambda (cmd) + (put cmd 'delete-selection t) ;for delsel (Emacs) + (put cmd 'pending-delete t)) ;for pending-del (XEmacs) + '(erlang-electric-semicolon + erlang-electric-comma + erlang-electric-gt)) + + (put 'bitsyntax-open-outer 'syntax-table '(4 . ?>)) + (put 'bitsyntax-open-outer 'rear-nonsticky '(category)) + (put 'bitsyntax-open-inner 'rear-nonsticky '(category)) + (put 'bitsyntax-close-inner 'rear-nonsticky '(category)) + (put 'bitsyntax-close-outer 'syntax-table '(5 . ?<)) + (put 'bitsyntax-close-outer 'rear-nonsticky '(category)) + (make-local-variable 'parse-sexp-lookup-properties) + (setq parse-sexp-lookup-properties 't)) + + +(defun erlang-mode-variables () + (or erlang-mode-abbrev-table + (define-abbrev-table 'erlang-mode-abbrev-table ())) + (setq local-abbrev-table erlang-mode-abbrev-table) + (make-local-variable 'paragraph-start) + (setq paragraph-start (concat "^$\\|" page-delimiter)) + (make-local-variable 'paragraph-separate) + (setq paragraph-separate paragraph-start) + (make-local-variable 'paragraph-ignore-fill-prefix) + (setq paragraph-ignore-fill-prefix t) + (make-local-variable 'require-final-newline) + (setq require-final-newline t) + (make-local-variable 'defun-prompt-regexp) + (setq defun-prompt-regexp erlang-defun-prompt-regexp) + (make-local-variable 'comment-start) + (setq comment-start "%") + (make-local-variable 'comment-start-skip) + (setq comment-start-skip "%+\\s *") + (make-local-variable 'comment-column) + (setq comment-column 48) + (make-local-variable 'indent-line-function) + (setq indent-line-function 'erlang-indent-command) + (make-local-variable 'indent-region-function) + (setq indent-region-function 'erlang-indent-region) + (set (make-local-variable 'comment-indent-function) 'erlang-comment-indent) + (if (<= erlang-emacs-major-version 18) + (set (make-local-variable 'comment-indent-hook) 'erlang-comment-indent)) + (set (make-local-variable 'parse-sexp-ignore-comments) t) + (set (make-local-variable 'dabbrev-case-fold-search) nil) + (set (make-local-variable 'imenu-prev-index-position-function) + 'erlang-beginning-of-function) + (set (make-local-variable 'imenu-extract-index-name-function) + 'erlang-get-function-name-and-arity) + (set (make-local-variable 'tempo-match-finder) + "[^-a-zA-Z0-9_]\\([-a-zA-Z0-9_]*\\)\\=") + (set (make-local-variable 'beginning-of-defun-function) + 'erlang-beginning-of-function) + (set (make-local-variable 'end-of-defun-function) 'erlang-end-of-function) + (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) + (set (make-local-variable 'fill-paragraph-function) 'erlang-fill-paragraph) + (set (make-local-variable 'comment-add) 1) + (set (make-local-variable 'outline-regexp) "[[:lower:]0-9_]+ *(.*) *-> *$") + (set (make-local-variable 'outline-level) (lambda () 1)) + (set (make-local-variable 'add-log-current-defun-function) + 'erlang-current-defun)) + +(defun erlang-font-lock-init () + "Initialize Font Lock for Erlang mode." + (or erlang-font-lock-syntax-table + (setq erlang-font-lock-syntax-table + (let ((table (copy-syntax-table erlang-mode-syntax-table))) + (modify-syntax-entry ?_ "w" table) + table))) + (set (make-local-variable 'font-lock-syntax-table) + erlang-font-lock-syntax-table) + (set (make-local-variable 'font-lock-beginning-of-syntax-function) + 'erlang-beginning-of-clause) + (make-local-variable 'font-lock-keywords) + (let ((level (cond ((boundp 'font-lock-maximum-decoration) + (symbol-value 'font-lock-maximum-decoration)) + ((boundp 'font-lock-use-maximal-decoration) + (symbol-value 'font-lock-use-maximal-decoration)) + (t nil)))) + (if (consp level) + (setq level (cdr-safe (or (assq 'erlang-mode level) + (assq t level))))) + ;; `level' can here be: + ;; A number - The fontification level + ;; nil - Use the default + ;; t - Use maximum + (cond ((eq level nil) + (set 'font-lock-keywords erlang-font-lock-keywords)) + ((eq level 1) + (set 'font-lock-keywords erlang-font-lock-keywords-1)) + ((eq level 2) + (set 'font-lock-keywords erlang-font-lock-keywords-2)) + ((eq level 3) + (set 'font-lock-keywords erlang-font-lock-keywords-3)) + (t + (set 'font-lock-keywords erlang-font-lock-keywords-4)))) + + ;; Modern font-locks can handle the above much more elegantly: + (set (make-local-variable 'font-lock-defaults) + '((erlang-font-lock-keywords erlang-font-lock-keywords-1 + erlang-font-lock-keywords-2 + erlang-font-lock-keywords-3 + erlang-font-lock-keywords-4) + nil nil ((?_ . "w")) erlang-beginning-of-clause + (font-lock-mark-block-function . erlang-mark-clause) + (font-lock-syntactic-keywords + ;; A dollar sign right before the double quote that ends a + ;; string is not a character escape. + ;; + ;; And a "string" consists of a double quote not escaped by a + ;; dollar sign, any number of non-backslash non-newline + ;; characters or escaped backslashes, a dollar sign + ;; (otherwise we wouldn't care) and a double quote. This + ;; doesn't match multi-line strings, but this is probably + ;; the best we can get, since while font-locking we don't + ;; know whether matching started inside a string: limiting + ;; search to a single line keeps things sane. + . (("\\(?:^\\|[^$]\\)\"\\(?:[^\"\n]\\|\\\\\"\\)*\\(\\$\\)\"" 1 "w") + ;; Likewise for atoms + ("\\(?:^\\|[^$]\\)'\\(?:[^'\n]\\|\\\\'\\)*\\(\\$\\)'" 1 "w") + ;; And the dollar sign in $\" or $\' escapes two + ;; characters, not just one. + ("\\(\\$\\)\\\\[\"']" 1 "'")))))) + + + +;; Useful when defining your own keywords. +(defun erlang-font-lock-set-face (ks &rest faces) + "Replace the face components in a list of keywords. + +The first argument, KS, is a list of keywords. The rest of the +arguments are expressions to replace the face information with. The +first expression replaces the face of the first keyword, the second +expression the second keyword etc. + +Should an expression be nil, the face of the corresponding keyword is +not changed. + +Should fewer expressions than keywords be given, the last expression +is used for all remaining keywords. + +Normally, the expressions are just atoms representing the new face. +They could however be more complex, returning different faces in +different situations. + +This function only handles keywords with elements on the forms: + (REGEXP NUMBER FACE) + (REGEXP NUMBER FACE OVERWRITE) + +This could be used when defining your own special font-lock setup, e.g: + +\(setq my-font-lock-keywords + (append erlang-font-lock-keywords-function-header + erlang-font-lock-keywords-dollar + (erlang-font-lock-set-face + erlang-font-lock-keywords-macros 'my-neon-green-face) + (erlang-font-lock-set-face + erlang-font-lock-keywords-lc 'my-deep-red 'my-light-red) + erlang-font-lock-keywords-attr)) + +For a more elaborate example, please see the beginning of the file +`erlang.el'." + (let ((res '())) + (while ks + (let* ((regexp (car (car ks))) + (number (car (cdr (car ks)))) + (new-face (if (and faces (car faces)) + (car faces) + (car (cdr (cdr (car ks)))))) + (overwrite (car (cdr (cdr (cdr (car ks)))))) + (new-keyword (list regexp number new-face))) + (if overwrite (nconc new-keyword (list overwrite))) + (setq res (cons new-keyword res)) + (setq ks (cdr ks)) + (if (and faces (cdr faces)) + (setq faces (cdr faces))))) + (nreverse res))) + + +(defun erlang-font-lock-level-0 () + ;; DocStringOrig: font-cmd + "Unfontify current buffer." + (interactive) + (font-lock-mode 0)) + + +(defun erlang-font-lock-level-1 () + ;; DocStringCopy: font-cmd + "Fontify current buffer at level 1. +This highlights function headers, reserved keywords, strings and comments." + (interactive) + (require 'font-lock) + (set 'font-lock-keywords erlang-font-lock-keywords-1) + (font-lock-mode 1) + (funcall (symbol-function 'font-lock-fontify-buffer))) + + +(defun erlang-font-lock-level-2 () + ;; DocStringCopy: font-cmd + "Fontify current buffer at level 2. +This highlights level 1 features (see `erlang-font-lock-level-1') +plus bifs, guards and `single quotes'." + (interactive) + (require 'font-lock) + (set 'font-lock-keywords erlang-font-lock-keywords-2) + (font-lock-mode 1) + (funcall (symbol-function 'font-lock-fontify-buffer))) + + +(defun erlang-font-lock-level-3 () + ;; DocStringCopy: font-cmd + "Fontify current buffer at level 3. +This highlights level 2 features (see `erlang-font-lock-level-2') +plus variables, macros and records." + (interactive) + (require 'font-lock) + (set 'font-lock-keywords erlang-font-lock-keywords-3) + (font-lock-mode 1) + (funcall (symbol-function 'font-lock-fontify-buffer))) + +(defun erlang-font-lock-level-4 () + ;; DocStringCopy: font-cmd + "Fontify current buffer at level 4. +This highlights level 3 features (see `erlang-font-lock-level-2') +plus variables, macros and records." + (interactive) + (require 'font-lock) + (set 'font-lock-keywords erlang-font-lock-keywords-4) + (font-lock-mode 1) + (funcall (symbol-function 'font-lock-fontify-buffer))) + + +(defun erlang-menu-init () + "Init menus for Erlang mode. + +The variable `erlang-menu-items' contain a description of the Erlang +mode menu. Normally, the list contains atoms, representing variables +bound to pieces of the menu. + +Personal extensions could be added to `erlang-menu-personal-items'. + +This function should be called if any variable describing the +menu configuration is changed." + (erlang-menu-install "Erlang" erlang-menu-items erlang-mode-map t)) + + +(defun erlang-menu-install (name items keymap &optional popup) + "Install a menu in Emacs or XEmacs based on an abstract description. + +NAME is the name of the menu. + +ITEMS is a list. The elements are either nil representing a horizontal +line or a list with two or three elements. The first is the name of +the menu item, the second the function to call, or a submenu, on the +same same form as ITEMS. The third optional element is an expression +which is evaluated every time the menu is displayed. Should the +expression evaluate to nil the menu item is ghosted. + +KEYMAP is the keymap to add to menu to. (When using XEmacs, the menu +will only be visible when this menu is the global, the local, or an +activate minor mode keymap.) + +If POPUP is non-nil, the menu is bound to the XEmacs `mode-popup-menu' +variable, i.e. it will popup when pressing the right mouse button. + +Please see the variable `erlang-menu-base-items'." + (cond (erlang-xemacs-p + (let ((menu (erlang-menu-xemacs name items keymap))) + ;; We add the menu to the global menubar. + ;;(funcall (symbol-function 'set-buffer-menubar) + ;; (symbol-value 'current-menubar)) + (funcall (symbol-function 'add-submenu) nil menu) + (setcdr erlang-xemacs-popup-menu (cdr menu)) + (if (and popup (boundp 'mode-popup-menu)) + (funcall (symbol-function 'set) + 'mode-popup-menu erlang-xemacs-popup-menu)))) + ((>= erlang-emacs-major-version 19) + (define-key keymap (vector 'menu-bar (intern name)) + (erlang-menu-make-keymap name items))) + (t nil))) + + +(defun erlang-menu-make-keymap (name items) + "Build a menu for Emacs 19." + (let ((menumap (funcall (symbol-function 'make-sparse-keymap) + name)) + (count 0) + id def first second third) + (setq items (reverse items)) + (while items + ;; Replace any occurrence of atoms by their value. + (while (and items (atom (car items)) (not (null (car items)))) + (if (and (boundp (car items)) + (listp (symbol-value (car items)))) + (setq items (append (reverse (symbol-value (car items))) + (cdr items))) + (setq items (cdr items)))) + (setq first (car-safe (car items))) + (setq second (car-safe (cdr-safe (car items)))) + (setq third (car-safe (cdr-safe (cdr-safe (car items))))) + (cond ((null first) + (setq count (+ count 1)) + (setq id (intern (format "separator-%d" count))) + (setq def '("--" . nil))) + ((and (consp second) (eq (car second) 'lambda)) + (setq count (+ count 1)) + (setq id (intern (format "lambda-%d" count))) + (setq def (cons first second))) + ((symbolp second) + (setq id second) + (setq def (cons first second))) + (t + (setq count (+ count 1)) + (setq id (intern (format "submenu-%d" count))) + (setq def (erlang-menu-make-keymap first second)))) + (define-key menumap (vector id) def) + (if third + (put id 'menu-enable third)) + (setq items (cdr items))) + (cons name menumap))) + + +(defun erlang-menu-xemacs (name items &optional keymap) + "Build a menu for XEmacs." + (let ((res '()) + first second third entry) + (while items + ;; Replace any occurrence of atoms by their value. + (while (and items (atom (car items)) (not (null (car items)))) + (if (and (boundp (car items)) + (listp (symbol-value (car items)))) + (setq items (append (reverse (symbol-value (car items))) + (cdr items))) + (setq items (cdr items)))) + (setq first (car-safe (car items))) + (setq second (car-safe (cdr-safe (car items)))) + (setq third (car-safe (cdr-safe (cdr-safe (car items))))) + (cond ((null first) + (setq res (cons "------" res))) + ((symbolp second) + (setq res (cons (vector first second (or third t)) res))) + ((and (consp second) (eq (car second) 'lambda)) + (setq res (cons (vector first (list 'call-interactively second) + (or third t)) res))) + (t + (setq res (cons (cons first + (cdr (erlang-menu-xemacs + first second))) + res)))) + (setq items (cdr items))) + (setq res (reverse res)) + ;; When adding a menu to a minor-mode keymap under Emacs, + ;; it disappears when the mode is disabled. The expression + ;; generated below imitates this behaviour. + ;; (This could be expressed much clearer using backquotes, + ;; but I don't want to pull in every package.) + (if keymap + (let ((expr (list 'or + (list 'eq keymap 'global-map) + (list 'eq keymap (list 'current-local-map)) + (list 'symbol-value + (list 'car-safe + (list 'rassq + keymap + 'minor-mode-map-alist)))))) + (setq res (cons ':included (cons expr res))))) + (cons name res))) + + +(defun erlang-menu-substitute (items alist) + "Substitute functions in menu described by ITEMS. + +The menu ITEMS is updated destructively. + +ALIST is list of pairs where the car is the old function and cdr the new." + (let (first second pair) + (while items + (setq first (car-safe (car items))) + (setq second (car-safe (cdr-safe (car items)))) + (cond ((null first)) + ((symbolp second) + (setq pair (and second (assq second alist))) + (if pair + (setcar (cdr (car items)) (cdr pair)))) + ((and (consp second) (eq (car second) 'lambda))) + (t + (erlang-menu-substitute second alist))) + (setq items (cdr items))))) + + +(defun erlang-menu-add-above (entry above items) + "Add menu ENTRY above menu entry ABOVE in menu ITEMS. +Do nothing if the items already should be in the menu. +Should ABOVE not be in the list, the entry is added at +the bottom of the menu. + +The new menu is returned. No guarantee is given that the original +menu is left unchanged. + +The equality test is performed by `eq'. + +Example: (erlang-menu-add-above 'my-erlang-menu-items + 'erlang-menu-man-items)" + (erlang-menu-add-below entry above items t)) + + +(defun erlang-menu-add-below (entry below items &optional above-p) + "Add menu ENTRY below menu items BELOW in the Erlang menu. +Do nothing if the items already should be in the menu. +Should BELOW not be in the list, items is added at the bottom +of the menu. + +The new menu is returned. No guarantee is given that the original +menu is left unchanged. + +The equality test is performed by `eq'. + +Example: + +\(setq erlang-menu-items + (erlang-menu-add-below 'my-erlang-menu-items + 'erlang-menu-base-items + erlang-menu-items))" + (if (memq entry items) + items ; Return the original menu. + (let ((head '()) + (done nil) + res) + (while (not done) + (cond ((null items) + (setq res (append head (list entry))) + (setq done t)) + ((eq below (car items)) + (setq res + (if above-p + (append head (cons entry items)) + (append head (cons (car items) + (cons entry (cdr items)))))) + (setq done t)) + (t + (setq head (append head (list (car items)))) + (setq items (cdr items))))) + res))) + +(defun erlang-menu-delete (entry items) + "Delete ENTRY from menu ITEMS. + +The new menu is returned. No guarantee is given that the original +menu is left unchanged." + (delq entry items)) + +;; Man code: + +(defun erlang-man-init () + "Add menus containing the manual pages of the Erlang. + +The variable `erlang-man-dirs' contains entries describing +the location of the manual pages." + (interactive) + (if erlang-man-inhibit + () + (setq erlang-menu-man-items + '(nil + ("Man - Function" erlang-man-function))) + (if erlang-man-dirs + (setq erlang-menu-man-items + (append erlang-menu-man-items + (erlang-man-make-top-menu erlang-man-dirs)))) + (setq erlang-menu-items + (erlang-menu-add-above 'erlang-menu-man-items + 'erlang-menu-version-items + erlang-menu-items)) + (erlang-menu-init))) + + +(defun erlang-man-uninstall () + "Remove the man pages from the Erlang mode." + (interactive) + (setq erlang-menu-items + (erlang-menu-delete 'erlang-menu-man-items erlang-menu-items)) + (erlang-menu-init)) + + +;; The man menu is a hierarchal structure, with the manual sections +;; at the top, described by `erlang-man-dirs'. The next level could +;; either be the manual pages if not to many, otherwise it is an index +;; menu whose submenus will contain up to `erlang-man-max-menu-size' +;; manual pages. + +(defun erlang-man-make-top-menu (dir-list) + "Create one menu entry per element of DIR-LIST. +The format is described in the documentation of `erlang-man-dirs'." + (let ((menu '()) + dir) + (while dir-list + (setq dir (cond ((nth 2 (car dir-list)) + ;; Relative to `erlang-root-dir'. + (and (stringp erlang-root-dir) + (concat erlang-root-dir (nth 1 (car dir-list))))) + (t + ;; Absolute + (nth 1 (car dir-list))))) + (if (and dir + (file-readable-p dir)) + (setq menu (cons (list (car (car dir-list)) + (erlang-man-make-middle-menu + (erlang-man-get-files dir))) + menu))) + (setq dir-list (cdr dir-list))) + ;; Should no menus be found, generate a menu item which + ;; will display a help text, when selected. + (if menu + (nreverse menu) + '(("Man Pages" + (("Error! Why?" erlang-man-describe-error))))))) + + +;; Should the menu be to long, let's split it into a number of +;; smaller menus. Warning, this code contains beautiful +;; destructive operations! +(defun erlang-man-make-middle-menu (filelist) + "Create the second level menu from FILELIST. + +Should the list be longer than `erlang-man-max-menu-size', a tree of +menus is created." + (if (<= (length filelist) erlang-man-max-menu-size) + (erlang-man-make-menu filelist) + (let ((menu '()) + (filelist (copy-sequence filelist)) + segment submenu pair) + (while filelist + (setq pair (nthcdr (- erlang-man-max-menu-size 1) filelist)) + (setq segment filelist) + (if (null pair) + (setq filelist nil) + (setq filelist (cdr pair)) + (setcdr pair nil)) + (setq submenu (erlang-man-make-menu segment)) + (setq menu (cons (list (concat (car (car submenu)) + " -- " + (car (car (reverse submenu)))) + submenu) + menu))) + (nreverse menu)))) + + +(defun erlang-man-make-menu (filelist) + "Make a leaf menu based on FILELIST." + (let ((menu '()) + item) + (while filelist + (setq item (erlang-man-make-menu-item (car filelist))) + (if item + (setq menu (cons item menu))) + (setq filelist (cdr filelist))) + (nreverse menu))) + + +(defun erlang-man-make-menu-item (file) + "Create a menu item containing the name of the man page." + (and (string-match ".+/\\([^/]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file) + (let ((page (substring file (match-beginning 1) (match-end 1)))) + (list (capitalize page) + (list 'lambda '() + '(interactive) + (list 'funcall 'erlang-man-display-function + file)))))) + + +(defun erlang-man-get-files (dir) + "Return files in directory DIR." + (directory-files dir t ".+\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?\\'")) + + +(defun erlang-man-module (&optional module) + "Find manual page for MODULE, defaults to module of function under point. +This function is aware of imported functions." + (interactive + (list (let* ((mod (car-safe (erlang-get-function-under-point))) + (input (read-string + (format "Manual entry for module%s: " + (if (or (null mod) (string= mod "")) + "" + (format " (default %s)" mod)))))) + (if (string= input "") + mod + input)))) + (or module (setq module (car (erlang-get-function-under-point)))) + (if (or (null module) (string= module "")) + (error "No Erlang module name given")) + (let ((dir-list erlang-man-dirs) + (pat (concat "/" (regexp-quote module) "\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$")) + (file nil) + file-list) + (while (and dir-list (null file)) + (setq file-list (erlang-man-get-files + (if (nth 2 (car dir-list)) + (concat erlang-root-dir (nth 1 (car dir-list))) + (nth 1 (car dir-list))))) + (while (and file-list (null file)) + (if (string-match pat (car file-list)) + (setq file (car file-list))) + (setq file-list (cdr file-list))) + (setq dir-list (cdr dir-list))) + (if file + (funcall erlang-man-display-function file) + (error "No manual page for module %s found" module)))) + + +;; Warning, the function `erlang-man-function' is a hack! +;; It links itself into the man code in a non-clean way. I have +;; chosen to keep it since it provides a very useful functionality +;; which is not possible to achieve using a clean approach. +;; / AndersL + +(defvar erlang-man-function-name nil + "Name of function for last `erlang-man-function' call. +Used for communication between `erlang-man-function' and the +patch to `Man-notify-when-ready'.") + +(defun erlang-man-function (&optional name) + "Find manual page for NAME, where NAME is module:function. +The entry for `function' is displayed. + +This function is aware of imported functions." + (interactive + (list (let* ((mod-func (erlang-get-function-under-point)) + (mod (car-safe mod-func)) + (func (nth 1 mod-func)) + (input (read-string + (format + "Manual entry for `module:func' or `module'%s: " + (if (or (null mod) (string= mod "")) + "" + (format " (default %s:%s)" mod func)))))) + (if (string= input "") + (if (and mod func) + (concat mod ":" func) + mod) + input)))) + ;; Emacs 18 doesn't provide `man'... + (condition-case nil + (require 'man) + (error nil)) + (let ((modname nil) + (funcname nil)) + (cond ((null name) + (let ((mod-func (erlang-get-function-under-point))) + (setq modname (car-safe mod-func)) + (setq funcname (nth 1 mod-func)))) + ((string-match ":" name) + (setq modname (substring name 0 (match-beginning 0))) + (setq funcname (substring name (match-end 0) nil))) + ((stringp name) + (setq modname name))) + (if (or (null modname) (string= modname "")) + (error "No Erlang module name given")) + (cond ((fboundp 'Man-notify-when-ready) + ;; Emacs 19: The man command could possibly start an + ;; asynchronous process, i.e. we must hook ourselves into + ;; the system to be activated when the man-process + ;; terminates. + (if (null funcname) + () + (erlang-man-patch-notify) + (setq erlang-man-function-name funcname)) + (condition-case nil + (erlang-man-module modname) + (error (setq erlang-man-function-name nil)))) + (t + (erlang-man-module modname) + (if funcname + (erlang-man-find-function + (or (get-buffer "*Manual Entry*") ; Emacs 18 + (current-buffer)) ; XEmacs + funcname)))))) + + +;; Should the defadvice be at the top level, the package `advice' would +;; be required. Now it is only required when this functionality +;; is used. (Emacs 19 specific.) +(defun erlang-man-patch-notify () + "Patch the function `Man-notify-when-ready' to search for function. +The variable `erlang-man-function-name' is assumed to be bound to +the function name, or to nil. + +The reason for patching a function is that under Emacs 19, the man +command is executed asynchronously." + (condition-case nil + (require 'advice) + ;; This should never happened since this is only called when + ;; running under Emacs 19. + (error (error (concat "This command needs the package `advice', " + "please upgrade your Emacs.")))) + (require 'man) + (defadvice Man-notify-when-ready + (after erlang-Man-notify-when-ready activate) + "Set point at the documentation of the function name in +`erlang-man-function-name' when the man page is displayed." + (if erlang-man-function-name + (erlang-man-find-function (ad-get-arg 0) erlang-man-function-name)) + (setq erlang-man-function-name nil))) + + +(defun erlang-man-find-function (buf func) + "Find manual page for function in `erlang-man-function-name' in buffer BUF." + (if func + (let ((win (get-buffer-window buf))) + (if win + (progn + (set-buffer buf) + (goto-char (point-min)) + (if (re-search-forward + (concat "^[ \t]+" func " ?(") + (point-max) t) + (progn + (forward-word -1) + (set-window-point win (point))) + (message "Could not find function `%s'" func))))))) + + +(defun erlang-man-display (file) + "Display FILE as a `man' file. +This is the default manual page display function. +The variables `erlang-man-display-function' contains the function +to be used." + ;; Emacs 18 doesn't `provide' man. + (condition-case nil + (require 'man) + (error nil)) + (if file + (let ((process-environment (copy-sequence process-environment))) + (if (string-match "\\(.*\\)/man[^/]*/\\([^.]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file) + (let ((dir (substring file (match-beginning 1) (match-end 1))) + (page (substring file (match-beginning 2) (match-end 2)))) + (if (fboundp 'setenv) + (setenv "MANPATH" dir) + ;; Emacs 18 + (setq process-environment (cons (concat "MANPATH=" dir) + process-environment))) + (cond ((not (and (not erlang-xemacs-p) + (= erlang-emacs-major-version 19) + (< erlang-emacs-minor-version 29))) + (manual-entry page)) + (t + ;; Emacs 19.28 and earlier versions of 19: + ;; The manual-entry command unconditionally prompts + ;; the user :-( + (funcall (symbol-function 'Man-getpage-in-background) + page)))) + (error "Can't find man page for %s\n" file))))) + + +(defun erlang-man-describe-error () + "Describe why the manual pages weren't found." + (interactive) + (with-output-to-temp-buffer "*Erlang Man Error*" + (princ "Normally, this menu should contain Erlang manual pages. + +In order to find the manual pages, the variable `erlang-root-dir' +should be bound to the name of the directory containing the Erlang +installation. The name should not include the final slash. + +Practically, you should add a line on the following form to +your ~/.emacs, or ask your system administrator to add it to +the site init file: + (setq erlang-root-dir \"/the/erlang/root/dir/goes/here\") + +For example: + (setq erlang-root-dir \"/usr/local/erlang\") + +After installing the line, kill and restart Emacs, or restart Erlang +mode with the command `M-x erlang-mode RET'."))) + +;; Skeleton code: + +;; This code is based on the package `tempo' which is part of modern +;; Emacsen. (GNU Emacs 19.25 (?) and XEmacs 19.14.) + +(defun erlang-skel-init () + "Generate the skeleton functions and menu items. +The variable `erlang-skel' contains the name and descriptions of +all skeletons. + +The skeleton routines are based on the `tempo' package. Should this +package not be present, this function does nothing." + (interactive) + (condition-case nil + (require 'tempo) + (error t)) + (if (featurep 'tempo) + (let ((skel erlang-skel) + (menu '())) + (while skel + (cond ((null (car skel)) + (setq menu (cons nil menu))) + (t + (funcall (symbol-function 'tempo-define-template) + (concat "erlang-" (nth 1 (car skel))) + ;; The tempo template used contains an `include' + ;; function call only, hence changes to the + ;; variables describing the templates take effect + ;; immdiately. + (list (list 'erlang-skel-include (nth 2 (car skel)))) + (nth 1 (car skel)) + (car (car skel)) + 'erlang-tempo-tags) + (setq menu (cons (erlang-skel-make-menu-item + (car skel)) menu)))) + (setq skel (cdr skel))) + (setq erlang-menu-skel-items + (list nil (list "Skeletons" (nreverse menu)))) + (setq erlang-menu-items + (erlang-menu-add-above 'erlang-menu-skel-items + 'erlang-menu-version-items + erlang-menu-items)) + (erlang-menu-init)))) + +(defun erlang-skel-make-menu-item (skel) + (let ((func (intern (concat "tempo-template-erlang-" (nth 1 skel))))) + (cond ((null (nth 3 skel)) + (list (car skel) func)) + (t + (list (car skel) + (list 'lambda '() + '(interactive) + (list 'funcall + (list 'quote (nth 3 skel)) + (list 'quote func)))))))) + +;; Functions designed to be added to the skeleton menu. +;; (Not normally used) +(defun erlang-skel-insert (func) + "Insert skeleton generated by FUNC and goto first tempo mark." + (save-excursion (funcall func)) + (funcall (symbol-function 'tempo-forward-mark))) + +(defun erlang-skel-header (func) + "Insert the header generated by FUNC at the beginning of the buffer." + (goto-char (point-min)) + (save-excursion (funcall func)) + (funcall (symbol-function 'tempo-forward-mark))) + + +;; Functions used inside the skeleton descriptions. +(defun erlang-skel-skip-blank () + (skip-chars-backward " \t") + nil) + +(defun erlang-skel-include (&rest args) + "Include a template inside another template. + +Example of use, assuming that `erlang-skel-func' is defined: + + (defvar foo-skeleton '(\"%%% New function:\" + (erlang-skel-include erlang-skel-func))) + +Technically, this function returns the `tempo' attribute`(l ...)' which +can contain other `tempo' attributes. Please see the function +`tempo-define-template' for a description of the `(l ...)' attribute." + (let ((res '()) + entry) + (while args + (setq entry (car args)) + (while entry + (setq res (cons (car entry) res)) + (setq entry (cdr entry))) + (setq args (cdr args))) + (cons 'l (nreverse res)))) + +(defvar erlang-skel-separator-length 70) + +(defun erlang-skel-separator (&optional percent) + "Return a comment separator." + (let ((percent (or percent 3))) + (concat (make-string percent ?%) + (make-string (- erlang-skel-separator-length percent) ?-) + "\n"))) + +(defun erlang-skel-double-separator (&optional percent) + "Return a comment separator." + (let ((percent (or percent 3))) + (concat (make-string percent ?%) + (make-string (- erlang-skel-separator-length percent) ?=) + "\n"))) + +(defun erlang-skel-dd-mmm-yyyy () + "Return the current date as a string in \"DD Mon YYYY\" form. +The first character of DD is space if the value is less than 10." + (let ((date (current-time-string))) + (format "%2d %s %s" + (erlang-string-to-int (substring date 8 10)) + (substring date 4 7) + (substring date -4)))) + +;; Indentation code: + +(defun erlang-indent-command (&optional whole-exp) + "Indent current line as Erlang code. +With argument, indent any additional lines of the same clause +rigidly along with this one." + (interactive "P") + (if whole-exp + ;; If arg, always indent this line as Erlang + ;; and shift remaining lines of clause the same amount. + (let ((shift-amt (erlang-indent-line)) + beg end) + (save-excursion + (if erlang-tab-always-indent + (beginning-of-line)) + (setq beg (point)) + (erlang-end-of-clause 1) + (setq end (point)) + (goto-char beg) + (forward-line 1) + (setq beg (point))) + (if (> end beg) + (indent-code-rigidly beg end shift-amt "\n"))) + (if (and (not erlang-tab-always-indent) + (save-excursion + (skip-chars-backward " \t") + (not (bolp)))) + (insert-tab) + (erlang-indent-line)))) + + +(defun erlang-indent-line () + "Indent current line as Erlang code. +Return the amount the indentation changed by." + (let ((pos (- (point-max) (point))) + indent beg + shift-amt) + (beginning-of-line 1) + (setq beg (point)) + (skip-chars-forward " \t") + (cond ((looking-at "%") + (setq indent (funcall comment-indent-function)) + (setq shift-amt (- indent (current-column)))) + (t + (setq indent (erlang-calculate-indent)) + (cond ((null indent) + (setq indent (current-indentation))) + ((eq indent t) + ;; This should never occur here. + (error "Erlang mode error")) + ;;((= (char-syntax (following-char)) ?\)) + ;; (setq indent (1- indent))) + ) + (setq shift-amt (- indent (current-column))))) + (if (zerop shift-amt) + nil + (delete-region beg (point)) + (indent-to indent)) + ;; If initial point was within line's indentation, position + ;; after the indentation. Else stay at same point in text. + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos))) + shift-amt)) + + +(defun erlang-indent-region (beg end) + "Indent region of Erlang code. + +This is automagically called by the user level function `indent-region'." + (interactive "r") + (save-excursion + (let ((case-fold-search nil) + (continue t) + (from-end (- (point-max) end)) + indent-point;; The beginning of the current line + indent;; The indent amount + state) + (goto-char beg) + (beginning-of-line) + (setq indent-point (point)) + (erlang-beginning-of-clause) + ;; Parse the Erlang code from the beginning of the clause to + ;; the beginning of the region. + (while (< (point) indent-point) + (setq state (erlang-partial-parse (point) indent-point state))) + ;; Indent every line in the region + (while continue + (goto-char indent-point) + (skip-chars-forward " \t") + (cond ((looking-at "%") + ;; Do not use our stack to help the user to customize + ;; comment indentation. + (setq indent (funcall comment-indent-function))) + ((looking-at "$") + ;; Don't indent empty lines. + (setq indent 0)) + (t + (setq indent + (save-excursion + (erlang-calculate-stack-indent (point) state))) + (cond ((null indent) + (setq indent (current-indentation))) + ((eq indent t) + ;; This should never occur here. + (error "Erlang mode error")) + ;;((= (char-syntax (following-char)) ?\)) + ;; (setq indent (1- indent))) + ))) + (if (zerop (- indent (current-column))) + nil + (delete-region indent-point (point)) + (indent-to indent)) + ;; Find the next line in the region + (goto-char indent-point) + (save-excursion + (forward-line 1) + (setq indent-point (point))) + (if (>= from-end (- (point-max) indent-point)) + (setq continue nil) + (while (< (point) indent-point) + (setq state (erlang-partial-parse + (point) indent-point state)))))))) + + +(defun erlang-indent-current-buffer () + "Indent current buffer as Erlang code." + (interactive) + (save-excursion + (save-restriction + (widen) + (erlang-indent-region (point-min) (point-max))))) + + +(defun erlang-indent-function () + "Indent current Erlang function." + (interactive) + (save-excursion + (let ((end (progn (erlang-end-of-function 1) (point))) + (beg (progn (erlang-beginning-of-function 1) (point)))) + (erlang-indent-region beg end)))) + + +(defun erlang-indent-clause () + "Indent current Erlang clause." + (interactive) + (save-excursion + (let ((end (progn (erlang-end-of-clause 1) (point))) + (beg (progn (erlang-beginning-of-clause 1) (point)))) + (erlang-indent-region beg end)))) + + +(defmacro erlang-push (x stack) (list 'setq stack (list 'cons x stack))) +(defmacro erlang-pop (stack) (list 'setq stack (list 'cdr stack))) +;; Would much prefer to make caddr a macro but this clashes. +(defun erlang-caddr (x) (car (cdr (cdr x)))) + + +(defun erlang-calculate-indent (&optional parse-start) + "Compute appropriate indentation for current line as Erlang code. +Return nil if line starts inside string, t if in a comment." + (save-excursion + (let ((indent-point (point)) + (case-fold-search nil) + (state nil)) + (if parse-start + (goto-char parse-start) + (erlang-beginning-of-clause)) + (while (< (point) indent-point) + (setq state (erlang-partial-parse (point) indent-point state))) + (erlang-calculate-stack-indent indent-point state)))) + +(defun erlang-show-syntactic-information () + "Show syntactic information for current line." + + (interactive) + + (save-excursion + (let ((starting-point (point)) + (case-fold-search nil) + (state nil)) + (erlang-beginning-of-clause) + (while (< (point) starting-point) + (setq state (erlang-partial-parse (point) starting-point state))) + (message "%S" state)))) + + +(defun erlang-partial-parse (from to &optional state) + "Parse Erlang syntax starting at FROM until TO, with an optional STATE. +Value is list (stack token-start token-type in-what)." + (goto-char from) ; Start at the beginning + (erlang-skip-blank to) + (let ((cs (char-syntax (following-char))) + (stack (car state)) + (token (point)) + in-what) + (cond + + ;; Done: Return previous state. + ((>= token to) + (setq token (nth 1 state)) + (setq cs (nth 2 state)) + (setq in-what (nth 3 state))) + + ;; Word constituent: check and handle keywords. + ((= cs ?w) + (cond ((looking-at "\\(end\\|after\\)[^_a-zA-Z0-9]") + ;; Must pop top icr layer, `after' will push a new + ;; layer next. + (progn + (while (and stack (eq (car (car stack)) '->)) + (erlang-pop stack)) + (if (and stack (memq (car (car stack)) '(icr begin fun try))) + (erlang-pop stack)))) + ((looking-at "catch\\b.*of") + t) + ((looking-at "catch\\b\\s *\\($\\|%\\|.*->\\)") + ;; Must pop top icr layer, `catch' in try/catch + ;;will push a new layer next. + (progn + (while (and stack (eq (car (car stack)) '->)) + (erlang-pop stack)) + (if (and stack (memq (car (car stack)) '(icr begin try))) + (erlang-pop stack)))) + ) + (cond ((looking-at "\\(if\\|case\\|receive\\)[^_a-zA-Z0-9]") + ;; Must push a new icr (if/case/receive) layer. + (erlang-push (list 'icr token (current-column)) stack)) + ((looking-at "\\(try\\|after\\)[^_a-zA-Z0-9]") + ;; Must handle separately, try catch or try X of -> catch + ;; same for `after', it could be + ;; receive after Time -> X end, or + ;; try after X end + (erlang-push (list 'try token (current-column)) stack)) + ((looking-at "\\(of\\)[^_a-zA-Z0-9]") + ;; Must handle separately, try X of -> catch + (if (and stack (eq (car (car stack)) 'try)) + (let ((try-column (nth 2 (car stack))) + (try-pos (nth 1 (car stack)))) + (erlang-pop stack) + (erlang-push (list 'icr try-pos try-column) stack)))) + + ((looking-at "\\(fun\\)[^_a-zA-Z0-9]") + ;; Push a new layer if we are defining a `fun' + ;; expression, not when we are refering an existing + ;; function. 'fun's defines are only indented one level now. + (if (save-excursion + (goto-char (match-end 1)) + (erlang-skip-blank to) + ;; Use erlang-variable-regexp here to look for an + ;; optional variable name to match EEP37 named funs. + (if (looking-at erlang-variable-regexp) + (progn + (goto-char (match-end 0)) + (erlang-skip-blank to))) + (eq (following-char) ?\()) + (erlang-push (list 'fun token (current-column)) stack))) + ((looking-at "\\(begin\\)[^_a-zA-Z0-9]") + (erlang-push (list 'begin token (current-column)) stack)) + ;; Normal when case + ;;((looking-at "when\\s ") + ;;((looking-at "when\\s *\\($\\|%\\)") + ((looking-at "when[^_a-zA-Z0-9]") + (erlang-push (list 'when token (current-column)) stack)) + ((looking-at "catch\\b.*of") + t) + ((looking-at "catch\\b\\s *\\($\\|%\\|.*->\\)") + (erlang-push (list 'icr token (current-column)) stack)) + ;;(erlang-push (list '-> token (current-column)) stack)) + ;;((looking-at "^of$") + ;; (erlang-push (list 'icr token (current-column)) stack) + ;;(erlang-push (list '-> token (current-column)) stack)) + ) + (forward-sexp 1)) + ;; String: Try to skip over it. (Catch error if not complete.) + ((= cs ?\") + (condition-case nil + (progn + (forward-sexp 1) + (if (> (point) to) + (progn + (setq in-what 'string) + (goto-char to)))) + (error + (setq in-what 'string) + (goto-char to)))) + + ;; Expression prefix e.i. $ or ^ (Note ^ can be in the character + ;; literal $^ or part of string and $ outside of a string denotes + ;; a character literal) + ((= cs ?') + (cond + ((= (following-char) ?\") ;; $ or ^ was the last char in a string + (forward-char 1)) + (t + ;; Maybe a character literal, quote the next char to avoid + ;; situations as $" being seen as the begining of a string. + ;; Note the quoting something in the middle of a string is harmless. + (quote (following-char)) + (forward-char 1)))) + + ;; Symbol constituent or punctuation + + ((memq cs '(?. ?_)) + (cond + + ;; Clause end + ((= (following-char) ?\;) + (if (eq (car (car (last stack))) 'spec) + (while (memq (car (car stack)) '(when ::)) + (erlang-pop stack))) + (if (and stack (eq (car (car stack)) '->)) + (erlang-pop stack)) + (forward-char 1)) + + ;; Parameter separator + ((looking-at ",") + (forward-char 1) + (if (and stack (eq (car (car stack)) '::)) + ;; Type or spec + (erlang-pop stack))) + + ;; Function end + ((looking-at "\\.\\(\\s \\|\n\\|\\s<\\)") + (setq stack nil) + (forward-char 1)) + + ;; Function head + ((looking-at "->") + (if (and stack (eq (car (car stack)) 'when)) + (erlang-pop stack)) + (erlang-push (list '-> token (current-column)) stack) + (forward-char 2)) + + ;; List-comprehension divider + ((looking-at "||") + (erlang-push (list '|| token (current-column)) stack) + (forward-char 2)) + + ;; Bit-syntax open paren + ((looking-at "<<") + (erlang-push (list '<< token (current-column)) stack) + (forward-char 2)) + + ;; Bbit-syntax close paren + ((looking-at ">>") + (while (memq (car (car stack)) '(|| ->)) + (erlang-pop stack)) + (cond ((eq (car (car stack)) '<<) + (erlang-pop stack)) + ((memq (car (car stack)) '(icr begin fun)) + (error "Missing `end'")) + (t + (error "Unbalanced parentheses"))) + (forward-char 2)) + + ;; Macro + ((= (following-char) ??) + ;; Skip over the ? + (forward-char 1) + ) + + ;; Type spec's + ((looking-at "-type\\s \\|-opaque\\s ") + (if stack + (forward-char 1) + (erlang-push (list 'icr token (current-column)) stack) + (forward-char 6))) + ((looking-at "-spec\\s ") + (if stack + (forward-char 1) + (forward-char 6) + (skip-chars-forward "^(\n") + (erlang-push (list 'spec (point) (current-column)) stack) + )) + + ;; Type spec delimiter + ((looking-at "::") + (erlang-push (list ':: token (current-column)) stack) + (forward-char 2)) + + ;; Don't follow through in the clause below + ;; '|' don't need spaces around it + ((looking-at "|") + (forward-char 1)) + + ;; Other punctuation: Skip over it and any following punctuation + ((= cs ?.) + ;; Skip over all characters in the operand. + (skip-syntax-forward ".")) + + ;; Other char: Skip over it. + (t + (forward-char 1)))) + + ;; Open parenthesis + ((= cs ?\() + (erlang-push (list '\( token (current-column)) stack) + (forward-char 1)) + + ;; Close parenthesis + ((= cs ?\)) + (while (memq (car (car stack)) '(|| -> :: when)) + (erlang-pop stack)) + (cond ((eq (car (car stack)) '\() + (erlang-pop stack) + (if (and (eq (car (car stack)) 'fun) + (or (eq (car (car (last stack))) 'spec) + (eq (car (car (cdr stack))) '::))) ;; -type() + ;; Inside fun type def ') closes fun definition + (erlang-pop stack))) + ((eq (car (car stack)) 'icr) + (erlang-pop stack) + ;; Normal catch not try-catch might have caused icr + ;; and then incr should be removed and is not an error. + (if (eq (car (car stack)) '\() + (erlang-pop stack) + (error "Missing `end'") + )) + ((eq (car (car stack)) 'begin) + (error "Missing `end'")) + (t + (error "Unbalanced parenthesis")) + ) + (forward-char 1)) + + ;; Character quote: Skip it and the quoted char. + ((= cs ?/) + (forward-char 2)) + + ;; Character escape: Skip it and the escape sequence. + ((= cs ?\\) + (forward-char 1) + (skip-syntax-forward "w")) + + ;; Everything else + (t + (forward-char 1))) + (list stack token cs in-what))) + +(defun erlang-calculate-stack-indent (indent-point state) + "From the given last position and state (stack) calculate indentation. +Return nil if inside string, t if in a comment." + (let* ((stack (and state (car state))) + (token (nth 1 state)) + (stack-top (and stack (car stack)))) + (cond ((null state) ;No state + 0) + ((nth 3 state) + ;; Return nil or t. + (eq (nth 3 state) 'comment)) + ((null stack) + (if (looking-at "when[^_a-zA-Z0-9]") + erlang-indent-guard + 0)) + ((eq (car stack-top) '\() + ;; Element of list, tuple or part of an expression, + (cond ((null erlang-argument-indent) + ;; indent to next column. + (1+ (nth 2 stack-top))) + ((= (char-syntax (following-char)) ?\)) + (goto-char (nth 1 stack-top)) + (cond ((looking-at "[({]\\s *\\($\\|%\\)") + ;; Line ends with parenthesis. + (let ((previous (erlang-indent-find-preceding-expr)) + (stack-pos (nth 2 stack-top))) + (if (>= previous stack-pos) stack-pos + (- (+ previous erlang-argument-indent) 1)))) + (t + (nth 2 stack-top)))) + ((= (following-char) ?,) + ;; a comma at the start of the line: line up with opening parenthesis. + (nth 2 stack-top)) + (t + (goto-char (nth 1 stack-top)) + (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)") + ;; Line ends with parenthesis. + (erlang-indent-parenthesis (nth 2 stack-top))) + (t + ;; Indent to the same column as the first + ;; argument. + (goto-char (1+ (nth 1 stack-top))) + (skip-chars-forward " \t") + (current-column))))) + (erlang-indent-standard indent-point token base 't))))) + ;; + ((eq (car stack-top) '<<) + ;; Element of binary (possible comprehension) expression, + (cond ((null erlang-argument-indent) + ;; indent to next column. + (+ 2 (nth 2 stack-top))) + ((looking-at "\\(>>\\)[^_a-zA-Z0-9]") + (nth 2 stack-top)) + (t + (goto-char (nth 1 stack-top)) + ;; Indent to the same column as the first + ;; argument. + (goto-char (+ 2 (nth 1 stack-top))) + (skip-chars-forward " \t") + (current-column)))) + + ((memq (car stack-top) '(icr fun spec)) + ;; The default indentation is the column of the option + ;; directly following the keyword. (This does not apply to + ;; `case'.) Should no option be on the same line, the + ;; indentation is the indentation of the keyword + + ;; `erlang-indent-level'. + ;; + ;; `after' should be indented to the same level as the + ;; corresponding receive. + (cond ((looking-at "\\(after\\|of\\)\\($\\|[^_a-zA-Z0-9]\\)") + (nth 2 stack-top)) + ((looking-at "when[^_a-zA-Z0-9]") + ;; Handling one when part + (+ (nth 2 stack-top) erlang-indent-level erlang-indent-guard)) + (t + (save-excursion + (goto-char (nth 1 stack-top)) + (if (looking-at "case[^_a-zA-Z0-9]") + (+ (nth 2 stack-top) erlang-indent-level) + (skip-chars-forward "a-z") + (skip-chars-forward " \t") + (if (memq (following-char) '(?% ?\n)) + (+ (nth 2 stack-top) erlang-indent-level) + (current-column)))))) + ) + ((and (eq (car stack-top) '||) (looking-at "\\(]\\|>>\\)[^_a-zA-Z0-9]")) + (nth 2 (car (cdr stack)))) + ;; Real indentation, where operators create extra indentation etc. + ((memq (car stack-top) '(-> || try begin)) + (if (looking-at "\\(of\\)[^_a-zA-Z0-9]") + (nth 2 stack-top) + (goto-char (nth 1 stack-top)) + ;; Check if there is more code after the '->' on the + ;; same line. If so use this indentation as base, else + ;; use parent indentation + 2 * level as base. + (let ((off erlang-indent-level) + (skip 2)) + (cond ((null (cdr stack))) ; Top level in function. + ((eq (car stack-top) 'begin) + (setq skip 5)) + ((eq (car stack-top) 'try) + (setq skip 5)) + ((eq (car stack-top) '->) + ;; If in fun definition use standard indent level not double + ;;(if (not (eq (car (car (cdr stack))) 'fun)) + ;; Removed it made multi clause fun's look to bad + (setq off (* 2 erlang-indent-level)))) ;; ) + (let ((base (erlang-indent-find-base stack indent-point off skip))) + ;; Special cases + (goto-char indent-point) + (cond ((looking-at "\\(end\\|after\\)\\($\\|[^_a-zA-Z0-9]\\)") + (if (eq (car stack-top) '->) + (erlang-pop stack)) + (if stack + (erlang-caddr (car stack)) + 0)) + ((looking-at "catch\\b\\($\\|[^_a-zA-Z0-9]\\)") + ;; Are we in a try + (let ((start (if (eq (car stack-top) '->) + (car (cdr stack)) + stack-top))) + (if (null start) nil + (goto-char (nth 1 start))) + (cond ((looking-at "try\\($\\|[^_a-zA-Z0-9]\\)") + (progn + (if (eq (car stack-top) '->) + (erlang-pop stack)) + (if stack + (erlang-caddr (car stack)) + 0))) + (t (erlang-indent-standard indent-point token base 'nil))))) ;; old catch + (t + (erlang-indent-standard indent-point token base 'nil) + )))) + )) + ((eq (car stack-top) 'when) + (goto-char (nth 1 stack-top)) + (if (looking-at "when\\s *\\($\\|%\\)") + (progn + (erlang-pop stack) + (if (and stack (memq (nth 0 (car stack)) '(icr fun))) + (progn + (goto-char (nth 1 (car stack))) + (+ (nth 2 (car stack)) erlang-indent-guard + ;; receive XYZ or receive + ;; XYZ + ;; This if thing does not seem to be needed + ;;(if (looking-at "[a-z]+\\s *\\($\\|%\\)") + ;; erlang-indent-level + ;; (* 2 erlang-indent-level)))) + (* 2 erlang-indent-level))) + ;;erlang-indent-level)) + (+ erlang-indent-level erlang-indent-guard))) + ;; "when" is followed by code, let's indent to the same + ;; column. + (forward-char 4) ; Skip "when" + (skip-chars-forward " \t") + (current-column))) + ;; Type and Spec indentation + ((eq (car stack-top) '::) + (if (looking-at "}") + ;; Closing record definition with types + ;; pop stack and recurse + (erlang-calculate-stack-indent indent-point + (cons (erlang-pop stack) (cdr state))) + (cond ((null erlang-argument-indent) + ;; indent to next column. + (+ 2 (nth 2 stack-top))) + ((looking-at "::[^_a-zA-Z0-9]") + (nth 2 stack-top)) + (t + (let ((start-alternativ (if (looking-at "|") 2 0))) + (goto-char (nth 1 stack-top)) + (- (cond ((looking-at "::\\s *\\($\\|%\\)") + ;; Line ends with :: + (if (eq (car (car (last stack))) 'spec) + (+ (erlang-indent-find-preceding-expr 1) + erlang-argument-indent) + (+ (erlang-indent-find-preceding-expr 2) + erlang-argument-indent))) + (t + ;; Indent to the same column as the first + ;; argument. + (goto-char (+ 2 (nth 1 stack-top))) + (skip-chars-forward " \t") + (current-column))) start-alternativ)))))) + ))) + +(defun erlang-indent-standard (indent-point token base inside-parenthesis) + "Standard indent when in blocks or tuple or arguments. + Look at last thing to see in what state we are, move relative to the base." + (goto-char token) + (cond ((looking-at "||\\|,\\|->\\||") + base) + ((erlang-at-keyword) + (+ (current-column) erlang-indent-level)) + ((or (= (char-syntax (following-char)) ?.) + (erlang-at-operator)) + (+ base erlang-indent-level)) + (t + (goto-char indent-point) + (cond ((memq (following-char) '(?\( )) + ;; Function application. + (+ (erlang-indent-find-preceding-expr) + erlang-argument-indent)) + ;; Empty line, or end; treat it as the end of + ;; the block. (Here we have a choice: should + ;; the user be forced to reindent continued + ;; lines, or should the "end" be reindented?) + + ;; Avoid treating comments a continued line. + ((= (following-char) ?%) + base) + ;; Continued line (e.g. line beginning + ;; with an operator.) + (t + (if (or (erlang-at-operator) (not inside-parenthesis)) + (+ base erlang-indent-level) + base)))))) + +(defun erlang-indent-find-base (stack indent-point &optional offset skip) + "Find the base column for current stack." + (or skip (setq skip 2)) + (or offset (setq offset erlang-indent-level)) + (save-excursion + (let* ((stack-top (car stack))) + (goto-char (nth 1 stack-top)) + (if (< skip (- (point-max) (point))) + (progn + (forward-char skip) + (if (looking-at "\\s *\\($\\|%\\)") + (progn + (if (memq (car stack-top) '(-> ||)) + (erlang-pop stack)) + ;; Take parent identation + offset, + ;; else just erlang-indent-level if no parent + (if stack + (+ (erlang-caddr (car stack)) + offset) + erlang-indent-level)) + (erlang-skip-blank indent-point) + (current-column))) + (+ (current-column) skip))))) + + +;; Does not handle `begin' .. `end'. +(defun erlang-indent-find-preceding-expr (&optional arg) + "Return the first column of the preceding expression. +This assumes that the preceding expression is either simple +\(i.e. an atom) or parenthesized." + (save-excursion + (or arg (setq arg 1)) + (ignore-errors (forward-sexp (- arg))) + (let ((col (current-column))) + (skip-chars-backward " \t") + ;; Special hack to handle: (note line break) + ;; [#myrecord{ + ;; foo = foo}] + ;; where the call (forward-sexp -1) will fail when point is at the `#'. + (or + (ignore-errors + ;; Needed to match the colon in "'foo':'bar'". + (cond ((eq (preceding-char) ?:) + (backward-char 1) + (forward-sexp -1) + (current-column)) + ((eq (preceding-char) ?#) + ;; We may now be at: + ;; - either a construction of a new record + ;; - or update of a record, in which case we want + ;; the column of the expression to be updated. + ;; + ;; To see which of the two cases we are at, we first + ;; move an expression backwards, check for keywords, + ;; then immediately an expression forwards. Moving + ;; backwards skips past tokens like `,' or `->', but + ;; when moving forwards again, we won't skip past such + ;; tokens. We use this: if, after having moved + ;; forwards, we're back where we started, then it was + ;; a record update. + ;; The check for keywords is to detect cases like: + ;; case Something of #record_construction{...} + (backward-char 1) + (let ((record-start (point)) + (record-start-col (current-column))) + (forward-sexp -1) + (let ((preceding-expr-col (current-column)) + ;; white space definition according to erl_scan + (white-space "\000-\040\200-\240")) + (if (erlang-at-keyword) + ;; The (forward-sexp -1) call moved past a keyword + (1+ record-start-col) + (forward-sexp 1) + (skip-chars-forward white-space record-start) + ;; Are we back where we started? If so, it was an update. + (if (= (point) record-start) + preceding-expr-col + (goto-char record-start) + (1+ (current-column))))))) + (t col))) + col)))) + +(defun erlang-indent-parenthesis (stack-position) + (let ((previous (erlang-indent-find-preceding-expr))) + (if (> previous stack-position) + (+ stack-position erlang-argument-indent) + (+ previous erlang-argument-indent)))) + +(defun erlang-skip-blank (&optional lim) + "Skip over whitespace and comments until limit reached." + (or lim (setq lim (point-max))) + (let (stop) + (while (and (not stop) (< (point) lim)) + (cond ((= (following-char) ?%) + (skip-chars-forward "^\n" lim)) + ((= (following-char) ?\n) + (skip-chars-forward "\n" lim)) + ((looking-at "\\s ") + (if (re-search-forward "\\S " lim 'move) + (forward-char -1))) + (t + (setq stop t)))) + stop)) + +(defun erlang-at-keyword () + "Are we looking at an Erlang keyword which will increase indentation?" + (looking-at (concat "\\(when\\|if\\|fun\\|case\\|begin\\|" + "of\\|receive\\|after\\|catch\\|try\\)\\b"))) + +(defun erlang-at-operator () + "Are we looking at an Erlang operator?" + (looking-at + "\\(bnot\\|div\\|mod\\|band\\|bor\\|bxor\\|bsl\\|bsr\\)\\b")) + +(defun erlang-comment-indent () + "Compute Erlang comment indentation. + +Used both by `indent-for-comment' and the Erlang specific indentation +commands." + (cond ((looking-at "%%%") 0) + ((looking-at "%%") + (or (erlang-calculate-indent) + (current-indentation))) + (t + (save-excursion + (skip-chars-backward " \t") + (max (if (bolp) 0 (1+ (current-column))) + comment-column))))) + +;;; Erlang movement commands + +;; All commands below work as movement commands. I.e. if the point is +;; at the end of the clause, and the command `erlang-end-of-clause' is +;; executed, the point is moved to the end of the NEXT clause. (This +;; mimics the behaviour of `end-of-defun'.) +;; +;; Personally I would like to rewrite them to be "pure", and add a set +;; of movement functions, like `erlang-next-clause', +;; `erlang-previous-clause', and the same for functions. +;; +;; The current implementation makes it hopeless to use the functions as +;; subroutines in more complex commands. /andersl + +(defun erlang-beginning-of-clause (&optional arg) + "Move backward to previous start of clause. +With argument, do this that many times. +Return t unless search stops due to end of buffer." + (interactive "p") + (or arg (setq arg 1)) + (if (< arg 0) + ;; Step back to the end of the previous line, unless we are at + ;; the beginning of the buffer. The reason for this move is + ;; that the regexp below includes the last character of the + ;; previous line. + (if (bobp) + (or (looking-at "\n") + (forward-char 1)) + (forward-char -1) + (if (looking-at "\\`\n") + (forward-char 1)))) + ;; The regexp matches a function header that isn't + ;; included in a string. + (and (re-search-forward "\\(\\`\\|\\`\n\\|[^\\]\n\\)\\(-?[a-z]\\|'\\|-\\)" + nil 'move (- arg)) + (let ((beg (match-beginning 2))) + (and beg (goto-char beg)) + t))) + +(defun erlang-end-of-clause (&optional arg) + "Move to the end of the current clause. +With argument, do this that many times." + (interactive "p") + (or arg (setq arg 1)) + (while (and (looking-at "[ \t]*[%\n]") + (zerop (forward-line 1)))) + ;; Move to the next clause. + (erlang-beginning-of-clause (- arg)) + (beginning-of-line);; Just to be sure... + (let ((continue t)) + (while (and (not (bobp)) continue) + (forward-line -1) + (skip-chars-forward " \t") + (if (looking-at "[%\n]") + nil + (end-of-line) + (setq continue nil))))) + +(defun erlang-mark-clause () + "Put mark at end of clause, point at beginning." + (interactive) + (push-mark (point)) + (erlang-end-of-clause 1) + ;; Sets the region. In Emacs 19 and XEmacs, we want to activate + ;; the region. + (condition-case nil + (push-mark (point) nil t) + (error (push-mark (point)))) + (erlang-beginning-of-clause 1) + ;; The above function deactivates the mark. + (if (boundp 'deactivate-mark) + (funcall (symbol-function 'set) 'deactivate-mark nil))) + +(defun erlang-beginning-of-function (&optional arg) + "Move backward to previous start of function. +With positive argument, do this that many times. +With negative argument, search forward. + +Return t unless search stops due to end of buffer." + (interactive "p") + (or arg (setq arg 1)) + (cond + ;; Search backward + ((> arg 0) + (while (and (> arg 0) + (and (erlang-beginning-of-clause 1) + (let ((start (point)) + (name (erlang-name-of-function)) + (arity (erlang-get-function-arity))) + ;; Note: "arity" is nil for e.g. "-import", hence + ;; two "-import" clauses are not considered to + ;; be part of the same function. + (while (and (erlang-beginning-of-clause 1) + (string-equal name + (erlang-name-of-function)) + arity + (equal arity + (erlang-get-function-arity))) + (setq start (point))) + (goto-char start) + t))) + (setq arg (1- arg)))) + ;; Search forward + ((< arg 0) + (end-of-line) + (erlang-beginning-of-clause 1) + ;; Step -arg functions forward. + (while (and (< arg 0) + ;; Step one function forward, or stop if the end of + ;; the buffer was reached. Return t if we found the + ;; function. + (let ((name (erlang-name-of-function)) + (arity (erlang-get-function-arity)) + (found (erlang-beginning-of-clause -1))) + (while (and found + (string-equal name (erlang-name-of-function)) + arity + (equal arity + (erlang-get-function-arity))) + (setq found (erlang-beginning-of-clause -1))) + found)) + (setq arg (1+ arg))))) + (zerop arg)) + + +(defun erlang-end-of-function (&optional arg) + "Move forward to next end of function. + +With argument, do this that many times. +With negative argument go towards the beginning of the buffer." + (interactive "p") + (or arg (setq arg 1)) + (let ((first t)) + ;; Forward + (while (and (> arg 0) (< (point) (point-max))) + (let ((pos (point))) + (while (progn + (if (and first + (progn + (forward-char 1) + (erlang-beginning-of-clause 1))) + nil + (or (bobp) (forward-char -1)) + (erlang-beginning-of-clause -1)) + (setq first nil) + (erlang-pass-over-function) + (skip-chars-forward " \t") + (if (looking-at "[%\n]") + (forward-line 1)) + (<= (point) pos)))) + (setq arg (1- arg))) + ;; Backward + (while (< arg 0) + (let ((pos (point))) + (erlang-beginning-of-clause 1) + (erlang-pass-over-function) + (forward-line 1) + (if (>= (point) pos) + (if (erlang-beginning-of-function 2) + (progn + (erlang-pass-over-function) + (skip-chars-forward " \t") + (if (looking-at "[%\n]") + (forward-line 1))) + (goto-char (point-min))))) + (setq arg (1+ arg))))) + +(eval-and-compile + (if (default-boundp 'beginning-of-defun-function) + (defalias 'erlang-mark-function 'mark-defun) + (defun erlang-mark-function () + "Put mark at end of function, point at beginning." + (interactive) + (push-mark (point)) + (erlang-end-of-function 1) + ;; Sets the region. In Emacs 19 and XEmacs, we want to activate + ;; the region. + (condition-case nil + (push-mark (point) nil t) + (error (push-mark (point)))) + (erlang-beginning-of-function 1) + ;; The above function deactivates the mark. + (if (boundp 'deactivate-mark) + (funcall (symbol-function 'set) 'deactivate-mark nil))))) + +(defun erlang-pass-over-function () + (while (progn + (erlang-skip-blank) + (and (not (looking-at "\\.\\(\\s \\|\n\\|\\s<\\)")) + (not (eobp)))) + (forward-sexp 1)) + (if (not (eobp)) + (forward-char 1))) + +(defun erlang-name-of-function () + (save-excursion + ;; Skip over attribute leader. + (if (looking-at "-[ \t]*") + (re-search-forward "-[ \t]*" nil 'move)) + (let ((start (point))) + (forward-sexp 1) + (buffer-substring start (point))))) + + +;;; Miscellaneous + +(defun erlang-fill-paragraph (&optional justify) + "Like \\[fill-paragraph], but handle Erlang comments. +If any of the current line is a comment, fill the comment or the +paragraph of it that point is in, preserving the comment's indentation +and initial `%':s." + (interactive "P") + (let ((has-comment nil) + ;; If has-comment, the appropriate fill-prefix for the comment. + comment-fill-prefix) + ;; Figure out what kind of comment we are looking at. + (save-excursion + (beginning-of-line) + (cond + ;; Find the command prefix. + ((looking-at (concat "\\s *" comment-start-skip)) + (setq has-comment t) + (setq comment-fill-prefix (buffer-substring (match-beginning 0) + (match-end 0)))) + ;; A line with some code, followed by a comment? Remember that the + ;; % which starts the comment shouldn't be part of a string or + ;; character. + ((progn + (while (not (looking-at "%\\|$")) + (skip-chars-forward "^%\n\"\\\\") + (cond + ((eq (char-after (point)) ?\\) (forward-char 2)) + ((eq (char-after (point)) ?\") (forward-sexp 1)))) + (looking-at comment-start-skip)) + (setq has-comment t) + (setq comment-fill-prefix + (concat (make-string (current-column) ? ) + (buffer-substring (match-beginning 0) (match-end 0))))))) + (if (not has-comment) + (fill-paragraph justify) + ;; Narrow to include only the comment, and then fill the region. + (save-restriction + (narrow-to-region + ;; Find the first line we should include in the region to fill. + (save-excursion + (while (and (zerop (forward-line -1)) + (looking-at "^\\s *%"))) + ;; We may have gone to far. Go forward again. + (or (looking-at "^\\s *%") + (forward-line 1)) + (point)) + ;; Find the beginning of the first line past the region to fill. + (save-excursion + (while (progn (forward-line 1) + (looking-at "^\\s *%"))) + (point))) + ;; Lines with only % on them can be paragraph boundaries. + (let ((paragraph-start (concat paragraph-start "\\|^[ \t%]*$")) + (paragraph-separate (concat paragraph-start "\\|^[ \t%]*$")) + (fill-prefix comment-fill-prefix)) + (fill-paragraph justify)))))) + + +(defun erlang-uncomment-region (beg end) + "Uncomment all commented lines in the region." + (interactive "r") + (uncomment-region beg end)) + + +(defun erlang-generate-new-clause () + "Create additional Erlang clause header. + +Parses the source file for the name of the current Erlang function. +Create the header containing the name, A pair of parentheses, +and an arrow. The space between the function name and the +first parenthesis is preserved. The point is placed between +the parentheses." + (interactive) + (let ((name (save-excursion + (and (erlang-beginning-of-clause) + (erlang-get-function-name t)))) + (arrow (save-excursion + (and (erlang-beginning-of-clause) + (erlang-get-function-arrow))))) + (if (or (null arrow) (null name)) + (error "Can't find name of current Erlang function")) + (if (and (bolp) (eolp)) + nil + (end-of-line) + (newline)) + (insert name) + (save-excursion + (insert ") " arrow)) + (if erlang-new-clause-with-arguments + (erlang-clone-arguments)))) + + +(defun erlang-clone-arguments () + "Insert, at the point, the argument list of the previous clause. + +The mark is set at the beginning of the inserted text, the point +at the end." + (interactive) + (let ((args (save-excursion + (beginning-of-line) + (and (erlang-beginning-of-clause) + (erlang-get-function-arguments)))) + (p (point))) + (if (null args) + (error "Can't clone argument list")) + (insert args) + (set-mark p))) + +;;; Information retrieval functions. + +(defun erlang-buffer-substring (beg end) + "Like `buffer-substring-no-properties'. +Although, this function works on all versions of Emacs." + (if (fboundp 'buffer-substring-no-properties) + (funcall (symbol-function 'buffer-substring-no-properties) beg end) + (buffer-substring beg end))) + + +(defun erlang-get-module () + "Return the name of the module as specified by `-module'. + +Return nil if file contains no `-module' attribute." + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (let ((md (match-data))) + (unwind-protect + (if (re-search-forward + (eval-when-compile + (concat "^-module\\s *(\\s *\\(\\(" + erlang-atom-regexp + "\\)?\\)\\s *)\\s *\\.")) + (point-max) t) + (erlang-remove-quotes + (erlang-buffer-substring (match-beginning 1) + (match-end 1))) + nil) + (store-match-data md)))))) + + +(defun erlang-get-module-from-file-name (&optional file) + "Extract the module name from a file name. + +First, the directory part is removed. Second, the part of the file name +matching `erlang-file-name-extension-regexp' is removed. + +Should the match fail, nil is returned. + +By modifying `erlang-file-name-extension-regexp' to match files other +than Erlang source files, Erlang specific functions could be applied on +non-Erlang files. Most notably; the support for Erlang modules in the +tags system could be used by files written in other languages." + (or file (setq file buffer-file-name)) + (if (null file) + nil + (setq file (file-name-nondirectory file)) + (if (string-match erlang-file-name-extension-regexp file) + (substring file 0 (match-beginning 0)) + nil))) + + +;; Used by `erlang-get-export' and `erlang-get-import'. + +(defun erlang-get-function-arity-list () + "Parse list of `function/arity' as used by `-import' and `-export'. + +Point must be before the opening bracket. When the +function returns the point will be placed after the closing bracket. + +The function does not return an error if the list is incorrectly +formatted. + +Return list of (function . arity). The order of the returned list +corresponds to the order of the parsed Erlang list." + (let ((res '())) + (erlang-skip-blank) + (forward-char 1) + (if (not (eq (preceding-char) ?\[)) + '() ; Not looking at an Erlang list. + (while ; Note: `while' has no body. + (progn + (erlang-skip-blank) + (and (looking-at (eval-when-compile + (concat erlang-atom-regexp "/\\([0-9]+\\)\\>"))) + (progn + (setq res (cons + (cons + (erlang-remove-quotes + (erlang-buffer-substring + (match-beginning 1) (match-end 1))) + (erlang-string-to-int + (erlang-buffer-substring + (match-beginning + (+ 1 erlang-atom-regexp-matches)) + (match-end + (+ 1 erlang-atom-regexp-matches))))) + res)) + (goto-char (match-end 0)) + (erlang-skip-blank) + (forward-char 1) + ;; Test if there are more exported functions. + (eq (preceding-char) ?,)))))) + (nreverse res))) + + +;;; Note that `-export' and the open parenthesis must be written on +;;; the same line. + +(defun erlang-get-export () + "Return a list of `(function . arity)' as specified by `-export'." + (save-excursion + (goto-char (point-min)) + (let ((md (match-data)) + (res '())) + (unwind-protect + (progn + (while (re-search-forward "^-export\\s *(" (point-max) t) + (erlang-skip-blank) + (setq res (nconc res (erlang-get-function-arity-list)))) + res) + (store-match-data md))))) + + +(defun erlang-get-import () + "Parse an Erlang source file for imported functions. + +Return an alist with module name as car part and list of conses containing +function and arity as cdr part." + (save-excursion + (goto-char (point-min)) + (let ((md (match-data)) + (res '())) + (unwind-protect + (progn + (while (re-search-forward "^-import\\s *(" (point-max) t) + (erlang-skip-blank) + (if (looking-at erlang-atom-regexp) + (let ((module (erlang-remove-quotes + (erlang-buffer-substring + (match-beginning 0) + (match-end 0))))) + (goto-char (match-end 0)) + (erlang-skip-blank) + (if (eq (following-char) ?,) + (progn + (forward-char 1) + (erlang-skip-blank) + (let ((funcs (erlang-get-function-arity-list)) + (pair (assoc module res))) + (if pair + (setcdr pair (nconc (cdr pair) funcs)) + (setq res (cons (cons module funcs) + res))))))))) + (nreverse res)) + (store-match-data md))))) + + +(defun erlang-get-function-name (&optional arg) + "Return name of current function, or nil. + +If optional argument is non-nil, everything up to and including +the first `(' is returned. + +Normally used in conjunction with `erlang-beginning-of-clause', e.g.: + (save-excursion + (if (not (eobp)) (forward-char 1)) + (and (erlang-beginning-of-clause) + (erlang-get-function-name t)))" + (let ((n (if arg 0 1))) + (and (looking-at (eval-when-compile + (concat "^" erlang-atom-regexp "\\s *("))) + (erlang-buffer-substring (match-beginning n) (match-end n))))) + + +(defun erlang-get-function-arrow () + "Return arrow of current function, could be \"->\" or nil. + +Normally used in conjunction with `erlang-beginning-of-clause', e.g.: + (save-excursion + (if (not (eobp)) (forward-char 1)) + (and (erlang-beginning-of-clause) + (erlang-get-function-arrow)))" + (and + (save-excursion + (re-search-forward "->" (point-max) t) + (erlang-buffer-substring (- (point) 2) (+ (point) 1))))) + +(defun erlang-get-function-arity () + "Return the number of arguments of function at point, or nil." + (and (looking-at (eval-when-compile + (concat "^" erlang-atom-regexp "\\s *("))) + (save-excursion + (goto-char (match-end 0)) + (condition-case nil + (let ((res 0) + (cont t)) + (while cont + (cond ((eobp) + (setq res nil) + (setq cont nil)) + ((looking-at "\\s *)") + (setq cont nil)) + ((looking-at "\\s *\\($\\|%\\)") + (forward-line 1)) + ((looking-at "\\s *<<[^>]*?>>") + (when (zerop res) + (setq res (+ 1 res))) + (goto-char (match-end 0))) + ((looking-at "\\s *,") + (setq res (+ 1 res)) + (goto-char (match-end 0))) + (t + (when (zerop res) + (setq res (+ 1 res))) + (forward-sexp 1)))) + res) + (error nil))))) + +(defun erlang-get-function-name-and-arity () + "Return the name and arity of the function at point, or nil. +The return value is a string of the form \"foo/1\"." + (let ((name (erlang-get-function-name)) + (arity (erlang-get-function-arity))) + (and name arity (format "%s/%d" name arity)))) + +(defun erlang-get-function-arguments () + "Return arguments of current function, or nil." + (if (not (looking-at (eval-when-compile + (concat "^" erlang-atom-regexp "\\s *(")))) + nil + (save-excursion + (condition-case nil + (let ((start (match-end 0))) + (goto-char (- start 1)) + (forward-sexp) + (erlang-buffer-substring start (- (point) 1))) + (error nil))))) + + +(defun erlang-get-function-under-point () + "Return the module and function under the point, or nil. + +Should no explicit module name be present at the point, the +list of imported functions is searched. + +The following could be returned: + (\"module\" \"function\") -- Both module and function name found. + (nil \"function\") -- No module name was found. + nil -- No function name found + +In the future the list may contain more elements." + (save-excursion + (let ((md (match-data)) + (res nil)) + (if (eq (char-syntax (following-char)) ? ) + (skip-chars-backward " \t")) + (skip-chars-backward "a-zA-Z0-9_:'") + (cond ((looking-at (eval-when-compile + (concat erlang-atom-regexp ":" erlang-atom-regexp))) + (setq res (list + (erlang-remove-quotes + (erlang-buffer-substring + (match-beginning 1) (match-end 1))) + (erlang-remove-quotes + (erlang-buffer-substring + (match-beginning (1+ erlang-atom-regexp-matches)) + (match-end (1+ erlang-atom-regexp-matches))))))) + ((looking-at erlang-atom-regexp) + (let ((fk (erlang-remove-quotes + (erlang-buffer-substring + (match-beginning 0) (match-end 0)))) + (mod nil) + (imports (erlang-get-import))) + (while (and imports (null mod)) + (if (assoc fk (cdr (car imports))) + (setq mod (car (car imports))) + (setq imports (cdr imports)))) + (setq res (list mod fk))))) + (store-match-data md) + res))) + + +;; TODO: Escape single quotes inside the string without +;; replace-regexp-in-string. +(defun erlang-add-quotes-if-needed (str) + "Return STR, possibly with quotes." + (let ((case-fold-search nil)) ; force string matching to be case sensitive + (if (and (stringp str) + (not (string-match (eval-when-compile + (concat "\\`" erlang-atom-regexp "\\'")) str))) + (progn (if (fboundp 'replace-regexp-in-string) + (setq str (replace-regexp-in-string "'" "\\'" str t t ))) + (concat "'" str "'")) + str))) + + +(defun erlang-remove-quotes (str) + "Return STR without quotes, if present." + (let ((md (match-data))) + (prog1 + (if (string-match "\\`'\\(.*\\)'\\'" str) + (substring str 1 -1) + str) + (store-match-data md)))) + +(defun erlang-match-next-exported-function (max) + "Returns non-nil if there is an exported function in the current +buffer between point and MAX." + (block nil + (while (and (not erlang-inhibit-exported-function-name-face) + (erlang-match-next-function max)) + (when (erlang-last-match-exported-p) + (return (match-data)))))) + +(defun erlang-match-next-function (max) + "Searches forward in current buffer for the next erlang function, +bounded by position MAX." + (re-search-forward erlang-defun-prompt-regexp max 'move-point)) + +(defun erlang-last-match-exported-p () + "Returns non-nil if match-data describes the name and arity of an +exported function." + (save-excursion + (save-match-data + (goto-char (match-beginning 1)) + (erlang-function-exported-p + (erlang-remove-quotes (erlang-get-function-name)) + (erlang-get-function-arity))))) + +(defun erlang-function-exported-p (name arity) + "Returns non-nil if function of name and arity is exported in current buffer." + (save-excursion + (let* ((old-match-data (match-data)) + (exports (erlang-get-export))) + (store-match-data old-match-data) + (member (cons name arity) exports)))) + + +;;; Check module name + +;; The function `write-file', bound to C-x C-w, calls +;; `set-visited-file-name' which clears the hook. :-( +;; To make sure that the hook always is present, we advise +;; `set-visited-file-name'. +(defun erlang-check-module-name-init () + "Initialize the functionality to compare file and module names. + +Unless we have `before-save-hook', we redefine the function +`set-visited-file-name' since it clears the variable +`local-write-file-hooks'. The original function definition is +stored in `erlang-orig-set-visited-file-name'." + (if (boundp 'before-save-hook) + ;; If we have that, `make-local-hook' is obsolete. + (add-hook 'before-save-hook 'erlang-check-module-name nil t) + (require 'advice) + (unless (ad-advised-definition-p 'set-visited-file-name) + (defadvice set-visited-file-name (after erlang-set-visited-file-name + activate) + (if (eq major-mode 'erlang-mode) + (add-hook 'local-write-file-hooks 'erlang-check-module-name)))) + (add-hook 'local-write-file-hooks 'erlang-check-module-name))) + + +(defun erlang-check-module-name () + "If the module name doesn't match file name, ask for permission to change. + +The variable `erlang-check-module-name' controls the behaviour of this +function. It it is nil, this function does nothing. If it is t, the +source is silently changed. If it is set to the atom `ask', the user +is prompted. + +This function is normally placed in the hook `local-write-file-hooks'." + (if erlang-check-module-name + (let ((mn (erlang-add-quotes-if-needed + (erlang-get-module))) + (fn (erlang-add-quotes-if-needed + (erlang-get-module-from-file-name (buffer-file-name))))) + (if (and (stringp mn) (stringp fn)) + (or (string-equal mn fn) + (if (or (eq erlang-check-module-name t) + (y-or-n-p + "Module does not match file name. Modify source? ")) + (save-excursion + (save-restriction + (widen) + (goto-char (point-min)) + (if (re-search-forward + (eval-when-compile + (concat "^-module\\s *(\\s *\\(\\(" + erlang-atom-regexp + "\\)?\\)\\s *)\\s *\\.")) + (point-max) t) + (progn + (goto-char (match-beginning 1)) + (delete-region (match-beginning 1) + (match-end 1)) + (insert fn)))))))))) + ;; Must return nil since it is added to `local-write-file-hook'. + nil) + + +;;; Electric functions. + +(defun erlang-electric-semicolon (&optional arg) + "Insert a semicolon character and possibly a prototype for the next line. + +The variable `erlang-electric-semicolon-criteria' states a criterion, +when fulfilled a newline is inserted, the next line is indented and a +prototype for the next line is inserted. Normally the prototype +consists of \" ->\". Should the semicolon end the clause a new clause +header is generated. + +The variable `erlang-electric-semicolon-insert-blank-lines' controls +the number of blank lines inserted between the current line and new +function header. + +Behaves just like the normal semicolon when supplied with a +numerical arg, point is inside string or comment, or when there are +non-whitespace characters following the point on the current line." + (interactive "P") + (self-insert-command (prefix-numeric-value arg)) + (if (or arg + (and (listp erlang-electric-commands) + (not (memq 'erlang-electric-semicolon + erlang-electric-commands))) + (erlang-in-literal) + (not (looking-at "\\s *\\(%.*\\)?$")) + (null (erlang-test-criteria-list + erlang-electric-semicolon-criteria))) + (setq erlang-electric-newline-inhibit nil) + (setq erlang-electric-newline-inhibit t) + (undo-boundary) + (erlang-indent-line) + (end-of-line) + (newline) + (if (condition-case nil + (progn (erlang-indent-line) t) + (error (if (bolp) (delete-backward-char 1)))) + (if (not (bolp)) + (save-excursion + (insert " ->")) + (condition-case nil + (progn + (erlang-generate-new-clause) + (if erlang-electric-semicolon-insert-blank-lines + (save-excursion + (beginning-of-line) + (newline + erlang-electric-semicolon-insert-blank-lines)))) + (error (if (bolp) (delete-backward-char 1)))))))) + + +(defun erlang-electric-comma (&optional arg) + "Insert a comma character and possibly a new indented line. +The variable `erlang-electric-comma-criteria' states a criterion, +when fulfilled a newline is inserted and the next line is indented. + +Behaves just like the normal comma when supplied with a +numerical arg, point is inside string or comment, or when there are +non-whitespace characters following the point on the current line." + (interactive "P") + + (self-insert-command (prefix-numeric-value arg)) + + (if (or arg + (and (listp erlang-electric-commands) + (not (memq 'erlang-electric-comma erlang-electric-commands))) + (erlang-in-literal) + (not (looking-at "\\s *\\(%.*\\)?$")) + (null (erlang-test-criteria-list + erlang-electric-comma-criteria))) + (setq erlang-electric-newline-inhibit nil) + (setq erlang-electric-newline-inhibit t) + (undo-boundary) + (erlang-indent-line) + (end-of-line) + (newline) + (condition-case nil + (erlang-indent-line) + (error (if (bolp) (delete-backward-char 1)))))) + +(defun erlang-electric-lt (&optional arg) + "Insert a less-than sign, and optionally mark it as an open paren." + + (interactive "p") + + (self-insert-command arg) + + ;; Was this the second char in bit-syntax open (`<<')? + (unless (<= (point) 2) + (save-excursion + (backward-char 2) + (when (and (eq (char-after (point)) ?<) + (not (eq (get-text-property (point) 'category) + 'bitsyntax-open-inner))) + ;; Then mark the two chars... + (put-text-property (point) (1+ (point)) + 'category 'bitsyntax-open-outer) + (forward-char 1) + (put-text-property (point) (1+ (point)) + 'category 'bitsyntax-open-inner) + ;;...and unmark any subsequent less-than chars. + (forward-char 1) + (while (eq (char-after (point)) ?<) + (remove-text-properties (point) (1+ (point)) + '(category nil)) + (forward-char 1)))))) + +(defun erlang-after-bitsyntax-close () + "Return t if point is immediately after a bit-syntax close parenthesis (`>>')." + (and (>= (point) 3) + (save-excursion + (backward-char 2) + (and (eq (char-after (point)) ?>) + (not (eq (get-text-property (point) 'category) + 'bitsyntax-close-outer)))))) + +(defun erlang-after-arrow () + "Return true if point is immediately after a function arrow (`->')." + (and (>= (point) 2) + (and + (save-excursion + (backward-char) + (eq (char-before (point)) ?-)) + (or (not (listp erlang-electric-commands)) + (memq 'erlang-electric-gt + erlang-electric-commands)) + (not (erlang-in-literal)) + (looking-at "\\s *\\(%.*\\)?$") + (erlang-test-criteria-list erlang-electric-arrow-criteria)))) + + +(defun erlang-electric-gt (&optional arg) + "Insert a greater-than sign, and optionally mark it as a close paren." + + (interactive "p") + + (self-insert-command arg) + + (cond + ;; Did we just write a bit-syntax close (`>>')? + ((erlang-after-bitsyntax-close) + (save-excursion + ;; Then mark the two chars... + (backward-char 2) + (put-text-property (point) (1+ (point)) + 'category 'bitsyntax-close-inner) + (forward-char) + (put-text-property (point) (1+ (point)) + 'category 'bitsyntax-close-outer) + ;;...and unmark any subsequent greater-than chars. + (forward-char) + (while (eq (char-after (point)) ?>) + (remove-text-properties (point) (1+ (point)) + '(category nil)) + (forward-char)))) + + ;; Did we just write a function arrow (`->')? + ((erlang-after-arrow) + (let ((erlang-electric-newline-inhibit t)) + (undo-boundary) + (end-of-line) + (newline) + (condition-case nil + (erlang-indent-line) + (error (if (bolp) (delete-backward-char 1)))))) + + ;; Then it's just a plain greater-than. + (t + nil))) + + +(defun erlang-electric-arrow\ off (&optional arg) + "Insert a '>'-sign and possibly a new indented line. + +This command is only `electric' when the `>' is part of an `->' arrow. +The variable `erlang-electric-arrow-criteria' states a sequence of +criteria, which decides when a newline should be inserted and the next +line indented. + +It behaves just like the normal greater than sign when supplied with a +numerical arg, point is inside string or comment, or when there are +non-whitespace characters following the point on the current line. + +After being split/merged into `erlang-after-arrow' and +`erlang-electric-gt', it is now unused and disabled." + (interactive "P") + (let ((prec (preceding-char))) + (self-insert-command (prefix-numeric-value arg)) + (if (or arg + (and (listp erlang-electric-commands) + (not (memq 'erlang-electric-arrow + erlang-electric-commands))) + (not (eq prec ?-)) + (erlang-in-literal) + (not (looking-at "\\s *\\(%.*\\)?$")) + (null (erlang-test-criteria-list + erlang-electric-arrow-criteria))) + (setq erlang-electric-newline-inhibit nil) + (setq erlang-electric-newline-inhibit t) + (undo-boundary) + (end-of-line) + (newline) + (condition-case nil + (erlang-indent-line) + (error (if (bolp) (delete-backward-char 1))))))) + + +(defun erlang-electric-newline (&optional arg) + "Break line at point and indent, continuing comment if within one. +The variable `erlang-electric-newline-criteria' states a criterion, +when fulfilled a newline is inserted and the next line is indented. + +Should the current line begin with a comment, and the variable +`comment-multi-line' be non-nil, a new comment start is inserted. + +Should the previous command be another electric command we assume that +the user pressed newline out of old habit, hence we will do nothing." + (interactive "P") + (cond ((and (not arg) + erlang-electric-newline-inhibit + (memq last-command erlang-electric-newline-inhibit-list)) + ()) ; Do nothing! + ((or arg + (and (listp erlang-electric-commands) + (not (memq 'erlang-electric-newline + erlang-electric-commands))) + (null (erlang-test-criteria-list + erlang-electric-newline-criteria))) + (newline (prefix-numeric-value arg))) + (t + (if (and comment-multi-line + (save-excursion + (beginning-of-line) + (looking-at (concat "\\s *" comment-start-skip)))) + (let ((str (buffer-substring + (or (match-end 1) (match-beginning 0)) + (min (match-end 0) (point))))) + (newline) + (undo-boundary) + (insert str)) + (newline) + (undo-boundary) + (indent-according-to-mode))))) + + +(defun erlang-test-criteria-list (criteria) + "Given a list of criterion functions, test if criteria are fulfilled. + +Each element in the criteria list can a function returning nil, t or +the atom `stop'. t means that the criterion is fulfilled, `stop' means +that it isn't fulfilled and that the search should stop, +and nil means continue searching. + +Should the list contain the atom t the criterion is assumed to be +fulfilled, unless preceded by a function returning `stop', of course. + +Should the argument be the atom t instead of a list, the criterion is +assumed to be trivially true. + +Should all functions return nil, the criteria are assumed not to be +fulfilled. + +Return t if criteria fulfilled, nil otherwise." + (if (eq criteria t) + t + (save-excursion + (let ((answer nil)) + (while (and criteria (null answer)) + (if (eq (car criteria) t) + (setq answer t) + (setq answer (funcall (car criteria)))) + (setq criteria (cdr criteria))) + (if (and answer (not (eq answer 'stop))) + t + nil))))) + + +(defun erlang-in-literal (&optional lim) + "Test if point is in string, quoted atom or comment. + +Return one of the three atoms `atom', `string', and `comment'. +Should the point be inside none of the above mentioned types of +context, nil is returned." + (save-excursion + (let* ((lim (or lim (save-excursion + (erlang-beginning-of-clause) + (point)))) + (state (if (fboundp 'syntax-ppss) ; post Emacs 21.3 + (funcall (symbol-function 'syntax-ppss)) + (parse-partial-sexp lim (point))))) + (cond + ((eq (nth 3 state) ?') 'atom) + ((nth 3 state) 'string) + ((nth 4 state) 'comment) + (t nil))))) + + +(defun erlang-at-end-of-function-p () + "Test if point is at end of an Erlang function. + +This function is designed to be a member of a criteria list." + (eq (save-excursion (erlang-skip-blank) (point)) + (save-excursion + (erlang-beginning-of-function -1) (point)))) + + +(defun erlang-at-end-of-clause-p () + "Test if point is at end of an Erlang clause. + +This function is designed to be a member of a criteria list." + (eq (save-excursion (erlang-skip-blank) (point)) + (save-excursion + (erlang-beginning-of-clause -1) (point)))) + + +(defun erlang-stop-when-inside-argument-list () + "Return `stop' if inside parenthesis list, nil otherwise. + +Knows about the list comprehension syntax. When the point is +after `||', `stop' is not returned. + +This function is designed to be a member of a criteria list." + (save-excursion + (condition-case nil + (let ((orig-point (point)) + (state nil)) + (up-list -1) + (if (not (eq (following-char) ?\[)) + 'stop + ;; Do not return `stop' when inside a list comprehension + ;; construction. (The point must be after `||'). + (while (< (point) orig-point) + (setq state (erlang-partial-parse (point) orig-point state))) + (if (and (car state) (eq (car (car (car state))) '||)) + nil + 'stop))) + (error + nil)))) + + +(defun erlang-stop-when-at-guard () + "Return `stop' when at function guards. + +This function is designed to be a member of a criteria list." + (save-excursion + (beginning-of-line) + (if (and (looking-at (eval-when-compile + (concat "^" erlang-atom-regexp "\\s *("))) + (not (looking-at + (eval-when-compile + (concat "^" erlang-atom-regexp ".*->"))))) + 'stop + nil))) + + +(defun erlang-stop-when-in-type-spec () + "Return `stop' when in a type spec line. + +This function is designed to be a member of a criteria list." + (save-excursion + (beginning-of-line) + (when (save-match-data (looking-at "-\\(spec\\|type\\)")) + 'stop))) + + +(defun erlang-next-lines-empty-p () + "Return non-nil if next lines are empty. + +The variable `erlang-next-lines-empty-threshold' contains the number +of lines required to be empty. + +A line containing only spaces and tabs is considered empty. + +This function is designed to be a member of a criteria list." + (and erlang-next-lines-empty-threshold + (save-excursion + (let ((left erlang-next-lines-empty-threshold) + (cont t)) + (while (and cont (> left 0)) + (forward-line 1) + (setq cont (looking-at "\\s *$")) + (setq left (- left 1))) + cont)))) + + +(defun erlang-at-keyword-end-p () + "Test if next readable token is the keyword end. + +This function is designed to be a member of a criteria list." + (save-excursion + (erlang-skip-blank) + (looking-at "end[^_a-zA-Z0-9]"))) + + +;; Erlang tags support which is aware of erlang modules. +;; +;; Not yet implemented under XEmacs. (Hint: The Emacs 19 etags +;; package works under XEmacs.) + +(eval-when-compile + (if (or (featurep 'bytecomp) + (featurep 'byte-compile)) + (progn + (require 'etags)))) + + +;; Variables: + +(defvar erlang-tags-function-alist + '((find-tag . erlang-find-tag) + (find-tag-other-window . erlang-find-tag-other-window) + (find-tag-regexp . erlang-find-tag-regexp) + (find-tag-other-frame . erlang-find-tag-other-frame)) + "Alist of old tags commands and the replacement functions.") + +(defvar erlang-tags-installed nil + "Non-nil when the Erlang tags system is installed.") +(defvar erlang-tags-file-list '() + "List of files in tag list. Used when finding tag on form `module:'.") +(defvar erlang-tags-completion-table nil + "Like `tags-completion-table', this table contains `tag' and `module:tag'.") +(defvar erlang-tags-buffer-installed-p nil + "Non-nil when Erlang module recognising functions installed.") +(defvar erlang-tags-buffer-list '() + "Temporary list of buffers.") +(defvar erlang-tags-orig-completion-table nil + "Temporary storage for `tags-completion-table'.") +(defvar erlang-tags-orig-tag-order nil + "Temporary storage for `find-tag-tag-order'.") +(defvar erlang-tags-orig-regexp-tag-order nil + "Temporary storage for `find-tag-regexp-tag-order'.") +(defvar erlang-tags-orig-search-function nil + "Temporary storage for `find-tag-search-function'.") +(defvar erlang-tags-orig-regexp-search-function nil + "Temporary storage for `find-tag-regexp-search-function'.") +(defvar erlang-tags-orig-format-hooks nil + "Temporary storage for `tags-table-format-hooks'.") ;v19 +(defvar erlang-tags-orig-format-functions nil + "Temporary storage for `tags-table-format-functions'.") ;v > 19 + +(defun erlang-tags-init () + "Install an alternate version of tags, aware of Erlang modules. + +After calling this function, the tags functions are aware of +Erlang modules. Tags can be entered on the for `module:tag' as well +as on the old form `tag'. + +In the completion list, `module:tag' and `module:' shows up. + +Call this function from an appropriate init file, or add it to +Erlang mode hook with the commands: + (add-hook 'erlang-mode-hook 'erlang-tags-init) + (add-hook 'erlang-shell-mode-hook 'erlang-tags-init) + +This function only works under Emacs 18 and Emacs 19. Currently, It +is not implemented under XEmacs. (Hint: The Emacs 19 etags module +works under XEmacs.)" + (interactive) + (cond ((= erlang-emacs-major-version 18) + (require 'tags) + (erlang-tags-define-keys (current-local-map)) + (setq erlang-tags-installed t)) + (t + (require 'etags) + ;; Test on a function available in the Emacs 19 version + ;; of tags but not in the XEmacs version. + (if (not (fboundp 'find-tag-noselect)) + () + (erlang-tags-define-keys (current-local-map)) + (setq erlang-tags-installed t))))) + + +;; Set all keys bound to `find-tag' et.al. in the global map and the +;; menu to `erlang-find-tag' et.al. in `map'. +;; +;; The function `substitute-key-definition' does not work properly +;; in all version of Emacs. + +(defun erlang-tags-define-keys (map) + "Bind tags commands to keymap MAP aware of Erlang modules." + (let ((alist erlang-tags-function-alist)) + (while alist + (let* ((old (car (car alist))) + (new (cdr (car alist))) + (keys (append (where-is-internal old global-map)))) + (while keys + (define-key map (car keys) new) + (setq keys (cdr keys)))) + (setq alist (cdr alist)))) + ;; Update the menu. + (erlang-menu-substitute erlang-menu-base-items erlang-tags-function-alist) + (erlang-menu-init)) + + +;; There exists a variable `find-tag-default-function'. It is not used +;; since `complete-tag' uses it to get current word under point. In that +;; situation we don't want the module to be prepended. + +(defun erlang-find-tag-default () + "Return the default tag. +Search `-import' list of imported functions. +Single quotes are been stripped away." + (let ((mod-func (erlang-get-function-under-point))) + (cond ((null mod-func) + nil) + ((null (car mod-func)) + (nth 1 mod-func)) + (t + (concat (car mod-func) ":" (nth 1 mod-func)))))) + + +;; Return `t' since it is used inside `tags-loop-form'. +;;;###autoload +(defun erlang-find-tag (modtagname &optional next-p regexp-p) + "Like `find-tag'. Capable of retrieving Erlang modules. + +Tags can be given on the forms `tag', `module:', `module:tag'." + (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) + (switch-to-buffer (erlang-find-tag-noselect modtagname next-p regexp-p)) + t) + + +;; Code mainly from `find-tag-other-window' in `etags.el'. +;;;###autoload +(defun erlang-find-tag-other-window (tagname &optional next-p regexp-p) + "Like `find-tag-other-window' but aware of Erlang modules." + (interactive (erlang-tag-interactive + "Find `module:tag' or `tag' other window: ")) + + ;; This is to deal with the case where the tag is found in the + ;; selected window's buffer; without this, point is moved in both + ;; windows. To prevent this, we save the selected window's point + ;; before doing find-tag-noselect, and restore it afterwards. + (let* ((window-point (window-point (selected-window))) + (tagbuf (erlang-find-tag-noselect tagname next-p regexp-p)) + (tagpoint (progn (set-buffer tagbuf) (point)))) + (set-window-point (prog1 + (selected-window) + (switch-to-buffer-other-window tagbuf) + ;; We have to set this new window's point; it + ;; might already have been displaying a + ;; different portion of tagbuf, in which case + ;; switch-to-buffer-other-window doesn't set + ;; the window's point from the buffer. + (set-window-point (selected-window) tagpoint)) + window-point))) + + +(defun erlang-find-tag-other-frame (tagname &optional next-p) + "Like `find-tag-other-frame' but aware of Erlang modules." + (interactive (erlang-tag-interactive + "Find `module:tag' or `tag' other frame: ")) + (let ((pop-up-frames t)) + (erlang-find-tag-other-window tagname next-p))) + + +(defun erlang-find-tag-regexp (regexp &optional next-p other-window) + "Like `find-tag-regexp' but aware of Erlang modules." + (interactive (if (fboundp 'find-tag-regexp) + (erlang-tag-interactive + "Find `module:regexp' or `regexp': ") + (error "This version of Emacs can't find tags by regexps"))) + (funcall (if other-window + 'erlang-find-tag-other-window + 'erlang-find-tag) + regexp next-p t)) + + +;; Just like C-u M-. This could be added to the menu. +(defun erlang-find-next-tag () + "Find next tag, like \\[find-tag] with prefix arg." + (interactive) + (let ((current-prefix-arg '(4))) + (if erlang-tags-installed + (call-interactively 'erlang-find-tag) + (call-interactively 'find-tag)))) + + +;; Mimics `find-tag-noselect' found in `etags.el', but uses `find-tag' to +;; be compatible with `tags.el'. +;; +;; Handles three cases: +;; * `module:' Loop over all possible file names. Stop if a file-name +;; without extension and directory matches the module. +;; +;; * `module:tag' +;; Emacs 19: Replace test functions with functions aware of +;; Erlang modules. Tricky because the etags system wasn't +;; built for these kind of operations... +;; +;; Emacs 18: We loop over `find-tag' until we find a file +;; whose module matches the requested module. The +;; drawback is that a lot of files could be loaded into +;; Emacs. +;; +;; * `tag' Just give it to `find-tag'. + +(defun erlang-find-tag-noselect (modtagname &optional next-p regexp-p) + "Like `find-tag-noselect' but aware of Erlang modules." + (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) + (or modtagname + (setq modtagname (symbol-value 'last-tag))) + (funcall (symbol-function 'set) 'last-tag modtagname) + ;; `tags.el' uses this variable to record how M-, would + ;; know where to restart a tags command. + (if (boundp 'tags-loop-form) + (funcall (symbol-function 'set) + 'tags-loop-form '(erlang-find-tag nil t))) + (save-window-excursion + (cond + ((string-match ":$" modtagname) + ;; Only the module name was given. Read all files whose file name + ;; match. + (let ((modname (substring modtagname 0 (match-beginning 0))) + (file nil)) + (if (not next-p) + (save-excursion + (visit-tags-table-buffer) + (setq erlang-tags-file-list + (funcall (symbol-function 'tags-table-files))))) + (while (null file) + (or erlang-tags-file-list + (save-excursion + (if (and (featurep 'etags) + (funcall + (symbol-function 'visit-tags-table-buffer) 'same) + (funcall + (symbol-function 'visit-tags-table-buffer) t)) + (setq erlang-tags-file-list + (funcall (symbol-function 'tags-table-files))) + (error "No %stags containing %s" (if next-p "more " "") + modtagname)))) + (if erlang-tags-file-list + (let ((this-module (erlang-get-module-from-file-name + (car erlang-tags-file-list)))) + (if (and (stringp this-module) + (string= modname this-module)) + (setq file (car erlang-tags-file-list))) + (setq erlang-tags-file-list (cdr erlang-tags-file-list))))) + (set-buffer (or (get-file-buffer file) + (find-file-noselect file))))) + + ((string-match ":" modtagname) + (if (boundp 'find-tag-tag-order) + ;; Method one: Add module-recognising functions to the + ;; list of order functions. However, the tags system + ;; from Emacs 18, and derives thereof (read: XEmacs) + ;; hasn't got this feature. + (progn + (erlang-tags-install-module-check) + (unwind-protect + (funcall (symbol-function 'find-tag) + modtagname next-p regexp-p) + (erlang-tags-remove-module-check))) + ;; Method two: Call the tags system until a file matching + ;; the module is found. This could result in that many + ;; files are read. (e.g. The tag "foo:file" will take a + ;; while to process.) + (let* ((modname (substring modtagname 0 (match-beginning 0))) + (tagname (substring modtagname (match-end 0) nil)) + (last-tag tagname) + file) + (while + (progn + (funcall (symbol-function 'find-tag) tagname next-p regexp-p) + (setq next-p t) + ;; Determine the module form the file name. (The + ;; alternative, to check `-module', would make this + ;; code useless for non-Erlang programs.) + (setq file (erlang-get-module-from-file-name buffer-file-name)) + (not (and (stringp file) + (string= modname file)))))))) + (t + (funcall (symbol-function 'find-tag) modtagname next-p regexp-p))) + (current-buffer))) ; Return the new buffer. + + +;; Process interactive arguments for erlang-find-tag-*. +;; +;; Negative arguments work only for `etags', not `tags'. This is not +;; a problem since negative arguments means step back into the +;; history list, a feature not implemented in `tags'. + +(defun erlang-tag-interactive (prompt) + (condition-case nil + (require 'etags) + (error + (require 'tags))) + (if current-prefix-arg + (list nil (if (< (prefix-numeric-value current-prefix-arg) 0) + '- + t)) + (let* ((default (erlang-find-tag-default)) + (prompt (if default + (format "%s(default %s) " prompt default) + prompt)) + (spec (if (featurep 'etags) + (completing-read prompt 'erlang-tags-complete-tag) + (read-string prompt)))) + (list (if (equal spec "") + (or default (error "There is no default tag")) + spec))))) + + +;; Search tag functions which are aware of Erlang modules. The tactic +;; is to store new search functions into the local variables of the +;; TAGS buffers. The variables are restored directly after the +;; search. The situation is complicated by the fact that new TAGS +;; files can be loaded during the search. +;; + +(defun erlang-tags-install-module-check () + "Install our own tag search functions." + ;; Make sure our functions are installed in TAGS files loaded + ;; into Emacs while searching. + (cond + ((>= erlang-emacs-major-version 20) + (setq erlang-tags-orig-format-functions + (symbol-value 'tags-table-format-functions)) + (funcall (symbol-function 'set) 'tags-table-format-functions + (cons 'erlang-tags-recognize-tags-table + erlang-tags-orig-format-functions)) + (setq erlang-tags-buffer-list '()) + ) + (t + (setq erlang-tags-orig-format-hooks + (symbol-value 'tags-table-format-hooks)) + (funcall (symbol-function 'set) 'tags-table-format-hooks + (cons 'erlang-tags-recognize-tags-table + erlang-tags-orig-format-hooks)) + (setq erlang-tags-buffer-list '()) + )) + + ;; Install our functions in the TAGS files already resident. + (save-excursion + (let ((files (symbol-value 'tags-table-computed-list))) + (while files + (if (stringp (car files)) + (if (get-file-buffer (car files)) + (progn + (set-buffer (get-file-buffer (car files))) + (erlang-tags-install-local)))) + (setq files (cdr files)))))) + + +(defun erlang-tags-install-local () + "Install our tag search functions in current buffer." + (if erlang-tags-buffer-installed-p + () + ;; Mark this buffer as "installed" and record. + (set (make-local-variable 'erlang-tags-buffer-installed-p) t) + (setq erlang-tags-buffer-list + (cons (current-buffer) erlang-tags-buffer-list)) + + ;; Save the original values. + (set (make-local-variable 'erlang-tags-orig-tag-order) + (symbol-value 'find-tag-tag-order)) + (set (make-local-variable 'erlang-tags-orig-regexp-tag-order) + (symbol-value 'find-tag-regexp-tag-order)) + (set (make-local-variable 'erlang-tags-orig-search-function) + (symbol-value 'find-tag-search-function)) + (set (make-local-variable 'erlang-tags-orig-regexp-search-function) + (symbol-value 'find-tag-regexp-search-function)) + + ;; Install our own functions. + (set (make-local-variable 'find-tag-search-function) + 'erlang-tags-search-forward) + (set (make-local-variable 'find-tag-regexp-search-function) + 'erlang-tags-regexp-search-forward) + (set (make-local-variable 'find-tag-tag-order) + '(erlang-tag-match-module-p)) + (set (make-local-variable 'find-tag-regexp-tag-order) + '(erlang-tag-match-module-regexp-p)))) + + +(defun erlang-tags-remove-module-check () + "Remove our own tags search functions." + (cond + ((>= erlang-emacs-major-version 20) + (funcall (symbol-function 'set) + 'tags-table-format-functions + erlang-tags-orig-format-functions) + ) + (t + (funcall (symbol-function 'set) + 'tags-table-format-hooks + erlang-tags-orig-format-hooks) + )) + + ;; Remove our functions from the TAGS files. (Note that + ;; `tags-table-computed-list' need not be the same list as when + ;; the search was started.) + (save-excursion + (let ((buffers erlang-tags-buffer-list)) + (while buffers + (if (buffer-name (car buffers)) + (progn + (set-buffer (car buffers)) + (erlang-tags-remove-local))) + (setq buffers (cdr buffers)))))) + + +(defun erlang-tags-remove-local () + "Remove our tag search functions from current buffer." + (if (null erlang-tags-buffer-installed-p) + () + (funcall (symbol-function 'set) 'erlang-tags-buffer-installed-p nil) + (funcall (symbol-function 'set) + 'find-tag-tag-order erlang-tags-orig-tag-order) + (funcall (symbol-function 'set) + 'find-tag-regexp-tag-order erlang-tags-orig-regexp-tag-order) + (funcall (symbol-function 'set) + 'find-tag-search-function erlang-tags-orig-search-function) + (funcall (symbol-function 'set) + 'find-tag-regexp-search-function + erlang-tags-orig-regexp-search-function))) + + +(defun erlang-tags-recognize-tags-table () + "Install our functions in all loaded TAGS files. + +This function is added to `tags-table-format-hooks/functions' when searching +for a tag on the form `module:tag'." + (if (null (funcall (symbol-function 'etags-recognize-tags-table))) + nil + (erlang-tags-install-local) + t)) + + +(defun erlang-tags-search-forward (tag &optional bound noerror count) + "Forward search function, aware of Erlang module prefix." + (if (string-match ":" tag) + (setq tag (substring tag (match-end 0) nil))) + ;; Avoid unintended recursion. + (if (eq erlang-tags-orig-search-function 'erlang-tags-search-forward) + (search-forward tag bound noerror count) + (funcall erlang-tags-orig-search-function tag bound noerror count))) + + +(defun erlang-tags-regexp-search-forward (tag &optional bound noerror count) + "Forward regexp search function, aware of Erlang module prefix." + (if (string-match ":" tag) + (setq tag (substring tag (match-end 0) nil))) + (if (eq erlang-tags-orig-regexp-search-function + 'erlang-tags-regexp-search-forward) + (re-search-forward tag bound noerror count) + (funcall erlang-tags-orig-regexp-search-function + tag bound noerror count))) + + +;; t if point is at a tag line that matches TAG, containing +;; module information. Assumes that all other order functions +;; are stored in `erlang-tags-orig-[regex]-tag-order'. + +(defun erlang-tag-match-module-p (tag) + (erlang-tag-match-module-common-p tag erlang-tags-orig-tag-order)) + +(defun erlang-tag-match-module-regexp-p (tag) + (erlang-tag-match-module-common-p tag erlang-tags-orig-regexp-tag-order)) + +(defun erlang-tag-match-module-common-p (tag order) + (let ((mod nil) + (found nil)) + (if (string-match ":" tag) + (progn + (setq mod (substring tag 0 (match-beginning 0))) + (setq tag (substring tag (match-end 0) nil)))) + (while (and order (not found)) + (setq found + (and (not (memq (car order) + '(erlang-tag-match-module-p + erlang-tag-match-module-regexp-p))) + (funcall (car order) tag))) + (setq order (cdr order))) + (and found + (or (null mod) + (string= mod (erlang-get-module-from-file-name + (file-of-tag))))))) + + +;;; Tags completion, Emacs 19 `etags' specific. +;;; +;;; The basic idea is to create a second completion table `erlang-tags- +;;; completion-table' containing all normal tags plus tags on the form +;;; `module:tag'. + + +(when (and (fboundp 'etags-tags-completion-table) + (fboundp 'tags-lazy-completion-table)) ; Emacs 23.1+ + (if (fboundp 'advice-add) + ;; Emacs 24.4+ + (advice-add 'etags-tags-completion-table :around + (lambda (oldfun) + (if (eq find-tag-default-function 'erlang-find-tag-for-completion) + (erlang-etags-tags-completion-table) + (funcall oldfun))) + (list :name 'erlang-replace-tags-table)) + ;; Emacs 23.1-24.3 + (defadvice etags-tags-completion-table (around erlang-replace-tags-table activate) + (if (eq find-tag-default-function 'erlang-find-tag-for-completion) + (setq ad-return-value (erlang-etags-tags-completion-table)) + ad-do-it)))) + + +(defun erlang-complete-tag () + "Perform tags completion on the text around point. +Completes to the set of names listed in the current tags table. + +Should the Erlang tags system be installed this command knows +about Erlang modules." + (interactive) + (condition-case nil + (require 'etags) + (error nil)) + (cond ((and erlang-tags-installed + (fboundp 'etags-tags-completion-table) + (fboundp 'tags-lazy-completion-table)) ; Emacs 23.1+ + ;; This depends on the advice called erlang-replace-tags-table + ;; above. It is not enough to let-bind + ;; tags-completion-table-function since that will not override + ;; the buffer-local value in the TAGS buffer. + (let ((find-tag-default-function 'erlang-find-tag-for-completion)) + (complete-tag))) + ((and erlang-tags-installed + (fboundp 'complete-tag) + (fboundp 'tags-complete-tag)) ; Emacs 19 + (let ((orig-tags-complete-tag (symbol-function 'tags-complete-tag))) + (fset 'tags-complete-tag + (symbol-function 'erlang-tags-complete-tag)) + (unwind-protect + (funcall (symbol-function 'complete-tag)) + (fset 'tags-complete-tag orig-tags-complete-tag)))) + ((fboundp 'complete-tag) ; Emacs 19 + (funcall (symbol-function 'complete-tag))) + ((fboundp 'tag-complete-symbol) ; XEmacs + (funcall (symbol-function 'tag-complete-symbol))) + (t + (error "This version of Emacs can't complete tags")))) + + +(defun erlang-find-tag-for-completion () + (let ((start (save-excursion + (skip-chars-backward "[:word:][:digit:]_:'") + (point)))) + (unless (eq start (point)) + (buffer-substring-no-properties start (point))))) + + + +;; Based on `tags-complete-tag', but this one uses +;; `erlang-tags-completion-table' instead of `tags-completion-table'. +;; +;; This is the entry-point called by system function `completing-read'. +(defun erlang-tags-complete-tag (string predicate what) + (save-excursion + ;; If we need to ask for the tag table, allow that. + (let ((enable-recursive-minibuffers t)) + (visit-tags-table-buffer)) + (if (eq what t) + (all-completions string (erlang-tags-completion-table) predicate) + (try-completion string (erlang-tags-completion-table) predicate)))) + + +;; `tags-completion-table' calls itself recursively, make it +;; call our own wedge instead. Note that the recursive call +;; is very rare; it only occurs when a tags-file contains +;; `include'-statements. +(defun erlang-tags-completion-table () + "Build completion table. Tags on the form `tag' or `module:tag'." + (setq erlang-tags-orig-completion-table + (symbol-function 'tags-completion-table)) + (fset 'tags-completion-table + (symbol-function 'erlang-tags-completion-table-1)) + (unwind-protect + (erlang-tags-completion-table-1) + (fset 'tags-completion-table + erlang-tags-orig-completion-table))) + + +(defun erlang-tags-completion-table-1 () + (make-local-variable 'erlang-tags-completion-table) + (or erlang-tags-completion-table + (let ((tags-completion-table nil) + (tags-completion-table-function + 'erlang-etags-tags-completion-table)) + (funcall erlang-tags-orig-completion-table) + (setq erlang-tags-completion-table tags-completion-table)))) + + +;; Based on `etags-tags-completion-table'. The difference is that we +;; add three symbols to the vector, the tag, module: and module:tag. +;; The module is extracted from the file name of a tag. (This one +;; only works if we are looking at an `etags' file. However, this is +;; the only format supported by Emacs, so far.) +(defun erlang-etags-tags-completion-table () + (let ((table (make-vector 511 0)) + (file nil) + (progress-reporter + (when (fboundp 'make-progress-reporter) + (make-progress-reporter + (format "Making erlang tags completion table for %s..." buffer-file-name) + (point-min) (point-max))))) + (save-excursion + (goto-char (point-min)) + ;; This monster regexp matches an etags tag line. + ;; \1 is the string to match; + ;; \2 is not interesting; + ;; \3 is the guessed tag name; XXX guess should be better eg DEFUN + ;; \4 is not interesting; + ;; \5 is the explicitly-specified tag name. + ;; \6 is the line to start searching at; + ;; \7 is the char to start searching at. + (while (progn + (while (and + (eq (following-char) ?\f) + (looking-at "\f\n\\([^,\n]*\\),.*\n")) + (setq file (buffer-substring + (match-beginning 1) (match-end 1))) + (goto-char (match-end 0))) + (re-search-forward + "\ +^\\(\\([^\177]+[^-a-zA-Z0-9_$\177]+\\)?\\([-a-zA-Z0-9_$?:]+\\)\ +\[^-a-zA-Z0-9_$?:\177]*\\)\177\\(\\([^\n\001]+\\)\001\\)?\ +\\([0-9]+\\)?,\\([0-9]+\\)?\n" + nil t)) + (let ((tag (if (match-beginning 5) + ;; There is an explicit tag name. + (buffer-substring (match-beginning 5) (match-end 5)) + ;; No explicit tag name. Best guess. + (buffer-substring (match-beginning 3) (match-end 3)))) + (module (and file + (erlang-get-module-from-file-name file)))) + (intern tag table) + (when (stringp module) + (intern (concat module ":" tag) table) + ;; Only the first ones will be stored in the table. + (intern (concat module ":") table) + (intern (concat module ":module_info") table)) + (when progress-reporter + (progress-reporter-update progress-reporter (point)))))) + table)) + +;;; +;;; Prepare for other methods to run an Erlang slave process. +;;; + +(defvar erlang-shell-function 'inferior-erlang + "Command to execute start a new Erlang shell. + +Change this variable to use your favorite +Erlang compilation package.") + +(defvar erlang-shell-display-function 'inferior-erlang-run-or-select + "Command to execute to display Erlang shell. + +Change this variable to use your favorite +Erlang compilation package.") + +(defvar erlang-compile-function 'inferior-erlang-compile + "Command to execute to compile current buffer. + +Change this variable to use your favorite +Erlang compilation package.") + +(defvar erlang-compile-erlang-function "c" + "Erlang function to call to compile an erlang file.") + +(defvar erlang-compile-display-function 'inferior-erlang-run-or-select + "Command to execute to view last compilation. + +Change this variable to use your favorite +Erlang compilation package.") + +(defvar erlang-next-error-function 'inferior-erlang-next-error + "Command to execute to go to the next error. + +Change this variable to use your favorite Erlang compilation +package. Not used in Emacs 21.") + + +;;;###autoload +(defun erlang-shell () + "Start a new Erlang shell. + +The variable `erlang-shell-function' decides which method to use, +default is to start a new Erlang host. It is possible that, in the +future, a new shell on an already running host will be started." + (interactive) + (call-interactively erlang-shell-function)) + + +;;;###autoload (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) + +;; It is customary for Emacs packages to supply a function on this +;; form, even though it violates the `erlang-*' name convention. +(defalias 'run-erlang 'erlang-shell) + + +(defun erlang-shell-display () + "Display an Erlang shell, or start a new." + (interactive) + (call-interactively erlang-shell-display-function)) + + +;;;###autoload +(defun erlang-compile () + "Compile Erlang module in current buffer." + (interactive) + (call-interactively erlang-compile-function)) + + +(defun erlang-compile-display () + "Display compilation output." + (interactive) + (call-interactively erlang-compile-display-function)) + + +(defun erlang-next-error () + "Display next error message from the latest compilation." + (interactive) + (call-interactively erlang-next-error-function)) + + + +;;; +;;; Erlang Shell Mode -- Major mode used for Erlang shells. +;;; + +;; This mode is designed to be implementation independent, +;; e.g. it does not assume that we are running an inferior +;; Erlang, there exists a lot of other possibilities. + + +(defvar erlang-shell-buffer-name "*erlang*" + "The name of the Erlang link shell buffer.") + +(defvar erlang-shell-mode-map nil + "Keymap used by Erlang shells.") + + +(defvar erlang-shell-mode-hook nil + "*User functions to run when an Erlang shell is started. + +This hook is used to change the behaviour of Erlang mode. It is +normally used by the user to personalise the programming environment. +When used in a site init file, it could be used to customise Erlang +mode for all users on the system. + +The function added to this hook is run every time a new Erlang +shell is started. + +See also `erlang-load-hook', a hook which is run once, when Erlang +mode is loaded, and `erlang-mode-hook' which is run every time a new +Erlang source file is loaded into Emacs.") + + +(defvar erlang-input-ring-file-name "~/.erlang_history" + "*When non-nil, file name used to store Erlang shell history information.") + + +(defun erlang-shell-mode () + "Major mode for interacting with an Erlang shell. + +We assume that we already are in Comint mode. + +The following special commands are available: +\\{erlang-shell-mode-map}" + (interactive) + (setq major-mode 'erlang-shell-mode) + (setq mode-name "Erlang Shell") + (erlang-mode-variables) + (if erlang-shell-mode-map + nil + (setq erlang-shell-mode-map (copy-keymap comint-mode-map)) + (erlang-shell-mode-commands erlang-shell-mode-map)) + (use-local-map erlang-shell-mode-map) + (unless inferior-erlang-use-cmm + ;; This was originally not a marker, but it needs to be, at least + ;; in Emacs 21, and should be backwards-compatible. Otherwise, + ;; would need to test whether compilation-parsing-end is a marker + ;; after requiring `compile'. + (set (make-local-variable 'compilation-parsing-end) (copy-marker 1)) + (set (make-local-variable 'compilation-error-list) nil) + (set (make-local-variable 'compilation-old-error-list) nil)) + ;; Needed when compiling directly from the Erlang shell. + (setq compilation-last-buffer (current-buffer)) + (setq comint-prompt-regexp "^[^>=]*> *") + (setq comint-eol-on-send t) + (setq comint-input-ignoredups t) + (setq comint-scroll-show-maximum-output t) + (setq comint-scroll-to-bottom-on-output t) + ;; In Emacs 19.30, `add-hook' has got a `local' flag, use it. If + ;; the call fails, just call the normal `add-hook'. + (condition-case nil + (progn + (add-hook 'comint-output-filter-functions + 'inferior-erlang-strip-delete nil t) + (add-hook 'comint-output-filter-functions + 'inferior-erlang-strip-ctrl-m nil t)) + (error + (funcall (symbol-function 'make-local-hook) + 'comint-output-filter-functions) ; obsolete as of Emacs 21.1 + (add-hook 'comint-output-filter-functions 'inferior-erlang-strip-delete) + (add-hook 'comint-output-filter-functions 'inferior-erlang-strip-ctrl-m))) + ;; Some older versions of comint don't have an input ring. + (if (fboundp 'comint-read-input-ring) + (progn + (setq comint-input-ring-file-name erlang-input-ring-file-name) + (comint-read-input-ring t) + (make-local-variable 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'comint-write-input-ring))) + ;; At least in Emacs 21, we need to be in `compilation-minor-mode' + ;; for `next-error' to work. We can avoid it clobbering the shell + ;; keys thus. + (when inferior-erlang-use-cmm + (compilation-minor-mode 1) + (set (make-local-variable 'minor-mode-overriding-map-alist) + `((compilation-minor-mode + . ,(let ((map (make-sparse-keymap))) + ;; It would be useful to put keymap properties on the + ;; error lines so that we could use RET and mouse-2 + ;; on them directly. + (when (boundp 'compilation-skip-threshold) ; new compile.el + (define-key map [mouse-2] #'erlang-mouse-2-command) + (define-key map "\C-m" #'erlang-RET-command)) + (if (boundp 'compilation-menu-map) + (define-key map [menu-bar compilation] + (cons "Errors" compilation-menu-map))) + map))))) + (run-hooks 'erlang-shell-mode-hook)) + + +(defun erlang-mouse-2-command (event) + "Command bound to `mouse-2' in inferior Erlang buffer. +Selects Comint or Compilation mode command as appropriate." + (interactive "e") + (if (save-window-excursion + (save-excursion + (mouse-set-point event) + (consp (get-text-property (line-beginning-position) 'message)))) + (call-interactively (lookup-key compilation-mode-map [mouse-2])) + (call-interactively (lookup-key comint-mode-map [mouse-2])))) + +(defun erlang-RET-command () + "Command bound to `RET' in inferior Erlang buffer. +Selects Comint or Compilation mode command as appropriate." + (interactive) + (if (consp (get-text-property (line-beginning-position) 'message)) + (call-interactively (lookup-key compilation-mode-map "\C-m")) + (call-interactively (lookup-key comint-mode-map "\C-m")))) + +(defun erlang-shell-mode-commands (map) + (define-key map "\M-\t" 'erlang-complete-tag) + (define-key map "\C-a" 'comint-bol) ; Normally the other way around. + (define-key map "\C-c\C-a" 'beginning-of-line) + (define-key map "\C-d" nil) ; Was `comint-delchar-or-maybe-eof' + (define-key map "\M-\C-m" 'compile-goto-error) + (unless inferior-erlang-use-cmm + (define-key map "\C-x`" 'erlang-next-error))) + +;;; +;;; Inferior Erlang -- Run an Erlang shell as a subprocess. +;;; + +(defvar inferior-erlang-display-buffer-any-frame nil + "*When nil, `inferior-erlang-display-buffer' use only selected frame. +When t, all frames are searched. When 'raise, the frame is raised.") + +(defvar inferior-erlang-shell-type 'newshell + "The type of Erlang shell to use. + +When this variable is set to the atom `oldshell', the old shell is used. +When set to `newshell' the new shell is used. Should the variable be +nil, the default shell is used. + +This variable influence the setting of other variables.") + +(defvar inferior-erlang-machine "erl" + "*The name of the Erlang shell.") + +(defvar inferior-erlang-machine-options '() + "*The options used when activating the Erlang shell. + +This must be a list of strings.") + +(defvar inferior-erlang-process-name "inferior-erlang" + "The name of the inferior Erlang process.") + +(defvar inferior-erlang-buffer-name erlang-shell-buffer-name + "The name of the inferior Erlang buffer.") + +(defvar inferior-erlang-prompt-timeout 60 + "*Number of seconds before `inferior-erlang-wait-prompt' timeouts. + +The time specified is waited after every output made by the inferior +Erlang shell. When this variable is t, we assume that we always have +a prompt. When nil, we will wait forever, or until \\[keyboard-quit].") + +(defvar inferior-erlang-process nil + "Process of last invoked inferior Erlang, or nil.") + +(defvar inferior-erlang-buffer nil + "Buffer of last invoked inferior Erlang, or nil.") + +;; Enable uniquifying Erlang shell buffers based on directory name. +(eval-after-load "uniquify" + '(add-to-list 'uniquify-list-buffers-directory-modes 'erlang-shell-mode)) + +;;;###autoload +(defun inferior-erlang (&optional command) + "Run an inferior Erlang. +With prefix command, prompt for command to start Erlang with. + +This is just like running Erlang in a normal shell, except that +an Emacs buffer is used for input and output. +\\ +The command line history can be accessed with \\[comint-previous-input] and \\[comint-next-input]. +The history is saved between sessions. + +Entry to this mode calls the functions in the variables +`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. + +The following commands imitate the usual Unix interrupt and +editing control characters: +\\{erlang-shell-mode-map}" + (interactive + (when current-prefix-arg + (list (if (fboundp 'read-shell-command) + ;; `read-shell-command' is a new function in Emacs 23. + (read-shell-command "Erlang command: ") + (read-string "Erlang command: "))))) + (require 'comint) + (let (cmd opts) + (if command + (setq cmd "sh" + opts (list "-c" command)) + (setq cmd inferior-erlang-machine + opts inferior-erlang-machine-options) + (cond ((eq inferior-erlang-shell-type 'oldshell) + (setq opts (cons "-oldshell" opts))) + ((eq inferior-erlang-shell-type 'newshell) + (setq opts (append '("-newshell" "-env" "TERM" "vt100") opts))))) + + ;; Using create-file-buffer and list-buffers-directory in this way + ;; makes uniquify give each buffer a unique name based on the + ;; directory. + (let ((fake-file-name (expand-file-name inferior-erlang-buffer-name default-directory))) + (setq inferior-erlang-buffer (create-file-buffer fake-file-name)) + (apply 'make-comint-in-buffer + inferior-erlang-process-name + inferior-erlang-buffer + cmd + nil opts) + (with-current-buffer inferior-erlang-buffer + (setq list-buffers-directory fake-file-name)))) + + (setq inferior-erlang-process + (get-buffer-process inferior-erlang-buffer)) + (if (> 21 erlang-emacs-major-version) ; funcalls to avoid compiler warnings + (funcall (symbol-function 'set-process-query-on-exit-flag) + inferior-erlang-process nil) + (funcall (symbol-function 'process-kill-without-query) inferior-erlang-process)) + (if erlang-inferior-shell-split-window + (switch-to-buffer-other-window inferior-erlang-buffer) + (switch-to-buffer inferior-erlang-buffer)) + (if (and (not (eq system-type 'windows-nt)) + (eq inferior-erlang-shell-type 'newshell)) + (setq comint-process-echoes t)) + (erlang-shell-mode)) + + +(defun inferior-erlang-run-or-select () + "Switch to an inferior Erlang buffer, possibly starting new process." + (interactive) + (if (null (inferior-erlang-running-p)) + (inferior-erlang) + (inferior-erlang-display-buffer t))) + + +(defun inferior-erlang-display-buffer (&optional select) + "Make the inferior Erlang process visible. +The window is returned. + +Should `inferior-erlang-display-buffer-any-frame' be nil the buffer is +displayed in the current frame. Should it be non-nil, and the buffer +already is visible in any other frame, no new window will be created. +Should it be the atom 'raise, the frame containing the window will +be raised. + +Should the optional argument SELECT be non-nil, the window is +selected. Should the window be in another frame, that frame is raised. + +Note, should the mouse pointer be places outside the raised frame, that +frame will become deselected before the next command." + (interactive) + (or (inferior-erlang-running-p) + (error "No inferior Erlang process is running")) + (let ((win (inferior-erlang-window + inferior-erlang-display-buffer-any-frame)) + (frames-p (fboundp 'selected-frame))) + (if (null win) + (let ((old-win (selected-window))) + (save-excursion + (switch-to-buffer-other-window inferior-erlang-buffer) + (setq win (selected-window))) + (select-window old-win)) + (if (and window-system + frames-p + (or select + (eq inferior-erlang-display-buffer-any-frame 'raise)) + (not (eq (selected-frame) (window-frame win)))) + (raise-frame (window-frame win)))) + (if select + (select-window win)) + (sit-for 0) + win)) + + +(defun inferior-erlang-running-p () + "Non-nil when an inferior Erlang is running." + (and inferior-erlang-process + (memq (process-status inferior-erlang-process) '(run open)) + inferior-erlang-buffer + (buffer-name inferior-erlang-buffer))) + + +(defun inferior-erlang-window (&optional all-frames) + "Return the window containing the inferior Erlang, or nil." + (and (inferior-erlang-running-p) + (if (and all-frames (>= erlang-emacs-major-version 19)) + (get-buffer-window inferior-erlang-buffer t) + (get-buffer-window inferior-erlang-buffer)))) + + +(defun inferior-erlang-wait-prompt () + "Wait until the inferior Erlang shell prompt appears." + (if (eq inferior-erlang-prompt-timeout t) + () + (or (inferior-erlang-running-p) + (error "No inferior Erlang shell is running")) + (save-excursion + (set-buffer inferior-erlang-buffer) + (let ((msg nil)) + (while (save-excursion + (goto-char (process-mark inferior-erlang-process)) + (forward-line 0) + (not (looking-at comint-prompt-regexp))) + (if msg + () + (setq msg t) + (message "Waiting for Erlang shell prompt (press C-g to abort).")) + (or (accept-process-output inferior-erlang-process + inferior-erlang-prompt-timeout) + (error "No Erlang shell prompt before timeout"))) + (if msg (message "")))))) + +(defun inferior-erlang-send-empty-cmd-unless-already-at-prompt () + "If not already at a prompt, try to send an empty cmd to get a prompt. +The empty command resembles hitting RET. This is useful in some +situations, for instance if a crash or error report from sasl +has been printed after the last prompt." + (save-excursion + (set-buffer inferior-erlang-buffer) + (if (> (point-max) 1) + ;; make sure we get a prompt if buffer contains data + (if (save-excursion + (goto-char (process-mark inferior-erlang-process)) + (forward-line 0) + (not (looking-at comint-prompt-regexp))) + (inferior-erlang-send-command ""))))) + +(autoload 'comint-send-input "comint") + +(defun inferior-erlang-send-command (cmd &optional hist) + "Send command CMD to the inferior Erlang. + +The contents of the current command line (if any) will +be placed at the next prompt. + +If optional second argument is non-nil the command is inserted into +the history list. + +Return the position after the newly inserted command." + (or (inferior-erlang-running-p) + (error "No inferior Erlang process is running")) + (let ((old-buffer (current-buffer)) + (insert-point (marker-position (process-mark inferior-erlang-process))) + (insert-length (if comint-process-echoes + 0 + (1+ (length cmd))))) + (set-buffer inferior-erlang-buffer) + (goto-char insert-point) + (insert cmd) + ;; Strange things happened if `comint-eol-on-send' is declared + ;; in the `let' expression above, but setq:d here. The + ;; `set-buffer' statement obviously makes the buffer local + ;; instance of `comint-eol-on-send' shadow this one. + ;; I'm considering this a bug in Elisp. + ;; + ;; This was previously cautioned against in the Lisp manual. It + ;; has been sorted out in Emacs 21. -- fx + (let ((comint-eol-on-send nil) + (comint-input-filter (if hist comint-input-filter 'ignore))) + (if (and (not erlang-xemacs-p) + (>= emacs-major-version 22)) + (comint-send-input nil t) + (comint-send-input))) + ;; Adjust all windows whose points are incorrect. + (if (null comint-process-echoes) + (walk-windows + (function + (lambda (window) + (if (and (eq (window-buffer window) inferior-erlang-buffer) + (= (window-point window) insert-point)) + (set-window-point window + (+ insert-point insert-length))))) + nil t)) + (set-buffer old-buffer) + (+ insert-point insert-length))) + + +(defun inferior-erlang-strip-delete (&optional s) + "Remove `^H' (delete) and the characters it was supposed to remove." + (interactive) + (if (and (boundp 'comint-last-input-end) + (boundp 'comint-last-output-start)) + (save-excursion + (goto-char + (if (interactive-p) + (symbol-value 'comint-last-input-end) + (symbol-value 'comint-last-output-start))) + (while (progn (skip-chars-forward "^\C-h") + (not (eq (point) (point-max)))) + (delete-char 1) + (or (bolp) + (backward-delete-char 1)))))) + + +;; Basically `comint-strip-ctrl-m', with a few extra checks. +(defun inferior-erlang-strip-ctrl-m (&optional string) + "Strip trailing `^M' characters from the current output group." + (interactive) + (if (and (boundp 'comint-last-input-end) + (boundp 'comint-last-output-start)) + (let ((pmark (process-mark (get-buffer-process (current-buffer))))) + (save-excursion + (goto-char + (if (interactive-p) + (symbol-value 'comint-last-input-end) + (symbol-value 'comint-last-output-start))) + (while (re-search-forward "\r+$" pmark t) + (replace-match "" t t)))))) + + +(defun inferior-erlang-compile (arg) + "Compile the file in the current buffer. + +With prefix arg, compiles for debug. + +Should Erlang return `{error, nofile}' it could not load the object +module after completing the compilation. This is due to a bug in the +compile command `c' when using the option `outdir'. + +There exists two workarounds for this bug: + + 1) Place the directory in the Erlang load path. + + 2) Set the Emacs variable `erlang-compile-use-outdir' to nil. + To do so, place the following line in your `~/.emacs'-file: + (setq erlang-compile-use-outdir nil)" + (interactive "P") + (save-some-buffers) + (inferior-erlang-prepare-for-input) + (let* ((dir (inferior-erlang-compile-outdir)) +;;; (file (file-name-nondirectory (buffer-file-name))) + (noext (substring (erlang-local-buffer-file-name) 0 -4)) + (opts (append (list (cons 'outdir dir)) + (if current-prefix-arg + (list 'debug_info 'export_all)) + erlang-compile-extra-opts)) + end) + (save-excursion + (set-buffer inferior-erlang-buffer) + (compilation-forget-errors)) + (setq end (inferior-erlang-send-command + (inferior-erlang-compute-compile-command noext opts) + nil)) + (sit-for 0) + (inferior-erlang-wait-prompt) + (save-excursion + (set-buffer inferior-erlang-buffer) + (setq compilation-error-list nil) + (set-marker compilation-parsing-end end)) + (setq compilation-last-buffer inferior-erlang-buffer))) + +(defun inferior-erlang-prepare-for-input (&optional no-display) + "Create an inferior erlang buffer if needed and ready it for input. +The buffer is displayed, according to `inferior-erlang-display-buffer' +unless the optional NO-DISPLAY is non-nil." + (or (inferior-erlang-running-p) + (save-excursion + (inferior-erlang))) + (or (inferior-erlang-running-p) + (error "Error starting inferior Erlang shell")) + (if (not no-display) + (inferior-erlang-display-buffer)) + (inferior-erlang-send-empty-cmd-unless-already-at-prompt) + (sit-for 0) + (inferior-erlang-wait-prompt)) + +(defun inferior-erlang-compile-outdir () + "Return the directory to compile the current buffer into." + (let* ((buffer-dir (directory-file-name + (file-name-directory (erlang-local-buffer-file-name)))) + (parent-dir (directory-file-name + (file-name-directory buffer-dir))) + (ebin-dir (concat (file-name-as-directory parent-dir) "ebin")) + (buffer-dir-base-name (file-name-nondirectory + (expand-file-name + (concat (file-name-as-directory buffer-dir) + "."))))) + (if (and (string= buffer-dir-base-name "src") + (file-directory-p ebin-dir)) + (file-name-as-directory ebin-dir) + (file-name-as-directory buffer-dir)))) + +(defun inferior-erlang-compute-compile-command (module-name opts) + (let ((ccfn erlang-compile-command-function-alist) + (res (inferior-erlang-compute-erl-compile-command module-name opts)) + ccfn-entry + done) + (if (not (null (erlang-local-buffer-file-name))) + (while (and (not done) (not (null ccfn))) + (setq ccfn-entry (car ccfn)) + (setq ccfn (cdr ccfn)) + (if (string-match (car ccfn-entry) (erlang-local-buffer-file-name)) + (let ((c-fn (cdr ccfn-entry))) + (setq done t) + (if (not (null c-fn)) + (setq result (funcall c-fn module-name opts))))))) + result)) + +(defun inferior-erlang-compute-erl-compile-command (module-name opts) + (let* ((out-dir-opt (assoc 'outdir opts)) + (out-dir (cdr out-dir-opt))) + (if erlang-compile-use-outdir + (format "%s(\"%s\"%s)." + erlang-compile-erlang-function + module-name + (inferior-erlang-format-comma-opts opts)) + (let (;; Hopefully, noone else will ever use these... + (tmpvar "Tmp7236") + (tmpvar2 "Tmp8742")) + (format + (concat + "f(%s), {ok, %s} = file:get_cwd(), " + "file:set_cwd(\"%s\"), " + "%s = %s(\"%s\"%s), file:set_cwd(%s), f(%s), %s.") + tmpvar2 tmpvar + out-dir + tmpvar2 + erlang-compile-erlang-function + module-name (inferior-erlang-format-comma-opts + (remq out-dir-opt opts)) + tmpvar tmpvar tmpvar2))))) + +(defun inferior-erlang-compute-leex-compile-command (module-name opts) + (let ((file-name (erlang-local-buffer-file-name)) + (erl-compile-expr (inferior-erlang-remove-any-trailing-dot + (inferior-erlang-compute-erl-compile-command + module-name opts)))) + (format (concat "f(LErr1__), f(LErr2__), " + "case case leex:file(\"%s\", [%s]) of" + " ok -> ok;" + " {ok,_} -> ok;" + " {ok,_,_} -> ok;" + " LErr1__ -> LErr1__ " + "end of" + " ok -> %s;" + " LErr2__ -> LErr2__ " + "end.") + file-name + (inferior-erlang-format-comma-opts erlang-leex-compile-opts) + erl-compile-expr))) + +(defun inferior-erlang-compute-yecc-compile-command (module-name opts) + (let ((file-name (erlang-local-buffer-file-name)) + (erl-compile-expr (inferior-erlang-remove-any-trailing-dot + (inferior-erlang-compute-erl-compile-command + module-name opts)))) + (format (concat "f(YErr1__), f(YErr2__), " + "case case yecc:file(\"%s\", [%s]) of" + " {ok,_} -> ok;" + " {ok,_,_} -> ok;" + " YErr1__ -> YErr1__ " + "end of" + " ok -> %s;" + " YErr2__ -> YErr2__ " + "end.") + file-name + (inferior-erlang-format-comma-opts erlang-yecc-compile-opts) + erl-compile-expr))) + +(defun inferior-erlang-remove-any-trailing-dot (str) + (if (string= (substring str -1) ".") + (substring str 0 (1- (length str))) + str)) + +(defun inferior-erlang-format-comma-opts (opts) + (if (null opts) + "" + (concat ", " (inferior-erlang-format-opts opts)))) + +(defun inferior-erlang-format-opts (opts) + (concat "[" (inferior-erlang-string-join (mapcar 'inferior-erlang-format-opt + opts) + ", ") + "]")) + +(defun inferior-erlang-format-opt (opt) + (cond ((stringp opt) (concat "\"" opt "\"")) + ((atom opt) (format "%s" opt)) + ((consp opt) (concat "{" (inferior-erlang-string-join + (mapcar 'inferior-erlang-format-opt + (list (car opt) (cdr opt))) + ", ") + "}")) + (t (error (format "Unexpected opt %s" opt))))) + +(defun inferior-erlang-string-join (strs sep) + (let ((result (or (car strs) ""))) + (setq strs (cdr strs)) + (while strs + (setq result (concat result sep (car strs))) + (setq strs (cdr strs))) + result)) + +(defun erlang-local-buffer-file-name () + ;; When editing a file remotely via tramp, + ;; the buffer's file name may be for example + ;; "/ssh:host.example.com:/some/path/x.erl" + ;; + ;; If I try to compile such a file using C-c C-k, an + ;; erlang shell on the remote host is automatically + ;; started if needed, but for it to successfully compile + ;; the file, the c(...) command that is sent must contain + ;; the file name "/some/path/x.erl" without the + ;; tramp-prefix "/ssh:host.example.com:". + (cond ((null (buffer-file-name)) + nil) + ((erlang-tramp-remote-file-p) + (erlang-tramp-get-localname)) + (t + (buffer-file-name)))) + +(defun erlang-tramp-remote-file-p () + (and (fboundp 'tramp-tramp-file-p) + (tramp-tramp-file-p (buffer-file-name)))) + +(defun erlang-tramp-get-localname () + (let ((tramp-info (tramp-dissect-file-name (buffer-file-name)))) + (if (fboundp 'tramp-file-name-localname) + (tramp-file-name-localname tramp-info) + ;; In old versions of tramp, it was `tramp-file-name-path' + ;; instead of the newer `tramp-file-name-localname' + (tramp-file-name-path tramp-info)))) + +;; `next-error' only accepts buffers with major mode `compilation-mode' +;; or with the minor mode `compilation-minor-mode' activated. +;; (To activate the minor mode is out of the question, since it will +;; ruin the inferior Erlang keymap.) +;; This is done differently in Emacs 21. +(defun inferior-erlang-next-error (&optional argp) + "Just like `next-error'. +Capable of finding error messages in an inferior Erlang buffer." + (interactive "P") + (let ((done nil) + (buf (or (and (boundp 'next-error-last-buffer) + next-error-last-buffer) + (and (boundp 'compilation-last-buffer) + compilation-last-buffer)))) + (if (and (bufferp buf) + (save-excursion + (set-buffer buf) + (and (eq major-mode 'erlang-shell-mode) + (setq major-mode 'compilation-mode)))) + (unwind-protect + (progn + (setq done t) + (next-error argp)) + (save-excursion + (set-buffer buf) + (setq major-mode 'erlang-shell-mode)))) + (or done + (next-error argp)))) + + +(defun inferior-erlang-change-directory (&optional dir) + "Make the inferior Erlang change directory. +The default is to go to the directory of the current buffer." + (interactive) + (or dir (setq dir (file-name-directory (erlang-local-buffer-file-name)))) + (or (inferior-erlang-running-p) + (error "No inferior Erlang is running")) + (inferior-erlang-display-buffer) + (inferior-erlang-send-empty-cmd-unless-already-at-prompt) + (inferior-erlang-wait-prompt) + (inferior-erlang-send-command (format "cd('%s')." dir) nil)) + +(defun erlang-align-arrows (start end) + "Align arrows (\"->\") in function clauses from START to END. +When called interactively, aligns arrows after function clauses inside +the region. + +With a prefix argument, aligns all arrows, not just those in function +clauses. + +Example: + +sum(L) -> sum(L, 0). +sum([H|T], Sum) -> sum(T, Sum + H); +sum([], Sum) -> Sum. + +becomes: + +sum(L) -> sum(L, 0). +sum([H|T], Sum) -> sum(T, Sum + H); +sum([], Sum) -> Sum." + (interactive "r") + (save-excursion + (let (;; regexp for matching arrows. without a prefix argument, + ;; the regexp matches function heads. With a prefix, it + ;; matches any arrow. + (re (if current-prefix-arg + "^.*\\(\\)->" + (eval-when-compile + (concat "^" erlang-atom-regexp ".*\\(\\)->")))) + ;; part of regexp matching directly before the arrow + (arrow-match-pos (if current-prefix-arg + 1 + (1+ erlang-atom-regexp-matches))) + ;; accumulator for positions where arrows are found, ordered + ;; by buffer position (from greatest to smallest) + (arrow-positions '()) + ;; accumulator for longest distance from start of line to arrow + (most-indent 0) + ;; marker to track the end of the region we're aligning + (end-marker (progn (goto-char end) + (point-marker)))) + ;; Pass 1: Find the arrow positions, adjust the whitespace + ;; before each arrow to one space, and find the greatest + ;; indentation level. + (goto-char start) + (while (re-search-forward re end-marker t) + (goto-char (match-beginning arrow-match-pos)) + (just-one-space) ; adjust whitespace + (setq arrow-positions (cons (point) arrow-positions)) + (setq most-indent (max most-indent (erlang-column-number)))) + (set-marker end-marker nil) ; free the marker + ;; Pass 2: Insert extra padding so that all arrow indentation is + ;; equal. This is done last-to-first by buffer position, so that + ;; inserting spaces before one arrow doesn't change the + ;; positions of the next ones. + (mapc (lambda (arrow-pos) + (goto-char arrow-pos) + (let* ((pad (- most-indent (erlang-column-number)))) + (when (> pad 0) + (insert-char ?\ pad)))) + arrow-positions)))) + +(defun erlang-column-number () + "Return the column number of the current position in the buffer. +Tab characters are counted by their visual width." + (string-width (buffer-substring (line-beginning-position) (point)))) + +(defun erlang-current-defun () + "`add-log-current-defun-function' for Erlang." + (save-excursion + (erlang-beginning-of-function) + (if (looking-at "[a-z0-9_]+") + (match-string 0)))) + +;; Aliases for backward compatibility with older versions of Erlang Mode. +;; +;; Unfortuantely, older versions of Emacs doesn't have `defalias' and +;; `make-obsolete' so we have to define our own `obsolete' function. + +(defun erlang-obsolete (sym newdef) + "Make the obsolete function SYM refer to the defined function NEWDEF. + +Simplified version of a combination `defalias' and `make-obsolete', +it assumes that NEWDEF is loaded." + (defalias sym (symbol-function newdef)) + (if (fboundp 'make-obsolete) + (make-obsolete sym newdef))) + + +(erlang-obsolete 'calculate-erlang-indent 'erlang-calculate-indent) +(erlang-obsolete 'calculate-erlang-stack-indent + 'erlang-calculate-stack-indent) +(erlang-obsolete 'at-erlang-keyword 'erlang-at-keyword) +(erlang-obsolete 'at-erlang-operator 'erlang-at-operator) +(erlang-obsolete 'beginning-of-erlang-clause 'erlang-beginning-of-clause) +(erlang-obsolete 'end-of-erlang-clause 'erlang-end-of-clause) +(erlang-obsolete 'mark-erlang-clause 'erlang-mark-clause) +(erlang-obsolete 'beginning-of-erlang-function 'erlang-beginning-of-function) +(erlang-obsolete 'end-of-erlang-function 'erlang-end-of-function) +(erlang-obsolete 'mark-erlang-function 'erlang-mark-function) +(erlang-obsolete 'pass-over-erlang-clause 'erlang-pass-over-function) +(erlang-obsolete 'name-of-erlang-function 'erlang-name-of-function) + + +;; Fixme: shouldn't redefine `set-visited-file-name' anyhow -- see above. +(defconst erlang-unload-hook + (list (lambda () + (defalias 'set-visited-file-name + 'erlang-orig-set-visited-file-name) + (when (featurep 'advice) + (ad-unadvise 'Man-notify-when-ready) + (ad-unadvise 'set-visited-file-name))))) + + +(defun erlang-string-to-int (string) + (if (fboundp 'string-to-number) + (string-to-number string) + (funcall (symbol-function 'string-to-int) string))) + +;; The end... + +(provide 'erlang) + +(run-hooks 'erlang-load-hook) + +;; Local variables: +;; coding: iso-8859-1 +;; End: + +;;; erlang.el ends here diff --git a/emacs.d/elpa/erlang-20141104.17/erlang_appwiz.el b/emacs.d/elpa/erlang-20150319.456/erlang_appwiz.el similarity index 100% rename from emacs.d/elpa/erlang-20141104.17/erlang_appwiz.el rename to emacs.d/elpa/erlang-20150319.456/erlang_appwiz.el diff --git a/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-autoloads.el b/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-autoloads.el deleted file mode 100644 index fae0221..0000000 --- a/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-autoloads.el +++ /dev/null @@ -1,40 +0,0 @@ -;;; find-file-in-project-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "find-file-in-project" "find-file-in-project.el" -;;;;;; (21570 28045 0 0)) -;;; Generated autoloads from find-file-in-project.el - -(autoload 'find-file-in-project "find-file-in-project" "\ -Prompt with a completing list of all files in the project to find one. - -The project's scope is defined as the first directory containing -an `.emacs-project' file. You can override this by locally -setting the variable `ffip-project-root'. - -\(fn)" t nil) - -(defalias 'ffip 'find-file-in-project) - -(put 'ffip-patterns 'safe-local-variable 'listp) - -(put 'ffip-find-options 'safe-local-variable 'stringp) - -(put 'ffip-project-file 'safe-local-variable 'stringp) - -(put 'ffip-project-root 'safe-local-variable 'stringp) - -(put 'ffip-project-root-function 'safe-local-variable 'functionp) - -(put 'ffip-limit 'safe-local-variable 'integerp) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; find-file-in-project-autoloads.el ends here diff --git a/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-pkg.el b/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-pkg.el deleted file mode 100644 index 9489c5b..0000000 --- a/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "find-file-in-project" "20140603.1619" "Find files in a project quickly." 'nil :url "http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject" :keywords '("project" "convenience")) diff --git a/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project.el b/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project.el deleted file mode 100644 index 757b13c..0000000 --- a/emacs.d/elpa/find-file-in-project-20140603.1619/find-file-in-project.el +++ /dev/null @@ -1,184 +0,0 @@ -;;; find-file-in-project.el --- Find files in a project quickly. - -;; Copyright (C) 2006-2009, 2011-2012 -;; Phil Hagelberg, Doug Alcorn, and Will Farrington - -;; Author: Phil Hagelberg, Doug Alcorn, and Will Farrington -;; URL: http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject -;; Git: git://github.com/technomancy/find-file-in-project.git -;; Version: 20140603.1619 -;; X-Original-Version: 3.3 -;; Created: 2008-03-18 -;; Keywords: project, convenience -;; EmacsWiki: FindFileInProject - -;; This file is NOT part of GNU Emacs. - -;;; License: - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; This library provides a couple methods for quickly finding any file -;; in a given project. It depends on GNU find. - -;; A project is found by searching up the directory tree until a file -;; is found that matches `ffip-project-file'. (".git" by default.) -;; You can set `ffip-project-root-function' to provide an alternate -;; function to search for the project root. By default, it looks only -;; for files whose names match `ffip-patterns', - -;; If you have so many files that it becomes unwieldy, you can set -;; `ffip-find-options' to a string which will be passed to the `find' -;; invocation in order to exclude irrelevant subdirectories. For -;; instance, in a Ruby on Rails project, you may be interested in all -;; .rb files that don't exist in the "vendor" directory. In that case -;; you could set `ffip-find-options' to "-not -regex \".*vendor.*\"". - -;; All these variables may be overridden on a per-directory basis in -;; your .dir-locals.el. See (info "(Emacs) Directory Variables") for -;; details. - -;; Recommended binding: (global-set-key (kbd "C-x f") 'find-file-in-project) - -;;; TODO: - -;; Add compatibility with BSD find (PDI; I can't virtualize OS X) - -;;; Code: - -(require 'cl) - -(defvar ffip-project-file ".git" - "The file that should be used to define a project root. - -May be set using .dir-locals.el. Checks each entry if set to a list.") - -(defvar ffip-patterns - '("*.html" "*.org" "*.txt" "*.md" "*.el" "*.clj" "*.py" "*.rb" "*.js" "*.pl" - "*.sh" "*.erl" "*.hs" "*.ml") - "List of patterns to look for with `find-file-in-project'.") - -(defvar ffip-prune-patterns - '(".git") - "List of directory patterns to not decend into when listing files in `find-file-in-project'.") - -(defvar ffip-find-options "" - "Extra options to pass to `find' when using `find-file-in-project'. - -Use this to exclude portions of your project: \"-not -regex \\\".*svn.*\\\"\".") - -(defvar ffip-project-root nil - "If non-nil, overrides the project root directory location.") - -(defvar ffip-project-root-function nil - "If non-nil, this function is called to determine the project root. - -This overrides variable `ffip-project-root' when set.") - -(defvar ffip-limit 512 - "Limit results to this many files.") - -(defvar ffip-full-paths nil - "If non-nil, show fully project-relative paths.") - -(defun ffip-project-root () - "Return the root of the project." - (let ((project-root (or ffip-project-root - (if (functionp ffip-project-root-function) - (funcall ffip-project-root-function) - (if (listp ffip-project-file) - (some (apply-partially 'locate-dominating-file - default-directory) - ffip-project-file) - (locate-dominating-file default-directory - ffip-project-file)))))) - (or project-root - (progn (message "No project was defined for the current file.") - nil)))) - -(defun ffip-uniqueify (file-cons) - "Set the car of FILE-CONS to include the directory name plus the file name." - (setcar file-cons - (concat (cadr (reverse (split-string (cdr file-cons) "/"))) "/" - (car file-cons)))) - -(defun ffip-join-patterns () - "Turn `ffip-patterns' into a string that `find' can use." - (mapconcat (lambda (pat) (format "-name \"%s\"" pat)) - ffip-patterns " -or ")) - -(defun ffip-prune-patterns () - "Turn `ffip-prune-patterns' into a string that `find' can use." - (mapconcat (lambda (pat) (format "-name \"%s\"" pat)) - ffip-prune-patterns " -or ")) - - -(defun ffip-project-files () - "Return an alist of all filenames in the project and their path. - -Files with duplicate filenames are suffixed with the name of the -directory they are found in so that they are unique." - (let ((file-alist nil) - (root (expand-file-name (or ffip-project-root (ffip-project-root) - (error "No project root found"))))) - (mapcar (lambda (file) - (if ffip-full-paths - (cons (substring (expand-file-name file) (length root)) - (expand-file-name file)) - (let ((file-cons (cons (file-name-nondirectory file) - (expand-file-name file)))) - (when (assoc (car file-cons) file-alist) - (ffip-uniqueify (assoc (car file-cons) file-alist)) - (ffip-uniqueify file-cons)) - (add-to-list 'file-alist file-cons) - file-cons))) - (split-string (shell-command-to-string - (format "find %s -type d -a \\( %s \\) -prune -o -type f \\( %s \\) -print %s | head -n %s" - root (ffip-prune-patterns) (ffip-join-patterns) - ffip-find-options ffip-limit)))))) - -;;;###autoload -(defun find-file-in-project () - "Prompt with a completing list of all files in the project to find one. - -The project's scope is defined as the first directory containing -an `.emacs-project' file. You can override this by locally -setting the variable `ffip-project-root'." - (interactive) - (let* ((project-files (ffip-project-files)) - (files (mapcar 'car project-files)) - (file (if (and (boundp 'ido-mode) ido-mode) - (ido-completing-read "Find file in project: " files) - (completing-read "Find file in project: " files)))) - (find-file (cdr (assoc file project-files))))) - -;;;###autoload -(defalias 'ffip 'find-file-in-project) - -;; safe locals -;;;###autoload -(progn - (put 'ffip-patterns 'safe-local-variable 'listp) - (put 'ffip-find-options 'safe-local-variable 'stringp) - (put 'ffip-project-file 'safe-local-variable 'stringp) - (put 'ffip-project-root 'safe-local-variable 'stringp) - (put 'ffip-project-root-function 'safe-local-variable 'functionp) - (put 'ffip-limit 'safe-local-variable 'integerp)) - -(provide 'find-file-in-project) -;;; find-file-in-project.el ends here diff --git a/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-autoloads.el b/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-autoloads.el new file mode 100644 index 0000000..e226192 --- /dev/null +++ b/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-autoloads.el @@ -0,0 +1,54 @@ +;;; find-file-in-project-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "find-file-in-project" "find-file-in-project.el" +;;;;;; (21837 24214 0 0)) +;;; Generated autoloads from find-file-in-project.el + +(autoload 'ffip-current-full-filename-match-pattern-p "find-file-in-project" "\ +Is current full file name (including directory) match the REGEX? + +\(fn REGEX)" nil nil) + +(autoload 'find-file-in-project "find-file-in-project" "\ +Prompt with a completing list of all files in the project to find one. + +The project's scope is defined as the first directory containing +a `ffip-project-file' (It's value is \".git\" by default. + +You can override this by setting the variable `ffip-project-root'. + +\(fn)" t nil) + +(autoload 'ffip-get-project-root-directory "find-file-in-project" "\ +Get the the full path of project root directory + +\(fn)" nil nil) + +(autoload 'find-file-in-project-by-selected "find-file-in-project" "\ +Similar to find-file-in-project. +But use string from selected region to search files in the project. +If no region is selected, you need provide one. + +\(fn)" t nil) + +(defalias 'ffip 'find-file-in-project) + +(put 'ffip-patterns 'safe-local-variable 'listp) + +(put 'ffip-project-file 'safe-local-variable 'stringp) + +(put 'ffip-project-root 'safe-local-variable 'stringp) + +(put 'ffip-limit 'safe-local-variable 'integerp) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; find-file-in-project-autoloads.el ends here diff --git a/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-pkg.el b/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-pkg.el new file mode 100644 index 0000000..ab9c5ff --- /dev/null +++ b/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project-pkg.el @@ -0,0 +1 @@ +(define-package "find-file-in-project" "20150506.33" "Find files in a project quickly." 'nil :url "http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject" :keywords '("project" "convenience")) diff --git a/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project.el b/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project.el new file mode 100644 index 0000000..8baa97d --- /dev/null +++ b/emacs.d/elpa/find-file-in-project-20150506.33/find-file-in-project.el @@ -0,0 +1,337 @@ +;;; find-file-in-project.el --- Find files in a project quickly. + +;; Copyright (C) 2006-2009, 2011-2012, 2015 +;; Phil Hagelberg, Doug Alcorn, and Will Farrington +;; Author: Phil Hagelberg, Doug Alcorn, and Will Farrington +;; Maintainer: Chen Bin +;; URL: http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject +;; Package-Version: 20150506.33 +;; Git: git://github.com/technomancy/find-file-in-project.git +;; Version: 3.5 +;; Created: 2008-03-18 +;; Keywords: project, convenience +;; EmacsWiki: FindFileInProject + +;; This file is NOT part of GNU Emacs. + +;;; License: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; This program provides a couple methods for quickly finding any file +;; in a given project. It depends on GNU find. +;; +;; Usage, +;; - `M-x find-file-in-project` will start search immediately +;; - `M-x find-file-in-project-by-selected` use the your selected +;; region as keyword to search. Or you need provide the keyword +;; if no region selected. +;; +;; A project is found by searching up the directory tree until a file +;; is found that matches `ffip-project-file'. (".git" by default.) +;; You can set `ffip-project-root-function' to provide an alternate +;; function to search for the project root. By default, it looks only +;; for files whose names match `ffip-patterns', + +;; If you have so many files that it becomes unwieldy, you can set +;; `ffip-find-options' to a string which will be passed to the `find' +;; invocation in order to exclude irrelevant subdirectories/files. +;; For instance, in a Ruby on Rails project, you are interested in all +;; .rb files that don't exist in the "vendor" directory. In that case +;; you could set `ffip-find-options' to "-not -regex \".*vendor.*\"". + +;; All these variables may be overridden on a per-directory basis in +;; your .dir-locals.el. See (info "(Emacs) Directory Variables") for +;; details. + +;; Ivy.el from https://github.com/abo-abo/swiper could be automatically +;; used if you insert below line into ~/.emacs, +;; (autoload 'ivy-read "ivy") +;; In Ivy.el, SPACE is translated to regex ".*". +;; For exmaple, the search string "dec fun pro" is transformed into +;; a regex "\\(dec\\).*\\(fun\\).*\\(pro\\)" +;; +;; If Ivy.el is not available, ido will be used. + +;; GNU Find can be installed, +;; - through `brew' on OS X +;; - through `cygwin' on Windows. +;; +;; This program works on Windows/Cygwin/Linux/Mac Emacs. +;; See https://github.com/technomancy/find-file-in-project for advanced tips + +;; Recommended binding: (global-set-key (kbd "C-x f") 'find-file-in-project) + +;;; Code: + +(require 'cl) + +(defvar ffip-find-executable nil "Path of GNU find. If nil, we will find `find' path automatically") + +(defvar ffip-project-file ".git" + "The file that should be used to define a project root. + +May be set using .dir-locals.el. Checks each entry if set to a list.") + +(defvar ffip-patterns nil + "List of patterns to look for with `find-file-in-project'.") + +(defvar ffip-prune-patterns + '(;; VCS + ".git" + ".svn" + ".cvs" + ".bzr" + ".hg" + ;; project misc + "*.log" + "bin" + "dist" + "target" + ;; Mac + ".DS_Store" + ;; Ctags + "tags" + "TAGS" + ;; Global/Cscope + "GTAGS" + "GPATH" + "GRTAGS" + "cscope.files" + ;; html/javascript/css + "*min.js" + "*min.css" + "node_modules" + "bower_components" + ;; Images + "*.png" + "*.jpg" + "*.jpeg" + "*.gif" + "*.bmp" + "*.tiff" + ;; documents + "*.doc" + "*.docx" + "*.pdf" + ;; C/C++ + "*.obj" + "*.o" + "*.a" + "*.dylib" + "*.lib" + "*.d" + "*.dll" + "*.exe" + ;; Java + ".metadata" + ".gradle" + "*.class" + "*.war" + "*.jar" + ;; Emacs/Vim + "*flymake" + "#*#" + ".#*" + "*.swp" + "*~" + "*.elc" + ".cask" + ;; Python + "*.pyc") + "List of directory/file patterns to not descend into when listing files in `find-file-in-project'.") + +(defvar ffip-find-options "" + "Extra options to pass to `find' when using `find-file-in-project'. + +Use this to exclude portions of your project: \"-not -regex \\\".*svn.*\\\"\".") + +(defvar ffip-project-root nil + "If non-nil, overrides the project root directory location.") + +(defvar ffip-project-root-function nil + "If non-nil, this function is called to determine the project root. + +This overrides variable `ffip-project-root' when set.") + +(defvar ffip-limit 0 + "Limit results to this many files. 0 means no limit") + +(defvar ffip-full-paths t + "If non-nil, show fully project-relative paths.") + +(defvar ffip-debug nil "Print debug information") + +(defun ffip-project-root () + "Return the root of the project." + (let ((project-root (or ffip-project-root + (if (functionp ffip-project-root-function) + (funcall ffip-project-root-function) + (if (listp ffip-project-file) + (some (apply-partially 'locate-dominating-file + default-directory) + ffip-project-file) + (locate-dominating-file default-directory + ffip-project-file)))))) + (or project-root + (progn (message "No project was defined for the current file.") + nil)))) + +(defun ffip--guess-gnu-find () + (let ((rlt "find")) + (if (eq system-type 'windows-nt) + (cond + ((executable-find "c:\\\\cygwin64\\\\bin\\\\find") + (setq rlt "c:\\\\cygwin64\\\\bin\\\\find")) + ((executable-find "d:\\\\cygwin64\\\\bin\\\\find") + (setq rlt "d:\\\\cygwin64\\\\bin\\\\find")) + ((executable-find "e:\\\\cygwin64\\\\bin\\\\find") + (setq rlt "e:\\\\cygwin64\\\\bin\\\\find")) + ((executable-find "c:\\\\cygwin\\\\bin\\\\find") + (setq rlt "c:\\\\cygwin\\\\bin\\\\find")) + ((executable-find "d:\\\\cygwin\\\\bin\\\\find") + (setq rlt "d:\\\\cygwin\\\\bin\\\\find")) + ((executable-find "e:\\\\cygwin\\\\bin\\\\find") + (setq rlt "e:\\\\cygwin\\\\bin\\\\find")))) + rlt)) + +(defun ffip-join-patterns () + "Turn `ffip-patterns' into a string that `find' can use." + (if ffip-patterns + (format "\\( %s \\)" + (mapconcat (lambda (pat) (format "-name \"%s\"" pat)) + ffip-patterns " -or ")) + "")) + +(defun ffip-prune-patterns () + "Turn `ffip-prune-patterns' into a string that `find' can use." + (mapconcat (lambda (pat) (format "-name \"%s\"" pat)) + ffip-prune-patterns " -or ")) + +(defun ffip-limit-find-results () + (let ((rlt "")) + (if (and (executable-find "head") (> ffip-limit 0)) + (setq rlt (format " | head -n %d" ffip-limit))) + rlt)) + +(defun ffip-completing-read (prompt collection) + (let (rlt) + (cond + ((fboundp 'ivy-read) + (setq rlt (ivy-read prompt collection))) + ((and (boundp 'ido-mode) ido-mode) + (setq rlt (ido-completing-read prompt collection))) + (t + (setq rlt (completing-read prompt collection)))) + rlt)) + +(defun ffip-project-files (&optional keyword) + "Return an alist of all filenames in the project and their path. + +Files with duplicate filenames are suffixed with the name of the +directory they are found in so that they are unique." + (let (rlt + cmd + (old-default-directory default-directory) + (file-alist nil) + (root (expand-file-name (or ffip-project-root (ffip-project-root) + (error "No project root found"))))) + (cd (file-name-as-directory root)) + ;; make the prune pattern more general + (setq cmd (format "%s . \\( %s \\) -prune -o -type f %s %s %s -print %s" + (if ffip-find-executable ffip-find-executable (ffip--guess-gnu-find)) + (ffip-prune-patterns) (ffip-join-patterns) + (if keyword (concat "-name \"*" keyword "*\"") "") + ffip-find-options (ffip-limit-find-results))) + + (if ffip-debug (message "run cmd at %s: %s" default-directory cmd)) + (setq rlt + (mapcar (lambda (file) + (if ffip-full-paths + (cons (replace-regexp-in-string "^\./" "" file) + (expand-file-name file)) + (let ((file-cons (cons (file-name-nondirectory file) + (expand-file-name file)))) + (add-to-list 'file-alist file-cons) + file-cons))) + ;; #15 improving handling of directories containing space + (split-string (shell-command-to-string cmd) "[\r\n]+" t))) + + ;; restore the original default-directory + (cd old-default-directory) + rlt)) + +(defun ffip-find-files (&optional keyword) + (let* ((project-files (ffip-project-files keyword)) + (files (mapcar 'car project-files)) + file root) + (cond + ((and files (> (length files) 0)) + (setq root (file-name-nondirectory (directory-file-name (or ffip-project-root (ffip-project-root))))) + (setq file (ffip-completing-read (format "Find file in %s/: " root) files)) + (find-file (cdr (assoc file project-files)))) + (t (message "No match file exist!"))) + )) + +;;;###autoload +(defun ffip-current-full-filename-match-pattern-p (REGEX) + "Is current full file name (including directory) match the REGEX?" + (let ((dir (if (buffer-file-name) (buffer-file-name) ""))) + (string-match-p REGEX dir))) + +;;;###autoload +(defun find-file-in-project () + "Prompt with a completing list of all files in the project to find one. + +The project's scope is defined as the first directory containing +a `ffip-project-file' (It's value is \".git\" by default. + +You can override this by setting the variable `ffip-project-root'." + (interactive) + (ffip-find-files)) + +;;;###autoload +(defun ffip-get-project-root-directory () + "Get the the full path of project root directory" + (expand-file-name (or ffip-project-root + (ffip-project-root)))) + +;;;###autoload +(defun find-file-in-project-by-selected () + "Similar to find-file-in-project. +But use string from selected region to search files in the project. +If no region is selected, you need provide one." + (interactive) + (let ((keyword (if (region-active-p) + (buffer-substring-no-properties (region-beginning) (region-end)) + (read-string "Enter keyword:")))) + (ffip-find-files keyword))) + +;;;###autoload +(defalias 'ffip 'find-file-in-project) + +;; safe locals +;;;###autoload +(progn + (put 'ffip-patterns 'safe-local-variable 'listp) + (put 'ffip-project-file 'safe-local-variable 'stringp) + (put 'ffip-project-root 'safe-local-variable 'stringp) + (put 'ffip-limit 'safe-local-variable 'integerp)) + +(provide 'find-file-in-project) +;;; find-file-in-project.el ends here diff --git a/emacs.d/elpa/flymake-cursor-1.0.2/Changes b/emacs.d/elpa/flymake-cursor-1.0.2/Changes deleted file mode 100644 index 6502457..0000000 --- a/emacs.d/elpa/flymake-cursor-1.0.2/Changes +++ /dev/null @@ -1,11 +0,0 @@ -* flymake-cursor.el 1.0.2 (2012-03-22-17:55) - * Fix the package description to the nicer Marmalade version too. - -* flymake-cursor.el 1.0.1 (2012-03-22-17:48) - * Add Changes file. - * Use butlast for error truncation rather than messing with car/cdr directly. - * Add myself as maintainer. - * Update author list. - * Neaten up package meta-data. - * Merge in some changes from Marmalade version ready to release as upgrade. - * Add GPL licence, bequeath to FSF. diff --git a/emacs.d/elpa/flymake-cursor-1.0.2/LICENSE.txt b/emacs.d/elpa/flymake-cursor-1.0.2/LICENSE.txt deleted file mode 100644 index 94a9ed0..0000000 --- a/emacs.d/elpa/flymake-cursor-1.0.2/LICENSE.txt +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/emacs.d/elpa/flymake-cursor-1.0.2/README.mkdn b/emacs.d/elpa/flymake-cursor-1.0.2/README.mkdn deleted file mode 100644 index 03c77ce..0000000 --- a/emacs.d/elpa/flymake-cursor-1.0.2/README.mkdn +++ /dev/null @@ -1,46 +0,0 @@ -flymake-cursor.el -================= - -This project is a plugin for Emacs to work in conjunction with flymake.el -it displays any flymake error for the current line on the minibuffer. - -The project is a fork of http://www.emacswiki.org/emacs/flymake-cursor.el - -It adds the following features: - - * Customizable delay before the error appears in the minibuffer. - * Customizable number of errors to display in the minibuffer. - * Does not overwrite the minibuffer if it's currently in use for user input. - * Updates message area more consistently as flymake changes state. - * Turns off when flymake-mode is turned off. - * Now operates as a minor-mode of its own so you can turn on and off directly. - * Requires flymake, ensuring a clean byte-compile. - -INSTALLATION ------------- - -Place `flymake-cursor.el` within your Emacs `load-path` and the following to your -`.emacs` file or your `init.el`: - -```lisp -(eval-after-load 'flymake '(require 'flymake-cursor)) -``` - -CUSTOMIZATION -------------- - -You can customize the behaviour of `flymake-cursor.el` with the -`flymake-cursor` group in customize mode, or you can edit the -following custom variables directly: - - * `flymake-cursor-error-display-delay` sets the delay before an error is - displayed in the minibuffer. - * `flymake-cursor-number-of-errors-to-display` sets how many errors to - display in the minibuffer at once. - * `flymake-cursor-auto-enable` sets whether flymake-cursor should - automatically enable itself whenever flymake is enabled. - -KNOWN ISSUES & BUGS -------------------- - - * None currently. diff --git a/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-autoloads.el b/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-autoloads.el deleted file mode 100644 index 4915a85..0000000 --- a/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-autoloads.el +++ /dev/null @@ -1,34 +0,0 @@ -;;; flymake-cursor-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "flymake-cursor" "flymake-cursor.el" (21570 -;;;;;; 26368 0 0)) -;;; Generated autoloads from flymake-cursor.el - -(autoload 'flymake-cursor-mode "flymake-cursor" "\ -Minor mode to show `flymake-mode' errors for the current line in the -message area. -When called interactively, toggles the minor mode. -With arg, turn Flymake Cursor mode on if and only if arg is positive. - -Usually `flymake-cursor-mode' is enabled and disabled automatically with -`flymake-mode' for the current buffer and you will not need to toggle -the mode directly. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("flymake-cursor-pkg.el") (21570 26368 -;;;;;; 350822 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; flymake-cursor-autoloads.el ends here diff --git a/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-pkg.el b/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-pkg.el deleted file mode 100644 index 361919e..0000000 --- a/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor-pkg.el +++ /dev/null @@ -1,3 +0,0 @@ -(define-package "flymake-cursor" "1.0.2" - "Show flymake messages in the minibuffer after delay" - '((flymake "0.3"))) diff --git a/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor.el b/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor.el deleted file mode 100644 index b6a315c..0000000 --- a/emacs.d/elpa/flymake-cursor-1.0.2/flymake-cursor.el +++ /dev/null @@ -1,227 +0,0 @@ -;;; flymake-cursor.el --- Show flymake messages in the minibuffer after delay -;; -;; Copyright (C) 2011-2012 Free Software Foundation, Inc. -;; -;; Author: Unknown Original Author -;; Dino Chiesa -;; Sam Graham -;; Maintainer: Sam Graham -;; URL: https://github.com/illusori/emacs-flymake-cursor -;; origin: http://paste.lisp.org/display/60617,1/raw -;; Version: 1.0.2 -;; Keywords: languages mode flymake -;; License: Gnu Public License -;; Package-Requires: ((flymake "0.3")) -;; 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: -;; -;; Additional functionality that makes flymake error messages appear -;; in the minibuffer when point is on a line containing a flymake -;; error. This saves having to mouse over the error, which is a -;; keyboard user's annoyance. -;; -;; ------------------------------------------------------- -;; -;; This flymake-cursor module displays the flymake error in the -;; minibuffer, after a short delay. It is based on code I found roaming -;; around on the net, unsigned and unattributed. I suppose it's public -;; domain, because, while there is a "License" listed in it, there -;; is no license holder, no one to own the license. -;; -;; This version is modified slightly from that code. The post-command fn -;; defined in this code does not display the message directly. Instead -;; it sets a timer, and when the timer fires, the timer event function -;; displays the message. -;; -;; The reason to do this: the error message is displayed only if the -;; user doesn't do anything, for about one second. This way, if the user -;; scrolls through a buffer and there are myriad errors, the minibuffer -;; is not constantly being updated. -;; -;; If the user moves away from the line with the flymake error message -;; before the timer expires, then no error is displayed in the minibuffer. -;; -;; I've also updated the names of the defuns. They all start with flyc now. -;; -;;; Usage: -;; (require 'flymake-cursor) -;; You can, of course, put that in an eval-after-load clause. - -;;; Code: - -(eval-when-compile (require 'flymake)) - -(defgroup flymake-cursor nil - "Show flymake errors for current line in message area." - :group 'tools) - -(defcustom flymake-cursor-error-display-delay 0.9 - "Delay in seconds to wait before displaying flymake errors for the current line." - :group 'flymake-cursor - :type 'number) - -(defcustom flymake-cursor-number-of-errors-to-display 1 - "Number of flymake errors to display if there are more than one. - -If set to nil, all errors for the line will be displayed. - -If there are more errors than can be displayed in the minibuffer, the -first ones will be scrolled off. You will probably want to set this -variable to a value consistent with your `max-mini-window-height' -setting." - :group 'flymake-cursor - :type '(choice integer (const nil))) - -(defcustom flymake-cursor-auto-enable t - "Whether flymake-cursor should automatically enable itself whenever -flymake is enabled. - -If set to t, flymake-cursor will turn on whenever flymake does. -If set to nil, flymake-cursor will need to be manually enabled. - -Regardless of this setting, flymake-cursor will always disable -itself automatically when flymake is disabled, to prevent -errors." - :group 'flymake-cursor - :type 'boolean) - -(defvar flymake-cursor-errors-at-point nil - "Errors at point, after last command") - -(defvar flymake-cursor-error-display-timer nil - "A timer; when it fires, it displays the stored error message.") - -;;;###autoload -(define-minor-mode flymake-cursor-mode - "Minor mode to show `flymake-mode' errors for the current line in the -message area. -When called interactively, toggles the minor mode. -With arg, turn Flymake Cursor mode on if and only if arg is positive. - -Usually `flymake-cursor-mode' is enabled and disabled automatically with -`flymake-mode' for the current buffer and you will not need to toggle -the mode directly." - :group 'flymake-cursor - (cond - - ;; Turning the mode ON. - (flymake-cursor-mode - (add-hook 'post-command-hook 'flymake-cursor-show-errors-at-point-pretty-soon nil t)) - ;; Turning the mode OFF. - (t - (flymake-cursor-cancel-error-display-timer) - (remove-hook 'post-command-hook 'flymake-cursor-show-errors-at-point-pretty-soon t)))) - -(defun flymake-cursor-get-errors-at-point () - "Gets the first `flymake-cursor-number-of-errors-to-display` flymake errors on the line at point." - (let ((line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info (line-number-at-pos))))) - (if flymake-cursor-number-of-errors-to-display - (butlast line-err-info-list (- (length line-err-info-list) flymake-cursor-number-of-errors-to-display)) - line-err-info-list))) - -(defun flymake-cursor-pyflake-determine-message (error) - "pyflake is flakey if it has compile problems, this adjusts the -message to display, so there is one ;)" - (cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t))) - ((null (flymake-ler-file error)) - ;; normal message do your thing - (flymake-ler-text error)) - (t ;; could not compile error - (format "compile error, problem on line %s" (flymake-ler-line error))))) - -(defun flymake-cursor-safe-to-display () - "Returns t if Flymake Cursor is safe to display to the minibuffer or nil if -something else is using the message area." - ;; Don't trash the minibuffer while they're being asked a question. - (not (or (active-minibuffer-window) cursor-in-echo-area))) - -(defun flymake-cursor-show-stored-errors-now () - "Displays the stored error in the minibuffer." - (interactive) - (when flymake-cursor-mode - (flymake-cursor-cancel-error-display-timer) - (when flymake-cursor-errors-at-point - (if (flymake-cursor-safe-to-display) - (message "%s" (mapconcat 'flymake-cursor-pyflake-determine-message flymake-cursor-errors-at-point "\n")) - (flymake-cursor-show-errors-at-point-pretty-soon))))) - -(defun flymake-cursor-show-errors-at-point-now () - "If the cursor is sitting on a flymake error, display -the error message in the minibuffer." - (interactive) - (when flymake-cursor-mode - (flymake-cursor-cancel-error-display-timer) - (setq flymake-cursor-errors-at-point (flymake-cursor-get-errors-at-point)) - (if flymake-cursor-errors-at-point - (flymake-cursor-show-stored-errors-now) - ;; If something is demanding we display errors immediately, we do - ;; want to clear the message area to indicate there's no errors. - ;; Otherwise flymake-cursor-after-syntax-check will just keep the - ;; old error for the current line if it has been corrected. - (when (flymake-cursor-safe-to-display) - (message nil))))) - -(defun flymake-cursor-cancel-error-display-timer () - "Cancels `flymake-cursor-error-display-timer'." - (when flymake-cursor-error-display-timer - (cancel-timer flymake-cursor-error-display-timer) - (setq flymake-cursor-error-display-timer nil))) - -(defun flymake-cursor-show-errors-at-point-pretty-soon () - "If the cursor is sitting on a flymake error, grab the error, -and set a timer for \"pretty soon\". When the timer fires, the error -message will be displayed in the minibuffer. - -The interval before the timer fires can be customized in the variable -`flymake-cursor-error-display-delay'. - -This allows a post-command-hook to NOT cause the minibuffer to be -updated 10,000 times as a user scrolls through a buffer -quickly. Only when the user pauses on a line for more than a -second, does the flymake error message (if any) get displayed." - (flymake-cursor-cancel-error-display-timer) - (setq flymake-cursor-errors-at-point (flymake-cursor-get-errors-at-point)) - (when flymake-cursor-errors-at-point - (setq flymake-cursor-error-display-timer - (run-at-time flymake-cursor-error-display-delay nil 'flymake-cursor-show-stored-errors-now)))) - -(defun flymake-cursor-follow-flymake-mode () - "Hook function to make `flymake-cursor-mode` follow the on/off -status of `flymake-mode'." - (if flymake-mode - (when flymake-cursor-auto-enable (flymake-cursor-mode 1)) - (flymake-cursor-mode 0))) - -(defun flymake-cursor-after-syntax-check () - "Run from `flymake-after-syntax-check-hook' to update our errors." - (when (eq (current-buffer) (window-buffer)) - (flymake-cursor-show-errors-at-point-now))) - -(eval-after-load "flymake" - '(progn - (if (boundp 'flymake-goto-error-hook) - (add-hook 'flymake-goto-error-hook 'flymake-cursor-show-errors-at-point-now) - (defadvice flymake-goto-line (after flymake-cursor-display-message-after-move-to-error activate compile) - "Display the error in the mini-buffer rather than having to mouse over it" - (flymake-cursor-show-errors-at-point-now))) - (if (boundp 'flymake-after-syntax-check-hook) - (add-hook 'flymake-after-syntax-check-hook 'flymake-cursor-after-syntax-check) - (defadvice flymake-post-syntax-check (after flymake-cursor-display-message-after-syntax-check activate compile) - "Display the error in the mini-buffer rather than having to mouse over it" - (flymake-cursor-after-syntax-check))) - (add-hook 'flymake-mode-hook 'flymake-cursor-follow-flymake-mode))) - -(provide 'flymake-cursor) -;;; flymake-cursor.el ends here diff --git a/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-autoloads.el b/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-autoloads.el new file mode 100644 index 0000000..8172e45 --- /dev/null +++ b/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-autoloads.el @@ -0,0 +1,37 @@ +;;; flymake-cursor-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "flymake-cursor" "flymake-cursor.el" (21837 +;;;;;; 24213 0 0)) +;;; Generated autoloads from flymake-cursor.el + +(autoload 'flyc/show-fly-error-at-point-now "flymake-cursor" "\ +If the cursor is sitting on a flymake error, display +the error message in the minibuffer. + +\(fn)" t nil) + +(autoload 'flyc/show-fly-error-at-point-pretty-soon "flymake-cursor" "\ +If the cursor is sitting on a flymake error, grab the error, +and set a timer for \"pretty soon\". When the timer fires, the error +message will be displayed in the minibuffer. + +This allows a post-command-hook to NOT cause the minibuffer to be +updated 10,000 times as a user scrolls through a buffer +quickly. Only when the user pauses on a line for more than a +second, does the flymake error message (if any) get displayed. + +\(fn)" nil nil) + +(eval-after-load "flymake" '(progn (defadvice flymake-goto-next-error (after flyc/display-message-1 activate compile) "Display the error in the mini-buffer rather than having to mouse over it" (flyc/show-fly-error-at-point-now)) (defadvice flymake-goto-prev-error (after flyc/display-message-2 activate compile) "Display the error in the mini-buffer rather than having to mouse over it" (flyc/show-fly-error-at-point-now)) (defadvice flymake-mode (before flyc/post-command-fn activate compile) "Add functionality to the post command hook so that if the\ncursor is sitting on a flymake error the error information is\ndisplayed in the minibuffer (rather than having to mouse over\nit)" (add-hook 'post-command-hook 'flyc/show-fly-error-at-point-pretty-soon t t)))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; flymake-cursor-autoloads.el ends here diff --git a/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-pkg.el b/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-pkg.el new file mode 100644 index 0000000..ed5e21f --- /dev/null +++ b/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor-pkg.el @@ -0,0 +1 @@ +(define-package "flymake-cursor" "20130822.1032" "displays flymake error msg in minibuffer after delay" 'nil :url "http://www.emacswiki.org/emacs/flymake-cursor.el" :keywords '("languages" "mode" "flymake")) diff --git a/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor.el b/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor.el new file mode 100644 index 0000000..d625944 --- /dev/null +++ b/emacs.d/elpa/flymake-cursor-20130822.1032/flymake-cursor.el @@ -0,0 +1,168 @@ +;;; flymake-cursor.el --- displays flymake error msg in minibuffer after delay +;; +;; Author : ?? +;; origin : http://paste.lisp.org/display/60617,1/raw +;; Maintainer : Dino Chiesa +;; : Donald Curtis +;; Created : May 2011 +;; Modified : December 2012 +;; Version : 0.1.5 +;; Keywords : languages mode flymake +;; Package-Version: 20130822.1032 +;; X-URL : http://www.emacswiki.org/emacs/flymake-cursor.el +;; Last-saved : <2012-Dec-20 09:49:28> +;; +;; ------------------------------------------------------- +;; +;; License: None. This code is in the Public Domain. +;; +;; +;; Additional functionality that makes flymake error messages appear +;; in the minibuffer when point is on a line containing a flymake +;; error. This saves having to mouse over the error, which is a +;; keyboard user's annoyance. +;; ------------------------------------------------------- +;; +;; This flymake-cursor module displays the flymake error in the +;; minibuffer, after a short delay. It is based on code I found roaming +;; around on the net, unsigned and unattributed. I suppose it's public +;; domain, because, while there is a "License" listed in it, there +;; is no license holder, no one to own the license. +;; +;; This version is modified slightly from that code. The post-command fn +;; defined in this code does not display the message directly. Instead +;; it sets a timer, and when the timer fires, the timer event function +;; displays the message. +;; +;; The reason to do this: the error message is displayed only if the +;; user doesn't do anything, for about one second. This way, if the user +;; scrolls through a buffer and there are myriad errors, the minibuffer +;; is not constantly being updated. +;; +;; If the user moves away from the line with the flymake error message +;; before the timer expires, then no error is displayed in the minibuffer. +;; +;; I've also updated the names of the defuns. They all start with flyc now. +;; +;; To use this, include this line in your .emacs: +;; +;; ;; enhancements for displaying flymake errors +;; (require 'flymake-cursor) +;; +;; You can, of course, put that in an eval-after-load clause. +;; +;; ------------------------------------------------------- +;; +;; Update 2012-03-06 by Donald Curtis +;; -- +;; Added some autoload statements and the closing comment to make +;; compatible with package.el parser. +;; +;; Update 2012-12-20 by Jeremy Moore +;; -- +;; Alter post-command-hook's local value via add-hook so that it plays +;; nicely with other packages. +;; + + +(require 'cl) + +(defvar flyc--e-at-point nil + "Error at point, after last command") + +(defvar flyc--e-display-timer nil + "A timer; when it fires, it displays the stored error message.") + +(defun flyc/maybe-fixup-message (errore) + "pyflake is flakey if it has compile problems, this adjusts the +message to display, so there is one ;)" + (cond ((not (or (eq major-mode 'Python) (eq major-mode 'python-mode) t))) + ((null (flymake-ler-file errore)) + ;; normal message do your thing + (flymake-ler-text errore)) + (t ;; could not compile error + (format "compile error, problem on line %s" (flymake-ler-line errore))))) + +(defun flyc/show-stored-error-now () + "Displays the stored error in the minibuffer." + (interactive) + (let ((editing-p (= (minibuffer-depth) 0))) + (if (and flyc--e-at-point editing-p) + (progn + (message "%s" (flyc/maybe-fixup-message flyc--e-at-point)) + (setq flyc--e-display-timer nil))))) + + +(defun flyc/-get-error-at-point () + "Gets the first flymake error on the line at point." + (let ((line-no (line-number-at-pos)) + flyc-e) + (dolist (elem flymake-err-info) + (if (eq (car elem) line-no) + (setq flyc-e (car (second elem))))) + flyc-e)) + + +;;;###autoload +(defun flyc/show-fly-error-at-point-now () + "If the cursor is sitting on a flymake error, display +the error message in the minibuffer." + (interactive) + (if flyc--e-display-timer + (progn + (cancel-timer flyc--e-display-timer) + (setq flyc--e-display-timer nil))) + (let ((error-at-point (flyc/-get-error-at-point))) + (if error-at-point + (progn + (setq flyc--e-at-point error-at-point) + (flyc/show-stored-error-now))))) + + +;;;###autoload +(defun flyc/show-fly-error-at-point-pretty-soon () + "If the cursor is sitting on a flymake error, grab the error, +and set a timer for \"pretty soon\". When the timer fires, the error +message will be displayed in the minibuffer. + +This allows a post-command-hook to NOT cause the minibuffer to be +updated 10,000 times as a user scrolls through a buffer +quickly. Only when the user pauses on a line for more than a +second, does the flymake error message (if any) get displayed. + +" + (if flyc--e-display-timer + (cancel-timer flyc--e-display-timer)) + + (let ((error-at-point (flyc/-get-error-at-point))) + (if error-at-point + (setq flyc--e-at-point error-at-point + flyc--e-display-timer + (run-at-time "0.9 sec" nil 'flyc/show-stored-error-now)) + (setq flyc--e-at-point nil + flyc--e-display-timer nil)))) + + +;;;###autoload +(eval-after-load "flymake" + '(progn + + (defadvice flymake-goto-next-error (after flyc/display-message-1 activate compile) + "Display the error in the mini-buffer rather than having to mouse over it" + (flyc/show-fly-error-at-point-now)) + + (defadvice flymake-goto-prev-error (after flyc/display-message-2 activate compile) + "Display the error in the mini-buffer rather than having to mouse over it" + (flyc/show-fly-error-at-point-now)) + + (defadvice flymake-mode (before flyc/post-command-fn activate compile) + "Add functionality to the post command hook so that if the +cursor is sitting on a flymake error the error information is +displayed in the minibuffer (rather than having to mouse over +it)" + (add-hook 'post-command-hook 'flyc/show-fly-error-at-point-pretty-soon t t)))) + + +(provide 'flymake-cursor) + +;;; flymake-cursor.el ends here diff --git a/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-autoloads.el b/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-autoloads.el deleted file mode 100644 index dfc34e3..0000000 --- a/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-autoloads.el +++ /dev/null @@ -1,22 +0,0 @@ -;;; flymake-elixir-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "flymake-elixir" "flymake-elixir.el" (21721 -;;;;;; 24080 0 0)) -;;; Generated autoloads from flymake-elixir.el - -(autoload 'flymake-elixir-load "flymake-elixir" "\ -Configure flymake mode to check the current buffer's elixir syntax. - -\(fn)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; flymake-elixir-autoloads.el ends here diff --git a/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-pkg.el b/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-pkg.el deleted file mode 100644 index 43f88fa..0000000 --- a/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "flymake-elixir" "0.5" "A flymake handler for elixir-mode .ex files." 'nil) diff --git a/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir.el b/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir.el deleted file mode 100644 index 6c988a2..0000000 --- a/emacs.d/elpa/flymake-elixir-0.5/flymake-elixir.el +++ /dev/null @@ -1,71 +0,0 @@ -;;; flymake-elixir.el --- A flymake handler for elixir-mode .ex files. -;; -;; Copyright (C) 2010-2013 Sylvain Benner -;; -;;; Author: Sylvain Benner -;;; Created: 10 Apr 2013 -;; Version: 0.5 -;;; Package-Pequires: ((flymake-easy "0.1")) -;; -;; This file is not part of GNU Emacs. -;; -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; -;; Usage: -;; (require 'flymake-elixir) -;; (add-hook 'elixir-mode-hook 'flymake-elixir-load) -;; -;; Based on flymake-ruby, from Steve Purcell -;; -;; Uses flymake-easy, from Steve Purcell - -;;; Code: - -(require 'flymake-easy) - -(defconst flymake-elixir-err-line-patterns - '(("^\\(** (.*) \\)?\\(.*\.ex\\):\\([0-9]+\\): \\(.*\\)$" 2 3 nil 4))) -(defconst flymake-elixir-warn-regex - (regexp-opt (list "^redefining" "^export_all" "future reserved" "deprecated" - "shadowed" "always matches$" "obsolete$" "unused$") t)) - -(defvar flymake-elixir-executable "elixirc" - "The elixir executable to use for syntax checking.") - -(defun flymake-elixir-command (filename) - "Construct a command that flymake can use to check elixir source." - (list flymake-elixir-executable - "--ignore-module-conflict" ; needed to prevent from module redefinition warning. - "+warn_obsolete_guard" - "+warn_unused_import" - "+warn_shadow_vars" - "+warn_export_vars" - "+strong_validation" - "+report" - filename)) - -;;;###autoload -(defun flymake-elixir-load () - "Configure flymake mode to check the current buffer's elixir syntax." - (interactive) - (flymake-easy-load 'flymake-elixir-command - flymake-elixir-err-line-patterns - 'tempdir - "ex" - flymake-elixir-warn-regex)) - -(provide 'flymake-elixir) -;;; flymake-elixir.el ends here diff --git a/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-autoloads.el b/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-autoloads.el new file mode 100644 index 0000000..1a4155f --- /dev/null +++ b/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-autoloads.el @@ -0,0 +1,22 @@ +;;; flymake-elixir-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "flymake-elixir" "flymake-elixir.el" (21837 +;;;;;; 24213 0 0)) +;;; Generated autoloads from flymake-elixir.el + +(autoload 'flymake-elixir-load "flymake-elixir" "\ +Configure flymake mode to check the current buffer's elixir syntax. + +\(fn)" t nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; flymake-elixir-autoloads.el ends here diff --git a/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-pkg.el b/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-pkg.el new file mode 100644 index 0000000..1fc546b --- /dev/null +++ b/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir-pkg.el @@ -0,0 +1 @@ +(define-package "flymake-elixir" "20130810.717" "A flymake handler for elixir-mode .ex files." 'nil) diff --git a/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir.el b/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir.el new file mode 100644 index 0000000..9943c6c --- /dev/null +++ b/emacs.d/elpa/flymake-elixir-20130810.717/flymake-elixir.el @@ -0,0 +1,72 @@ +;;; flymake-elixir.el --- A flymake handler for elixir-mode .ex files. +;; +;; Copyright (C) 2010-2013 Sylvain Benner +;; +;;; Author: Sylvain Benner +;;; Created: 10 Apr 2013 +;; Version: 0.5 +;; Package-Version: 20130810.717 +;;; Package-Pequires: ((flymake-easy "0.1")) +;; +;; This file is not part of GNU Emacs. +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;; +;; Usage: +;; (require 'flymake-elixir) +;; (add-hook 'elixir-mode-hook 'flymake-elixir-load) +;; +;; Based on flymake-ruby, from Steve Purcell +;; +;; Uses flymake-easy, from Steve Purcell + +;;; Code: + +(require 'flymake-easy) + +(defconst flymake-elixir-err-line-patterns + '(("^\\(** (.*) \\)?\\(.*\.ex\\):\\([0-9]+\\): \\(.*\\)$" 2 3 nil 4))) +(defconst flymake-elixir-warn-regex + (regexp-opt (list "^redefining" "^export_all" "future reserved" "deprecated" + "shadowed" "always matches$" "obsolete$" "unused$") t)) + +(defvar flymake-elixir-executable "elixirc" + "The elixir executable to use for syntax checking.") + +(defun flymake-elixir-command (filename) + "Construct a command that flymake can use to check elixir source." + (list flymake-elixir-executable + "--ignore-module-conflict" ; needed to prevent from module redefinition warning. + "+warn_obsolete_guard" + "+warn_unused_import" + "+warn_shadow_vars" + "+warn_export_vars" + "+strong_validation" + "+report" + filename)) + +;;;###autoload +(defun flymake-elixir-load () + "Configure flymake mode to check the current buffer's elixir syntax." + (interactive) + (flymake-easy-load 'flymake-elixir-command + flymake-elixir-err-line-patterns + 'tempdir + "ex" + flymake-elixir-warn-regex)) + +(provide 'flymake-elixir) +;;; flymake-elixir.el ends here diff --git a/emacs.d/elpa/flymake-php-20121104.1102/flymake-php-autoloads.el b/emacs.d/elpa/flymake-php-20121104.1102/flymake-php-autoloads.el deleted file mode 100644 index 780973c..0000000 --- a/emacs.d/elpa/flymake-php-20121104.1102/flymake-php-autoloads.el +++ /dev/null @@ -1,22 +0,0 @@ -;;; flymake-php-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "flymake-php" "flymake-php.el" (21570 26215 -;;;;;; 0 0)) -;;; Generated autoloads from flymake-php.el - -(autoload 'flymake-php-load "flymake-php" "\ -Configure flymake mode to check the current buffer's php syntax. - -\(fn)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; flymake-php-autoloads.el ends here diff --git a/emacs.d/elpa/flymake-php-20121104.1102/flymake-php-pkg.el b/emacs.d/elpa/flymake-php-20121104.1102/flymake-php-pkg.el deleted file mode 100644 index fe8048b..0000000 --- a/emacs.d/elpa/flymake-php-20121104.1102/flymake-php-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "flymake-php" "20121104.1102" "A flymake handler for php-mode files" '((flymake-easy "0.1")) :url "https://github.com/purcell/flymake-php") diff --git a/emacs.d/elpa/flymake-php-20121104.1102/flymake-php.el b/emacs.d/elpa/flymake-php-20121104.1102/flymake-php.el deleted file mode 100644 index 1182b3b..0000000 --- a/emacs.d/elpa/flymake-php-20121104.1102/flymake-php.el +++ /dev/null @@ -1,40 +0,0 @@ -;;; flymake-php.el --- A flymake handler for php-mode files -;; -;;; Author: Steve Purcell -;;; URL: https://github.com/purcell/flymake-php -;; Version: 20121104.1102 -;;; X-Original-Version: DEV -;;; Package-Requires: ((flymake-easy "0.1")) -;;; -;;; Commentary: -;; Usage: -;; (require 'flymake-php) -;; (add-hook 'php-mode-hook 'flymake-php-load) -;; -;; Uses flymake-easy, from https://github.com/purcell/flymake-easy - -;;; Code: -(require 'flymake-easy) - -(defconst flymake-php-err-line-patterns - '(("\\(?:Parse\\|Fatal\\|syntax\\) error[:,] \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1))) - -(defvar flymake-php-executable "php" - "The php executable to use for syntax checking.") - -(defun flymake-php-command (filename) - "Construct a command that flymake can use to check php source." - (list flymake-php-executable "-l" "-f" filename)) - -;;;###autoload -(defun flymake-php-load () - "Configure flymake mode to check the current buffer's php syntax." - (interactive) - (flymake-easy-load 'flymake-php-command - flymake-php-err-line-patterns - 'tempdir - "php")) - - -(provide 'flymake-php) -;;; flymake-php.el ends here diff --git a/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-autoloads.el b/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-autoloads.el new file mode 100644 index 0000000..037981d --- /dev/null +++ b/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-autoloads.el @@ -0,0 +1,30 @@ +;;; git-commit-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "git-commit-mode" "git-commit-mode.el" (21837 +;;;;;; 24197 0 0)) +;;; Generated autoloads from git-commit-mode.el + +(autoload 'git-commit-mode "git-commit-mode" "\ +Major mode for editing git commit messages. + +This mode helps with editing git commit messages both by +providing commands to do common tasks, and by highlighting the +basic structure of and errors in git commit messages. + +\(fn)" t nil) + +(add-to-list 'auto-mode-alist '("/MERGE_MSG\\'" . git-commit-mode)) + +(add-to-list 'auto-mode-alist '("/\\(?:COMMIT\\|NOTES\\|TAG\\|PULLREQ\\)_EDITMSG\\'" . git-commit-mode)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; git-commit-mode-autoloads.el ends here diff --git a/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-pkg.el b/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-pkg.el new file mode 100644 index 0000000..1c1d177 --- /dev/null +++ b/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode-pkg.el @@ -0,0 +1 @@ +(define-package "git-commit-mode" "20150330.1048" "Major mode for editing git commit messages" 'nil :url "https://github.com/magit/git-modes" :keywords '("convenience" "vc" "git")) diff --git a/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode.el b/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode.el new file mode 100644 index 0000000..fbee5dc --- /dev/null +++ b/emacs.d/elpa/git-commit-mode-20150330.1048/git-commit-mode.el @@ -0,0 +1,668 @@ +;;; git-commit-mode.el --- Major mode for editing git commit messages -*- lexical-binding: t; -*- + +;; Copyright (c) 2010-2012 Florian Ragwitz +;; Copyright (c) 2012-2013 Sebastian Wiesner +;; Copyright (C) 2010-2015 The Magit Project Developers + +;; Authors: Jonas Bernoulli +;; Sebastian Wiesner +;; Florian Ragwitz +;; Maintainer: Jonas Bernoulli +;; Homepage: https://github.com/magit/git-modes +;; Keywords: convenience vc git +;; Package-Version: 20150330.1048 + +;; 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 this file. If not, see . + +;;; Commentary: + +;; A major mode for editing Git commit messages. + +;;;; Formatting + +;; Highlight the formatting of git commit messages and indicate errors according +;; to the guidelines for commit messages (see +;; http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). +;; +;; Highlight the first line (aka "summary") specially if it exceeds 50 +;; characters (configurable using `git-commit-summary-max-length'). +;; +;; Enable `auto-fill-mode' and set the `fill-column' to 72 according to the +;; aforementioned guidelines (configurable using `git-commit-fill-column'). + +;;;; Headers + +;; Provide commands to insert standard headers into commit messages. +;; +;; - C-c C-s inserts Signed-off-by (`git-commit-signoff'). +;; - C-C C-a inserts Acked-by (`git-commit-ack'). +;; - C-c C-t inserts Tested-by (`git-commit-test'). +;; - C-c C-r inserts Reviewed-by (`git-commit-review'). +;; - C-c C-o inserts Cc (`git-commit-cc'). +;; - C-c C-p inserts Reported-by (`git-commit-reported'). + +;;;; Committing + +;; C-c C-c finishes a commit. +;; +;; Check a buffer for stylistic errors before committing, and ask for +;; confirmation before committing with style errors. + +;;; Code: + +(require 'log-edit) +(require 'ring) +(require 'server) + +;;; Options +;;;; Variables + +(defgroup git-commit nil + "Edit Git commit messages." + :prefix "git-commit-" + :group 'tools) + +(defcustom git-commit-confirm-commit nil + "Whether to ask for confirmation before committing. + +If t, ask for confirmation before creating a commit with style +errors, unless the commit is forced. If nil, never ask for +confirmation before committing." + :group 'git-commit + :type '(choice (const :tag "On style errors" t) + (const :tag "Never" nil))) + +(defcustom git-commit-mode-hook '(turn-on-auto-fill) + "Hook run when entering Git Commit mode." + :options '(turn-on-auto-fill flyspell-mode git-commit-save-message) + :type 'hook + :group 'git-commit) + +(defcustom git-commit-kill-buffer-hook '(git-commit-save-message) + "Hook run when killing a Git Commit mode buffer. +This hook is run by both `git-commit-commit' +and `git-commit-abort'." + :options '(git-commit-save-message) + :type 'hook + :group 'git-commit) + +(defcustom git-commit-summary-max-length 50 + "Fontify characters beyond this column in summary lines as errors." + :group 'git-commit + :type 'number) + +(defcustom git-commit-fill-column 72 + "Automatically wrap commit message lines beyond this column." + :group 'git-commit + :type 'number) + +(defcustom git-commit-known-pseudo-headers + '("Signed-off-by" "Acked-by" "Cc" + "Suggested-by" "Reported-by" "Tested-by" "Reviewed-by") + "A list of git pseudo headers to be highlighted." + :group 'git-commit + :type '(repeat string)) + +;;;; Faces + +(defgroup git-commit-faces nil + "Faces for highlighting Git commit messages." + :prefix "git-commit-" + :group 'git-commit + :group 'faces) + +(defface git-commit-summary-face + '((t :inherit font-lock-type-face)) + "Face used to highlight the summary in git commit messages" + :group 'git-commit-faces) + +(defface git-commit-overlong-summary-face + '((t :inherit font-lock-warning-face)) + "Face used to highlight overlong parts of git commit message summaries" + :group 'git-commit-faces) + +(defface git-commit-nonempty-second-line-face + '((t :inherit font-lock-warning-face)) + "Face used to highlight text on the second line of git commit messages" + :group 'git-commit-faces) + +(defface git-commit-note-face + '((t :inherit font-lock-string-face)) + "Face used to highlight notes in git commit messages" + :group 'git-commit-faces) + +(defface git-commit-pseudo-header-face + '((t :inherit font-lock-string-face)) + "Font used to hightlight pseudo headers in git commit messages" + :group 'git-commit-faces) + +(defface git-commit-known-pseudo-header-face + '((t :inherit font-lock-keyword-face)) + "Face used to hightlight common pseudo headers in git commit messages" + :group 'git-commit-faces) + +(defface git-commit-branch-face + '((t :inherit font-lock-variable-name-face)) + "Face used to highlight the branch name in comments in git commit messages" + :group 'git-commit-faces) + +(defface git-commit-no-branch-face + '((t :inherit git-commit-branch-face)) + "Face used when a commit is going to be made outside of any branches" + :group 'git-commit-faces) + +(defface git-commit-comment-heading-face + '((t :inherit git-commit-known-pseudo-header-face)) + "Face used to highlight section headings in the default +comments in git commit messages" + :group 'git-commit-faces) + +(defface git-commit-comment-file-face + '((t :inherit git-commit-pseudo-header-face)) + "Face used to highlight file names in the default comments in +git commit messages" + :group 'git-commit-faces) + +(defface git-commit-comment-action-face + '((t :inherit git-commit-branch-face)) + "Face used to highlight what has happened to files in the +default comments in git commit messages" + :group 'git-commit-faces) + +;;; Keymap + +(defvar git-commit-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-c C-c") 'git-commit-commit) + (define-key map (kbd "C-c C-k") 'git-commit-abort) + (define-key map (kbd "C-c C-s") 'git-commit-signoff) + (define-key map (kbd "C-c C-a") 'git-commit-ack) + (define-key map (kbd "C-c C-t") 'git-commit-test) + (define-key map (kbd "C-c C-r") 'git-commit-review) + (define-key map (kbd "C-c C-o") 'git-commit-cc) + (define-key map (kbd "C-c C-p") 'git-commit-reported) + (define-key map (kbd "C-c C-i") 'git-commit-suggested) + (define-key map (kbd "C-c M-s") 'git-commit-save-message) + (define-key map (kbd "M-p") 'git-commit-prev-message) + (define-key map (kbd "M-n") 'git-commit-next-message) + (define-key map [remap server-edit] 'git-commit-commit) + (define-key map [remap kill-buffer] 'git-commit-abort) + (define-key map [remap ido-kill-buffer] 'git-commit-abort) + (define-key map [remap iswitchb-kill-buffer] 'git-commit-abort) + ;; Old bindings to avoid confusion + (define-key map (kbd "C-c C-x s") 'git-commit-signoff) + (define-key map (kbd "C-c C-x a") 'git-commit-ack) + (define-key map (kbd "C-c C-x t") 'git-commit-test) + (define-key map (kbd "C-c C-x r") 'git-commit-review) + (define-key map (kbd "C-c C-x o") 'git-commit-cc) + (define-key map (kbd "C-c C-x p") 'git-commit-reported) + map) + "Key map used by `git-commit-mode'.") + +;;; Menu + +(require 'easymenu) +(easy-menu-define git-commit-mode-menu git-commit-mode-map + "Git Commit Mode Menu" + '("Commit" + ["Previous" git-commit-prev-message t] + ["Next" git-commit-next-message t] + "-" + ["Ack" git-commit-ack :active t + :help "Insert an 'Acked-by' header"] + ["Sign-Off" git-commit-signoff :active t + :help "Insert a 'Signed-off-by' header"] + ["Tested-by" git-commit-test :active t + :help "Insert a 'Tested-by' header"] + ["Reviewed-by" git-commit-review :active t + :help "Insert a 'Reviewed-by' header"] + ["CC" git-commit-cc t + :help "Insert a 'Cc' header"] + ["Reported" git-commit-reported :active t + :help "Insert a 'Reported-by' header"] + ["Suggested" git-commit-suggested t + :help "Insert a 'Suggested-by' header"] + "-" + ["Save" git-commit-save-message t] + ["Cancel" git-commit-abort t] + ["Commit" git-commit-commit t])) + +;;; Committing + +(defvar git-commit-commit-hook nil + "Hook run by `git-commit-commit' unless clients exist. +Only use this if you know what you are doing.") + +(defvar git-commit-previous-winconf nil) + +(defmacro git-commit-restore-previous-winconf (&rest body) + "Run BODY and then restore `git-commit-previous-winconf'. +When `git-commit-previous-winconf' is nil or was created from +another frame do nothing." + (declare (indent 0)) + (let ((winconf (make-symbol "winconf")) + (frame (make-symbol "frame"))) + `(let ((,winconf git-commit-previous-winconf) + (,frame (selected-frame))) + ,@body + (when (and ,winconf + (equal ,frame (window-configuration-frame ,winconf))) + (set-window-configuration ,winconf) + (setq git-commit-previous-winconf nil))))) + +(defun git-commit-commit (&optional force) + "Finish editing the commit message and commit. + +Check for stylistic errors in the current commit, and ask the +user for confirmation depending on `git-commit-confirm-commit'. +If FORCE is non-nil or if a raw prefix arg is given, commit +immediately without asking. + +Return t, if the commit was successful, or nil otherwise." + (interactive "P") + (if (and git-commit-confirm-commit + (git-commit-has-style-errors-p) + (not force) + (not (y-or-n-p "Commit despite stylistic errors?"))) + (message "Commit canceled due to stylistic errors.") + (save-buffer) + (run-hooks 'git-commit-kill-buffer-hook) + (remove-hook 'kill-buffer-query-functions + 'git-commit-kill-buffer-noop t) + (git-commit-restore-previous-winconf + (if (git-commit-buffer-clients) + (server-edit) + (run-hook-with-args 'git-commit-commit-hook) + (kill-buffer))))) + +(defun git-commit-abort () + "Abort the commit. +The commit message is saved to the kill ring." + (interactive) + (when (< emacs-major-version 24) + ;; Emacsclient doesn't exit with non-zero when -error is used. + ;; Instead cause Git to error out by feeding it an empty file. + (erase-buffer)) + (save-buffer) + (run-hooks 'git-commit-kill-buffer-hook) + (remove-hook 'kill-buffer-hook 'server-kill-buffer t) + (remove-hook 'kill-buffer-query-functions 'git-commit-kill-buffer-noop t) + (git-commit-restore-previous-winconf + (let ((buffer (current-buffer)) + (clients (git-commit-buffer-clients))) + (if clients + (progn + (dolist (client clients) + (ignore-errors + (server-send-string client "-error Commit aborted by user")) + (delete-process client)) + (when (buffer-live-p buffer) + (kill-buffer buffer))) + (kill-buffer)))) + (accept-process-output nil 0.1) + (message (concat "Commit aborted." + (when (memq 'git-commit-save-message + git-commit-kill-buffer-hook) + " Message saved to `log-edit-comment-ring'.")))) + +(defun git-commit-buffer-clients () + (and (fboundp 'server-edit) + (boundp 'server-buffer-clients) + server-buffer-clients)) + +;;; History + +(defun git-commit-save-message () + "Save current message to `log-edit-comment-ring'." + (interactive) + (let ((message (buffer-substring + (point-min) + (git-commit-find-pseudo-header-position)))) + (when (and (string-match "^\\s-*\\sw" message) + (or (ring-empty-p log-edit-comment-ring) + (not (ring-member log-edit-comment-ring message)))) + ;; if index is nil, we end up cycling back to message we just saved! + (unless log-edit-comment-ring-index + (setq log-edit-comment-ring-index 0)) + (ring-insert log-edit-comment-ring message)))) + +(defun git-commit-prev-message (arg) + "Cycle backward through message history, after saving current message. +With a numeric prefix ARG, go back ARG comments." + (interactive "*p") + (when (and (git-commit-save-message) (> arg 0)) + (setq log-edit-comment-ring-index + (log-edit-new-comment-index + arg (ring-length log-edit-comment-ring)))) + (save-restriction + (narrow-to-region (point-min) (git-commit-find-pseudo-header-position)) + (log-edit-previous-comment arg))) + +(defun git-commit-next-message (arg) + "Cycle forward through message history, after saving current message. +With a numeric prefix ARG, go forward ARG comments." + (interactive "*p") + (git-commit-prev-message (- arg))) + +;;; Headers + +(defun git-commit-find-pseudo-header-position () + "Find the position at which commit pseudo headers should be inserted. + +Those headers usually live at the end of a commit message, but +before any trailing comments git or the user might have +inserted." + (save-excursion + (goto-char (point-max)) + (if (re-search-backward "^[^#\n]" nil t) + ;; we found last non-empty non-comment line, headers go after + (forward-line 1) + ;; there's only blanks & comments, headers go before comments + (goto-char (point-min)) + (and (re-search-forward "^#" nil t) (forward-line 0))) + (skip-chars-forward "\n") + (point))) + +(defun git-commit-determine-pre-for-pseudo-header () + "Find the characters to insert before the pseudo header. +Returns either zero, one or two newlines after computation. + +`point' either points to an empty line (with a non-empty previous +line) or the end of a non-empty line." + (let ((pre "") + (prev-line nil)) + (if (not (eq (point) (point-at-bol))) + (progn + (setq pre (concat pre "\n")) + (setq prev-line (thing-at-point 'line))) + ;; else: (point) is at an empty line + (when (not (eq (point) (point-min))) + (setq prev-line + (save-excursion + (forward-line -1) + (thing-at-point 'line))))) + + ;; we have prev-line now; if it doesn't match any known pseudo + ;; header, add a newline + (when prev-line + (if (not (delq nil (mapcar (lambda (pseudo-header) + (string-match pseudo-header prev-line)) + git-commit-known-pseudo-headers))) + (setq pre (concat pre "\n")))) + pre)) + +(defun git-commit-insert-header (type name email) + "Insert a header into the commit message. +The inserted header has the format 'TYPE: NAME '. + +The header is inserted at the position returned by +`git-commit-find-pseudo-header-position'. When this position +isn't after an existing header or a newline, an extra newline is +inserted before the header." + (let ((header-at (git-commit-find-pseudo-header-position))) + (save-excursion + (goto-char header-at) + (let ((pre (git-commit-determine-pre-for-pseudo-header))) + (insert (format "%s%s: %s <%s>\n" pre type name email)))))) + +(defun git-commit-insert-header-as-self (type) + "Insert a header with the name and email of the current user. +The inserted header has the format 'TYPE: NAME '. +Also see `git-commit-insert-header'." + (git-commit-insert-header + type + (or (getenv "GIT_AUTHOR_NAME") + (getenv "GIT_COMMITTER_NAME") + (ignore-errors (car (process-lines "git" "config" "user.name"))) + user-full-name) + (or (getenv "GIT_AUTHOR_EMAIL") + (getenv "GIT_COMMITTER_EMAIL") + (getenv "EMAIL") + (ignore-errors (car (process-lines "git" "config" "user.email"))) + user-mail-address))) + +(defmacro git-define-git-commit-self (action header) + "Create function git-commit-ACTION. +ACTION will be part of the function name. +HEADER is the actual header to be inserted into the comment." + (let ((func-name (intern (concat "git-commit-" action)))) + `(defun ,func-name () + ,(format "Insert a '%s' header at the end of the commit message. + +The author name and email address used for the header are +retrieved automatically with the same mechanism git uses." + header) + (interactive) + (git-commit-insert-header-as-self ,header)))) + +(git-define-git-commit-self "ack" "Acked-by") +(git-define-git-commit-self "review" "Reviewed-by") +(git-define-git-commit-self "signoff" "Signed-off-by") +(git-define-git-commit-self "test" "Tested-by") + +(defmacro git-define-git-commit (action header) + "Create interactive function git-commit-ACTION. +ACTION will be part of the function name. +HEADER is the actual header to be inserted into the comment." + (let ((func-name (intern (concat "git-commit-" action)))) + `(defun ,func-name (name email) + ,(format "Insert a '%s' header at the end of the commit message. +The value of the header is determined by NAME and EMAIL. + +When called interactively, both NAME and EMAIL are read from the +minibuffer." + header) + (interactive + (list (read-string "Name: ") + (read-string "Email: "))) + (git-commit-insert-header ,header name email)))) + +(git-define-git-commit "cc" "Cc") +(git-define-git-commit "reported" "Reported-by") +(git-define-git-commit "suggested" "Suggested-by") + +(defconst git-commit-comment-headings-alist + '(("Not currently on any branch." . git-commit-no-branch-face) + ("Changes to be committed:" . git-commit-comment-heading-face) + ("Untracked files:" . git-commit-comment-heading-face) + ("Changed but not updated:" . git-commit-comment-heading-face) + ("Changes not staged for commit:" . git-commit-comment-heading-face) + ("Unmerged paths:" . git-commit-comment-heading-face)) + "Headings in message comments. + +The `car' of each cell is the heading text, the `cdr' the face to +use for fontification.") + +(defun git-commit-summary-regexp () + (concat + ;; Skip empty lines or comments before the summary + "\\`\\(?:^\\(?:\\s-*\\|\\s<.*\\)\n\\)*" + ;; The summary line + (format "\\(.\\{0,%d\\}\\)\\(.*\\)" git-commit-summary-max-length) + ;; Non-empty non-comment second line + ;; + ;; For instant highlighting of non-empty second lines in font-lock, + ;; the last capturing group must capture the empty string ("") in + ;; "summary line\n". + ;; That's why the simpler regex "\\(?:\n\\([^\n#].*\\)\\)?", + ;; which captures 'nil', can't be used. + "\\(?:\n\\#\\|\n\\(.*\\)\\)?")) + +(defun git-commit-has-style-errors-p () + "Check whether the current buffer has style errors. + +Return t, if the current buffer has style errors, or nil +otherwise." + (save-excursion + (goto-char (point-min)) + (when (re-search-forward (git-commit-summary-regexp) nil t) + (or (string-match-p ".+" (or (match-string 2) "")) + (string-match-p "^.+$" (or (match-string 3) "")))))) + +;;; Font-Lock + +(defun git-commit-mode-summary-font-lock-keywords (&optional errors) + "Create font lock keywords to fontify the Git summary. + +If ERRORS is non-nil create keywords that highlight errors in the +summary line, not the summary line itself." + (if errors + `(,(git-commit-summary-regexp) + (2 'git-commit-overlong-summary-face t t) + (3 'git-commit-nonempty-second-line-face t t)) + `(,(git-commit-summary-regexp) + (1 'git-commit-summary-face t)))) + +(defun git-commit-mode-heading-keywords () + "Create font lock keywords to fontify comment headings. + +Known comment headings are provided by `git-commit-comment-headings'." + (mapcar (lambda (cell) `(,(format "^\\s<\\s-+\\(%s\\)$" + (regexp-quote (car cell))) + (1 ',(cdr cell) t))) + git-commit-comment-headings-alist)) + +(defun git-commit-mode-font-lock-keywords () + (append + `(("^\\s<.*$" . 'font-lock-comment-face) + ("^\\s<\\s-On branch \\(.*\\)$" (1 'git-commit-branch-face t)) + ("^\\s<\t\\(?:\\([^:\n]+\\):\\s-+\\)?\\(.*\\)$" + (1 'git-commit-comment-action-face t t) + (2 'git-commit-comment-file-face t)) + (,(concat "^\\(" + (regexp-opt git-commit-known-pseudo-headers) + ":\\)\\(\s.*\\)$") + (1 'git-commit-known-pseudo-header-face) + (2 'git-commit-pseudo-header-face)) + ("^\\<\\S-+:\\s-.*$" . 'git-commit-pseudo-header-face) + (eval . (git-commit-mode-summary-font-lock-keywords)) + ("\\[[^\n]+?\\]" (0 'git-commit-note-face t)) ; Notes override summary line + ;; Warnings from overlong lines and nonempty second line override + ;; everything + (eval . (git-commit-mode-summary-font-lock-keywords t))) + (git-commit-mode-heading-keywords))) + +(defun git-commit-font-lock-diff () + "Add font lock on diff." + (save-excursion + (goto-char (point-min)) + (when (re-search-forward "^diff --git" nil t) + (let ((beg (match-beginning 0))) + (let* ((buffer (current-buffer)) + (font-lock-verbose nil) + (font-lock-support-mode nil) + (text (with-temp-buffer + (insert + (with-current-buffer buffer + (buffer-substring-no-properties beg (point-max)))) + (diff-mode) + (font-lock-fontify-buffer) + (let ((pos (point-min)) + next) + (while (setq next (next-single-property-change pos 'face)) + (put-text-property pos next 'font-lock-face + (get-text-property pos 'face)) + (setq pos next))) + (buffer-string)))) + (delete-region beg (point-max)) + (insert text)))))) + +;;; Mode + +(defvar git-commit-mode-syntax-table + (let ((table (make-syntax-table text-mode-syntax-table))) + (modify-syntax-entry ?# "<" table) + (modify-syntax-entry ?\n ">" table) + (modify-syntax-entry ?\r ">" table) + table) + "Syntax table used by `git-commit-mode'.") + +;;;###autoload +(define-derived-mode git-commit-mode text-mode "Git Commit" + "Major mode for editing git commit messages. + +This mode helps with editing git commit messages both by +providing commands to do common tasks, and by highlighting the +basic structure of and errors in git commit messages." + ;; Font locking + (setq font-lock-defaults (list (git-commit-mode-font-lock-keywords) t)) + (set (make-local-variable 'font-lock-multiline) t) + (git-commit-font-lock-diff) + ;; Filling according to the guidelines + (setq fill-column git-commit-fill-column) + ;; Recognize changelog-style paragraphs + (set (make-local-variable 'paragraph-start) + (concat paragraph-start "\\|*\\|(")) + ;; Treat lines starting with a hash/pound as comments + (set (make-local-variable 'comment-start) "#") + (set (make-local-variable 'comment-start-skip) + (concat "^" (regexp-quote comment-start) "+" + "\\s-*")) + (set (make-local-variable 'comment-use-syntax) nil) + ;; Do not remember point location in commit messages + (when (boundp 'save-place) + (setq save-place nil)) + ;; If the commit summary is empty, insert a newline after point + (when (string= "" (buffer-substring-no-properties + (line-beginning-position) + (line-end-position))) + (open-line 1)) + ;; That's what happens when every little detail is commented + (make-local-variable 'log-edit-comment-ring-index) + ;; Make sure `git-commit-abort' cannot be by-passed + (add-hook 'kill-buffer-query-functions + 'git-commit-kill-buffer-noop nil t) + ;; Make the wrong usage info from `server-execute' go way + (run-with-timer 0.01 nil (lambda (m) (message "%s" m)) + (substitute-command-keys + (concat "Type \\[git-commit-commit] " + (let ((n (buffer-file-name))) + (cond ((equal n "TAG_EDITMSG") "to tag") + ((or (equal n "NOTES_EDITMSG") + (equal n "PULLREQ_EDITMSG")) + "when done") + (t "to commit"))) + " (\\[git-commit-abort] to abort).")))) + +(defun git-commit-kill-buffer-noop () + (message + (substitute-command-keys + "Don't kill this buffer. Instead abort using \\[git-commit-abort].")) + nil) + +(defun git-commit-mode-flyspell-verify () + (not (nth 4 (syntax-ppss)))) ; not inside a comment + +(eval-after-load 'flyspell + '(put 'git-commit-mode 'flyspell-mode-predicate + 'git-commit-mode-flyspell-verify)) + +;;;###autoload +(add-to-list 'auto-mode-alist '("/MERGE_MSG\\'" . git-commit-mode)) +;;;###autoload +(add-to-list 'auto-mode-alist + '("/\\(?:COMMIT\\|NOTES\\|TAG\\|PULLREQ\\)_EDITMSG\\'" + . git-commit-mode)) + +(defun git-commit-auto-mode-enable () + (message "git-commit-auto-mode-enable is obsolete and doesn't do anything")) +(make-obsolete 'git-commit-auto-mode-enable "This mode is a noop now" "") + +(provide 'git-commit-mode) +;; Local Variables: +;; indent-tabs-mode: nil +;; End: +;;; git-commit-mode.el ends here diff --git a/emacs.d/elpa/git-gutter-20141007.2327/git-gutter-autoloads.el b/emacs.d/elpa/git-gutter-20141007.2327/git-gutter-autoloads.el deleted file mode 100644 index fa5bd62..0000000 --- a/emacs.d/elpa/git-gutter-20141007.2327/git-gutter-autoloads.el +++ /dev/null @@ -1,99 +0,0 @@ -;;; git-gutter-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "git-gutter" "git-gutter.el" (21569 50819 0 -;;;;;; 0)) -;;; Generated autoloads from git-gutter.el - -(autoload 'git-gutter:linum-setup "git-gutter" "\ -Setup for linum-mode. - -\(fn)" nil nil) - -(autoload 'git-gutter-mode "git-gutter" "\ -Git-Gutter mode - -\(fn &optional ARG)" t nil) - -(defvar global-git-gutter-mode nil "\ -Non-nil if Global-Git-Gutter mode is enabled. -See the command `global-git-gutter-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `global-git-gutter-mode'.") - -(custom-autoload 'global-git-gutter-mode "git-gutter" nil) - -(autoload 'global-git-gutter-mode "git-gutter" "\ -Toggle Git-Gutter mode in all buffers. -With prefix ARG, enable Global-Git-Gutter mode if ARG is positive; -otherwise, disable it. If called from Lisp, enable the mode if -ARG is omitted or nil. - -Git-Gutter mode is enabled in all buffers where -`git-gutter--turn-on' would do it. -See `git-gutter-mode' for more information on Git-Gutter mode. - -\(fn &optional ARG)" t nil) - -(autoload 'git-gutter:revert-hunk "git-gutter" "\ -Revert current hunk. - -\(fn)" t nil) - -(autoload 'git-gutter:stage-hunk "git-gutter" "\ -Stage this hunk like 'git add -p'. - -\(fn)" t nil) - -(autoload 'git-gutter:popup-hunk "git-gutter" "\ -Popup current diff hunk. - -\(fn &optional DIFFINFO)" t nil) - -(autoload 'git-gutter:next-hunk "git-gutter" "\ -Move to next diff hunk - -\(fn ARG)" t nil) - -(autoload 'git-gutter:previous-hunk "git-gutter" "\ -Move to previous diff hunk - -\(fn ARG)" t nil) - -(autoload 'git-gutter "git-gutter" "\ -Show diff information in gutter - -\(fn)" t nil) - -(autoload 'git-gutter:clear "git-gutter" "\ -Clear diff information in gutter. - -\(fn)" t nil) - -(autoload 'git-gutter:toggle "git-gutter" "\ -Toggle to show diff information. - -\(fn)" t nil) - -(autoload 'git-gutter:set-start-revision "git-gutter" "\ -Set start revision. If `start-rev' is nil or empty string then reset -start revision. - -\(fn START-REV)" t nil) - -(autoload 'git-gutter:update-all-windows "git-gutter" "\ -Update git-gutter informations for all visible buffers. - -\(fn)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; git-gutter-autoloads.el ends here diff --git a/emacs.d/elpa/git-gutter-20141007.2327/git-gutter-pkg.el b/emacs.d/elpa/git-gutter-20141007.2327/git-gutter-pkg.el deleted file mode 100644 index 84462c9..0000000 --- a/emacs.d/elpa/git-gutter-20141007.2327/git-gutter-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "git-gutter" "20141007.2327" "Port of Sublime Text plugin GitGutter" '((cl-lib "0.5") (emacs "24")) :url "https://github.com/syohex/emacs-git-gutter") diff --git a/emacs.d/elpa/git-gutter-20141007.2327/git-gutter.el b/emacs.d/elpa/git-gutter-20141007.2327/git-gutter.el deleted file mode 100644 index baad89e..0000000 --- a/emacs.d/elpa/git-gutter-20141007.2327/git-gutter.el +++ /dev/null @@ -1,876 +0,0 @@ -;;; git-gutter.el --- Port of Sublime Text plugin GitGutter -*- lexical-binding: t; -*- - -;; Copyright (C) 2014 by Syohei YOSHIDA - -;; Author: Syohei YOSHIDA -;; URL: https://github.com/syohex/emacs-git-gutter -;; Version: 20141007.2327 -;; X-Original-Version: 0.77 -;; Package-Requires: ((cl-lib "0.5") (emacs "24")) - -;; 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: -;; -;; Port of GitGutter which is a plugin of Sublime Text - -;;; Code: - -(require 'cl-lib) - -(defgroup git-gutter nil - "Port GitGutter" - :prefix "git-gutter:" - :group 'vc) - -(defcustom git-gutter:window-width nil - "Character width of gutter window. Emacs mistakes width of some characters. -It is better to explicitly assign width to this variable, if you use full-width -character for signs of changes" - :type 'integer - :group 'git-gutter) - -(defcustom git-gutter:diff-option "" - "Option of 'git diff'" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:mercurial-diff-option "" - "Option of 'hg diff'" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:update-commands - '(ido-switch-buffer helm-buffers-list) - "Each command of this list is executed, gutter information is updated." - :type '(list (function :tag "Update command") - (repeat :inline t (function :tag "Update command"))) - :group 'git-gutter) - -(defcustom git-gutter:update-windows-commands - '(kill-buffer ido-kill-buffer) - "Each command of this list is executed, gutter information is updated and -gutter information of other windows." - :type '(list (function :tag "Update command") - (repeat :inline t (function :tag "Update command"))) - :group 'git-gutter) - -(defcustom git-gutter:update-hooks - '(after-save-hook after-revert-hook find-file-hook after-change-major-mode-hook - text-scale-mode-hook magit-revert-buffer-hook) - "hook points of updating gutter" - :type '(list (hook :tag "HookPoint") - (repeat :inline t (hook :tag "HookPoint"))) - :group 'git-gutter) - -(defcustom git-gutter:separator-sign nil - "Separator sign" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:modified-sign "=" - "Modified sign" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:added-sign "+" - "Added sign" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:deleted-sign "-" - "Deleted sign" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:unchanged-sign nil - "Unchanged sign" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:hide-gutter nil - "Hide gutter if there are no changes" - :type 'boolean - :group 'git-gutter) - -(defcustom git-gutter:lighter " GitGutter" - "Minor mode lighter in mode-line" - :type 'string - :group 'git-gutter) - -(defcustom git-gutter:verbosity 0 - "Log/message level. 4 means all, 0 nothing." - :type 'integer - :group 'git-gutter) - -(defface git-gutter:separator - '((t (:foreground "cyan" :weight bold))) - "Face of separator" - :group 'git-gutter) - -(defface git-gutter:modified - '((t (:foreground "magenta" :weight bold))) - "Face of modified" - :group 'git-gutter) - -(defface git-gutter:added - '((t (:foreground "green" :weight bold))) - "Face of added" - :group 'git-gutter) - -(defface git-gutter:deleted - '((t (:foreground "red" :weight bold))) - "Face of deleted" - :group 'git-gutter) - -(defface git-gutter:unchanged - '((t (:background "yellow"))) - "Face of unchanged" - :group 'git-gutter) - -(defcustom git-gutter:disabled-modes nil - "A list of modes which `global-git-gutter-mode' should be disabled." - :type '(repeat symbol) - :group 'git-gutter) - -(defcustom git-gutter:handled-backends '(git hg) - "List of version control backends for which `git-gutter.el` will be used. -`git' and `hg' are supported." - :type '(repeat symbol) - :group 'git-gutter) - -(defvar git-gutter:view-diff-function 'git-gutter:view-diff-infos - "Function of viewing changes") - -(defvar git-gutter:clear-function 'git-gutter:clear-diff-infos - "Function of clear changes") - -(defvar git-gutter:init-function 'nil - "Function of initialize") - -(defcustom git-gutter-mode-on-hook nil - "Hook run when git-gutter mode enable" - :type 'hook - :group 'git-gutter) - -(defcustom git-gutter-mode-off-hook nil - "Hook run when git-gutter mode disable" - :type 'hook - :group 'git-gutter) - -(defvar git-gutter:enabled nil) -(defvar git-gutter:toggle-flag t) -(defvar git-gutter:force nil) -(defvar git-gutter:diffinfos nil) -(defvar git-gutter:has-indirect-buffers nil) -(defvar git-gutter:real-this-command nil) -(defvar git-gutter:linum-enabled nil) -(defvar git-gutter:linum-prev-window-margin nil) -(defvar git-gutter:vcs-type nil) -(defvar git-gutter:start-revision nil) -(defvar git-gutter:revision-history nil) - -(defvar git-gutter:popup-buffer "*git-gutter:diff*") -(defvar git-gutter:ignore-commands - '(minibuffer-complete-and-exit - exit-minibuffer - ido-exit-minibuffer - helm-maybe-exit-minibuffer - helm-confirm-and-exit-minibuffer)) - -(defmacro git-gutter:awhen (test &rest body) - "Anaphoric when." - (declare (indent 1)) - `(let ((it ,test)) - (when it ,@body))) - -(defsubst git-gutter:execute-command (cmd output &rest args) - (apply 'process-file cmd nil output nil args)) - -(defun git-gutter:in-git-repository-p () - (when (executable-find "git") - (with-temp-buffer - (when (zerop (git-gutter:execute-command "git" t "rev-parse" "--is-inside-work-tree")) - (goto-char (point-min)) - (string= "true" (buffer-substring-no-properties - (point) (line-end-position))))))) - -(defun git-gutter:in-hg-repository-p () - (and (executable-find "hg") - (locate-dominating-file default-directory ".hg") - (zerop (git-gutter:execute-command "hg" nil "root")) - (not (string-match-p "/\.hg/" default-directory)))) - -(defsubst git-gutter:vcs-check-function (vcs) - (cl-case vcs - (git 'git-gutter:in-git-repository-p) - (hg 'git-gutter:in-hg-repository-p))) - -(defsubst git-gutter:in-repository-p () - (cl-loop for vcs in git-gutter:handled-backends - for check-func = (git-gutter:vcs-check-function vcs) - when (funcall check-func) - return (set (make-local-variable 'git-gutter:vcs-type) vcs))) - -(defsubst git-gutter:changes-to-number (str) - (if (string= str "") - 1 - (string-to-number str))) - -(defsubst git-gutter:make-diffinfo (type content start end) - (list :type type :content content :start-line start :end-line end)) - -(defsubst git-gutter:base-file () - (buffer-file-name (buffer-base-buffer))) - -(defun git-gutter:diff-content () - (save-excursion - (goto-char (line-beginning-position)) - (let ((curpoint (point))) - (forward-line 1) - (if (re-search-forward "^@@" nil t) - (backward-char 3) ;; for '@@' - (goto-char (point-max))) - (buffer-substring curpoint (point))))) - -(defun git-gutter:process-diff-output (proc) - (when (buffer-live-p (process-buffer proc)) - (let ((regexp "^@@ -\\(?:[0-9]+\\),?\\([0-9]*\\) \\+\\([0-9]+\\),?\\([0-9]*\\) @@")) - (with-current-buffer (process-buffer proc) - (goto-char (point-min)) - (cl-loop while (re-search-forward regexp nil t) - for new-line = (string-to-number (match-string 2)) - for orig-changes = (git-gutter:changes-to-number (match-string 1)) - for new-changes = (git-gutter:changes-to-number (match-string 3)) - for type = (cond ((zerop orig-changes) 'added) - ((zerop new-changes) 'deleted) - (t 'modified)) - for end-line = (if (eq type 'deleted) - new-line - (1- (+ new-line new-changes))) - for content = (git-gutter:diff-content) - collect - (let ((start (if (zerop new-line) 1 new-line)) - (end (if (zerop end-line) 1 end-line))) - (git-gutter:make-diffinfo type content start end))))))) - -(defsubst git-gutter:window-margin () - (or git-gutter:window-width (git-gutter:longest-sign-width))) - -(defun git-gutter:set-window-margin (width) - (when (and (not git-gutter:linum-enabled) (>= width 0)) - (let ((curwin (get-buffer-window))) - (set-window-margins curwin width (cdr (window-margins curwin)))))) - -(defsubst git-gutter:revision-set-p () - (and git-gutter:start-revision (not (string= git-gutter:start-revision "")))) - -(defun git-gutter:git-diff-arguments (file) - (let (args) - (unless (string= git-gutter:diff-option "") - (setq args (nreverse (split-string git-gutter:diff-option)))) - (when (git-gutter:revision-set-p) - (push git-gutter:start-revision args)) - (nreverse (cons file args)))) - -(defun git-gutter:start-git-diff-process (file proc-buf) - (let ((arg (git-gutter:git-diff-arguments file))) - (apply 'start-file-process "git-gutter" proc-buf - "git" "--no-pager" "diff" "--no-color" "--no-ext-diff" "--relative" "-U0" - arg))) - -(defun git-gutter:hg-diff-arguments (file) - (let (args) - (unless (string= git-gutter:mercurial-diff-option "") - (setq args (nreverse (split-string git-gutter:mercurial-diff-option)))) - (when (git-gutter:revision-set-p) - (push "-r" args) - (push git-gutter:start-revision args)) - (nreverse (cons file args)))) - -(defsubst git-gutter:start-hg-diff-process (file proc-buf) - (let ((args (git-gutter:hg-diff-arguments file))) - (apply 'start-file-process "git-gutter" proc-buf "hg" "diff" "-U0" args))) - -(defun git-gutter:start-diff-process1 (file proc-buf) - (cl-case git-gutter:vcs-type - (git (git-gutter:start-git-diff-process file proc-buf)) - (hg (git-gutter:start-hg-diff-process file proc-buf)))) - -(defun git-gutter:start-diff-process (curfile proc-buf) - (git-gutter:set-window-margin (git-gutter:window-margin)) - (let ((file (git-gutter:base-file)) ;; for tramp - (curbuf (current-buffer)) - (process (git-gutter:start-diff-process1 curfile proc-buf))) - (set-process-query-on-exit-flag process nil) - (set-process-sentinel - process - (lambda (proc _event) - (when (eq (process-status proc) 'exit) - (setq git-gutter:enabled nil) - (let ((diffinfos (git-gutter:process-diff-output proc))) - (when (buffer-live-p curbuf) - (with-current-buffer curbuf - (git-gutter:update-diffinfo diffinfos) - (when git-gutter:has-indirect-buffers - (git-gutter:update-indirect-buffers file)) - (setq git-gutter:enabled t))) - (kill-buffer proc-buf))))))) - -(defsubst git-gutter:gutter-sperator () - (when git-gutter:separator-sign - (propertize git-gutter:separator-sign 'face 'git-gutter:separator))) - -(defun git-gutter:before-string (sign) - (let ((gutter-sep (concat sign (git-gutter:gutter-sperator)))) - (propertize " " 'display `((margin left-margin) ,gutter-sep)))) - -(defsubst git-gutter:select-face (type) - (cl-case type - (added 'git-gutter:added) - (modified 'git-gutter:modified) - (deleted 'git-gutter:deleted))) - -(defsubst git-gutter:select-sign (type) - (cl-case type - (added git-gutter:added-sign) - (modified git-gutter:modified-sign) - (deleted git-gutter:deleted-sign))) - -(defun git-gutter:propertized-sign (type) - (let ((sign (git-gutter:select-sign type)) - (face (git-gutter:select-face type))) - (propertize sign 'face face))) - -(defsubst git-gutter:linum-get-overlay (pos) - (cl-loop for ov in (overlays-in pos pos) - when (overlay-get ov 'linum-str) - return ov)) - -(defun git-gutter:view-at-pos-linum (sign pos) - (git-gutter:awhen (git-gutter:linum-get-overlay pos) - (overlay-put it 'before-string - (propertize " " - 'display - `((margin left-margin) - ,(concat sign (overlay-get it 'linum-str))))))) - -(defun git-gutter:view-at-pos (sign pos) - (if git-gutter:linum-enabled - (git-gutter:view-at-pos-linum sign pos) - (let ((ov (make-overlay pos pos))) - (overlay-put ov 'before-string (git-gutter:before-string sign)) - (overlay-put ov 'git-gutter t)))) - -(defsubst git-gutter:sign-width (sign) - (cl-loop for s across sign - sum (char-width s))) - -(defun git-gutter:longest-sign-width () - (let ((signs (list git-gutter:modified-sign - git-gutter:added-sign - git-gutter:deleted-sign))) - (when git-gutter:unchanged-sign - (push git-gutter:unchanged-sign signs)) - (+ (apply 'max (mapcar 'git-gutter:sign-width signs)) - (git-gutter:sign-width git-gutter:separator-sign)))) - -(defun git-gutter:view-for-unchanged () - (save-excursion - (let ((sign (if git-gutter:unchanged-sign - (propertize git-gutter:unchanged-sign - 'face 'git-gutter:unchanged) - " "))) - (goto-char (point-min)) - (while (not (eobp)) - (git-gutter:view-at-pos sign (point)) - (forward-line 1))))) - -(defsubst git-gutter:check-file-and-directory () - (and (git-gutter:base-file) - default-directory (file-directory-p default-directory))) - -(defun git-gutter:pre-command-hook () - (unless (memq this-command git-gutter:ignore-commands) - (setq git-gutter:real-this-command this-command))) - -(defun git-gutter:update-other-window-buffers (curwin curbuf) - (save-selected-window - (cl-loop for win in (window-list) - unless (eq win curwin) - do - (progn - (select-window win) - (let ((win-width (window-margins win))) - (unless (car win-width) - (if (eq (current-buffer) curbuf) - (git-gutter:set-window-margin (git-gutter:window-margin)) - (git-gutter:update-diffinfo git-gutter:diffinfos)))))))) - -(defun git-gutter:post-command-hook () - (cond ((memq git-gutter:real-this-command git-gutter:update-commands) - (git-gutter)) - ((memq git-gutter:real-this-command git-gutter:update-windows-commands) - (git-gutter) - (unless global-linum-mode - (git-gutter:update-other-window-buffers (selected-window) (current-buffer)))))) - -(defsubst git-gutter:diff-process-buffer (curfile) - (concat " *git-gutter-" curfile "-*")) - -(defun git-gutter:kill-buffer-hook () - (let ((buf (git-gutter:diff-process-buffer (git-gutter:base-file)))) - (git-gutter:awhen (get-buffer buf) - (kill-buffer it)))) - -(defsubst git-gutter:linum-padding () - (cl-loop repeat (git-gutter:window-margin) - collect " " into paddings - finally return (apply 'concat paddings))) - -(defun git-gutter:linum-prepend-spaces () - (save-excursion - (goto-char (point-min)) - (let ((padding (git-gutter:linum-padding))) - (while (not (eobp)) - (git-gutter:view-at-pos-linum padding (point)) - (forward-line 1))))) - -(defun git-gutter:linum-update (diffinfos) - (let ((linum-width (car (window-margins)))) - (when linum-width - (git-gutter:linum-prepend-spaces) - (git-gutter:view-set-overlays diffinfos) - (let ((curwin (get-buffer-window)) - (margin (+ linum-width (git-gutter:window-margin)))) - (setq git-gutter:linum-prev-window-margin margin) - (set-window-margins curwin margin (cdr (window-margins curwin))))))) - -(defun git-gutter:linum-init () - (set (make-local-variable 'git-gutter:linum-enabled) t) - (make-local-variable 'git-gutter:linum-prev-window-margin)) - -;;;###autoload -(defun git-gutter:linum-setup () - "Setup for linum-mode." - (setq git-gutter:init-function 'git-gutter:linum-init - git-gutter:view-diff-function nil) - (defadvice linum-update-window (after git-gutter:linum-update-window activate) - (if (and git-gutter-mode git-gutter:diffinfos) - (git-gutter:linum-update git-gutter:diffinfos) - (let ((curwin (get-buffer-window)) - (margin (or git-gutter:linum-prev-window-margin - (car (window-margins))))) - (set-window-margins curwin margin (cdr (window-margins curwin))))))) - -;;;###autoload -(define-minor-mode git-gutter-mode - "Git-Gutter mode" - :group 'git-gutter - :init-value nil - :global nil - :lighter git-gutter:lighter - (if git-gutter-mode - (if (and (git-gutter:check-file-and-directory) - (git-gutter:in-repository-p)) - (progn - (when git-gutter:init-function - (funcall git-gutter:init-function)) - (make-local-variable 'git-gutter:enabled) - (set (make-local-variable 'git-gutter:has-indirect-buffers) nil) - (set (make-local-variable 'git-gutter:toggle-flag) t) - (make-local-variable 'git-gutter:diffinfos) - (set (make-local-variable 'git-gutter:start-revision) nil) - (add-hook 'kill-buffer-hook 'git-gutter:kill-buffer-hook nil t) - (add-hook 'pre-command-hook 'git-gutter:pre-command-hook) - (add-hook 'post-command-hook 'git-gutter:post-command-hook nil t) - (dolist (hook git-gutter:update-hooks) - (add-hook hook 'git-gutter nil t)) - (git-gutter)) - (when (> git-gutter:verbosity 2) - (message "Here is not Git/Mercurial work tree")) - (git-gutter-mode -1)) - (remove-hook 'kill-buffer-hook 'git-gutter:kill-buffer-hook t) - (remove-hook 'pre-command-hook 'git-gutter:pre-command-hook) - (remove-hook 'post-command-hook 'git-gutter:post-command-hook t) - (dolist (hook git-gutter:update-hooks) - (remove-hook hook 'git-gutter t)) - (git-gutter:clear))) - -(defun git-gutter--turn-on () - (when (and (buffer-file-name) - (not (memq major-mode git-gutter:disabled-modes))) - (git-gutter-mode +1))) - -;;;###autoload -(define-global-minor-mode global-git-gutter-mode git-gutter-mode git-gutter--turn-on - :group 'git-gutter) - -(defsubst git-gutter:show-gutter-p (diffinfos) - (if git-gutter:hide-gutter - (or diffinfos git-gutter:unchanged-sign) - (or global-git-gutter-mode git-gutter:unchanged-sign diffinfos))) - -(defun git-gutter:show-gutter (diffinfos) - (when (git-gutter:show-gutter-p diffinfos) - (git-gutter:set-window-margin (git-gutter:window-margin)))) - -(defun git-gutter:view-set-overlays (diffinfos) - (save-excursion - (goto-char (point-min)) - (cl-loop with curline = 1 - for info in diffinfos - for start-line = (plist-get info :start-line) - for end-line = (plist-get info :end-line) - for type = (plist-get info :type) - for sign = (git-gutter:propertized-sign type) - do - (progn - (forward-line (- start-line curline)) - (cl-case type - ((modified added) - (setq curline start-line) - (while (and (<= curline end-line) (not (eobp))) - (git-gutter:view-at-pos sign (point)) - (cl-incf curline) - (forward-line 1))) - (deleted - (git-gutter:view-at-pos sign (point)) - (forward-line 1) - (setq curline (1+ end-line)))))))) - -(defun git-gutter:view-diff-infos (diffinfos) - (when diffinfos - (when (or git-gutter:unchanged-sign git-gutter:separator-sign) - (git-gutter:view-for-unchanged)) - (git-gutter:view-set-overlays diffinfos)) - (git-gutter:show-gutter diffinfos)) - -(defsubst git-gutter:reset-window-margin-p () - (or git-gutter:force - git-gutter:hide-gutter - (not global-git-gutter-mode))) - -(defun git-gutter:clear-diff-infos () - (when (git-gutter:reset-window-margin-p) - (git-gutter:set-window-margin 0)) - (remove-overlays (point-min) (point-max) 'git-gutter t)) - -(defsubst git-gutter:clear-gutter () - (when git-gutter:clear-function - (funcall git-gutter:clear-function))) - -(defun git-gutter:update-diffinfo (diffinfos) - (save-restriction - (widen) - (git-gutter:clear-gutter) - (setq git-gutter:diffinfos diffinfos) - (when git-gutter:view-diff-function - (funcall git-gutter:view-diff-function diffinfos)))) - -(defun git-gutter:search-near-diff-index (diffinfos is-reverse) - (cl-loop with current-line = (line-number-at-pos) - with cmp-fn = (if is-reverse '> '<) - for diffinfo in (if is-reverse (reverse diffinfos) diffinfos) - for index = 0 then (1+ index) - for start-line = (plist-get diffinfo :start-line) - when (funcall cmp-fn current-line start-line) - return (if is-reverse - (1- (- (length diffinfos) index)) - index))) - -(defun git-gutter:search-here-diffinfo (diffinfos) - (cl-loop with current-line = (line-number-at-pos) - for diffinfo in diffinfos - for start = (plist-get diffinfo :start-line) - for end = (or (plist-get diffinfo :end-line) (1+ start)) - when (and (>= current-line start) (<= current-line end)) - return diffinfo)) - -(defun git-gutter:collect-deleted-line (str) - (with-temp-buffer - (insert str) - (goto-char (point-min)) - (cl-loop while (re-search-forward "^-\\(.*?\\)$" nil t) - collect (match-string 1) into deleted-lines - finally return deleted-lines))) - -(defun git-gutter:delete-added-lines (start-line end-line) - (forward-line (1- start-line)) - (let ((start-point (point))) - (forward-line (1+ (- end-line start-line))) - (delete-region start-point (point)))) - -(defun git-gutter:insert-deleted-lines (content) - (dolist (line (git-gutter:collect-deleted-line content)) - (insert (concat line "\n")))) - -(defsubst git-gutter:delete-from-first-line-p (start-line end-line) - (and (not (= start-line 1)) (not (= end-line 1)))) - -(defun git-gutter:do-revert-hunk (diffinfo) - (save-excursion - (goto-char (point-min)) - (let ((start-line (plist-get diffinfo :start-line)) - (end-line (plist-get diffinfo :end-line)) - (content (plist-get diffinfo :content))) - (cl-case (plist-get diffinfo :type) - (added (git-gutter:delete-added-lines start-line end-line)) - (deleted (when (git-gutter:delete-from-first-line-p start-line end-line) - (forward-line start-line)) - (git-gutter:insert-deleted-lines content)) - (modified (git-gutter:delete-added-lines start-line end-line) - (git-gutter:insert-deleted-lines content)))))) - -(defsubst git-gutter:popup-buffer-window () - (get-buffer-window (get-buffer git-gutter:popup-buffer))) - -;;;###autoload -(defun git-gutter:revert-hunk () - "Revert current hunk." - (interactive) - (git-gutter:awhen (git-gutter:search-here-diffinfo git-gutter:diffinfos) - (save-window-excursion - (git-gutter:popup-hunk it) - (when (yes-or-no-p "Revert current hunk ?") - (git-gutter:do-revert-hunk it) - (save-buffer)) - (delete-window (git-gutter:popup-buffer-window))))) - -(defun git-gutter:extract-hunk-header () - (git-gutter:awhen (git-gutter:base-file) - (with-temp-buffer - (when (zerop (git-gutter:execute-command "git" t "diff" "--relative" it)) - (goto-char (point-min)) - (forward-line 4) - (buffer-substring-no-properties (point-min) (point)))))) - -(defun git-gutter:read-hunk-header (header) - (let ((header-regexp "^@@ -\\([0-9]+\\),?\\([0-9]*\\) \\+\\([0-9]+\\),?\\([0-9]*\\) @@")) - (when (string-match header-regexp header) - (list (string-to-number (match-string 1 header)) - (git-gutter:changes-to-number (match-string 2 header)) - (string-to-number (match-string 3 header)) - (git-gutter:changes-to-number (match-string 4 header)))))) - -(defun git-gutter:convert-hunk-header (type) - (let ((header (buffer-substring-no-properties (point) (line-end-position)))) - (delete-region (point) (line-end-position)) - (cl-destructuring-bind - (orig-line orig-changes new-line new-changes) (git-gutter:read-hunk-header header) - (cl-case type - (added (setq new-line (1+ orig-line))) - (t (setq new-line orig-line))) - (let ((new-header (format "@@ -%d,%d +%d,%d @@" - orig-line orig-changes new-line new-changes))) - (insert new-header))))) - -(defun git-gutter:insert-staging-hunk (hunk type) - (save-excursion - (insert hunk "\n")) - (git-gutter:convert-hunk-header type)) - -(defun git-gutter:apply-directory-option () - (let ((root (locate-dominating-file default-directory ".git"))) - (file-name-directory (file-relative-name (git-gutter:base-file) root)))) - -(defun git-gutter:do-stage-hunk (diff-info) - (let ((content (plist-get diff-info :content)) - (type (plist-get diff-info :type)) - (header (git-gutter:extract-hunk-header)) - (patch (make-temp-name "git-gutter"))) - (when header - (with-temp-file patch - (insert header) - (git-gutter:insert-staging-hunk content type)) - (let ((dir-option (git-gutter:apply-directory-option)) - (options (list "--cached" patch))) - (when dir-option - (setq options (cons "--directory" (cons dir-option options)))) - (unless (zerop (apply 'git-gutter:execute-command - "git" nil "apply" "--unidiff-zero" - options)) - (message "Failed: stating this hunk")) - (delete-file patch))))) - -;;;###autoload -(defun git-gutter:stage-hunk () - "Stage this hunk like 'git add -p'." - (interactive) - (git-gutter:awhen (git-gutter:search-here-diffinfo git-gutter:diffinfos) - (save-window-excursion - (git-gutter:popup-hunk it) - (when (yes-or-no-p "Stage current hunk ?") - (git-gutter:do-stage-hunk it) - (git-gutter)) - (delete-window (git-gutter:popup-buffer-window))))) - -(defun git-gutter:update-popuped-buffer (diffinfo) - (with-current-buffer (get-buffer-create git-gutter:popup-buffer) - (view-mode -1) - (setq buffer-read-only nil) - (erase-buffer) - (insert (plist-get diffinfo :content)) - (insert "\n") - (goto-char (point-min)) - (diff-mode) - (view-mode +1) - (current-buffer))) - -;;;###autoload -(defun git-gutter:popup-hunk (&optional diffinfo) - "Popup current diff hunk." - (interactive) - (git-gutter:awhen (or diffinfo - (git-gutter:search-here-diffinfo git-gutter:diffinfos)) - (save-selected-window - (pop-to-buffer (git-gutter:update-popuped-buffer it))))) - -;;;###autoload -(defun git-gutter:next-hunk (arg) - "Move to next diff hunk" - (interactive "p") - (if (not git-gutter:diffinfos) - (when (> git-gutter:verbosity 3) - (message "There are no changes!!")) - (let* ((is-reverse (< arg 0)) - (diffinfos git-gutter:diffinfos) - (len (length diffinfos)) - (index (git-gutter:search-near-diff-index diffinfos is-reverse)) - (real-index (if index - (let ((next (if is-reverse (1+ index) (1- index)))) - (mod (+ arg next) len)) - (if is-reverse (1- len) 0))) - (diffinfo (nth real-index diffinfos))) - (goto-char (point-min)) - (forward-line (1- (plist-get diffinfo :start-line))) - (when (buffer-live-p (get-buffer git-gutter:popup-buffer)) - (git-gutter:update-popuped-buffer diffinfo))))) - -;;;###autoload -(defun git-gutter:previous-hunk (arg) - "Move to previous diff hunk" - (interactive "p") - (git-gutter:next-hunk (- arg))) - -(defalias 'git-gutter:next-diff 'git-gutter:next-hunk) -(make-obsolete 'git-gutter:next-diff 'git-gutter:next-hunk "0.60") -(defalias 'git-gutter:previous-diff 'git-gutter:previous-hunk) -(make-obsolete 'git-gutter:previous-diff 'git-gutter:previous-hunk "0.60") -(defalias 'git-gutter:popup-diff 'git-gutter:popup-hunk) -(make-obsolete 'git-gutter:popup-diff 'git-gutter:popup-hunk "0.60") - -(defun git-gutter:update-indirect-buffers (orig-file) - (cl-loop with diffinfos = git-gutter:diffinfos - for win in (window-list) - for buf = (window-buffer win) - for base = (buffer-base-buffer buf) - when (and base (string= (buffer-file-name base) orig-file)) - do - (with-current-buffer buf - (git-gutter:update-diffinfo diffinfos)))) - -;;;###autoload -(defun git-gutter () - "Show diff information in gutter" - (interactive) - (when (or git-gutter:force git-gutter:toggle-flag) - (let* ((file (git-gutter:base-file)) - (proc-buf (git-gutter:diff-process-buffer file))) - (when (and (called-interactively-p 'interactive) (get-buffer proc-buf)) - (kill-buffer proc-buf)) - (when (and file (file-exists-p file) (not (get-buffer proc-buf))) - (git-gutter:start-diff-process (file-name-nondirectory file) - (get-buffer-create proc-buf)))))) - -(defadvice make-indirect-buffer (before git-gutter:has-indirect-buffers activate) - (when (and git-gutter-mode (not (buffer-base-buffer))) - (setq git-gutter:has-indirect-buffers t))) - -(defadvice vc-revert (after git-gutter:vc-revert activate) - (when git-gutter-mode - (run-with-idle-timer 0.1 nil 'git-gutter))) - -;; `quit-window' and `switch-to-buffer' are called from other -;; commands. So we should use `defadvice' instead of `post-command-hook'. -(defadvice quit-window (after git-gutter:quit-window activate) - (when git-gutter-mode - (git-gutter))) - -(defadvice switch-to-buffer (after git-gutter:switch-to-buffer activate) - (when git-gutter-mode - (git-gutter))) - -;;;###autoload -(defun git-gutter:clear () - "Clear diff information in gutter." - (interactive) - (save-restriction - (widen) - (git-gutter:clear-gutter)) - (setq git-gutter:enabled nil - git-gutter:diffinfos nil)) - -;;;###autoload -(defun git-gutter:toggle () - "Toggle to show diff information." - (interactive) - (let ((git-gutter:force t)) - (if git-gutter:enabled - (progn - (git-gutter:clear) - (setq git-gutter-mode nil - git-gutter:toggle-flag nil)) - (git-gutter) - (setq git-gutter-mode t - git-gutter:toggle-flag t)) - (force-mode-line-update))) - -(defun git-gutter:revision-valid-p (revision) - (zerop (cl-case git-gutter:vcs-type - (git (git-gutter:execute-command "git" nil - "rev-parse" "--quiet" "--verify" - revision)) - (hg (git-gutter:execute-command "hg" nil "id" "-r" revision))))) - -;;;###autoload -(defun git-gutter:set-start-revision (start-rev) - "Set start revision. If `start-rev' is nil or empty string then reset -start revision." - (interactive - (list (read-string "Start Revision: " - nil 'git-gutter:revision-history))) - (when (and start-rev (not (string= start-rev ""))) - (unless (git-gutter:revision-valid-p start-rev) - (error "Revision '%s' is not valid." start-rev))) - (setq git-gutter:start-revision start-rev) - (git-gutter)) - -;;;###autoload -(defun git-gutter:update-all-windows () - "Update git-gutter informations for all visible buffers." - (interactive) - (dolist (win (window-list)) - (let ((buf (window-buffer win))) - (with-current-buffer buf - (when git-gutter-mode - (git-gutter)))))) - -;; for linum-user -(when (and global-linum-mode (not (boundp 'git-gutter-fringe))) - (git-gutter:linum-setup)) - -(provide 'git-gutter) - -;;; git-gutter.el ends here diff --git a/emacs.d/elpa/git-gutter-20150501.756/git-gutter-autoloads.el b/emacs.d/elpa/git-gutter-20150501.756/git-gutter-autoloads.el new file mode 100644 index 0000000..15ca0a5 --- /dev/null +++ b/emacs.d/elpa/git-gutter-20150501.756/git-gutter-autoloads.el @@ -0,0 +1,109 @@ +;;; git-gutter-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "git-gutter" "git-gutter.el" (21837 24213 0 +;;;;;; 0)) +;;; Generated autoloads from git-gutter.el + +(autoload 'git-gutter:linum-setup "git-gutter" "\ +Setup for linum-mode. + +\(fn)" nil nil) + +(autoload 'git-gutter-mode "git-gutter" "\ +Git-Gutter mode + +\(fn &optional ARG)" t nil) + +(defvar global-git-gutter-mode nil "\ +Non-nil if Global-Git-Gutter mode is enabled. +See the command `global-git-gutter-mode' for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `global-git-gutter-mode'.") + +(custom-autoload 'global-git-gutter-mode "git-gutter" nil) + +(autoload 'global-git-gutter-mode "git-gutter" "\ +Toggle Git-Gutter mode in all buffers. +With prefix ARG, enable Global-Git-Gutter mode if ARG is positive; +otherwise, disable it. If called from Lisp, enable the mode if +ARG is omitted or nil. + +Git-Gutter mode is enabled in all buffers where +`git-gutter--turn-on' would do it. +See `git-gutter-mode' for more information on Git-Gutter mode. + +\(fn &optional ARG)" t nil) + +(autoload 'git-gutter:revert-hunk "git-gutter" "\ +Revert current hunk. + +\(fn)" t nil) + +(autoload 'git-gutter:stage-hunk "git-gutter" "\ +Stage this hunk like 'git add -p'. + +\(fn)" t nil) + +(autoload 'git-gutter:popup-hunk "git-gutter" "\ +Popup current diff hunk. + +\(fn &optional DIFFINFO)" t nil) + +(autoload 'git-gutter:next-hunk "git-gutter" "\ +Move to next diff hunk + +\(fn ARG)" t nil) + +(autoload 'git-gutter:previous-hunk "git-gutter" "\ +Move to previous diff hunk + +\(fn ARG)" t nil) + +(autoload 'git-gutter "git-gutter" "\ +Show diff information in gutter + +\(fn)" t nil) + +(autoload 'git-gutter:clear "git-gutter" "\ +Clear diff information in gutter. + +\(fn)" t nil) + +(autoload 'git-gutter:toggle "git-gutter" "\ +Toggle to show diff information. + +\(fn)" t nil) + +(autoload 'git-gutter:set-start-revision "git-gutter" "\ +Set start revision. If `start-rev' is nil or empty string then reset +start revision. + +\(fn START-REV)" t nil) + +(autoload 'git-gutter:update-all-windows "git-gutter" "\ +Update git-gutter informations for all visible buffers. + +\(fn)" t nil) + +(autoload 'git-gutter:start-update-timer "git-gutter" "\ + + +\(fn)" t nil) + +(autoload 'git-gutter:cancel-update-timer "git-gutter" "\ + + +\(fn)" t nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; git-gutter-autoloads.el ends here diff --git a/emacs.d/elpa/git-gutter-20150501.756/git-gutter-pkg.el b/emacs.d/elpa/git-gutter-20150501.756/git-gutter-pkg.el new file mode 100644 index 0000000..2a5d6d4 --- /dev/null +++ b/emacs.d/elpa/git-gutter-20150501.756/git-gutter-pkg.el @@ -0,0 +1 @@ +(define-package "git-gutter" "20150501.756" "Port of Sublime Text plugin GitGutter" '((cl-lib "0.5") (emacs "24")) :url "https://github.com/syohex/emacs-git-gutter") diff --git a/emacs.d/elpa/git-gutter-20150501.756/git-gutter.el b/emacs.d/elpa/git-gutter-20150501.756/git-gutter.el new file mode 100644 index 0000000..2de54c7 --- /dev/null +++ b/emacs.d/elpa/git-gutter-20150501.756/git-gutter.el @@ -0,0 +1,1030 @@ +;;; git-gutter.el --- Port of Sublime Text plugin GitGutter -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 by Syohei YOSHIDA + +;; Author: Syohei YOSHIDA +;; URL: https://github.com/syohex/emacs-git-gutter +;; Package-Version: 20150501.756 +;; Version: 0.83 +;; Package-Requires: ((cl-lib "0.5") (emacs "24")) + +;; 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: +;; +;; Port of GitGutter which is a plugin of Sublime Text + +;;; Code: + +(require 'cl-lib) + +(defgroup git-gutter nil + "Port GitGutter" + :prefix "git-gutter:" + :group 'vc) + +(defcustom git-gutter:window-width nil + "Character width of gutter window. Emacs mistakes width of some characters. +It is better to explicitly assign width to this variable, if you use full-width +character for signs of changes" + :type 'integer + :group 'git-gutter) + +(defcustom git-gutter:diff-option "" + "Option of 'git diff'" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:subversion-diff-option "" + "Option of 'svn diff'" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:mercurial-diff-option "" + "Option of 'hg diff'" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:bazaar-diff-option "" + "Option of 'bzr diff'" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:update-commands + '(ido-switch-buffer helm-buffers-list) + "Each command of this list is executed, gutter information is updated." + :type '(list (function :tag "Update command") + (repeat :inline t (function :tag "Update command"))) + :group 'git-gutter) + +(defcustom git-gutter:update-windows-commands + '(kill-buffer ido-kill-buffer) + "Each command of this list is executed, gutter information is updated and +gutter information of other windows." + :type '(list (function :tag "Update command") + (repeat :inline t (function :tag "Update command"))) + :group 'git-gutter) + +(defcustom git-gutter:update-hooks + '(after-save-hook after-revert-hook find-file-hook after-change-major-mode-hook + text-scale-mode-hook magit-revert-buffer-hook) + "hook points of updating gutter" + :type '(list (hook :tag "HookPoint") + (repeat :inline t (hook :tag "HookPoint"))) + :group 'git-gutter) + +(defcustom git-gutter:always-show-separator nil + "Show separator even if there are no changes." + :type 'boolean + :group 'git-gutter) + +(defcustom git-gutter:separator-sign nil + "Separator sign" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:modified-sign "=" + "Modified sign" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:added-sign "+" + "Added sign" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:deleted-sign "-" + "Deleted sign" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:unchanged-sign nil + "Unchanged sign" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:hide-gutter nil + "Hide gutter if there are no changes" + :type 'boolean + :group 'git-gutter) + +(defcustom git-gutter:lighter " GitGutter" + "Minor mode lighter in mode-line" + :type 'string + :group 'git-gutter) + +(defcustom git-gutter:verbosity 0 + "Log/message level. 4 means all, 0 nothing." + :type 'integer + :group 'git-gutter) + +(defface git-gutter:separator + '((t (:foreground "cyan" :weight bold))) + "Face of separator" + :group 'git-gutter) + +(defface git-gutter:modified + '((t (:foreground "magenta" :weight bold))) + "Face of modified" + :group 'git-gutter) + +(defface git-gutter:added + '((t (:foreground "green" :weight bold))) + "Face of added" + :group 'git-gutter) + +(defface git-gutter:deleted + '((t (:foreground "red" :weight bold))) + "Face of deleted" + :group 'git-gutter) + +(defface git-gutter:unchanged + '((t (:background "yellow"))) + "Face of unchanged" + :group 'git-gutter) + +(defcustom git-gutter:disabled-modes nil + "A list of modes which `global-git-gutter-mode' should be disabled." + :type '(repeat symbol) + :group 'git-gutter) + +(defcustom git-gutter:handled-backends '(git) + "List of version control backends for which `git-gutter.el` will be used. +`git', `svn', `hg', and `bzr' are supported." + :type '(repeat symbol) + :group 'git-gutter) + +(defvar git-gutter:view-diff-function 'git-gutter:view-diff-infos + "Function of viewing changes") + +(defvar git-gutter:clear-function 'git-gutter:clear-diff-infos + "Function of clear changes") + +(defvar git-gutter:init-function 'nil + "Function of initialize") + +(defcustom git-gutter-mode-on-hook nil + "Hook run when git-gutter mode enable" + :type 'hook + :group 'git-gutter) + +(defcustom git-gutter-mode-off-hook nil + "Hook run when git-gutter mode disable" + :type 'hook + :group 'git-gutter) + +(defcustom git-gutter:update-interval 0 + "Time interval in seconds for updating diff information." + :type 'integer + :group 'git-gutter) + +(defvar git-gutter:enabled nil) +(defvar git-gutter:toggle-flag t) +(defvar git-gutter:force nil) +(defvar git-gutter:diffinfos nil) +(defvar git-gutter:has-indirect-buffers nil) +(defvar git-gutter:real-this-command nil) +(defvar git-gutter:linum-enabled nil) +(defvar git-gutter:linum-prev-window-margin nil) +(defvar git-gutter:vcs-type nil) +(defvar git-gutter:start-revision nil) +(defvar git-gutter:revision-history nil) +(defvar git-gutter:update-timer nil) +(defvar git-gutter:last-sha1 nil) + +(defvar git-gutter:popup-buffer "*git-gutter:diff*") +(defvar git-gutter:ignore-commands + '(minibuffer-complete-and-exit + exit-minibuffer + ido-exit-minibuffer + helm-maybe-exit-minibuffer + helm-confirm-and-exit-minibuffer)) + +(defmacro git-gutter:awhen (test &rest body) + "Anaphoric when." + (declare (indent 1)) + `(let ((it ,test)) + (when it ,@body))) + +(defsubst git-gutter:execute-command (cmd output &rest args) + (apply 'process-file cmd nil output nil args)) + +(defun git-gutter:in-git-repository-p () + (when (executable-find "git") + (with-temp-buffer + (when (zerop (git-gutter:execute-command "git" t "rev-parse" "--is-inside-work-tree")) + (goto-char (point-min)) + (string= "true" (buffer-substring-no-properties + (point) (line-end-position))))))) + +(defun git-gutter:in-svn-repository-p () + (and (executable-find "svn") + (locate-dominating-file default-directory ".svn") + (zerop (git-gutter:execute-command "svn" nil "info")) + (not (string-match-p "/\.svn/" default-directory)))) + +(defun git-gutter:in-hg-repository-p () + (and (executable-find "hg") + (locate-dominating-file default-directory ".hg") + (zerop (git-gutter:execute-command "hg" nil "root")) + (not (string-match-p "/\.hg/" default-directory)))) + +(defun git-gutter:in-bzr-repository-p () + (and (executable-find "bzr") + (locate-dominating-file default-directory ".bzr") + (zerop (git-gutter:execute-command "bzr" nil "root")) + (not (string-match-p "/\.bzr/" default-directory)))) + +(defsubst git-gutter:vcs-check-function (vcs) + (cl-case vcs + (git 'git-gutter:in-git-repository-p) + (svn 'git-gutter:in-svn-repository-p) + (hg 'git-gutter:in-hg-repository-p) + (bzr 'git-gutter:in-bzr-repository-p))) + +(defsubst git-gutter:in-repository-p () + (cl-loop for vcs in git-gutter:handled-backends + for check-func = (git-gutter:vcs-check-function vcs) + when (funcall check-func) + return (set (make-local-variable 'git-gutter:vcs-type) vcs))) + +(defsubst git-gutter:changes-to-number (str) + (if (string= str "") + 1 + (string-to-number str))) + +(defsubst git-gutter:make-diffinfo (type content start end) + (list :type type :content content :start-line start :end-line end)) + +(defsubst git-gutter:base-file () + (buffer-file-name (buffer-base-buffer))) + +(defun git-gutter:diff-content () + (save-excursion + (goto-char (line-beginning-position)) + (let ((curpoint (point))) + (forward-line 1) + (if (re-search-forward "^@@" nil t) + (backward-char 3) ;; for '@@' + (goto-char (point-max))) + (buffer-substring curpoint (point))))) + +(defun git-gutter:process-diff-output (buf) + (when (buffer-live-p buf) + (with-current-buffer buf + (goto-char (point-min)) + (cl-loop with regexp = "^@@ -\\(?:[0-9]+\\),?\\([0-9]*\\) \\+\\([0-9]+\\),?\\([0-9]*\\) @@" + while (re-search-forward regexp nil t) + for new-line = (string-to-number (match-string 2)) + for orig-changes = (git-gutter:changes-to-number (match-string 1)) + for new-changes = (git-gutter:changes-to-number (match-string 3)) + for type = (cond ((zerop orig-changes) 'added) + ((zerop new-changes) 'deleted) + (t 'modified)) + for end-line = (if (eq type 'deleted) + new-line + (1- (+ new-line new-changes))) + for content = (git-gutter:diff-content) + collect + (let ((start (if (zerop new-line) 1 new-line)) + (end (if (zerop end-line) 1 end-line))) + (git-gutter:make-diffinfo type content start end)))))) + +(defsubst git-gutter:window-margin () + (or git-gutter:window-width (git-gutter:longest-sign-width))) + +(defun git-gutter:set-window-margin (width) + (when (and (not git-gutter:linum-enabled) (>= width 0)) + (let ((curwin (get-buffer-window))) + (set-window-margins curwin width (cdr (window-margins curwin)))))) + +(defsubst git-gutter:revision-set-p () + (and git-gutter:start-revision (not (string= git-gutter:start-revision "")))) + +(defun git-gutter:git-diff-arguments (file) + (let (args) + (unless (string= git-gutter:diff-option "") + (setq args (nreverse (split-string git-gutter:diff-option)))) + (when (git-gutter:revision-set-p) + (push git-gutter:start-revision args)) + (nreverse (cons file args)))) + +(defun git-gutter:start-git-diff-process (file proc-buf) + (let ((arg (git-gutter:git-diff-arguments file))) + (apply 'start-file-process "git-gutter" proc-buf + "git" "--no-pager" "diff" "--no-color" "--no-ext-diff" "--relative" "-U0" + arg))) + +(defun git-gutter:svn-diff-arguments (file) + (let (args) + (unless (string= git-gutter:subversion-diff-option "") + (setq args (nreverse (split-string git-gutter:subversion-diff-option)))) + (when (git-gutter:revision-set-p) + (push "-r" args) + (push git-gutter:start-revision args)) + (nreverse (cons file args)))) + +(defsubst git-gutter:start-svn-diff-process (file proc-buf) + (let ((args (git-gutter:svn-diff-arguments file))) + (apply 'start-file-process "git-gutter" proc-buf "svn" "diff" "--diff-cmd" + "diff" "-x" "-U0" args))) + +(defun git-gutter:hg-diff-arguments (file) + (let (args) + (unless (string= git-gutter:mercurial-diff-option "") + (setq args (nreverse (split-string git-gutter:mercurial-diff-option)))) + (when (git-gutter:revision-set-p) + (push "-r" args) + (push git-gutter:start-revision args)) + (nreverse (cons file args)))) + +(defsubst git-gutter:start-hg-diff-process (file proc-buf) + (let ((args (git-gutter:hg-diff-arguments file))) + (apply 'start-file-process "git-gutter" proc-buf "hg" "diff" "-U0" args))) + +(defun git-gutter:bzr-diff-arguments (file) + (let (args) + (unless (string= git-gutter:bazaar-diff-option "") + (setq args (nreverse (split-string git-gutter:bazaar-diff-option)))) + (when (git-gutter:revision-set-p) + (push "-r" args) + (push git-gutter:start-revision args)) + (nreverse (cons file args)))) + +(defsubst git-gutter:start-bzr-diff-process (file proc-buf) + (let ((args (git-gutter:bzr-diff-arguments file))) + (apply 'start-file-process "git-gutter" proc-buf + "bzr" "diff" "--context=0" args))) + +(defun git-gutter:start-diff-process1 (file proc-buf) + (cl-case git-gutter:vcs-type + (git (git-gutter:start-git-diff-process file proc-buf)) + (svn (git-gutter:start-svn-diff-process file proc-buf)) + (hg (git-gutter:start-hg-diff-process file proc-buf)) + (bzr (git-gutter:start-bzr-diff-process file proc-buf)))) + +(defun git-gutter:start-diff-process (curfile proc-buf) + (git-gutter:set-window-margin (git-gutter:window-margin)) + (let ((file (git-gutter:base-file)) ;; for tramp + (curbuf (current-buffer)) + (process (git-gutter:start-diff-process1 curfile proc-buf))) + (set-process-query-on-exit-flag process nil) + (set-process-sentinel + process + (lambda (proc _event) + (when (eq (process-status proc) 'exit) + (setq git-gutter:enabled nil) + (let ((diffinfos (git-gutter:process-diff-output (process-buffer proc)))) + (when (buffer-live-p curbuf) + (with-current-buffer curbuf + (git-gutter:update-diffinfo diffinfos) + (when git-gutter:has-indirect-buffers + (git-gutter:update-indirect-buffers file)) + (setq git-gutter:enabled t))) + (kill-buffer proc-buf))))))) + +(defsubst git-gutter:gutter-sperator () + (when git-gutter:separator-sign + (propertize git-gutter:separator-sign 'face 'git-gutter:separator))) + +(defun git-gutter:before-string (sign) + (let ((gutter-sep (concat sign (git-gutter:gutter-sperator)))) + (propertize " " 'display `((margin left-margin) ,gutter-sep)))) + +(defsubst git-gutter:select-face (type) + (cl-case type + (added 'git-gutter:added) + (modified 'git-gutter:modified) + (deleted 'git-gutter:deleted))) + +(defsubst git-gutter:select-sign (type) + (cl-case type + (added git-gutter:added-sign) + (modified git-gutter:modified-sign) + (deleted git-gutter:deleted-sign))) + +(defun git-gutter:propertized-sign (type) + (let ((sign (git-gutter:select-sign type)) + (face (git-gutter:select-face type))) + (propertize sign 'face face))) + +(defsubst git-gutter:linum-get-overlay (pos) + (cl-loop for ov in (overlays-in pos pos) + when (overlay-get ov 'linum-str) + return ov)) + +(defun git-gutter:view-at-pos-linum (sign pos) + (git-gutter:awhen (git-gutter:linum-get-overlay pos) + (overlay-put it 'before-string + (propertize " " + 'display + `((margin left-margin) + ,(concat sign (overlay-get it 'linum-str))))))) + +(defun git-gutter:view-at-pos (sign pos) + (if git-gutter:linum-enabled + (git-gutter:view-at-pos-linum sign pos) + (let ((ov (make-overlay pos pos))) + (overlay-put ov 'before-string (git-gutter:before-string sign)) + (overlay-put ov 'git-gutter t)))) + +(defsubst git-gutter:sign-width (sign) + (cl-loop for s across sign + sum (char-width s))) + +(defun git-gutter:longest-sign-width () + (let ((signs (list git-gutter:modified-sign + git-gutter:added-sign + git-gutter:deleted-sign))) + (when git-gutter:unchanged-sign + (push git-gutter:unchanged-sign signs)) + (+ (apply 'max (mapcar 'git-gutter:sign-width signs)) + (git-gutter:sign-width git-gutter:separator-sign)))) + +(defun git-gutter:view-for-unchanged () + (save-excursion + (let ((sign (if git-gutter:unchanged-sign + (propertize git-gutter:unchanged-sign + 'face 'git-gutter:unchanged) + " "))) + (goto-char (point-min)) + (while (not (eobp)) + (git-gutter:view-at-pos sign (point)) + (forward-line 1))))) + +(defsubst git-gutter:check-file-and-directory () + (and (git-gutter:base-file) + default-directory (file-directory-p default-directory))) + +(defun git-gutter:pre-command-hook () + (unless (memq this-command git-gutter:ignore-commands) + (setq git-gutter:real-this-command this-command))) + +(defun git-gutter:update-other-window-buffers (curwin curbuf) + (save-selected-window + (cl-loop for win in (window-list) + unless (eq win curwin) + do + (progn + (select-window win) + (let ((win-width (window-margins win))) + (unless (car win-width) + (if (eq (current-buffer) curbuf) + (git-gutter:set-window-margin (git-gutter:window-margin)) + (git-gutter:update-diffinfo git-gutter:diffinfos)))))))) + +(defun git-gutter:post-command-hook () + (cond ((memq git-gutter:real-this-command git-gutter:update-commands) + (git-gutter)) + ((memq git-gutter:real-this-command git-gutter:update-windows-commands) + (git-gutter) + (unless global-linum-mode + (git-gutter:update-other-window-buffers (selected-window) (current-buffer)))))) + +(defsubst git-gutter:diff-process-buffer (curfile) + (concat " *git-gutter-" curfile "-*")) + +(defun git-gutter:kill-buffer-hook () + (let ((buf (git-gutter:diff-process-buffer (git-gutter:base-file)))) + (git-gutter:awhen (get-buffer buf) + (kill-buffer it)))) + +(defsubst git-gutter:linum-padding () + (cl-loop repeat (git-gutter:window-margin) + collect " " into paddings + finally return (apply 'concat paddings))) + +(defun git-gutter:linum-prepend-spaces () + (save-excursion + (goto-char (point-min)) + (let ((padding (git-gutter:linum-padding))) + (while (not (eobp)) + (git-gutter:view-at-pos-linum padding (point)) + (forward-line 1))))) + +(defun git-gutter:linum-update (diffinfos) + (let ((linum-width (car (window-margins)))) + (when linum-width + (git-gutter:linum-prepend-spaces) + (git-gutter:view-set-overlays diffinfos) + (let ((curwin (get-buffer-window)) + (margin (+ linum-width (git-gutter:window-margin)))) + (setq git-gutter:linum-prev-window-margin margin) + (set-window-margins curwin margin (cdr (window-margins curwin))))))) + +(defun git-gutter:linum-init () + (set (make-local-variable 'git-gutter:linum-enabled) t) + (make-local-variable 'git-gutter:linum-prev-window-margin)) + +;;;###autoload +(defun git-gutter:linum-setup () + "Setup for linum-mode." + (setq git-gutter:init-function 'git-gutter:linum-init + git-gutter:view-diff-function nil) + (defadvice linum-update-window (after git-gutter:linum-update-window activate) + (if (and git-gutter-mode git-gutter:diffinfos) + (git-gutter:linum-update git-gutter:diffinfos) + (let ((curwin (get-buffer-window)) + (margin (or git-gutter:linum-prev-window-margin + (car (window-margins))))) + (set-window-margins curwin margin (cdr (window-margins curwin))))))) + +(defun git-gutter:show-backends () + (mapconcat (lambda (backend) + (capitalize (symbol-name backend))) + git-gutter:handled-backends "/")) + +;;;###autoload +(define-minor-mode git-gutter-mode + "Git-Gutter mode" + :group 'git-gutter + :init-value nil + :global nil + :lighter git-gutter:lighter + (if git-gutter-mode + (if (and (git-gutter:check-file-and-directory) + (git-gutter:in-repository-p)) + (progn + (when git-gutter:init-function + (funcall git-gutter:init-function)) + (make-local-variable 'git-gutter:enabled) + (set (make-local-variable 'git-gutter:has-indirect-buffers) nil) + (set (make-local-variable 'git-gutter:toggle-flag) t) + (make-local-variable 'git-gutter:diffinfos) + (set (make-local-variable 'git-gutter:start-revision) nil) + (add-hook 'kill-buffer-hook 'git-gutter:kill-buffer-hook nil t) + (add-hook 'pre-command-hook 'git-gutter:pre-command-hook) + (add-hook 'post-command-hook 'git-gutter:post-command-hook nil t) + (dolist (hook git-gutter:update-hooks) + (add-hook hook 'git-gutter nil t)) + (git-gutter) + (when (and (not git-gutter:update-timer) (> git-gutter:update-interval 0)) + (setq git-gutter:update-timer + (run-with-idle-timer 1 git-gutter:update-interval 'git-gutter:live-update)))) + (when (> git-gutter:verbosity 2) + (message "Here is not %s work tree" (git-gutter:show-backends))) + (git-gutter-mode -1)) + (remove-hook 'kill-buffer-hook 'git-gutter:kill-buffer-hook t) + (remove-hook 'pre-command-hook 'git-gutter:pre-command-hook) + (remove-hook 'post-command-hook 'git-gutter:post-command-hook t) + (dolist (hook git-gutter:update-hooks) + (remove-hook hook 'git-gutter t)) + (git-gutter:clear))) + +(defun git-gutter--turn-on () + (when (and (buffer-file-name) + (not (memq major-mode git-gutter:disabled-modes))) + (git-gutter-mode +1))) + +;;;###autoload +(define-global-minor-mode global-git-gutter-mode git-gutter-mode git-gutter--turn-on + :group 'git-gutter) + +(defsubst git-gutter:show-gutter-p (diffinfos) + (if git-gutter:hide-gutter + (or diffinfos git-gutter:unchanged-sign) + (or global-git-gutter-mode git-gutter:unchanged-sign diffinfos))) + +(defun git-gutter:show-gutter (diffinfos) + (when (git-gutter:show-gutter-p diffinfos) + (git-gutter:set-window-margin (git-gutter:window-margin)))) + +(defun git-gutter:view-set-overlays (diffinfos) + (save-excursion + (goto-char (point-min)) + (cl-loop with curline = 1 + for info in diffinfos + for start-line = (plist-get info :start-line) + for end-line = (plist-get info :end-line) + for type = (plist-get info :type) + for sign = (git-gutter:propertized-sign type) + do + (progn + (forward-line (- start-line curline)) + (cl-case type + ((modified added) + (setq curline start-line) + (while (and (<= curline end-line) (not (eobp))) + (git-gutter:view-at-pos sign (point)) + (cl-incf curline) + (forward-line 1))) + (deleted + (git-gutter:view-at-pos sign (point)) + (forward-line 1) + (setq curline (1+ end-line)))))))) + +(defun git-gutter:view-diff-infos (diffinfos) + (when (or diffinfos git-gutter:always-show-separator) + (when (or git-gutter:unchanged-sign git-gutter:separator-sign) + (git-gutter:view-for-unchanged)) + (git-gutter:view-set-overlays diffinfos)) + (git-gutter:show-gutter diffinfos)) + +(defsubst git-gutter:reset-window-margin-p () + (or git-gutter:force + git-gutter:hide-gutter + (not global-git-gutter-mode))) + +(defun git-gutter:clear-diff-infos () + (when (git-gutter:reset-window-margin-p) + (git-gutter:set-window-margin 0)) + (remove-overlays (point-min) (point-max) 'git-gutter t)) + +(defsubst git-gutter:clear-gutter () + (when git-gutter:clear-function + (funcall git-gutter:clear-function))) + +(defun git-gutter:update-diffinfo (diffinfos) + (save-restriction + (widen) + (git-gutter:clear-gutter) + (setq git-gutter:diffinfos diffinfos) + (when git-gutter:view-diff-function + (funcall git-gutter:view-diff-function diffinfos)))) + +(defun git-gutter:search-near-diff-index (diffinfos is-reverse) + (cl-loop with current-line = (line-number-at-pos) + with cmp-fn = (if is-reverse '> '<) + for diffinfo in (if is-reverse (reverse diffinfos) diffinfos) + for index = 0 then (1+ index) + for start-line = (plist-get diffinfo :start-line) + when (funcall cmp-fn current-line start-line) + return (if is-reverse + (1- (- (length diffinfos) index)) + index))) + +(defun git-gutter:search-here-diffinfo (diffinfos) + (save-restriction + (widen) + (cl-loop with current-line = (line-number-at-pos) + for diffinfo in diffinfos + for start = (plist-get diffinfo :start-line) + for end = (or (plist-get diffinfo :end-line) (1+ start)) + when (and (>= current-line start) (<= current-line end)) + return diffinfo))) + +(defun git-gutter:collect-deleted-line (str) + (with-temp-buffer + (insert str) + (goto-char (point-min)) + (cl-loop while (re-search-forward "^-\\(.*?\\)$" nil t) + collect (match-string 1) into deleted-lines + finally return deleted-lines))) + +(defun git-gutter:delete-added-lines (start-line end-line) + (forward-line (1- start-line)) + (let ((start-point (point))) + (forward-line (1+ (- end-line start-line))) + (delete-region start-point (point)))) + +(defun git-gutter:insert-deleted-lines (content) + (dolist (line (git-gutter:collect-deleted-line content)) + (insert (concat line "\n")))) + +(defsubst git-gutter:delete-from-first-line-p (start-line end-line) + (and (not (= start-line 1)) (not (= end-line 1)))) + +(defun git-gutter:do-revert-hunk (diffinfo) + (save-excursion + (goto-char (point-min)) + (let ((start-line (plist-get diffinfo :start-line)) + (end-line (plist-get diffinfo :end-line)) + (content (plist-get diffinfo :content))) + (cl-case (plist-get diffinfo :type) + (added (git-gutter:delete-added-lines start-line end-line)) + (deleted (when (git-gutter:delete-from-first-line-p start-line end-line) + (forward-line start-line)) + (git-gutter:insert-deleted-lines content)) + (modified (git-gutter:delete-added-lines start-line end-line) + (git-gutter:insert-deleted-lines content)))))) + +(defsubst git-gutter:popup-buffer-window () + (get-buffer-window (get-buffer git-gutter:popup-buffer))) + +;;;###autoload +(defun git-gutter:revert-hunk () + "Revert current hunk." + (interactive) + (git-gutter:awhen (git-gutter:search-here-diffinfo git-gutter:diffinfos) + (save-window-excursion + (git-gutter:popup-hunk it) + (when (yes-or-no-p "Revert current hunk ?") + (git-gutter:do-revert-hunk it) + (save-buffer)) + (delete-window (git-gutter:popup-buffer-window))))) + +(defun git-gutter:extract-hunk-header () + (git-gutter:awhen (git-gutter:base-file) + (with-temp-buffer + (when (zerop (git-gutter:execute-command "git" t "diff" "--relative" it)) + (goto-char (point-min)) + (forward-line 4) + (buffer-substring-no-properties (point-min) (point)))))) + +(defun git-gutter:read-hunk-header (header) + (let ((header-regexp "^@@ -\\([0-9]+\\),?\\([0-9]*\\) \\+\\([0-9]+\\),?\\([0-9]*\\) @@")) + (when (string-match header-regexp header) + (list (string-to-number (match-string 1 header)) + (git-gutter:changes-to-number (match-string 2 header)) + (string-to-number (match-string 3 header)) + (git-gutter:changes-to-number (match-string 4 header)))))) + +(defun git-gutter:convert-hunk-header (type) + (let ((header (buffer-substring-no-properties (point) (line-end-position)))) + (delete-region (point) (line-end-position)) + (cl-destructuring-bind + (orig-line orig-changes new-line new-changes) (git-gutter:read-hunk-header header) + (cl-case type + (added (setq new-line (1+ orig-line))) + (t (setq new-line orig-line))) + (let ((new-header (format "@@ -%d,%d +%d,%d @@" + orig-line orig-changes new-line new-changes))) + (insert new-header))))) + +(defun git-gutter:insert-staging-hunk (hunk type) + (save-excursion + (insert hunk "\n")) + (git-gutter:convert-hunk-header type)) + +(defun git-gutter:apply-directory-option () + (let ((root (locate-dominating-file default-directory ".git"))) + (file-name-directory (file-relative-name (git-gutter:base-file) root)))) + +(defun git-gutter:do-stage-hunk (diff-info) + (let ((content (plist-get diff-info :content)) + (type (plist-get diff-info :type)) + (header (git-gutter:extract-hunk-header)) + (patch (make-temp-name "git-gutter"))) + (when header + (with-temp-file patch + (insert header) + (git-gutter:insert-staging-hunk content type)) + (let ((dir-option (git-gutter:apply-directory-option)) + (options (list "--cached" patch))) + (when dir-option + (setq options (cons "--directory" (cons dir-option options)))) + (unless (zerop (apply 'git-gutter:execute-command + "git" nil "apply" "--unidiff-zero" + options)) + (message "Failed: stating this hunk")) + (delete-file patch))))) + +;;;###autoload +(defun git-gutter:stage-hunk () + "Stage this hunk like 'git add -p'." + (interactive) + (git-gutter:awhen (git-gutter:search-here-diffinfo git-gutter:diffinfos) + (save-window-excursion + (git-gutter:popup-hunk it) + (when (yes-or-no-p "Stage current hunk ?") + (git-gutter:do-stage-hunk it) + (git-gutter)) + (delete-window (git-gutter:popup-buffer-window))))) + +(defun git-gutter:update-popuped-buffer (diffinfo) + (with-current-buffer (get-buffer-create git-gutter:popup-buffer) + (view-mode -1) + (setq buffer-read-only nil) + (erase-buffer) + (insert (plist-get diffinfo :content)) + (insert "\n") + (goto-char (point-min)) + (diff-mode) + (view-mode +1) + (current-buffer))) + +;;;###autoload +(defun git-gutter:popup-hunk (&optional diffinfo) + "Popup current diff hunk." + (interactive) + (git-gutter:awhen (or diffinfo + (git-gutter:search-here-diffinfo git-gutter:diffinfos)) + (save-selected-window + (pop-to-buffer (git-gutter:update-popuped-buffer it))))) + +;;;###autoload +(defun git-gutter:next-hunk (arg) + "Move to next diff hunk" + (interactive "p") + (if (not git-gutter:diffinfos) + (when (> git-gutter:verbosity 3) + (message "There are no changes!!")) + (let* ((is-reverse (< arg 0)) + (diffinfos git-gutter:diffinfos) + (len (length diffinfos)) + (index (git-gutter:search-near-diff-index diffinfos is-reverse)) + (real-index (if index + (let ((next (if is-reverse (1+ index) (1- index)))) + (mod (+ arg next) len)) + (if is-reverse (1- len) 0))) + (diffinfo (nth real-index diffinfos))) + (goto-char (point-min)) + (forward-line (1- (plist-get diffinfo :start-line))) + (when (buffer-live-p (get-buffer git-gutter:popup-buffer)) + (git-gutter:update-popuped-buffer diffinfo))))) + +;;;###autoload +(defun git-gutter:previous-hunk (arg) + "Move to previous diff hunk" + (interactive "p") + (git-gutter:next-hunk (- arg))) + +(defalias 'git-gutter:next-diff 'git-gutter:next-hunk) +(make-obsolete 'git-gutter:next-diff 'git-gutter:next-hunk "0.60") +(defalias 'git-gutter:previous-diff 'git-gutter:previous-hunk) +(make-obsolete 'git-gutter:previous-diff 'git-gutter:previous-hunk "0.60") +(defalias 'git-gutter:popup-diff 'git-gutter:popup-hunk) +(make-obsolete 'git-gutter:popup-diff 'git-gutter:popup-hunk "0.60") + +(defun git-gutter:update-indirect-buffers (orig-file) + (cl-loop with diffinfos = git-gutter:diffinfos + for win in (window-list) + for buf = (window-buffer win) + for base = (buffer-base-buffer buf) + when (and base (string= (buffer-file-name base) orig-file)) + do + (with-current-buffer buf + (git-gutter:update-diffinfo diffinfos)))) + +;;;###autoload +(defun git-gutter () + "Show diff information in gutter" + (interactive) + (when (and (or git-gutter:toggle-flag git-gutter:force) + (or git-gutter:vcs-type (git-gutter:in-repository-p))) + (let* ((file (git-gutter:base-file)) + (proc-buf (git-gutter:diff-process-buffer file))) + (when (and (called-interactively-p 'interactive) (get-buffer proc-buf)) + (kill-buffer proc-buf)) + (when (and file (file-exists-p file) (not (get-buffer proc-buf))) + (git-gutter:start-diff-process (file-name-nondirectory file) + (get-buffer-create proc-buf)))))) + +(defadvice make-indirect-buffer (before git-gutter:has-indirect-buffers activate) + (when (and git-gutter-mode (not (buffer-base-buffer))) + (setq git-gutter:has-indirect-buffers t))) + +(defadvice vc-revert (after git-gutter:vc-revert activate) + (when git-gutter-mode + (run-with-idle-timer 0.1 nil 'git-gutter))) + +;; `quit-window' and `switch-to-buffer' are called from other +;; commands. So we should use `defadvice' instead of `post-command-hook'. +(defadvice quit-window (after git-gutter:quit-window activate) + (when git-gutter-mode + (git-gutter))) + +(defadvice switch-to-buffer (after git-gutter:switch-to-buffer activate) + (when git-gutter-mode + (git-gutter))) + +;;;###autoload +(defun git-gutter:clear () + "Clear diff information in gutter." + (interactive) + (save-restriction + (widen) + (git-gutter:clear-gutter)) + (setq git-gutter:enabled nil + git-gutter:diffinfos nil)) + +;;;###autoload +(defun git-gutter:toggle () + "Toggle to show diff information." + (interactive) + (let ((git-gutter:force t)) + (if git-gutter:enabled + (progn + (git-gutter:clear) + (setq git-gutter-mode nil + git-gutter:toggle-flag nil)) + (git-gutter) + (setq git-gutter-mode t + git-gutter:toggle-flag t)) + (force-mode-line-update))) + +(defun git-gutter:revision-valid-p (revision) + (zerop (cl-case git-gutter:vcs-type + (git (git-gutter:execute-command "git" nil + "rev-parse" "--quiet" "--verify" + revision)) + (svn (git-gutter:execute-command "svn" nil "info" "-r" revision + (file-relative-name (buffer-file-name)))) + (hg (git-gutter:execute-command "hg" nil "id" "-r" revision)) + (bzr (git-gutter:execute-command "bzr" nil + "revno" "-r" revision))))) + +;;;###autoload +(defun git-gutter:set-start-revision (start-rev) + "Set start revision. If `start-rev' is nil or empty string then reset +start revision." + (interactive + (list (read-string "Start Revision: " + nil 'git-gutter:revision-history))) + (when (and start-rev (not (string= start-rev ""))) + (unless (git-gutter:revision-valid-p start-rev) + (error "Revision '%s' is not valid." start-rev))) + (setq git-gutter:start-revision start-rev) + (git-gutter)) + +;;;###autoload +(defun git-gutter:update-all-windows () + "Update git-gutter informations for all visible buffers." + (interactive) + (dolist (win (window-list)) + (let ((buf (window-buffer win))) + (with-current-buffer buf + (when git-gutter-mode + (git-gutter)))))) + +;;;###autoload +(defun git-gutter:start-update-timer () + (interactive) + (when git-gutter:update-timer + (error "Update timer is already running.")) + (setq git-gutter:update-timer + (run-with-idle-timer 1 git-gutter:update-interval 'git-gutter:live-update))) + +;;;###autoload +(defun git-gutter:cancel-update-timer () + (interactive) + (unless git-gutter:update-timer + (error "Timer is no running.")) + (cancel-timer git-gutter:update-timer) + (setq git-gutter:update-timer nil)) + +(defsubst git-gutter:write-current-content (tmpfile) + (let ((content (buffer-substring-no-properties (point-min) (point-max)))) + (with-temp-file tmpfile + (insert content)))) + +(defsubst git-gutter:original-file-content (file) + (with-temp-buffer + (when (zerop (process-file "git" nil t nil "show" (concat ":" file))) + (buffer-substring-no-properties (point-min) (point-max))))) + +(defun git-gutter:write-original-content (tmpfile filename) + (git-gutter:awhen (git-gutter:original-file-content filename) + (with-temp-file tmpfile + (insert it) + t))) + +(defsubst git-gutter:start-raw-diff-process (proc-buf original now) + (start-file-process "git-gutter:update-timer" proc-buf + "diff" "-U0" original now)) + +(defun git-gutter:start-live-update (file original now) + (let ((proc-bufname (git-gutter:diff-process-buffer file))) + (when (get-buffer proc-bufname) + (kill-buffer proc-bufname)) + (let* ((curbuf (current-buffer)) + (proc-buf (get-buffer-create proc-bufname)) + (process (git-gutter:start-raw-diff-process proc-buf original now))) + (set-process-query-on-exit-flag process nil) + (set-process-sentinel + process + (lambda (proc _event) + (when (eq (process-status proc) 'exit) + (setq git-gutter:enabled nil) + (let ((diffinfos (git-gutter:process-diff-output (process-buffer proc)))) + (when (buffer-live-p curbuf) + (with-current-buffer curbuf + (git-gutter:update-diffinfo diffinfos) + (setq git-gutter:enabled t))) + (kill-buffer proc-buf) + (delete-file original) + (delete-file now)))))))) + +(defun git-gutter:should-update-p () + (let ((sha1 (secure-hash 'sha1 (current-buffer)))) + (unless (equal sha1 git-gutter:last-sha1) + (setq git-gutter:last-sha1 sha1)))) + +(defun git-gutter:live-update () + (when (and git-gutter:enabled (buffer-modified-p)) + (when (git-gutter:should-update-p) + (let ((file (file-name-nondirectory (git-gutter:base-file))) + (now (make-temp-file "git-gutter-cur")) + (original (make-temp-file "git-gutter-orig"))) + (when (git-gutter:write-original-content original file) + (git-gutter:write-current-content now) + (git-gutter:start-live-update file original now)))))) + +;; for linum-user +(when (and global-linum-mode (not (boundp 'git-gutter-fringe))) + (git-gutter:linum-setup)) + +(provide 'git-gutter) + +;;; git-gutter.el ends here diff --git a/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-autoloads.el b/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-autoloads.el new file mode 100644 index 0000000..a694c34 --- /dev/null +++ b/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-autoloads.el @@ -0,0 +1,29 @@ +;;; git-rebase-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "git-rebase-mode" "git-rebase-mode.el" (21837 +;;;;;; 24197 0 0)) +;;; Generated autoloads from git-rebase-mode.el + +(autoload 'git-rebase-mode "git-rebase-mode" "\ +Major mode for editing of a Git rebase file. + +Rebase files are generated when you run 'git rebase -i' or run +`magit-interactive-rebase'. They describe how Git should perform +the rebase. See the documentation for git-rebase (e.g., by +running 'man git-rebase' at the command line) for details. + +\(fn)" t nil) + +(add-to-list 'auto-mode-alist '("/git-rebase-todo\\'" . git-rebase-mode)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; git-rebase-mode-autoloads.el ends here diff --git a/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-pkg.el b/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-pkg.el new file mode 100644 index 0000000..97f9cc4 --- /dev/null +++ b/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode-pkg.el @@ -0,0 +1 @@ +(define-package "git-rebase-mode" "20150122.1114" "Major mode for editing git rebase files" 'nil :url "https://github.com/magit/git-modes" :keywords '("convenience" "vc" "git")) diff --git a/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode.el b/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode.el new file mode 100644 index 0000000..b72151d --- /dev/null +++ b/emacs.d/elpa/git-rebase-mode-20150122.1114/git-rebase-mode.el @@ -0,0 +1,393 @@ +;;; git-rebase-mode.el --- Major mode for editing git rebase files + +;; Copyright (C) 2010-2015 The Magit Project Developers + +;; Author: Phil Jackson +;; Maintainer: Jonas Bernoulli +;; Homepage: https://github.com/magit/git-modes +;; Keywords: convenience vc git +;; Package-Version: 20150122.1114 + +;; 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 this file. If not, see . + +;;; Commentary: + +;; Allows the editing of a git rebase file (which you might get when +;; using 'git rebase -i' or hitting 'E' in Magit). Assumes editing is +;; happening in a server. + +;;; Code: + +(require 'easymenu) +(require 'server) +(require 'thingatpt) + +;;; Options +;;;; Variables + +(defgroup git-rebase nil + "Edit Git rebase sequences." + :group 'tools) + +(defcustom git-rebase-auto-advance nil + "If non-nil, moves point forward a line after running an action." + :group 'git-rebase + :type 'boolean) + +(defcustom git-rebase-remove-instructions nil + "Whether to remove the instructions from the rebase buffer. +Because you have seen them before and can still remember." + :group 'git-rebase + :type 'boolean) + +;;;; Faces + +(defgroup git-rebase-faces nil + "Faces used by Git-Rebase mode." + :group 'faces + :group 'git-rebase) + +(defface git-rebase-hash + '((((class color) (background light)) + :foreground "firebrick") + (((class color) (background dark)) + :foreground "tomato")) + "Face for commit hashes." + :group 'git-rebase-faces) + +(defface git-rebase-description nil + "Face for commit descriptions." + :group 'git-rebase-faces) + +(defface git-rebase-killed-action + '((((class color)) + :inherit font-lock-comment-face + :strike-through t)) + "Face for commented action and exec lines." + :group 'git-rebase-faces) + +(define-obsolete-face-alias 'git-rebase-description-face + 'git-rebase-description "1.0.0") +(define-obsolete-face-alias 'git-rebase-killed-action-face + 'git-rebase-killed-action "1.0.0") + +;;; Regexps + +(defconst git-rebase-action-line-re + (concat "^#?" + "\\([efprs]\\|pick\\|reword\\|edit\\|squash\\|fixup\\) " + "\\([a-z0-9]\\{4,40\\}\\) " + "\\(.*\\)") + "Regexp matching action lines in rebase buffers.") + +(defconst git-rebase-exec-line-re + "^#?\\(x\\|exec\\)[[:space:]]\\(.*\\)" + "Regexp matching exec lines in rebase buffer.") + +(defconst git-rebase-dead-line-re + (format "^#\\(?:%s\\|%s\\)" + (substring git-rebase-action-line-re 1) + (substring git-rebase-exec-line-re 1)) + "Regexp matching commented action and exex lines in rebase buffers.") + +;;; Keymaps + +(defvar git-rebase-mode-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map special-mode-map) + (define-key map (kbd "q") 'git-rebase-server-edit) + (define-key map (kbd "C-c C-c") 'git-rebase-server-edit) + (define-key map (kbd "a") 'git-rebase-abort) + (define-key map (kbd "C-c C-k") 'git-rebase-abort) + (define-key map [remap undo] 'git-rebase-undo) + (define-key map (kbd "RET") 'git-rebase-show-commit) + (define-key map (kbd "x") 'git-rebase-exec) + (define-key map (kbd "c") 'git-rebase-pick) + (define-key map (kbd "r") 'git-rebase-reword) + (define-key map (kbd "e") 'git-rebase-edit) + (define-key map (kbd "s") 'git-rebase-squash) + (define-key map (kbd "f") 'git-rebase-fixup) + (define-key map (kbd "y") 'git-rebase-insert) + (define-key map (kbd "k") 'git-rebase-kill-line) + (define-key map (kbd "C-k") 'git-rebase-kill-line) + (define-key map (kbd "p") 'git-rebase-backward-line) + (define-key map (kbd "n") 'forward-line) + (define-key map (kbd "M-p") 'git-rebase-move-line-up) + (define-key map (kbd "M-n") 'git-rebase-move-line-down) + (define-key map (kbd "M-") 'git-rebase-move-line-up) + (define-key map (kbd "M-") 'git-rebase-move-line-down) + map) + "Keymap for Git-Rebase mode.") + +(easy-menu-define git-rebase-mode-menu git-rebase-mode-map + "Git-Rebase mode menu" + '("Rebase" + ["Pick" git-rebase-pick t] + ["Reword" git-rebase-reword t] + ["Edit" git-rebase-edit t] + ["Squash" git-rebase-squash t] + ["Fixup" git-rebase-fixup t] + ["Kill" git-rebase-kill-line t] + ["Move Down" git-rebase-move-line-down t] + ["Move Up" git-rebase-move-line-up t] + ["Execute" git-rebase-exec t] + "---" + ["Abort" git-rebase-abort t] + ["Done" git-rebase-server-edit t])) + +;;; Utilities + +(defun git-rebase-edit-line (change-to) + (when (git-rebase-looking-at-action) + (let ((buffer-read-only nil) + (start (point))) + (goto-char (point-at-bol)) + (delete-region (point) (progn (forward-word 1) (point))) + (insert change-to) + (goto-char start) + (when git-rebase-auto-advance + (forward-line))))) + +(defmacro git-rebase-define-action (sym) + (declare (indent defun)) + (let ((fn (intern (format "git-rebase-%s" sym)))) + `(progn + (defun ,fn () + (interactive) + (git-rebase-edit-line ,(symbol-name sym))) + (put ',fn 'definition-name ',sym)))) + +(defun git-rebase-looking-at-action () + "Return non-nil if looking at an action line." + (save-excursion + (goto-char (point-at-bol)) + (looking-at git-rebase-action-line-re))) + +(defun git-rebase-looking-at-action-or-exec () + "Return non-nil if looking at an action line or exec line." + (save-excursion + (goto-char (point-at-bol)) + (or (looking-at git-rebase-action-line-re) + (looking-at git-rebase-exec-line-re)))) + +(defun git-rebase-looking-at-exec () + "Return non-nil if cursor is on an exec line." + (string-match git-rebase-exec-line-re (thing-at-point 'line))) + +(defun git-rebase-looking-at-killed-exec () + "Return non-nil if looking at an exec line that has been commented out." + (let ((line (thing-at-point 'line))) + (and (eq (aref line 0) ?#) + (string-match git-rebase-exec-line-re line)))) + +;;; Commands + +(git-rebase-define-action pick) +(git-rebase-define-action reword) +(git-rebase-define-action edit) +(git-rebase-define-action squash) +(git-rebase-define-action fixup) + +(defun git-rebase-move-line-up () + "Move the current action line up." + (interactive) + (when (git-rebase-looking-at-action-or-exec) + (let ((buffer-read-only nil) + (col (current-column))) + (goto-char (point-at-bol)) + (unless (bobp) + (transpose-lines 1) + (forward-line -2)) + (move-to-column col)))) + +(defun git-rebase-move-line-down () + "Assuming the next line is also an action line, move the current line down." + (interactive) + ;; if we're on an action and the next line is also an action + (when (and (git-rebase-looking-at-action-or-exec) + (save-excursion + (forward-line) + (git-rebase-looking-at-action-or-exec))) + (let ((buffer-read-only nil) + (col (current-column))) + (forward-line 1) + (transpose-lines 1) + (forward-line -1) + (move-to-column col)))) + +(defun git-rebase-server-edit () + "Save the action buffer and end the session." + (interactive) + (save-buffer) + (server-edit)) + +(defun git-rebase-abort () + "Abort this rebase. +This is dune by emptying the buffer, saving and closing server +connection." + (interactive) + (when (or (not (buffer-modified-p)) + (y-or-n-p "Abort this rebase? ")) + (let ((buffer-read-only nil)) + (erase-buffer) + (save-buffer) + (server-edit)))) + +(defun git-rebase-kill-line () + "Kill the current action line." + (interactive) + (when (and (not (eq (char-after (point-at-bol)) ?#)) + (git-rebase-looking-at-action-or-exec)) + (beginning-of-line) + (let ((inhibit-read-only t)) + (insert "#")) + (forward-line))) + +(defun git-rebase-insert (rev) + "Read an arbitrary commit and insert it below current line." + (interactive + (list (if (fboundp 'magit-read-branch-or-commit) + (magit-read-branch-or-commit "Insert revision") + (read-string "Insert revision: ")))) + (forward-line) + (let ((summary (if (fboundp 'magit-rev-format) + (magit-rev-format "%h %s" rev) + (process-lines "git" "show" "-s" "--format=%h %s" rev)))) + (if summary + (let ((inhibit-read-only t)) + (insert "pick " summary ?\n)) + (user-error "Unknown revision")))) + +(defun git-rebase-exec (edit) + "Prompt the user for a shell command to be executed, and +add it to the todo list. + +If the cursor is on a commented-out exec line, uncomment the +current line instead of prompting. + +When the prefix argument EDIT is non-nil and the cursor is on an +exec line, edit that line instead of inserting a new one. If the +exec line was commented out, also uncomment it." + (interactive "P") + (cond + ((and edit (git-rebase-looking-at-exec)) + (let ((new-line (git-rebase-read-exec-line + (match-string-no-properties 2 (thing-at-point 'line)))) + (inhibit-read-only t)) + (delete-region (point-at-bol) (point-at-eol)) + (if (not (equal "" new-line)) + (insert "exec " new-line) + (delete-char -1) + (forward-line)) + (move-beginning-of-line nil))) + ((git-rebase-looking-at-killed-exec) + (save-excursion + (beginning-of-line) + (let ((buffer-read-only nil)) + (delete-char 1)))) + (t + (let ((inhibit-read-only t) + (line (git-rebase-read-exec-line))) + (unless (equal "" line) + (move-end-of-line nil) + (newline) + (insert (concat "exec " line)))) + (move-beginning-of-line nil)))) + +(defun git-rebase-read-exec-line (&optional initial-line) + (read-shell-command "Execute: " initial-line)) + +(defun git-rebase-undo (&optional arg) + "A thin wrapper around `undo', which allows undoing in read-only buffers." + (interactive "P") + (let ((inhibit-read-only t)) + (undo arg))) + +(defun git-rebase-show-commit (&optional arg) + "Show the commit on the current line if any." + (interactive "P") + (save-excursion + (goto-char (point-at-bol)) + (when (looking-at git-rebase-action-line-re) + (let ((commit (match-string 2))) + (if (fboundp 'magit-show-commit) + (magit-show-commit commit) + (shell-command (concat "git show " commit))))))) + +(defun git-rebase-backward-line (&optional n) + "Move N lines backward (forward if N is negative). +Like `forward-line' but go into the opposite direction." + (interactive "p") + (forward-line (* n -1))) + +;;; Mode + +;;;###autoload +(define-derived-mode git-rebase-mode special-mode "Git Rebase" + "Major mode for editing of a Git rebase file. + +Rebase files are generated when you run 'git rebase -i' or run +`magit-interactive-rebase'. They describe how Git should perform +the rebase. See the documentation for git-rebase (e.g., by +running 'man git-rebase' at the command line) for details." + (setq font-lock-defaults '(git-rebase-mode-font-lock-keywords t t)) + (when git-rebase-remove-instructions + (let ((inhibit-read-only t)) + (flush-lines "^\\($\\|#\\)")))) + +(defvar git-rebase-mode-font-lock-keywords + `((,git-rebase-action-line-re + (1 font-lock-keyword-face) + (2 'git-rebase-hash) + (3 'git-rebase-description)) + (,git-rebase-exec-line-re 1 font-lock-keyword-face) + ("^#.*" 0 font-lock-comment-face) + (,git-rebase-dead-line-re 0 'git-rebase-killed-action t)) + "Font lock keywords for Git-Rebase mode.") + +(defun git-rebase-mode-show-keybindings () + "Modify the \"Commands:\" section of the comment Git generates +at the bottom of the file so that in place of the one-letter +abbreviation for the command, it shows the command's keybinding. +By default, this is the same except for the \"pick\" command." + (save-excursion + (goto-char (point-min)) + (while (search-forward-regexp "^# \\(.\\), \\([[:alpha:]]+\\) = " nil t) + (let ((start (match-beginning 1)) + (end (match-end 1)) + (command (intern (concat "git-rebase-" (match-string 2))))) + (when (fboundp command) + (let ((overlay (make-overlay start end))) + (overlay-put + overlay 'display + (key-description (where-is-internal command nil t))))))))) + +(add-hook 'git-rebase-mode-hook 'git-rebase-mode-show-keybindings t) + +(defun git-rebase-mode-disable-before-save-hook () + (set (make-local-variable 'before-save-hook) nil)) + +(add-hook 'git-rebase-mode-hook 'git-rebase-mode-disable-before-save-hook) + +;;;###autoload +(add-to-list 'auto-mode-alist + '("/git-rebase-todo\\'" . git-rebase-mode)) + +(provide 'git-rebase-mode) +;; Local Variables: +;; indent-tabs-mode: nil +;; End: +;;; git-rebase-mode.el ends here diff --git a/emacs.d/elpa/go-mode-20140905.2210/go-mode-autoloads.el b/emacs.d/elpa/go-mode-20140905.2210/go-mode-autoloads.el deleted file mode 100644 index 5e94fae..0000000 --- a/emacs.d/elpa/go-mode-20140905.2210/go-mode-autoloads.el +++ /dev/null @@ -1,95 +0,0 @@ -;;; go-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "go-mode" "go-mode.el" (21573 46911 0 0)) -;;; Generated autoloads from go-mode.el - -(autoload 'go-mode "go-mode" "\ -Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt and -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -In addition to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-imports' -- `go-play-buffer' and `go-play-region' -- `go-download-play' -- `godef-describe' and `godef-jump' -- `go-coverage' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook #'gofmt-before-save) - -If you want to use `godef-jump' instead of etags (or similar), -consider binding godef-jump to `M-.', which is the default key -for `find-tag': - -\(add-hook 'go-mode-hook (lambda () - (local-set-key (kbd \"M-.\") #'godef-jump))) - -Please note that godef is an external dependency. You can install -it with - -go get code.google.com/p/rog-go/exp/cmd/godef - - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended that you look at flycheck -\(see URL `https://github.com/flycheck/flycheck') or flymake in combination -with goflymake (see URL `https://github.com/dougm/goflymake'), gocode -\(see URL `https://github.com/nsf/gocode'), go-eldoc -\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go -\(see URL `https://github.com/dominikh/yasnippet-go') - -\(fn)" t nil) - -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(autoload 'gofmt-before-save "go-mode" "\ -Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading. - -\(fn)" t nil) - -(autoload 'godoc "go-mode" "\ -Show Go documentation for a query, much like M-x man. - -\(fn QUERY)" t nil) - -(autoload 'go-download-play "go-mode" "\ -Downloads a paste from the playground and inserts it in a Go -buffer. Tries to look for a URL at point. - -\(fn URL)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; go-mode-autoloads.el ends here diff --git a/emacs.d/elpa/go-mode-20140905.2210/go-mode-pkg.el b/emacs.d/elpa/go-mode-20140905.2210/go-mode-pkg.el deleted file mode 100644 index 717221e..0000000 --- a/emacs.d/elpa/go-mode-20140905.2210/go-mode-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "go-mode" "20140905.2210" "Major mode for the Go programming language" 'nil :url "https://github.com/dominikh/go-mode.el" :keywords '("languages" "go")) diff --git a/emacs.d/elpa/go-mode-20140905.2210/go-mode.el b/emacs.d/elpa/go-mode-20140905.2210/go-mode.el deleted file mode 100644 index f76ced3..0000000 --- a/emacs.d/elpa/go-mode-20140905.2210/go-mode.el +++ /dev/null @@ -1,1505 +0,0 @@ -;;; go-mode.el --- Major mode for the Go programming language - -;; Copyright 2013 The go-mode Authors. All rights reserved. -;; Use of this source code is governed by a BSD-style -;; license that can be found in the LICENSE file. - -;; Author: The go-mode Authors -;; Version: 20140905.2210 -;; X-Original-Version: 10 -;; Keywords: languages go -;; URL: https://github.com/dominikh/go-mode.el -;; -;; This file is not part of GNU Emacs. - -;;; Code: - -(require 'cl) -(require 'etags) -(require 'ffap) -(require 'find-file) -(require 'ring) -(require 'url) - -;; XEmacs compatibility guidelines -;; - Minimum required version of XEmacs: 21.5.32 -;; - Feature that cannot be backported: POSIX character classes in -;; regular expressions -;; - Functions that could be backported but won't because 21.5.32 -;; covers them: plenty. -;; - Features that are still partly broken: -;; - godef will not work correctly if multibyte characters are -;; being used -;; - Fontification will not handle unicode correctly -;; -;; - Do not use \_< and \_> regexp delimiters directly; use -;; go--regexp-enclose-in-symbol -;; -;; - The character `_` must not be a symbol constituent but a -;; character constituent -;; -;; - Do not use process-lines -;; -;; - Use go--old-completion-list-style when using a plain list as the -;; collection for completing-read -;; -;; - Use go--position-bytes instead of position-bytes -(defmacro go--xemacs-p () - `(featurep 'xemacs)) - -;; Delete the current line without putting it in the kill-ring. -(defun go--delete-whole-line (&optional arg) - ;; Derived from `kill-whole-line'. - ;; ARG is defined as for that function. - (setq arg (or arg 1)) - (if (and (> arg 0) - (eobp) - (save-excursion (forward-visible-line 0) (eobp))) - (signal 'end-of-buffer nil)) - (if (and (< arg 0) - (bobp) - (save-excursion (end-of-visible-line) (bobp))) - (signal 'beginning-of-buffer nil)) - (cond ((zerop arg) - (delete-region (progn (forward-visible-line 0) (point)) - (progn (end-of-visible-line) (point)))) - ((< arg 0) - (delete-region (progn (end-of-visible-line) (point)) - (progn (forward-visible-line (1+ arg)) - (unless (bobp) - (backward-char)) - (point)))) - (t - (delete-region (progn (forward-visible-line 0) (point)) - (progn (forward-visible-line arg) (point)))))) - -;; declare-function is an empty macro that only byte-compile cares -;; about. Wrap in always false if to satisfy Emacsen without that -;; macro. -(if nil - (declare-function go--position-bytes "go-mode" (point))) - -;; XEmacs unfortunately does not offer position-bytes. We can fall -;; back to just using (point), but it will be incorrect as soon as -;; multibyte characters are being used. -(if (fboundp 'position-bytes) - (defalias 'go--position-bytes #'position-bytes) - (defun go--position-bytes (point) point)) - -(defun go--old-completion-list-style (list) - (mapcar (lambda (x) (cons x nil)) list)) - -;; GNU Emacs 24 has prog-mode, older GNU Emacs and XEmacs do not, so -;; copy its definition for those. -(if (not (fboundp 'prog-mode)) - (define-derived-mode prog-mode fundamental-mode "Prog" - "Major mode for editing source code." - (set (make-local-variable 'require-final-newline) mode-require-final-newline) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (setq bidi-paragraph-direction 'left-to-right))) - -(defun go--regexp-enclose-in-symbol (s) - ;; XEmacs does not support \_<, GNU Emacs does. In GNU Emacs we make - ;; extensive use of \_< to support unicode in identifiers. Until we - ;; come up with a better solution for XEmacs, this solution will - ;; break fontification in XEmacs for identifiers such as "typeµ". - ;; XEmacs will consider "type" a keyword, GNU Emacs won't. - - (if (go--xemacs-p) - (concat "\\<" s "\\>") - (concat "\\_<" s "\\_>"))) - -;; Move up one level of parentheses. -(defun go-goto-opening-parenthesis (&optional legacy-unused) - ;; The old implementation of go-goto-opening-parenthesis had an - ;; optional argument to speed up the function. It didn't change the - ;; function's outcome. - - ;; Silently fail if there's no matching opening parenthesis. - (condition-case nil - (backward-up-list) - (scan-error nil))) - - -(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]") -(defconst go-identifier-regexp "[[:word:][:multibyte:]]+") -(defconst go-type-name-no-prefix-regexp "\\(?:[[:word:][:multibyte:]]+\\.\\)?[[:word:][:multibyte:]]+") -(defconst go-qualified-identifier-regexp (concat go-identifier-regexp "\\." go-identifier-regexp)) -(defconst go-label-regexp go-identifier-regexp) -(defconst go-type-regexp "[[:word:][:multibyte:]*]+") -(defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s *\\(" go-identifier-regexp "\\)")) -(defconst go-func-meth-regexp (concat - (go--regexp-enclose-in-symbol "func") "\\s *\\(?:(\\s *" - "\\(" go-identifier-regexp "\\s +\\)?" go-type-regexp - "\\s *)\\s *\\)?\\(" - go-identifier-regexp - "\\)(")) - -(defconst go-builtins - '("append" "cap" "close" "complex" "copy" - "delete" "imag" "len" "make" "new" - "panic" "print" "println" "real" "recover") - "All built-in functions in the Go language. Used for font locking.") - -(defconst go-mode-keywords - '("break" "default" "func" "interface" "select" - "case" "defer" "go" "map" "struct" - "chan" "else" "goto" "package" "switch" - "const" "fallthrough" "if" "range" "type" - "continue" "for" "import" "return" "var") - "All keywords in the Go language. Used for font locking.") - -(defconst go-constants '("nil" "true" "false" "iota")) -(defconst go-type-name-regexp (concat "\\(?:[*(]\\)*\\(\\(?:" go-identifier-regexp "\\.\\)?" go-identifier-regexp "\\)")) - -;; Maximum number of identifiers that can be highlighted as type names -;; in one function type/declaration. -(defconst go--font-lock-func-param-num-groups 16) - -(defvar go-dangling-cache) -(defvar go-godoc-history nil) -(defvar go--coverage-current-file-name) - -(defgroup go nil - "Major mode for editing Go code" - :group 'languages) - -(defgroup go-cover nil - "Options specific to `cover`" - :group 'go) - -(defcustom go-fontify-function-calls t - "Fontify function and method calls if this is non-nil." - :type 'boolean - :group 'go) - -(defcustom go-mode-hook nil - "Hook called by `go-mode'." - :type 'hook - :group 'go) - -(defcustom go-command "go" - "The 'go' command. Some users have multiple Go development -trees and invoke the 'go' tool via a wrapper that sets GOROOT and -GOPATH based on the current directory. Such users should -customize this variable to point to the wrapper script." - :type 'string - :group 'go) - -(defcustom gofmt-command "gofmt" - "The 'gofmt' command. Some users may replace this with 'goimports' -from https://github.com/bradfitz/goimports." - :type 'string - :group 'go) - -(defcustom gofmt-show-errors 'buffer - "Where to display gofmt error output. It can either be -displayed in its own buffer, in the echo area, or not at all. - -Please note that Emacs outputs to the echo area when writing -files and will overwrite gofmt's echo output if used from inside -a before-save-hook." - :type '(choice - (const :tag "Own buffer" buffer) - (const :tag "Echo area" echo) - (const :tag "None" nil)) - :group 'go) - -(defcustom go-other-file-alist - '(("_test\\.go\\'" (".go")) - ("\\.go\\'" ("_test.go"))) - "See the documentation of `ff-other-file-alist' for details." - :type '(repeat (list regexp (choice (repeat string) function))) - :group 'go) - -(defcustom go-coverage-display-buffer-func 'display-buffer-reuse-window - "How go-coverage should display the coverage buffer. See -`display-buffer' for a list of possible functions." - :type 'function - :group 'go-cover) - -(defface go-coverage-untracked - '((t (:foreground "#505050"))) - "Coverage color of untracked code." - :group 'go-cover) - -(defface go-coverage-0 - '((t (:foreground "#c00000"))) - "Coverage color for uncovered code." - :group 'go-cover) -(defface go-coverage-1 - '((t (:foreground "#808080"))) - "Coverage color for covered code with weight 1." - :group 'go-cover) -(defface go-coverage-2 - '((t (:foreground "#748c83"))) - "Coverage color for covered code with weight 2." - :group 'go-cover) -(defface go-coverage-3 - '((t (:foreground "#689886"))) - "Coverage color for covered code with weight 3." - :group 'go-cover) -(defface go-coverage-4 - '((t (:foreground "#5ca489"))) - "Coverage color for covered code with weight 4." - :group 'go-cover) -(defface go-coverage-5 - '((t (:foreground "#50b08c"))) - "Coverage color for covered code with weight 5." - :group 'go-cover) -(defface go-coverage-6 - '((t (:foreground "#44bc8f"))) - "Coverage color for covered code with weight 6." - :group 'go-cover) -(defface go-coverage-7 - '((t (:foreground "#38c892"))) - "Coverage color for covered code with weight 7." - :group 'go-cover) -(defface go-coverage-8 - '((t (:foreground "#2cd495"))) - "Coverage color for covered code with weight 8. -For mode=set, all covered lines will have this weight." - :group 'go-cover) -(defface go-coverage-9 - '((t (:foreground "#20e098"))) - "Coverage color for covered code with weight 9." - :group 'go-cover) -(defface go-coverage-10 - '((t (:foreground "#14ec9b"))) - "Coverage color for covered code with weight 10." - :group 'go-cover) -(defface go-coverage-covered - '((t (:foreground "#2cd495"))) - "Coverage color of covered code." - :group 'go-cover) - -(defvar go-mode-syntax-table - (let ((st (make-syntax-table))) - (modify-syntax-entry ?+ "." st) - (modify-syntax-entry ?- "." st) - (modify-syntax-entry ?% "." st) - (modify-syntax-entry ?& "." st) - (modify-syntax-entry ?| "." st) - (modify-syntax-entry ?^ "." st) - (modify-syntax-entry ?! "." st) - (modify-syntax-entry ?= "." st) - (modify-syntax-entry ?< "." st) - (modify-syntax-entry ?> "." st) - (modify-syntax-entry ?/ (if (go--xemacs-p) ". 1456" ". 124b") st) - (modify-syntax-entry ?* ". 23" st) - (modify-syntax-entry ?\n "> b" st) - (modify-syntax-entry ?\" "\"" st) - (modify-syntax-entry ?\' "\"" st) - (modify-syntax-entry ?` "\"" st) - (modify-syntax-entry ?\\ "\\" st) - ;; It would be nicer to have _ as a symbol constituent, but that - ;; would trip up XEmacs, which does not support the \_< anchor - (modify-syntax-entry ?_ "w" st) - - st) - "Syntax table for Go mode.") - -(defun go--build-font-lock-keywords () - ;; we cannot use 'symbols in regexp-opt because GNU Emacs <24 - ;; doesn't understand that - (append - `((go--match-func - ,@(mapcar (lambda (x) `(,x font-lock-type-face)) - (number-sequence 1 go--font-lock-func-param-num-groups))) - (,(go--regexp-enclose-in-symbol (regexp-opt go-mode-keywords t)) . font-lock-keyword-face) - (,(concat "\\(" (go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) "\\)[[:space:]]*(") 1 font-lock-builtin-face) - (,(go--regexp-enclose-in-symbol (regexp-opt go-constants t)) . font-lock-constant-face) - (,go-func-regexp 1 font-lock-function-name-face)) ;; function (not method) name - - (if go-fontify-function-calls - `((,(concat "\\(" go-identifier-regexp "\\)[[:space:]]*(") 1 font-lock-function-name-face) ;; function call/method name - (,(concat "[^[:word:][:multibyte:]](\\(" go-identifier-regexp "\\))[[:space:]]*(") 1 font-lock-function-name-face)) ;; bracketed function call - `((,go-func-meth-regexp 2 font-lock-function-name-face))) ;; method name - - `( - ("\\(`[^`]*`\\)" 1 font-lock-multiline) ;; raw string literal, needed for font-lock-syntactic-keywords - (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+\\([^[:space:]]+\\)") 1 font-lock-type-face) ;; types - (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+" go-identifier-regexp "[[:space:]]*" go-type-name-regexp) 1 font-lock-type-face) ;; types - (,(concat "[^[:word:][:multibyte:]]\\[\\([[:digit:]]+\\|\\.\\.\\.\\)?\\]" go-type-name-regexp) 2 font-lock-type-face) ;; Arrays/slices - (,(concat "\\(" go-type-name-regexp "\\)" "{") 1 font-lock-type-face) - (,(concat (go--regexp-enclose-in-symbol "map") "\\[[^]]+\\]" go-type-name-regexp) 1 font-lock-type-face) ;; map value type - (,(concat (go--regexp-enclose-in-symbol "map") "\\[" go-type-name-regexp) 1 font-lock-type-face) ;; map key type - (,(concat (go--regexp-enclose-in-symbol "chan") "[[:space:]]*\\(?:<-[[:space:]]*\\)?" go-type-name-regexp) 1 font-lock-type-face) ;; channel type - (,(concat (go--regexp-enclose-in-symbol "\\(?:new\\|make\\)") "\\(?:[[:space:]]\\|)\\)*(" go-type-name-regexp) 1 font-lock-type-face) ;; new/make type - ;; TODO do we actually need this one or isn't it just a function call? - (,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type conversion - ;; Like the original go-mode this also marks compound literal - ;; fields. There, it was marked as to fix, but I grew quite - ;; accustomed to it, so it'll stay for now. - (,(concat "^[[:space:]]*\\(" go-label-regexp "\\)[[:space:]]*:\\(\\S.\\|$\\)") 1 font-lock-constant-face) ;; Labels and compound literal fields - (,(concat (go--regexp-enclose-in-symbol "\\(goto\\|break\\|continue\\)") "[[:space:]]*\\(" go-label-regexp "\\)") 2 font-lock-constant-face)))) ;; labels in goto/break/continue - -(defconst go--font-lock-syntactic-keywords - ;; Override syntax property of raw string literal contents, so that - ;; backslashes have no special meaning in ``. Used in Emacs 23 or older. - '((go--match-raw-string-literal - (1 (7 . ?`)) - (2 (15 . nil)) ;; 15 = "generic string" - (3 (7 . ?`))))) - -(defvar go-mode-map - (let ((m (make-sparse-keymap))) - (define-key m "}" #'go-mode-insert-and-indent) - (define-key m ")" #'go-mode-insert-and-indent) - (define-key m "," #'go-mode-insert-and-indent) - (define-key m ":" #'go-mode-insert-and-indent) - (define-key m "=" #'go-mode-insert-and-indent) - (define-key m (kbd "C-c C-a") #'go-import-add) - (define-key m (kbd "C-c C-j") #'godef-jump) - (define-key m (kbd "C-x 4 C-c C-j") #'godef-jump-other-window) - (define-key m (kbd "C-c C-d") #'godef-describe) - m) - "Keymap used by Go mode to implement electric keys.") - -(defun go-mode-insert-and-indent (key) - "Invoke the global binding of KEY, then reindent the line." - - (interactive (list (this-command-keys))) - (call-interactively (lookup-key (current-global-map) key)) - (indent-according-to-mode)) - -(defmacro go-paren-level () - `(car (syntax-ppss))) - -(defmacro go-in-string-or-comment-p () - `(nth 8 (syntax-ppss))) - -(defmacro go-in-string-p () - `(nth 3 (syntax-ppss))) - -(defmacro go-in-comment-p () - `(nth 4 (syntax-ppss))) - -(defmacro go-goto-beginning-of-string-or-comment () - `(goto-char (nth 8 (syntax-ppss)))) - -(defun go--backward-irrelevant (&optional stop-at-string) - "Skips backwards over any characters that are irrelevant for -indentation and related tasks. - -It skips over whitespace, comments, cases and labels and, if -STOP-AT-STRING is not true, over strings." - - (let (pos (start-pos (point))) - (skip-chars-backward "\n\s\t") - (if (and (save-excursion (beginning-of-line) (go-in-string-p)) (looking-back "`") (not stop-at-string)) - (backward-char)) - (if (and (go-in-string-p) (not stop-at-string)) - (go-goto-beginning-of-string-or-comment)) - (if (looking-back "\\*/") - (backward-char)) - (if (go-in-comment-p) - (go-goto-beginning-of-string-or-comment)) - (setq pos (point)) - (beginning-of-line) - (if (or (looking-at (concat "^" go-label-regexp ":")) (looking-at "^[[:space:]]*\\(case .+\\|default\\):")) - (end-of-line 0) - (goto-char pos)) - (if (/= start-pos (point)) - (go--backward-irrelevant stop-at-string)) - (/= start-pos (point)))) - -(defun go--buffer-narrowed-p () - "Return non-nil if the current buffer is narrowed." - (/= (buffer-size) - (- (point-max) - (point-min)))) - -(defun go--match-raw-string-literal (end) - "Search for a raw string literal. Set point to the end of the -occurence found on success. Returns nil on failure." - (unless (go-in-string-or-comment-p) - (when (search-forward "`" end t) - (goto-char (match-beginning 0)) - (if (go-in-string-or-comment-p) - (progn (goto-char (match-end 0)) - (go--match-raw-string-literal end)) - (when (looking-at "\\(`\\)\\([^`]*\\)\\(`\\)") - (goto-char (match-end 0)) - t))))) - -(defun go-previous-line-has-dangling-op-p () - "Returns non-nil if the current line is a continuation line." - (let* ((cur-line (line-number-at-pos)) - (val (gethash cur-line go-dangling-cache 'nope))) - (if (or (go--buffer-narrowed-p) (equal val 'nope)) - (save-excursion - (beginning-of-line) - (go--backward-irrelevant t) - (setq val (looking-back go-dangling-operators-regexp)) - (if (not (go--buffer-narrowed-p)) - (puthash cur-line val go-dangling-cache)))) - val)) - -(defun go--at-function-definition () - "Return non-nil if point is on the opening curly brace of a -function definition. - -We do this by first calling (beginning-of-defun), which will take -us to the start of *some* function. We then look for the opening -curly brace of that function and compare its position against the -curly brace we are checking. If they match, we return non-nil." - (if (= (char-after) ?\{) - (save-excursion - (let ((old-point (point)) - start-nesting) - (beginning-of-defun) - (when (looking-at "func ") - (setq start-nesting (go-paren-level)) - (skip-chars-forward "^{") - (while (> (go-paren-level) start-nesting) - (forward-char) - (skip-chars-forward "^{") 0) - (if (and (= (go-paren-level) start-nesting) (= old-point (point))) - t)))))) - -(defun go--indentation-for-opening-parenthesis () - "Return the semantic indentation for the current opening parenthesis. - -If point is on an opening curly brace and said curly brace -belongs to a function declaration, the indentation of the func -keyword will be returned. Otherwise the indentation of the -current line will be returned." - (save-excursion - (if (go--at-function-definition) - (progn - (beginning-of-defun) - (current-indentation)) - (current-indentation)))) - -(defun go-indentation-at-point () - (save-excursion - (let (start-nesting) - (back-to-indentation) - (setq start-nesting (go-paren-level)) - - (cond - ((go-in-string-p) - (current-indentation)) - ((looking-at "[])}]") - (go-goto-opening-parenthesis) - (if (go-previous-line-has-dangling-op-p) - (- (current-indentation) tab-width) - (go--indentation-for-opening-parenthesis))) - ((progn (go--backward-irrelevant t) (looking-back go-dangling-operators-regexp)) - ;; only one nesting for all dangling operators in one operation - (if (go-previous-line-has-dangling-op-p) - (current-indentation) - (+ (current-indentation) tab-width))) - ((zerop (go-paren-level)) - 0) - ((progn (go-goto-opening-parenthesis) (< (go-paren-level) start-nesting)) - (if (go-previous-line-has-dangling-op-p) - (current-indentation) - (+ (go--indentation-for-opening-parenthesis) tab-width))) - (t - (current-indentation)))))) - -(defun go-mode-indent-line () - (interactive) - (let (indent - shift-amt - (pos (- (point-max) (point))) - (point (point)) - (beg (line-beginning-position))) - (back-to-indentation) - (if (go-in-string-or-comment-p) - (goto-char point) - (setq indent (go-indentation-at-point)) - (if (looking-at (concat go-label-regexp ":\\([[:space:]]*/.+\\)?$\\|case .+:\\|default:")) - (decf indent tab-width)) - (setq shift-amt (- indent (current-column))) - (if (zerop shift-amt) - nil - (delete-region beg (point)) - (indent-to indent)) - ;; If initial point was within line's indentation, - ;; position after the indentation. Else stay at same point in text. - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos)))))) - -(defun go-beginning-of-defun (&optional count) - (unless (bolp) - (end-of-line)) - (setq count (or count 1)) - (let (first failure) - (dotimes (i (abs count)) - (setq first t) - (while (and (not failure) - (or first (go-in-string-or-comment-p))) - (if (>= count 0) - (progn - (go--backward-irrelevant) - (if (not (re-search-backward go-func-meth-regexp nil t)) - (setq failure t))) - (if (looking-at go-func-meth-regexp) - (forward-char)) - (if (not (re-search-forward go-func-meth-regexp nil t)) - (setq failure t))) - (setq first nil))) - (if (< count 0) - (beginning-of-line)) - (not failure))) - -(defun go-end-of-defun () - (let (orig-level) - ;; It can happen that we're not placed before a function by emacs - (if (not (looking-at "func")) - (go-beginning-of-defun -1)) - ;; Find the { that starts the function, i.e., the next { that isn't - ;; preceded by struct or interface, or a comment or struct tag. BUG: - ;; breaks if there's a comment between the struct/interface keyword and - ;; bracket, like this: - ;; - ;; struct /* why? */ { - (while (progn - (skip-chars-forward "^{") - (forward-char) - (or (go-in-string-or-comment-p) - (looking-back "\\(struct\\|interface\\)\\s-*{")))) - (setq orig-level (go-paren-level)) - (while (>= (go-paren-level) orig-level) - (skip-chars-forward "^}") - (forward-char)))) - -(defun go--find-enclosing-parentheses (position) - "Return points of outermost '(' and ')' surrounding POSITION if -such parentheses exist. - -If outermost '(' exists but ')' does not, it returns the next blank -line or end-of-buffer position instead of the position of the closing -parenthesis. - -If the starting parenthesis is not found, it returns (POSITION -POSITION). -" - (save-excursion - (let (beg end) - (goto-char position) - (while (> (go-paren-level) 0) - (re-search-backward "[(\\[{]" nil t) - (when (looking-at "(") - (setq beg (point)))) - (if (null beg) - (list position position) - (goto-char position) - (while (and (> (go-paren-level) 0) - (search-forward ")" nil t))) - (when (> (go-paren-level) 0) - (unless (re-search-forward "^[[:space:]]*$" nil t) - (goto-char (point-max)))) - (list beg (point)))))) - -(defun go--search-next-comma (end) - "Search forward from point for a comma whose nesting level is -the same as point. If it reaches the end of line or a closing -parenthesis before a comma, it stops at it." - (let ((orig-level (go-paren-level))) - (while (and (< (point) end) - (or (looking-at "[^,)\n]") - (> (go-paren-level) orig-level))) - (forward-char)) - (when (and (looking-at ",") - (< (point) (1- end))) - (forward-char)))) - -(defun go--looking-at-keyword () - (and (looking-at (concat "\\(" go-identifier-regexp "\\)")) - (member (match-string 1) go-mode-keywords))) - -(defun go--match-func (end) - "Search for identifiers used as type names from a function -parameter list, and set the identifier positions as the results -of last search. Return t if search succeeded." - (when (re-search-forward (go--regexp-enclose-in-symbol "func") end t) - (let ((regions (go--match-func-type-names end))) - (if (null regions) - ;; Nothing to highlight. This can happen if the current func - ;; is "func()". Try next one. - (go--match-func end) - ;; There are something to highlight. Set those positions as - ;; last search results. - (setq regions (go--filter-match-data regions end)) - (when regions - (set-match-data (go--make-match-data regions)) - t))))) - -(defun go--match-func-type-names (end) - (cond - ;; Function declaration (e.g. "func foo(") - ((looking-at (concat "[[:space:]\n]*" go-identifier-regexp "[[:space:]\n]*(")) - (goto-char (match-end 0)) - (nconc (go--match-parameter-list end) - (go--match-function-result end))) - ;; Method declaration, function literal, or function type - ((looking-at "[[:space:]]*(") - (goto-char (match-end 0)) - (let ((regions (go--match-parameter-list end))) - ;; Method declaration (e.g. "func (x y) foo(") - (when (looking-at (concat "[[:space:]]*" go-identifier-regexp "[[:space:]\n]*(")) - (goto-char (match-end 0)) - (setq regions (nconc regions (go--match-parameter-list end)))) - (nconc regions (go--match-function-result end)))))) - -(defun go--parameter-list-type (end) - "Return 'present if the parameter list has names, or 'absent if -not, assuming point is at the beginning of a parameter list, just -after '('." - (save-excursion - (skip-chars-forward "[:space:]\n" end) - (cond ((> (point) end) - nil) - ((looking-at (concat go-identifier-regexp "[[:space:]\n]*,")) - (goto-char (match-end 0)) - (go--parameter-list-type end)) - ((or (looking-at go-qualified-identifier-regexp) - (looking-at (concat go-type-name-no-prefix-regexp "[[:space:]\n]*\\(?:)\\|\\'\\)")) - (go--looking-at-keyword) - (looking-at "[*\\[]\\|\\.\\.\\.\\|\\'")) - 'absent) - (t 'present)))) - -(defconst go--opt-dotdotdot-regexp "\\(?:\\.\\.\\.\\)?") -(defconst go--parameter-type-regexp - (concat go--opt-dotdotdot-regexp "[[:space:]*\n]*\\(" go-type-name-no-prefix-regexp "\\)[[:space:]\n]*\\([,)]\\|\\'\\)")) -(defconst go--func-type-in-parameter-list-regexp - (concat go--opt-dotdotdot-regexp "[[:space:]*\n]*\\(" (go--regexp-enclose-in-symbol "func") "\\)")) - -(defun go--match-parameters-common (identifier-regexp end) - (let ((acc ()) - (start -1)) - (while (progn (skip-chars-forward "[:space:]\n" end) - (and (not (looking-at "\\(?:)\\|\\'\\)")) - (< start (point)) - (<= (point) end))) - (setq start (point)) - (cond - ((looking-at (concat identifier-regexp go--parameter-type-regexp)) - (setq acc (nconc acc (list (match-beginning 1) (match-end 1)))) - (goto-char (match-beginning 2))) - ((looking-at (concat identifier-regexp go--func-type-in-parameter-list-regexp)) - (goto-char (match-beginning 1)) - (setq acc (nconc acc (go--match-func-type-names end))) - (go--search-next-comma end)) - (t - (go--search-next-comma end)))) - (when (and (looking-at ")") - (< (point) end)) - (forward-char)) - acc)) - -(defun go--match-parameters-with-identifier-list (end) - (go--match-parameters-common - (concat go-identifier-regexp "[[:space:]\n]+") - end)) - -(defun go--match-parameters-without-identifier-list (end) - (go--match-parameters-common "" end)) - -(defun go--filter-match-data (regions end) - "Remove points from regions if they are beyond end. Regions are -a list whose size is multiple of 2. Element 2n is beginning of a -region and 2n+1 is end of it. - -This function is used to make sure we don't override end point -that font-lock-mode gave to us." - (when regions - (let* ((vec (vconcat regions)) - (i 0) - (len (length vec))) - (while (and (< i len) - (<= (nth i regions) end) - (<= (nth (1+ i) regions) end)) - (setq i (+ i 2))) - (cond ((= i len) - regions) - ((zerop i) - nil) - (t - (setcdr (nth i regions) nil) - regions))))) - -(defun go--make-match-data (regions) - (let ((deficit (- (* 2 go--font-lock-func-param-num-groups) - (length regions)))) - (when (> deficit 0) - (let ((last (car (last regions)))) - (setq regions (nconc regions (make-list deficit last)))))) - `(,(car regions) ,@(last regions) ,@regions)) - -(defun go--match-parameter-list (end) - "Returns a list of identifier positions that are used as type -names in a function parameter list, assuming point is at the -beginning of a parameter list. Returns nil if the text after -point does not look like a parameter list. - -Set point to end of closing parenthesis on success. - -In Go, the names must either all be present or all be absent -within a list of parameters. - -Parsing a parameter list is a little bit complicated because we -have to scan through the parameter list to determine whether or -not the list has names. Until a type name is found or reaching -end of a parameter list, we are not sure which form the parameter -list is. - -For example, X and Y are type names in a parameter list \"(X, -Y)\" but are parameter names in \"(X, Y int)\". We cannot say if -X is a type name until we see int after Y. - -Note that even \"(int, float T)\" is a valid parameter -list. Builtin type names are not reserved words. In this example, -int and float are parameter names and only T is a type name. - -In this function, we first scan the parameter list to see if the -list has names, and then handle it accordingly." - (let ((name (go--parameter-list-type end))) - (cond ((eq name 'present) - (go--match-parameters-with-identifier-list end)) - ((eq name 'absent) - (go--match-parameters-without-identifier-list end)) - (t nil)))) - -(defun go--match-function-result (end) - "Returns a list of identifier positions that are used as type -names in a function result, assuming point is at the beginning of -a result. - -Function result is a unparenthesized type or a parameter list." - (cond ((and (looking-at (concat "[[:space:]*]*\\(" go-type-name-no-prefix-regexp "\\)")) - (not (member (match-string 1) go-mode-keywords))) - (list (match-beginning 1) (match-end 1))) - ((looking-at "[[:space:]]*(") - (goto-char (match-end 0)) - (go--match-parameter-list end)) - (t nil))) - -;;;###autoload -(define-derived-mode go-mode prog-mode "Go" - "Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt and -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -In addition to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-imports' -- `go-play-buffer' and `go-play-region' -- `go-download-play' -- `godef-describe' and `godef-jump' -- `go-coverage' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook #'gofmt-before-save) - -If you want to use `godef-jump' instead of etags (or similar), -consider binding godef-jump to `M-.', which is the default key -for `find-tag': - -\(add-hook 'go-mode-hook (lambda () - (local-set-key (kbd \"M-.\") #'godef-jump))) - -Please note that godef is an external dependency. You can install -it with - -go get code.google.com/p/rog-go/exp/cmd/godef - - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended that you look at flycheck -\(see URL `https://github.com/flycheck/flycheck') or flymake in combination -with goflymake \(see URL `https://github.com/dougm/goflymake'), gocode -\(see URL `https://github.com/nsf/gocode'), go-eldoc -\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go -\(see URL `https://github.com/dominikh/yasnippet-go')" - - ;; Font lock - (set (make-local-variable 'font-lock-defaults) - '(go--build-font-lock-keywords)) - - ;; Indentation - (set (make-local-variable 'indent-line-function) #'go-mode-indent-line) - - ;; Comments - (set (make-local-variable 'comment-start) "// ") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'comment-use-syntax) t) - (set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *") - - (set (make-local-variable 'beginning-of-defun-function) #'go-beginning-of-defun) - (set (make-local-variable 'end-of-defun-function) #'go-end-of-defun) - - (set (make-local-variable 'parse-sexp-lookup-properties) t) - (if (boundp 'syntax-propertize-function) - (set (make-local-variable 'syntax-propertize-function) #'go-propertize-syntax) - (set (make-local-variable 'font-lock-syntactic-keywords) - go--font-lock-syntactic-keywords) - (set (make-local-variable 'font-lock-multiline) t)) - - (set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql)) - (add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t) - - ;; ff-find-other-file - (setq ff-other-file-alist 'go-other-file-alist) - - (setq imenu-generic-expression - '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1) - ("func" "^func *\\(.*\\) {" 1))) - (imenu-add-to-menubar "Index") - - ;; Go style - (setq indent-tabs-mode t) - - ;; Handle unit test failure output in compilation-mode - ;; - ;; Note the final t argument to add-to-list for append, ie put these at the - ;; *ends* of compilation-error-regexp-alist[-alist]. We want go-test to be - ;; handled first, otherwise other elements will match that don't work, and - ;; those alists are traversed in *reverse* order: - ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2001-12/msg00674.html - (when (and (boundp 'compilation-error-regexp-alist) - (boundp 'compilation-error-regexp-alist-alist)) - (add-to-list 'compilation-error-regexp-alist 'go-test t) - (add-to-list 'compilation-error-regexp-alist-alist - '(go-test . ("^\t+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$" 1 2)) t))) - -;;;###autoload -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(defun go--apply-rcs-patch (patch-buffer) - "Apply an RCS-formatted diff from PATCH-BUFFER to the current -buffer." - (let ((target-buffer (current-buffer)) - ;; Relative offset between buffer line numbers and line numbers - ;; in patch. - ;; - ;; Line numbers in the patch are based on the source file, so - ;; we have to keep an offset when making changes to the - ;; buffer. - ;; - ;; Appending lines decrements the offset (possibly making it - ;; negative), deleting lines increments it. This order - ;; simplifies the forward-line invocations. - (line-offset 0)) - (save-excursion - (with-current-buffer patch-buffer - (goto-char (point-min)) - (while (not (eobp)) - (unless (looking-at "^\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)") - (error "invalid rcs patch or internal error in go--apply-rcs-patch")) - (forward-line) - (let ((action (match-string 1)) - (from (string-to-number (match-string 2))) - (len (string-to-number (match-string 3)))) - (cond - ((equal action "a") - (let ((start (point))) - (forward-line len) - (let ((text (buffer-substring start (point)))) - (with-current-buffer target-buffer - (decf line-offset len) - (goto-char (point-min)) - (forward-line (- from len line-offset)) - (insert text))))) - ((equal action "d") - (with-current-buffer target-buffer - (go--goto-line (- from line-offset)) - (incf line-offset len) - (go--delete-whole-line len))) - (t - (error "invalid rcs patch or internal error in go--apply-rcs-patch"))))))))) - -(defun gofmt () - "Formats the current buffer according to the gofmt tool." - - (interactive) - (let ((tmpfile (make-temp-file "gofmt" nil ".go")) - (patchbuf (get-buffer-create "*Gofmt patch*")) - (errbuf (if gofmt-show-errors (get-buffer-create "*Gofmt Errors*"))) - (coding-system-for-read 'utf-8) - (coding-system-for-write 'utf-8)) - - (save-restriction - (widen) - (if errbuf - (with-current-buffer errbuf - (setq buffer-read-only nil) - (erase-buffer))) - (with-current-buffer patchbuf - (erase-buffer)) - - (write-region nil nil tmpfile) - - ;; We're using errbuf for the mixed stdout and stderr output. This - ;; is not an issue because gofmt -w does not produce any stdout - ;; output in case of success. - (if (zerop (call-process gofmt-command nil errbuf nil "-w" tmpfile)) - (progn - (if (zerop (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "-" tmpfile)) - (message "Buffer is already gofmted") - (go--apply-rcs-patch patchbuf) - (message "Applied gofmt")) - (if errbuf (kill-buffer errbuf))) - (message "Could not apply gofmt") - (if errbuf (gofmt--process-errors (buffer-file-name) tmpfile errbuf))) - - (kill-buffer patchbuf) - (delete-file tmpfile)))) - - -(defun gofmt--process-errors (filename tmpfile errbuf) - (with-current-buffer errbuf - (if (eq gofmt-show-errors 'echo) - (progn - (message "%s" (buffer-string)) - (kill-buffer errbuf)) - ;; Convert the gofmt stderr to something understood by the compilation mode. - (goto-char (point-min)) - (insert "gofmt errors:\n") - (while (search-forward-regexp (concat "^\\(" (regexp-quote tmpfile) "\\):") nil t) - (replace-match (file-name-nondirectory filename) t t nil 1)) - (compilation-mode) - (display-buffer errbuf)))) - -;;;###autoload -(defun gofmt-before-save () - "Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading." - - (interactive) - (when (eq major-mode 'go-mode) (gofmt))) - -(defun godoc--read-query () - "Read a godoc query from the minibuffer." - ;; Compute the default query as the symbol under the cursor. - ;; TODO: This does the wrong thing for e.g. multipart.NewReader (it only grabs - ;; half) but I see no way to disambiguate that from e.g. foobar.SomeMethod. - (let* ((bounds (bounds-of-thing-at-point 'symbol)) - (symbol (if bounds - (buffer-substring-no-properties (car bounds) - (cdr bounds))))) - (completing-read (if symbol - (format "godoc (default %s): " symbol) - "godoc: ") - (go--old-completion-list-style (go-packages)) nil nil nil 'go-godoc-history symbol))) - -(defun godoc--get-buffer (query) - "Get an empty buffer for a godoc query." - (let* ((buffer-name (concat "*godoc " query "*")) - (buffer (get-buffer buffer-name))) - ;; Kill the existing buffer if it already exists. - (when buffer (kill-buffer buffer)) - (get-buffer-create buffer-name))) - -(defun godoc--buffer-sentinel (proc event) - "Sentinel function run when godoc command completes." - (with-current-buffer (process-buffer proc) - (cond ((string= event "finished\n") ;; Successful exit. - (goto-char (point-min)) - (view-mode 1) - (display-buffer (current-buffer) t)) - ((/= (process-exit-status proc) 0) ;; Error exit. - (let ((output (buffer-string))) - (kill-buffer (current-buffer)) - (message (concat "godoc: " output))))))) - -;;;###autoload -(defun godoc (query) - "Show Go documentation for a query, much like M-x man." - (interactive (list (godoc--read-query))) - (unless (string= query "") - (set-process-sentinel - (start-process-shell-command "godoc" (godoc--get-buffer query) - (concat "godoc " query)) - 'godoc--buffer-sentinel) - nil)) - -(defun godoc-at-point (point) - "Show Go documentation for the identifier at POINT. - -`godoc-at-point' requires godef to work. - -Due to a limitation in godoc, it is not possible to differentiate -between functions and methods, which may cause `godoc-at-point' -to display more documentation than desired." - ;; TODO(dominikh): Support executing godoc-at-point on a package - ;; name. - (interactive "d") - (condition-case nil - (let* ((output (godef--call point)) - (file (car output)) - (name-parts (split-string (cadr output) " ")) - (first (car name-parts))) - (if (not (godef--successful-p file)) - (message "%s" (godef--error file)) - (godoc (format "%s %s" - (file-name-directory file) - (if (or (string= first "type") (string= first "const")) - (cadr name-parts) - (car name-parts)))))) - (file-error (message "Could not run godef binary")))) - -(defun go-goto-imports () - "Move point to the block of imports. - -If using - - import ( - \"foo\" - \"bar\" - ) - -it will move point directly behind the last import. - -If using - - import \"foo\" - import \"bar\" - -it will move point to the next line after the last import. - -If no imports can be found, point will be moved after the package -declaration." - (interactive) - ;; FIXME if there's a block-commented import before the real - ;; imports, we'll jump to that one. - - ;; Generally, this function isn't very forgiving. it'll bark on - ;; extra whitespace. It works well for clean code. - (let ((old-point (point))) - (goto-char (point-min)) - (cond - ((re-search-forward "^import ()" nil t) - (backward-char 1) - 'block-empty) - ((re-search-forward "^import ([^)]+)" nil t) - (backward-char 2) - 'block) - ((re-search-forward "\\(^import \\([^\"]+ \\)?\"[^\"]+\"\n?\\)+" nil t) - 'single) - ((re-search-forward "^[[:space:]\n]*package .+?\n" nil t) - (message "No imports found, moving point after package declaration") - 'none) - (t - (goto-char old-point) - (message "No imports or package declaration found. Is this really a Go file?") - 'fail)))) - -(defun go-play-buffer () - "Like `go-play-region', but acts on the entire buffer." - (interactive) - (go-play-region (point-min) (point-max))) - -(defun go-play-region (start end) - "Send the region to the Playground and stores the resulting -link in the kill ring." - (interactive "r") - (let* ((url-request-method "POST") - (url-request-extra-headers - '(("Content-Type" . "application/x-www-form-urlencoded"))) - (url-request-data - (encode-coding-string - (buffer-substring-no-properties start end) - 'utf-8)) - (content-buf (url-retrieve - "http://play.golang.org/share" - (lambda (arg) - (cond - ((equal :error (car arg)) - (signal 'go-play-error (cdr arg))) - (t - (re-search-forward "\n\n") - (kill-new (format "http://play.golang.org/p/%s" (buffer-substring (point) (point-max)))) - (message "http://play.golang.org/p/%s" (buffer-substring (point) (point-max))))))))))) - -;;;###autoload -(defun go-download-play (url) - "Downloads a paste from the playground and inserts it in a Go -buffer. Tries to look for a URL at point." - (interactive (list (read-from-minibuffer "Playground URL: " (ffap-url-p (ffap-string-at-point 'url))))) - (with-current-buffer - (let ((url-request-method "GET") url-request-data url-request-extra-headers) - (url-retrieve-synchronously (concat url ".go"))) - (let ((buffer (generate-new-buffer (concat (car (last (split-string url "/"))) ".go")))) - (goto-char (point-min)) - (re-search-forward "\n\n") - (copy-to-buffer buffer (point) (point-max)) - (kill-buffer) - (with-current-buffer buffer - (go-mode) - (switch-to-buffer buffer))))) - -(defun go-propertize-syntax (start end) - (save-excursion - (goto-char start) - (while (search-forward "\\" end t) - (put-text-property (1- (point)) (point) 'syntax-table (if (= (char-after) ?`) '(1) '(9)))))) - -(defun go-import-add (arg import) - "Add a new import to the list of imports. - -When called with a prefix argument asks for an alternative name -to import the package as. - -If no list exists yet, one will be created if possible. - -If an identical import has been commented, it will be -uncommented, otherwise a new import will be added." - - ;; - If there's a matching `// import "foo"`, uncomment it - ;; - If we're in an import() block and there's a matching `"foo"`, uncomment it - ;; - Otherwise add a new import, with the appropriate syntax - (interactive - (list - current-prefix-arg - (replace-regexp-in-string "^[\"']\\|[\"']$" "" (completing-read "Package: " (go--old-completion-list-style (go-packages)))))) - (save-excursion - (let (as line import-start) - (if arg - (setq as (read-from-minibuffer "Import as: "))) - (if as - (setq line (format "%s \"%s\"" as import)) - (setq line (format "\"%s\"" import))) - - (goto-char (point-min)) - (if (re-search-forward (concat "^[[:space:]]*//[[:space:]]*import " line "$") nil t) - (uncomment-region (line-beginning-position) (line-end-position)) - (case (go-goto-imports) - ('fail (message "Could not find a place to add import.")) - ('block-empty - (insert "\n\t" line "\n")) - ('block - (save-excursion - (re-search-backward "^import (") - (setq import-start (point))) - (if (re-search-backward (concat "^[[:space:]]*//[[:space:]]*" line "$") import-start t) - (uncomment-region (line-beginning-position) (line-end-position)) - (insert "\n\t" line))) - ('single (insert "import " line "\n")) - ('none (insert "\nimport (\n\t" line "\n)\n"))))))) - -(defun go-root-and-paths () - (let* ((output (split-string (shell-command-to-string (concat go-command " env GOROOT GOPATH")) - "\n")) - (root (car output)) - (paths (split-string (cadr output) path-separator))) - (append (list root) paths))) - -(defun go--string-prefix-p (s1 s2 &optional ignore-case) - "Return non-nil if S1 is a prefix of S2. -If IGNORE-CASE is non-nil, the comparison is case-insensitive." - (eq t (compare-strings s1 nil nil - s2 0 (length s1) ignore-case))) - -(defun go--directory-dirs (dir) - "Recursively return all subdirectories in DIR." - (if (file-directory-p dir) - (let ((dir (directory-file-name dir)) - (dirs '()) - (files (directory-files dir nil nil t))) - (dolist (file files) - (unless (member file '("." "..")) - (let ((file (concat dir "/" file))) - (if (file-directory-p file) - (setq dirs (append (cons file - (go--directory-dirs file)) - dirs)))))) - dirs) - '())) - - -(defun go-packages () - (sort - (delete-dups - (mapcan - (lambda (topdir) - (let ((pkgdir (concat topdir "/pkg/"))) - (mapcan (lambda (dir) - (mapcar (lambda (file) - (let ((sub (substring file (length pkgdir) -2))) - (unless (or (go--string-prefix-p "obj/" sub) (go--string-prefix-p "tool/" sub)) - (mapconcat #'identity (cdr (split-string sub "/")) "/")))) - (if (file-directory-p dir) - (directory-files dir t "\\.a$")))) - (if (file-directory-p pkgdir) - (go--directory-dirs pkgdir))))) - (go-root-and-paths))) - #'string<)) - -(defun go-unused-imports-lines () - ;; FIXME Technically, -o /dev/null fails in quite some cases (on - ;; Windows, when compiling from within GOPATH). Practically, - ;; however, it has the same end result: There won't be a - ;; compiled binary/archive, and we'll get our import errors when - ;; there are any. - (reverse (remove nil - (mapcar - (lambda (line) - (if (string-match "^\\(.+\\):\\([[:digit:]]+\\): imported and not used: \".+\".*$" line) - (if (string= (file-truename (match-string 1 line)) (file-truename buffer-file-name)) - (string-to-number (match-string 2 line))))) - (split-string (shell-command-to-string - (concat go-command - (if (string-match "_test\.go$" buffer-file-truename) - " test -c" - " build -o /dev/null"))) "\n"))))) - -(defun go-remove-unused-imports (arg) - "Removes all unused imports. If ARG is non-nil, unused imports -will be commented, otherwise they will be removed completely." - (interactive "P") - (save-excursion - (let ((cur-buffer (current-buffer)) flymake-state lines) - (when (boundp 'flymake-mode) - (setq flymake-state flymake-mode) - (flymake-mode-off)) - (save-some-buffers nil (lambda () (equal cur-buffer (current-buffer)))) - (if (buffer-modified-p) - (message "Cannot operate on unsaved buffer") - (setq lines (go-unused-imports-lines)) - (dolist (import lines) - (go--goto-line import) - (beginning-of-line) - (if arg - (comment-region (line-beginning-position) (line-end-position)) - (go--delete-whole-line))) - (message "Removed %d imports" (length lines))) - (if flymake-state (flymake-mode-on))))) - -(defun godef--find-file-line-column (specifier other-window) - "Given a file name in the format of `filename:line:column', -visit FILENAME and go to line LINE and column COLUMN." - (if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier)) - ;; We've only been given a directory name - (funcall (if other-window #'find-file-other-window #'find-file) specifier) - (let ((filename (match-string 1 specifier)) - (line (string-to-number (match-string 2 specifier))) - (column (string-to-number (match-string 3 specifier)))) - (with-current-buffer (funcall (if other-window #'find-file-other-window #'find-file) filename) - (go--goto-line line) - (beginning-of-line) - (forward-char (1- column)) - (if (buffer-modified-p) - (message "Buffer is modified, file position might not have been correct")))))) - -(defun godef--call (point) - "Call godef, acquiring definition position and expression -description at POINT." - (if (go--xemacs-p) - (error "godef does not reliably work in XEmacs, expect bad results")) - (if (not (buffer-file-name (go--coverage-origin-buffer))) - (error "Cannot use godef on a buffer without a file name") - (let ((outbuf (get-buffer-create "*godef*"))) - (with-current-buffer outbuf - (erase-buffer)) - (call-process-region (point-min) - (point-max) - "godef" - nil - outbuf - nil - "-i" - "-t" - "-f" - (file-truename (buffer-file-name (go--coverage-origin-buffer))) - "-o" - (number-to-string (go--position-bytes point))) - (with-current-buffer outbuf - (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))))) - -(defun godef--successful-p (output) - (not (or (string= "-" output) - (string= "godef: no identifier found" output) - (go--string-prefix-p "godef: no declaration found for " output) - (go--string-prefix-p "error finding import path for " output)))) - -(defun godef--error (output) - (cond - ((godef--successful-p output) - nil) - ((string= "-" output) - "godef: expression is not defined anywhere") - (t - output))) - -(defun godef-describe (point) - "Describe the expression at POINT." - (interactive "d") - (condition-case nil - (let ((description (cdr (butlast (godef--call point) 1)))) - (if (not description) - (message "No description found for expression at point") - (message "%s" (mapconcat #'identity description "\n")))) - (file-error (message "Could not run godef binary")))) - -(defun godef-jump (point &optional other-window) - "Jump to the definition of the expression at POINT." - (interactive "d") - (condition-case nil - (let ((file (car (godef--call point)))) - (if (not (godef--successful-p file)) - (message "%s" (godef--error file)) - (push-mark) - (ring-insert find-tag-marker-ring (point-marker)) - (godef--find-file-line-column file other-window))) - (file-error (message "Could not run godef binary")))) - -(defun godef-jump-other-window (point) - (interactive "d") - (godef-jump point t)) - -(defun go--goto-line (line) - (goto-char (point-min)) - (forward-line (1- line))) - -(defun go--line-column-to-point (line column) - (save-excursion - (go--goto-line line) - (forward-char (1- column)) - (point))) - -(defstruct go--covered - start-line start-column end-line end-column covered count) - -(defun go--coverage-file () - "Return the coverage file to use, either by reading it from the -current coverage buffer or by prompting for it." - (if (boundp 'go--coverage-current-file-name) - go--coverage-current-file-name - (read-file-name "Coverage file: " nil nil t))) - -(defun go--coverage-origin-buffer () - "Return the buffer to base the coverage on." - (or (buffer-base-buffer) (current-buffer))) - -(defun go--coverage-face (count divisor) - "Return the intensity face for COUNT when using DIVISOR -to scale it to a range [0,10]. - -DIVISOR scales the absolute cover count to values from 0 to 10. -For DIVISOR = 0 the count will always translate to 8." - (let* ((norm (cond - ((= count 0) - -0.1) ;; Uncovered code, set to -0.1 so n becomes 0. - ((= divisor 0) - 0.8) ;; covermode=set, set to 0.8 so n becomes 8. - (t - (/ (log count) divisor)))) - (n (1+ (floor (* norm 9))))) ;; Convert normalized count [0,1] to intensity [0,10] - (concat "go-coverage-" (number-to-string n)))) - -(defun go--coverage-make-overlay (range divisor) - "Create a coverage overlay for a RANGE of covered/uncovered -code. Uses DIVISOR to scale absolute counts to a [0,10] scale." - (let* ((count (go--covered-count range)) - (face (go--coverage-face count divisor)) - (ov (make-overlay (go--line-column-to-point (go--covered-start-line range) - (go--covered-start-column range)) - (go--line-column-to-point (go--covered-end-line range) - (go--covered-end-column range))))) - - (overlay-put ov 'face face) - (overlay-put ov 'help-echo (format "Count: %d" count)))) - -(defun go--coverage-clear-overlays () - "Remove existing overlays and put a single untracked overlay -over the entire buffer." - (remove-overlays) - (overlay-put (make-overlay (point-min) (point-max)) - 'face - 'go-coverage-untracked)) - -(defun go--coverage-parse-file (coverage-file file-name) - "Parse COVERAGE-FILE and extract coverage information and -divisor for FILE-NAME." - (let (ranges - (max-count 0)) - (with-temp-buffer - (insert-file-contents coverage-file) - (go--goto-line 2) ;; Skip over mode - (while (not (eobp)) - (let* ((parts (split-string (buffer-substring (point-at-bol) (point-at-eol)) ":")) - (file (car parts)) - (rest (split-string (nth 1 parts) "[., ]"))) - - (destructuring-bind - (start-line start-column end-line end-column num count) - (mapcar #'string-to-number rest) - - (when (string= (file-name-nondirectory file) file-name) - (if (> count max-count) - (setq max-count count)) - (push (make-go--covered :start-line start-line - :start-column start-column - :end-line end-line - :end-column end-column - :covered (/= count 0) - :count count) - ranges))) - - (forward-line))) - - (list ranges (if (> max-count 0) (log max-count) 0))))) - -(defun go-coverage (&optional coverage-file) - "Open a clone of the current buffer and overlay it with -coverage information gathered via go test -coverprofile=COVERAGE-FILE. - -If COVERAGE-FILE is nil, it will either be inferred from the -current buffer if it's already a coverage buffer, or be prompted -for." - (interactive) - (let* ((cur-buffer (current-buffer)) - (origin-buffer (go--coverage-origin-buffer)) - (gocov-buffer-name (concat (buffer-name origin-buffer) "")) - (coverage-file (or coverage-file (go--coverage-file))) - (ranges-and-divisor (go--coverage-parse-file - coverage-file - (file-name-nondirectory (buffer-file-name origin-buffer)))) - (cov-mtime (nth 5 (file-attributes coverage-file))) - (cur-mtime (nth 5 (file-attributes (buffer-file-name origin-buffer))))) - - (if (< (float-time cov-mtime) (float-time cur-mtime)) - (message "Coverage file is older than the source file.")) - - (with-current-buffer (or (get-buffer gocov-buffer-name) - (make-indirect-buffer origin-buffer gocov-buffer-name t)) - (set (make-local-variable 'go--coverage-current-file-name) coverage-file) - - (save-excursion - (go--coverage-clear-overlays) - (dolist (range (car ranges-and-divisor)) - (go--coverage-make-overlay range (cadr ranges-and-divisor)))) - - (if (not (eq cur-buffer (current-buffer))) - (display-buffer (current-buffer) `(,go-coverage-display-buffer-func)))))) - -(provide 'go-mode) - -;;; go-mode.el ends here diff --git a/emacs.d/elpa/go-mode-20150503.258/go-mode-autoloads.el b/emacs.d/elpa/go-mode-20150503.258/go-mode-autoloads.el new file mode 100644 index 0000000..1529540 --- /dev/null +++ b/emacs.d/elpa/go-mode-20150503.258/go-mode-autoloads.el @@ -0,0 +1,102 @@ +;;; go-mode-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + + +;;;### (autoloads nil "go-mode" "go-mode.el" (21837 24213 0 0)) +;;; Generated autoloads from go-mode.el + +(autoload 'go-mode "go-mode" "\ +Major mode for editing Go source text. + +This mode provides (not just) basic editing capabilities for +working with Go code. It offers almost complete syntax +highlighting, indentation that is almost identical to gofmt and +proper parsing of the buffer content to allow features such as +navigation by function, manipulation of comments or detection of +strings. + +In addition to these core features, it offers various features to +help with writing Go code. You can directly run buffer content +through gofmt, read godoc documentation from within Emacs, modify +and clean up the list of package imports or interact with the +Playground (uploading and downloading pastes). + +The following extra functions are defined: + +- `gofmt' +- `godoc' +- `go-import-add' +- `go-remove-unused-imports' +- `go-goto-imports' +- `go-play-buffer' and `go-play-region' +- `go-download-play' +- `godef-describe' and `godef-jump' +- `go-coverage' + +If you want to automatically run `gofmt' before saving a file, +add the following hook to your emacs configuration: + +\(add-hook 'before-save-hook #'gofmt-before-save) + +If you want to use `godef-jump' instead of etags (or similar), +consider binding godef-jump to `M-.', which is the default key +for `find-tag': + +\(add-hook 'go-mode-hook (lambda () + (local-set-key (kbd \"M-.\") #'godef-jump))) + +Please note that godef is an external dependency. You can install +it with + +go get code.google.com/p/rog-go/exp/cmd/godef + + +If you're looking for even more integration with Go, namely +on-the-fly syntax checking, auto-completion and snippets, it is +recommended that you look at flycheck +\(see URL `https://github.com/flycheck/flycheck') or flymake in combination +with goflymake (see URL `https://github.com/dougm/goflymake'), gocode +\(see URL `https://github.com/nsf/gocode'), go-eldoc +\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go +\(see URL `https://github.com/dominikh/yasnippet-go') + +\(fn)" t nil) + +(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) + +(autoload 'gofmt-before-save "go-mode" "\ +Add this to .emacs to run gofmt on the current buffer when saving: + (add-hook 'before-save-hook 'gofmt-before-save). + +Note that this will cause go-mode to get loaded the first time +you save any file, kind of defeating the point of autoloading. + +\(fn)" t nil) + +(autoload 'godoc "go-mode" "\ +Show Go documentation for QUERY, much like M-x man. + +\(fn QUERY)" t nil) + +(autoload 'go-download-play "go-mode" "\ +Download a paste from the playground and insert it in a Go buffer. +Tries to look for a URL at point. + +\(fn URL)" t nil) + +;;;*** + +;;;### (autoloads nil nil ("go-mode-pkg.el") (21837 24213 414192 +;;;;;; 0)) + +;;;*** + +(provide 'go-mode-autoloads) +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; go-mode-autoloads.el ends here diff --git a/emacs.d/elpa/go-mode-20150503.258/go-mode-pkg.el b/emacs.d/elpa/go-mode-20150503.258/go-mode-pkg.el new file mode 100644 index 0000000..35a6c13 --- /dev/null +++ b/emacs.d/elpa/go-mode-20150503.258/go-mode-pkg.el @@ -0,0 +1,5 @@ +(define-package "go-mode" "20150503.258" "Major mode for the Go programming language" 'nil :url "https://github.com/dominikh/go-mode.el" :keywords + '("languages" "go")) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/go-mode-20150503.258/go-mode.el b/emacs.d/elpa/go-mode-20150503.258/go-mode.el new file mode 100644 index 0000000..71fe692 --- /dev/null +++ b/emacs.d/elpa/go-mode-20150503.258/go-mode.el @@ -0,0 +1,1564 @@ +;;; go-mode.el --- Major mode for the Go programming language + +;; Copyright 2013 The go-mode Authors. All rights reserved. +;; Use of this source code is governed by a BSD-style +;; license that can be found in the LICENSE file. + +;; Author: The go-mode Authors +;; Version: 1.2.1 +;; Keywords: languages go +;; URL: https://github.com/dominikh/go-mode.el +;; +;; This file is not part of GNU Emacs. + +;;; Code: + +(require 'cl) +(require 'etags) +(require 'ffap) +(require 'find-file) +(require 'ring) +(require 'url) + +;; XEmacs compatibility guidelines +;; - Minimum required version of XEmacs: 21.5.32 +;; - Feature that cannot be backported: POSIX character classes in +;; regular expressions +;; - Functions that could be backported but won't because 21.5.32 +;; covers them: plenty. +;; - Features that are still partly broken: +;; - godef will not work correctly if multibyte characters are +;; being used +;; - Fontification will not handle unicode correctly +;; +;; - Do not use \_< and \_> regexp delimiters directly; use +;; go--regexp-enclose-in-symbol +;; +;; - The character `_` must not be a symbol constituent but a +;; character constituent +;; +;; - Do not use process-lines +;; +;; - Use go--old-completion-list-style when using a plain list as the +;; collection for completing-read +;; +;; - Use go--position-bytes instead of position-bytes +(defmacro go--xemacs-p () + `(featurep 'xemacs)) + +(defun go--delete-whole-line (&optional arg) + "Delete the current line without putting it in the `kill-ring'. +Derived from function `kill-whole-line'. ARG is defined as for that +function." + (setq arg (or arg 1)) + (if (and (> arg 0) + (eobp) + (save-excursion (forward-visible-line 0) (eobp))) + (signal 'end-of-buffer nil)) + (if (and (< arg 0) + (bobp) + (save-excursion (end-of-visible-line) (bobp))) + (signal 'beginning-of-buffer nil)) + (cond ((zerop arg) + (delete-region (progn (forward-visible-line 0) (point)) + (progn (end-of-visible-line) (point)))) + ((< arg 0) + (delete-region (progn (end-of-visible-line) (point)) + (progn (forward-visible-line (1+ arg)) + (unless (bobp) + (backward-char)) + (point)))) + (t + (delete-region (progn (forward-visible-line 0) (point)) + (progn (forward-visible-line arg) (point)))))) + +;; declare-function is an empty macro that only byte-compile cares +;; about. Wrap in always false if to satisfy Emacsen without that +;; macro. +(if nil + (declare-function go--position-bytes "go-mode" (point))) + +;; XEmacs unfortunately does not offer position-bytes. We can fall +;; back to just using (point), but it will be incorrect as soon as +;; multibyte characters are being used. +(if (fboundp 'position-bytes) + (defalias 'go--position-bytes #'position-bytes) + (defun go--position-bytes (point) point)) + +(defun go--old-completion-list-style (list) + (mapcar (lambda (x) (cons x nil)) list)) + +;; GNU Emacs 24 has prog-mode, older GNU Emacs and XEmacs do not, so +;; copy its definition for those. +(if (not (fboundp 'prog-mode)) + (define-derived-mode prog-mode fundamental-mode "Prog" + "Major mode for editing source code." + (set (make-local-variable 'require-final-newline) mode-require-final-newline) + (set (make-local-variable 'parse-sexp-ignore-comments) t) + (setq bidi-paragraph-direction 'left-to-right))) + +(defun go--regexp-enclose-in-symbol (s) + "Enclose S as regexp symbol. +XEmacs does not support \\_<, GNU Emacs does. In GNU Emacs we +make extensive use of \\_< to support unicode in identifiers. +Until we come up with a better solution for XEmacs, this solution +will break fontification in XEmacs for identifiers such as +\"typeµ\". XEmacs will consider \"type\" a keyword, GNU Emacs +won't." + (if (go--xemacs-p) + (concat "\\<" s "\\>") + (concat "\\_<" s "\\_>"))) + +(defun go-goto-opening-parenthesis (&optional _legacy-unused) + "Move up one level of parentheses." + ;; The old implementation of go-goto-opening-parenthesis had an + ;; optional argument to speed up the function. It didn't change the + ;; function's outcome. + + ;; Silently fail if there's no matching opening parenthesis. + (condition-case nil + (backward-up-list) + (scan-error nil))) + + +(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]") +(defconst go-identifier-regexp "[[:word:][:multibyte:]]+") +(defconst go-type-name-no-prefix-regexp "\\(?:[[:word:][:multibyte:]]+\\.\\)?[[:word:][:multibyte:]]+") +(defconst go-qualified-identifier-regexp (concat go-identifier-regexp "\\." go-identifier-regexp)) +(defconst go-label-regexp go-identifier-regexp) +(defconst go-type-regexp "[[:word:][:multibyte:]*]+") +(defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s *\\(" go-identifier-regexp "\\)")) +(defconst go-func-meth-regexp (concat + (go--regexp-enclose-in-symbol "func") "\\s *\\(?:(\\s *" + "\\(" go-identifier-regexp "\\s +\\)?" go-type-regexp + "\\s *)\\s *\\)?\\(" + go-identifier-regexp + "\\)(")) + +(defconst go-builtins + '("append" "cap" "close" "complex" "copy" + "delete" "imag" "len" "make" "new" + "panic" "print" "println" "real" "recover") + "All built-in functions in the Go language. Used for font locking.") + +(defconst go-mode-keywords + '("break" "default" "func" "interface" "select" + "case" "defer" "go" "map" "struct" + "chan" "else" "goto" "package" "switch" + "const" "fallthrough" "if" "range" "type" + "continue" "for" "import" "return" "var") + "All keywords in the Go language. Used for font locking.") + +(defconst go-constants '("nil" "true" "false" "iota")) +(defconst go-type-name-regexp (concat "\\(?:[*(]\\)*\\(\\(?:" go-identifier-regexp "\\.\\)?" go-identifier-regexp "\\)")) + +;; Maximum number of identifiers that can be highlighted as type names +;; in one function type/declaration. +(defconst go--font-lock-func-param-num-groups 16) + +(defvar go-dangling-cache) +(defvar go-godoc-history nil) +(defvar go--coverage-current-file-name) + +(defgroup go nil + "Major mode for editing Go code." + :link '(url-link "https://github.com/dominikh/go-mode.el") + :group 'languages) + +(defgroup go-cover nil + "Options specific to `cover`." + :group 'go) + +(defcustom go-fontify-function-calls t + "Fontify function and method calls if this is non-nil." + :type 'boolean + :group 'go) + +(defcustom go-mode-hook nil + "Hook called by `go-mode'." + :type 'hook + :group 'go) + +(defcustom go-command "go" + "The 'go' command. +Some users have multiple Go development trees and invoke the 'go' +tool via a wrapper that sets GOROOT and GOPATH based on the +current directory. Such users should customize this variable to +point to the wrapper script." + :type 'string + :group 'go) + +(defcustom gofmt-command "gofmt" + "The 'gofmt' command. +Some users may replace this with 'goimports' +from https://github.com/bradfitz/goimports." + :type 'string + :group 'go) + +(defcustom gofmt-show-errors 'buffer + "Where to display gofmt error output. +It can either be displayed in its own buffer, in the echo area, or not at all. + +Please note that Emacs outputs to the echo area when writing +files and will overwrite gofmt's echo output if used from inside +a `before-save-hook'." + :type '(choice + (const :tag "Own buffer" buffer) + (const :tag "Echo area" echo) + (const :tag "None" nil)) + :group 'go) + +(defcustom godef-command "godef" + "The 'godef' command." + :type 'string + :group 'go) + +(defcustom go-other-file-alist + '(("_test\\.go\\'" (".go")) + ("\\.go\\'" ("_test.go"))) + "See the documentation of `ff-other-file-alist' for details." + :type '(repeat (list regexp (choice (repeat string) function))) + :group 'go) + +(defun go--kill-new-message (url) + "Make URL the latest kill and print a message." + (kill-new url) + (message "%s" url)) + +(defcustom go-play-browse-function 'go--kill-new-message + "Function to call with the Playground URL. +See `go-play-region' for more details." + :type '(choice + (const :tag "Nothing" nil) + (const :tag "Kill + Message" go--kill-new-message) + (const :tag "Browse URL" browse-url) + (function :tag "Call function")) + :group 'go) + +(defcustom go-coverage-display-buffer-func 'display-buffer-reuse-window + "How `go-coverage' should display the coverage buffer. +See `display-buffer' for a list of possible functions." + :type 'function + :group 'go-cover) + +(defface go-coverage-untracked + '((t (:foreground "#505050"))) + "Coverage color of untracked code." + :group 'go-cover) + +(defface go-coverage-0 + '((t (:foreground "#c00000"))) + "Coverage color for uncovered code." + :group 'go-cover) +(defface go-coverage-1 + '((t (:foreground "#808080"))) + "Coverage color for covered code with weight 1." + :group 'go-cover) +(defface go-coverage-2 + '((t (:foreground "#748c83"))) + "Coverage color for covered code with weight 2." + :group 'go-cover) +(defface go-coverage-3 + '((t (:foreground "#689886"))) + "Coverage color for covered code with weight 3." + :group 'go-cover) +(defface go-coverage-4 + '((t (:foreground "#5ca489"))) + "Coverage color for covered code with weight 4." + :group 'go-cover) +(defface go-coverage-5 + '((t (:foreground "#50b08c"))) + "Coverage color for covered code with weight 5." + :group 'go-cover) +(defface go-coverage-6 + '((t (:foreground "#44bc8f"))) + "Coverage color for covered code with weight 6." + :group 'go-cover) +(defface go-coverage-7 + '((t (:foreground "#38c892"))) + "Coverage color for covered code with weight 7." + :group 'go-cover) +(defface go-coverage-8 + '((t (:foreground "#2cd495"))) + "Coverage color for covered code with weight 8. +For mode=set, all covered lines will have this weight." + :group 'go-cover) +(defface go-coverage-9 + '((t (:foreground "#20e098"))) + "Coverage color for covered code with weight 9." + :group 'go-cover) +(defface go-coverage-10 + '((t (:foreground "#14ec9b"))) + "Coverage color for covered code with weight 10." + :group 'go-cover) +(defface go-coverage-covered + '((t (:foreground "#2cd495"))) + "Coverage color of covered code." + :group 'go-cover) + +(defvar go-mode-syntax-table + (let ((st (make-syntax-table))) + (modify-syntax-entry ?+ "." st) + (modify-syntax-entry ?- "." st) + (modify-syntax-entry ?% "." st) + (modify-syntax-entry ?& "." st) + (modify-syntax-entry ?| "." st) + (modify-syntax-entry ?^ "." st) + (modify-syntax-entry ?! "." st) + (modify-syntax-entry ?= "." st) + (modify-syntax-entry ?< "." st) + (modify-syntax-entry ?> "." st) + (modify-syntax-entry ?/ (if (go--xemacs-p) ". 1456" ". 124b") st) + (modify-syntax-entry ?* ". 23" st) + (modify-syntax-entry ?\n "> b" st) + (modify-syntax-entry ?\" "\"" st) + (modify-syntax-entry ?\' "\"" st) + (modify-syntax-entry ?` "\"" st) + (modify-syntax-entry ?\\ "\\" st) + ;; It would be nicer to have _ as a symbol constituent, but that + ;; would trip up XEmacs, which does not support the \_< anchor + (modify-syntax-entry ?_ "w" st) + + st) + "Syntax table for Go mode.") + +(defun go--build-font-lock-keywords () + ;; we cannot use 'symbols in regexp-opt because GNU Emacs <24 + ;; doesn't understand that + (append + `((go--match-func + ,@(mapcar (lambda (x) `(,x font-lock-type-face)) + (number-sequence 1 go--font-lock-func-param-num-groups))) + (,(go--regexp-enclose-in-symbol (regexp-opt go-mode-keywords t)) . font-lock-keyword-face) + (,(concat "\\(" (go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) "\\)[[:space:]]*(") 1 font-lock-builtin-face) + (,(go--regexp-enclose-in-symbol (regexp-opt go-constants t)) . font-lock-constant-face) + (,go-func-regexp 1 font-lock-function-name-face)) ;; function (not method) name + + (if go-fontify-function-calls + `((,(concat "\\(" go-identifier-regexp "\\)[[:space:]]*(") 1 font-lock-function-name-face) ;; function call/method name + (,(concat "[^[:word:][:multibyte:]](\\(" go-identifier-regexp "\\))[[:space:]]*(") 1 font-lock-function-name-face)) ;; bracketed function call + `((,go-func-meth-regexp 2 font-lock-function-name-face))) ;; method name + + `( + ("\\(`[^`]*`\\)" 1 font-lock-multiline) ;; raw string literal, needed for font-lock-syntactic-keywords + (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+\\([^[:space:]]+\\)") 1 font-lock-type-face) ;; types + (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+" go-identifier-regexp "[[:space:]]*" go-type-name-regexp) 1 font-lock-type-face) ;; types + (,(concat "[^[:word:][:multibyte:]]\\[\\([[:digit:]]+\\|\\.\\.\\.\\)?\\]" go-type-name-regexp) 2 font-lock-type-face) ;; Arrays/slices + (,(concat "\\(" go-identifier-regexp "\\)" "{") 1 font-lock-type-face) + (,(concat (go--regexp-enclose-in-symbol "map") "\\[[^]]+\\]" go-type-name-regexp) 1 font-lock-type-face) ;; map value type + (,(concat (go--regexp-enclose-in-symbol "map") "\\[" go-type-name-regexp) 1 font-lock-type-face) ;; map key type + (,(concat (go--regexp-enclose-in-symbol "chan") "[[:space:]]*\\(?:<-[[:space:]]*\\)?" go-type-name-regexp) 1 font-lock-type-face) ;; channel type + (,(concat (go--regexp-enclose-in-symbol "\\(?:new\\|make\\)") "\\(?:[[:space:]]\\|)\\)*(" go-type-name-regexp) 1 font-lock-type-face) ;; new/make type + ;; TODO do we actually need this one or isn't it just a function call? + (,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type conversion + ;; Like the original go-mode this also marks compound literal + ;; fields. There, it was marked as to fix, but I grew quite + ;; accustomed to it, so it'll stay for now. + (,(concat "^[[:space:]]*\\(" go-label-regexp "\\)[[:space:]]*:\\(\\S.\\|$\\)") 1 font-lock-constant-face) ;; Labels and compound literal fields + (,(concat (go--regexp-enclose-in-symbol "\\(goto\\|break\\|continue\\)") "[[:space:]]*\\(" go-label-regexp "\\)") 2 font-lock-constant-face)))) ;; labels in goto/break/continue + +(defconst go--font-lock-syntactic-keywords + ;; Override syntax property of raw string literal contents, so that + ;; backslashes have no special meaning in ``. Used in Emacs 23 or older. + '((go--match-raw-string-literal + (1 (7 . ?`)) + (2 (15 . nil)) ;; 15 = "generic string" + (3 (7 . ?`))))) + +(defvar go-mode-map + (let ((m (make-sparse-keymap))) + (define-key m "}" #'go-mode-insert-and-indent) + (define-key m ")" #'go-mode-insert-and-indent) + (define-key m "," #'go-mode-insert-and-indent) + (define-key m ":" #'go-mode-insert-and-indent) + (define-key m "=" #'go-mode-insert-and-indent) + (define-key m (kbd "C-c C-a") #'go-import-add) + (define-key m (kbd "C-c C-j") #'godef-jump) + (define-key m (kbd "C-x 4 C-c C-j") #'godef-jump-other-window) + (define-key m (kbd "C-c C-d") #'godef-describe) + m) + "Keymap used by Go mode to implement electric keys.") + +(easy-menu-define go-mode-menu go-mode-map + "Menu for Go mode." + '("Go" + ["Describe Expression" godef-describe t] + ["Jump to Definition" godef-jump t] + "---" + ["Add Import" go-import-add t] + ["Remove Unused Imports" go-remove-unused-imports t] + ["Go to Imports" go-goto-imports t] + "---" + ("Playground" + ["Send Buffer" go-play-buffer t] + ["Send Region" go-play-region t] + ["Download" go-download-play t]) + "---" + ["Coverage" go-coverage t] + ["Gofmt" gofmt t] + ["Godoc" godoc t] + "---" + ["Customize Mode" (customize-group 'go) t])) + +(defun go-mode-insert-and-indent (key) + "Invoke the global binding of KEY, then reindent the line." + + (interactive (list (this-command-keys))) + (call-interactively (lookup-key (current-global-map) key)) + (indent-according-to-mode)) + +(defmacro go-paren-level () + `(car (syntax-ppss))) + +(defmacro go-in-string-or-comment-p () + `(nth 8 (syntax-ppss))) + +(defmacro go-in-string-p () + `(nth 3 (syntax-ppss))) + +(defmacro go-in-comment-p () + `(nth 4 (syntax-ppss))) + +(defmacro go-goto-beginning-of-string-or-comment () + `(goto-char (nth 8 (syntax-ppss)))) + +(defun go--backward-irrelevant (&optional stop-at-string) + "Skip backwards over any characters that are irrelevant for +indentation and related tasks. + +It skips over whitespace, comments, cases and labels and, if +STOP-AT-STRING is not true, over strings." + + (let (pos (start-pos (point))) + (skip-chars-backward "\n\s\t") + (if (and (save-excursion (beginning-of-line) (go-in-string-p)) (looking-back "`") (not stop-at-string)) + (backward-char)) + (if (and (go-in-string-p) (not stop-at-string)) + (go-goto-beginning-of-string-or-comment)) + (if (looking-back "\\*/") + (backward-char)) + (if (go-in-comment-p) + (go-goto-beginning-of-string-or-comment)) + (setq pos (point)) + (beginning-of-line) + (if (or (looking-at (concat "^" go-label-regexp ":")) (looking-at "^[[:space:]]*\\(case .+\\|default\\):")) + (end-of-line 0) + (goto-char pos)) + (if (/= start-pos (point)) + (go--backward-irrelevant stop-at-string)) + (/= start-pos (point)))) + +(defun go--buffer-narrowed-p () + "Return non-nil if the current buffer is narrowed." + (/= (buffer-size) + (- (point-max) + (point-min)))) + +(defun go--match-raw-string-literal (end) + "Search for a raw string literal. +Set point to the end of the occurence found on success. Return nil on failure." + (unless (go-in-string-or-comment-p) + (when (search-forward "`" end t) + (goto-char (match-beginning 0)) + (if (go-in-string-or-comment-p) + (progn (goto-char (match-end 0)) + (go--match-raw-string-literal end)) + (when (looking-at "\\(`\\)\\([^`]*\\)\\(`\\)") + (goto-char (match-end 0)) + t))))) + +(defun go-previous-line-has-dangling-op-p () + "Return non-nil if the current line is a continuation line." + (let* ((cur-line (line-number-at-pos)) + (val (gethash cur-line go-dangling-cache 'nope))) + (if (or (go--buffer-narrowed-p) (equal val 'nope)) + (save-excursion + (beginning-of-line) + (go--backward-irrelevant t) + (setq val (looking-back go-dangling-operators-regexp)) + (if (not (go--buffer-narrowed-p)) + (puthash cur-line val go-dangling-cache)))) + val)) + +(defun go--at-function-definition () + "Return non-nil if point is on the opening curly brace of a +function definition. + +We do this by first calling (beginning-of-defun), which will take +us to the start of *some* function. We then look for the opening +curly brace of that function and compare its position against the +curly brace we are checking. If they match, we return non-nil." + (if (= (char-after) ?\{) + (save-excursion + (let ((old-point (point)) + start-nesting) + (beginning-of-defun) + (when (looking-at "func ") + (setq start-nesting (go-paren-level)) + (skip-chars-forward "^{") + (while (> (go-paren-level) start-nesting) + (forward-char) + (skip-chars-forward "^{") 0) + (if (and (= (go-paren-level) start-nesting) (= old-point (point))) + t)))))) + +(defun go--indentation-for-opening-parenthesis () + "Return the semantic indentation for the current opening parenthesis. + +If point is on an opening curly brace and said curly brace +belongs to a function declaration, the indentation of the func +keyword will be returned. Otherwise the indentation of the +current line will be returned." + (save-excursion + (if (go--at-function-definition) + (progn + (beginning-of-defun) + (current-indentation)) + (current-indentation)))) + +(defun go-indentation-at-point () + (save-excursion + (let (start-nesting) + (back-to-indentation) + (setq start-nesting (go-paren-level)) + + (cond + ((go-in-string-p) + (current-indentation)) + ((looking-at "[])}]") + (go-goto-opening-parenthesis) + (if (go-previous-line-has-dangling-op-p) + (- (current-indentation) tab-width) + (go--indentation-for-opening-parenthesis))) + ((progn (go--backward-irrelevant t) (looking-back go-dangling-operators-regexp)) + ;; only one nesting for all dangling operators in one operation + (if (go-previous-line-has-dangling-op-p) + (current-indentation) + (+ (current-indentation) tab-width))) + ((zerop (go-paren-level)) + 0) + ((progn (go-goto-opening-parenthesis) (< (go-paren-level) start-nesting)) + (if (go-previous-line-has-dangling-op-p) + (current-indentation) + (+ (go--indentation-for-opening-parenthesis) tab-width))) + (t + (current-indentation)))))) + +(defun go-mode-indent-line () + (interactive) + (let (indent + shift-amt + (pos (- (point-max) (point))) + (point (point)) + (beg (line-beginning-position))) + (back-to-indentation) + (if (go-in-string-or-comment-p) + (goto-char point) + (setq indent (go-indentation-at-point)) + (if (looking-at (concat go-label-regexp ":\\([[:space:]]*/.+\\)?$\\|case .+:\\|default:")) + (decf indent tab-width)) + (setq shift-amt (- indent (current-column))) + (if (zerop shift-amt) + nil + (delete-region beg (point)) + (indent-to indent)) + ;; If initial point was within line's indentation, + ;; position after the indentation. Else stay at same point in text. + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos)))))) + +(defun go-beginning-of-defun (&optional count) + (unless (bolp) + (end-of-line)) + (setq count (or count 1)) + (let (first failure) + (dotimes (i (abs count)) + (setq first t) + (while (and (not failure) + (or first (go-in-string-or-comment-p))) + (if (>= count 0) + (progn + (go--backward-irrelevant) + (if (not (re-search-backward go-func-meth-regexp nil t)) + (setq failure t))) + (if (looking-at go-func-meth-regexp) + (forward-char)) + (if (not (re-search-forward go-func-meth-regexp nil t)) + (setq failure t))) + (setq first nil))) + (if (< count 0) + (beginning-of-line)) + (not failure))) + +(defun go-end-of-defun () + (let (orig-level) + ;; It can happen that we're not placed before a function by emacs + (if (not (looking-at "func")) + (go-beginning-of-defun -1)) + ;; Find the { that starts the function, i.e., the next { that isn't + ;; preceded by struct or interface, or a comment or struct tag. BUG: + ;; breaks if there's a comment between the struct/interface keyword and + ;; bracket, like this: + ;; + ;; struct /* why? */ { + (while (progn + (skip-chars-forward "^{") + (forward-char) + (or (go-in-string-or-comment-p) + (looking-back "\\(struct\\|interface\\)\\s-*{")))) + (setq orig-level (go-paren-level)) + (while (>= (go-paren-level) orig-level) + (skip-chars-forward "^}") + (forward-char)))) + +(defun go--find-enclosing-parentheses (position) + "Return points of outermost '(' and ')' surrounding POSITION if +such parentheses exist. + +If outermost '(' exists but ')' does not, it returns the next blank +line or end-of-buffer position instead of the position of the closing +parenthesis. + +If the starting parenthesis is not found, it returns (POSITION +POSITION)." + (save-excursion + (let (beg end) + (goto-char position) + (while (> (go-paren-level) 0) + (re-search-backward "[(\\[{]" nil t) + (when (looking-at "(") + (setq beg (point)))) + (if (null beg) + (list position position) + (goto-char position) + (while (and (> (go-paren-level) 0) + (search-forward ")" nil t))) + (when (> (go-paren-level) 0) + (unless (re-search-forward "^[[:space:]]*$" nil t) + (goto-char (point-max)))) + (list beg (point)))))) + +(defun go--search-next-comma (end) + "Search forward from point for a comma whose nesting level is +the same as point. If it reaches the end of line or a closing +parenthesis before a comma, it stops at it." + (let ((orig-level (go-paren-level))) + (while (and (< (point) end) + (or (looking-at "[^,)\n]") + (> (go-paren-level) orig-level))) + (forward-char)) + (when (and (looking-at ",") + (< (point) (1- end))) + (forward-char)))) + +(defun go--looking-at-keyword () + (and (looking-at (concat "\\(" go-identifier-regexp "\\)")) + (member (match-string 1) go-mode-keywords))) + +(defun go--match-func (end) + "Search for identifiers used as type names from a function +parameter list, and set the identifier positions as the results +of last search. Return t if search succeeded." + (when (re-search-forward (go--regexp-enclose-in-symbol "func") end t) + (let ((regions (go--match-func-type-names end))) + (if (null regions) + ;; Nothing to highlight. This can happen if the current func + ;; is "func()". Try next one. + (go--match-func end) + ;; There are something to highlight. Set those positions as + ;; last search results. + (setq regions (go--filter-match-data regions end)) + (when regions + (set-match-data (go--make-match-data regions)) + t))))) + +(defun go--match-func-type-names (end) + (cond + ;; Function declaration (e.g. "func foo(") + ((looking-at (concat "[[:space:]\n]*" go-identifier-regexp "[[:space:]\n]*(")) + (goto-char (match-end 0)) + (nconc (go--match-parameter-list end) + (go--match-function-result end))) + ;; Method declaration, function literal, or function type + ((looking-at "[[:space:]]*(") + (goto-char (match-end 0)) + (let ((regions (go--match-parameter-list end))) + ;; Method declaration (e.g. "func (x y) foo(") + (when (looking-at (concat "[[:space:]]*" go-identifier-regexp "[[:space:]\n]*(")) + (goto-char (match-end 0)) + (setq regions (nconc regions (go--match-parameter-list end)))) + (nconc regions (go--match-function-result end)))))) + +(defun go--parameter-list-type (end) + "Return `present' if the parameter list has names, or `absent' if +not, assuming point is at the beginning of a parameter list, just +after '('." + (save-excursion + (skip-chars-forward "[:space:]\n" end) + (cond ((> (point) end) + nil) + ((looking-at (concat go-identifier-regexp "[[:space:]\n]*,")) + (goto-char (match-end 0)) + (go--parameter-list-type end)) + ((or (looking-at go-qualified-identifier-regexp) + (looking-at (concat go-type-name-no-prefix-regexp "[[:space:]\n]*\\(?:)\\|\\'\\)")) + (go--looking-at-keyword) + (looking-at "[*\\[]\\|\\.\\.\\.\\|\\'")) + 'absent) + (t 'present)))) + +(defconst go--opt-dotdotdot-regexp "\\(?:\\.\\.\\.\\)?") +(defconst go--parameter-type-regexp + (concat go--opt-dotdotdot-regexp "[[:space:]*\n]*\\(" go-type-name-no-prefix-regexp "\\)[[:space:]\n]*\\([,)]\\|\\'\\)")) +(defconst go--func-type-in-parameter-list-regexp + (concat go--opt-dotdotdot-regexp "[[:space:]*\n]*\\(" (go--regexp-enclose-in-symbol "func") "\\)")) + +(defun go--match-parameters-common (identifier-regexp end) + (let ((acc ()) + (start -1)) + (while (progn (skip-chars-forward "[:space:]\n" end) + (and (not (looking-at "\\(?:)\\|\\'\\)")) + (< start (point)) + (<= (point) end))) + (setq start (point)) + (cond + ((looking-at (concat identifier-regexp go--parameter-type-regexp)) + (setq acc (nconc acc (list (match-beginning 1) (match-end 1)))) + (goto-char (match-beginning 2))) + ((looking-at (concat identifier-regexp go--func-type-in-parameter-list-regexp)) + (goto-char (match-beginning 1)) + (setq acc (nconc acc (go--match-func-type-names end))) + (go--search-next-comma end)) + (t + (go--search-next-comma end)))) + (when (and (looking-at ")") + (< (point) end)) + (forward-char)) + acc)) + +(defun go--match-parameters-with-identifier-list (end) + (go--match-parameters-common + (concat go-identifier-regexp "[[:space:]\n]+") + end)) + +(defun go--match-parameters-without-identifier-list (end) + (go--match-parameters-common "" end)) + +(defun go--filter-match-data (regions end) + "Remove points from REGIONS if they are beyond END. +REGIONS are a list whose size is multiple of 2. Element 2n is beginning of a +region and 2n+1 is end of it. + +This function is used to make sure we don't override end point +that `font-lock-mode' gave to us." + (when regions + (let* ((vec (vconcat regions)) + (i 0) + (len (length vec))) + (while (and (< i len) + (<= (nth i regions) end) + (<= (nth (1+ i) regions) end)) + (setq i (+ i 2))) + (cond ((= i len) + regions) + ((zerop i) + nil) + (t + (setcdr (nth i regions) nil) + regions))))) + +(defun go--make-match-data (regions) + (let ((deficit (- (* 2 go--font-lock-func-param-num-groups) + (length regions)))) + (when (> deficit 0) + (let ((last (car (last regions)))) + (setq regions (nconc regions (make-list deficit last)))))) + `(,(car regions) ,@(last regions) ,@regions)) + +(defun go--match-parameter-list (end) + "Return a list of identifier positions that are used as type +names in a function parameter list, assuming point is at the +beginning of a parameter list. Return nil if the text after +point does not look like a parameter list. + +Set point to end of closing parenthesis on success. + +In Go, the names must either all be present or all be absent +within a list of parameters. + +Parsing a parameter list is a little bit complicated because we +have to scan through the parameter list to determine whether or +not the list has names. Until a type name is found or reaching +end of a parameter list, we are not sure which form the parameter +list is. + +For example, X and Y are type names in a parameter list \"(X, +Y)\" but are parameter names in \"(X, Y int)\". We cannot say if +X is a type name until we see int after Y. + +Note that even \"(int, float T)\" is a valid parameter +list. Builtin type names are not reserved words. In this example, +int and float are parameter names and only T is a type name. + +In this function, we first scan the parameter list to see if the +list has names, and then handle it accordingly." + (let ((name (go--parameter-list-type end))) + (cond ((eq name 'present) + (go--match-parameters-with-identifier-list end)) + ((eq name 'absent) + (go--match-parameters-without-identifier-list end)) + (t nil)))) + +(defun go--match-function-result (end) + "Return a list of identifier positions that are used as type +names in a function result, assuming point is at the beginning of +a result. + +Function result is a unparenthesized type or a parameter list." + (cond ((and (looking-at (concat "[[:space:]*]*\\(" go-type-name-no-prefix-regexp "\\)")) + (not (member (match-string 1) go-mode-keywords))) + (list (match-beginning 1) (match-end 1))) + ((looking-at "[[:space:]]*(") + (goto-char (match-end 0)) + (go--match-parameter-list end)) + (t nil))) + +;;;###autoload +(define-derived-mode go-mode prog-mode "Go" + "Major mode for editing Go source text. + +This mode provides (not just) basic editing capabilities for +working with Go code. It offers almost complete syntax +highlighting, indentation that is almost identical to gofmt and +proper parsing of the buffer content to allow features such as +navigation by function, manipulation of comments or detection of +strings. + +In addition to these core features, it offers various features to +help with writing Go code. You can directly run buffer content +through gofmt, read godoc documentation from within Emacs, modify +and clean up the list of package imports or interact with the +Playground (uploading and downloading pastes). + +The following extra functions are defined: + +- `gofmt' +- `godoc' +- `go-import-add' +- `go-remove-unused-imports' +- `go-goto-imports' +- `go-play-buffer' and `go-play-region' +- `go-download-play' +- `godef-describe' and `godef-jump' +- `go-coverage' + +If you want to automatically run `gofmt' before saving a file, +add the following hook to your emacs configuration: + +\(add-hook 'before-save-hook #'gofmt-before-save) + +If you want to use `godef-jump' instead of etags (or similar), +consider binding godef-jump to `M-.', which is the default key +for `find-tag': + +\(add-hook 'go-mode-hook (lambda () + (local-set-key (kbd \"M-.\") #'godef-jump))) + +Please note that godef is an external dependency. You can install +it with + +go get code.google.com/p/rog-go/exp/cmd/godef + + +If you're looking for even more integration with Go, namely +on-the-fly syntax checking, auto-completion and snippets, it is +recommended that you look at flycheck +\(see URL `https://github.com/flycheck/flycheck') or flymake in combination +with goflymake \(see URL `https://github.com/dougm/goflymake'), gocode +\(see URL `https://github.com/nsf/gocode'), go-eldoc +\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go +\(see URL `https://github.com/dominikh/yasnippet-go')" + + ;; Font lock + (set (make-local-variable 'font-lock-defaults) + '(go--build-font-lock-keywords)) + + ;; Indentation + (set (make-local-variable 'indent-line-function) #'go-mode-indent-line) + + ;; Comments + (set (make-local-variable 'comment-start) "// ") + (set (make-local-variable 'comment-end) "") + (set (make-local-variable 'comment-use-syntax) t) + (set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *") + + (set (make-local-variable 'beginning-of-defun-function) #'go-beginning-of-defun) + (set (make-local-variable 'end-of-defun-function) #'go-end-of-defun) + + (set (make-local-variable 'parse-sexp-lookup-properties) t) + (if (boundp 'syntax-propertize-function) + (set (make-local-variable 'syntax-propertize-function) #'go-propertize-syntax) + (set (make-local-variable 'font-lock-syntactic-keywords) + go--font-lock-syntactic-keywords) + (set (make-local-variable 'font-lock-multiline) t)) + + (set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql)) + (add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t) + + ;; ff-find-other-file + (setq ff-other-file-alist 'go-other-file-alist) + + (setq imenu-generic-expression + '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1) + ("func" "^func *\\(.*\\) {" 1))) + (imenu-add-to-menubar "Index") + + ;; Go style + (setq indent-tabs-mode t) + + ;; Handle unit test failure output in compilation-mode + ;; + ;; Note the final t argument to add-to-list for append, ie put these at the + ;; *ends* of compilation-error-regexp-alist[-alist]. We want go-test to be + ;; handled first, otherwise other elements will match that don't work, and + ;; those alists are traversed in *reverse* order: + ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2001-12/msg00674.html + (when (and (boundp 'compilation-error-regexp-alist) + (boundp 'compilation-error-regexp-alist-alist)) + (add-to-list 'compilation-error-regexp-alist 'go-test t) + (add-to-list 'compilation-error-regexp-alist-alist + '(go-test . ("^\t+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$" 1 2)) t))) + +;;;###autoload +(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) + +(defun go--apply-rcs-patch (patch-buffer) + "Apply an RCS-formatted diff from PATCH-BUFFER to the current buffer." + (let ((target-buffer (current-buffer)) + ;; Relative offset between buffer line numbers and line numbers + ;; in patch. + ;; + ;; Line numbers in the patch are based on the source file, so + ;; we have to keep an offset when making changes to the + ;; buffer. + ;; + ;; Appending lines decrements the offset (possibly making it + ;; negative), deleting lines increments it. This order + ;; simplifies the forward-line invocations. + (line-offset 0)) + (save-excursion + (with-current-buffer patch-buffer + (goto-char (point-min)) + (while (not (eobp)) + (unless (looking-at "^\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)") + (error "invalid rcs patch or internal error in go--apply-rcs-patch")) + (forward-line) + (let ((action (match-string 1)) + (from (string-to-number (match-string 2))) + (len (string-to-number (match-string 3)))) + (cond + ((equal action "a") + (let ((start (point))) + (forward-line len) + (let ((text (buffer-substring start (point)))) + (with-current-buffer target-buffer + (decf line-offset len) + (goto-char (point-min)) + (forward-line (- from len line-offset)) + (insert text))))) + ((equal action "d") + (with-current-buffer target-buffer + (go--goto-line (- from line-offset)) + (incf line-offset len) + (go--delete-whole-line len))) + (t + (error "invalid rcs patch or internal error in go--apply-rcs-patch"))))))))) + +(defun gofmt () + "Format the current buffer according to the gofmt tool." + (interactive) + (let ((tmpfile (make-temp-file "gofmt" nil ".go")) + (patchbuf (get-buffer-create "*Gofmt patch*")) + (errbuf (if gofmt-show-errors (get-buffer-create "*Gofmt Errors*"))) + (coding-system-for-read 'utf-8) + (coding-system-for-write 'utf-8)) + + (save-restriction + (widen) + (if errbuf + (with-current-buffer errbuf + (setq buffer-read-only nil) + (erase-buffer))) + (with-current-buffer patchbuf + (erase-buffer)) + + (write-region nil nil tmpfile) + + ;; We're using errbuf for the mixed stdout and stderr output. This + ;; is not an issue because gofmt -w does not produce any stdout + ;; output in case of success. + (if (zerop (call-process gofmt-command nil errbuf nil "-w" tmpfile)) + (progn + (if (zerop (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "-" tmpfile)) + (message "Buffer is already gofmted") + (go--apply-rcs-patch patchbuf) + (message "Applied gofmt")) + (if errbuf (gofmt--kill-error-buffer errbuf))) + (message "Could not apply gofmt") + (if errbuf (gofmt--process-errors (buffer-file-name) tmpfile errbuf))) + + (kill-buffer patchbuf) + (delete-file tmpfile)))) + + +(defun gofmt--process-errors (filename tmpfile errbuf) + (with-current-buffer errbuf + (if (eq gofmt-show-errors 'echo) + (progn + (message "%s" (buffer-string)) + (gofmt--kill-error-buffer errbuf)) + ;; Convert the gofmt stderr to something understood by the compilation mode. + (goto-char (point-min)) + (insert "gofmt errors:\n") + (while (search-forward-regexp (concat "^\\(" (regexp-quote tmpfile) "\\):") nil t) + (replace-match (file-name-nondirectory filename) t t nil 1)) + (compilation-mode) + (display-buffer errbuf)))) + +(defun gofmt--kill-error-buffer (errbuf) + (let ((win (get-buffer-window errbuf))) + (if win + (quit-window t win) + (kill-buffer errbuf)))) + +;;;###autoload +(defun gofmt-before-save () + "Add this to .emacs to run gofmt on the current buffer when saving: + (add-hook 'before-save-hook 'gofmt-before-save). + +Note that this will cause go-mode to get loaded the first time +you save any file, kind of defeating the point of autoloading." + + (interactive) + (when (eq major-mode 'go-mode) (gofmt))) + +(defun godoc--read-query () + "Read a godoc query from the minibuffer." + ;; Compute the default query as the symbol under the cursor. + ;; TODO: This does the wrong thing for e.g. multipart.NewReader (it only grabs + ;; half) but I see no way to disambiguate that from e.g. foobar.SomeMethod. + (let* ((bounds (bounds-of-thing-at-point 'symbol)) + (symbol (if bounds + (buffer-substring-no-properties (car bounds) + (cdr bounds))))) + (completing-read (if symbol + (format "godoc (default %s): " symbol) + "godoc: ") + (go--old-completion-list-style (go-packages)) nil nil nil 'go-godoc-history symbol))) + +(defun godoc--get-buffer (query) + "Get an empty buffer for a godoc query." + (let* ((buffer-name (concat "*godoc " query "*")) + (buffer (get-buffer buffer-name))) + ;; Kill the existing buffer if it already exists. + (when buffer (kill-buffer buffer)) + (get-buffer-create buffer-name))) + +(defun godoc--buffer-sentinel (proc event) + "Sentinel function run when godoc command completes." + (with-current-buffer (process-buffer proc) + (cond ((string= event "finished\n") ;; Successful exit. + (goto-char (point-min)) + (godoc-mode) + (display-buffer (current-buffer) t)) + ((/= (process-exit-status proc) 0) ;; Error exit. + (let ((output (buffer-string))) + (kill-buffer (current-buffer)) + (message (concat "godoc: " output))))))) + +(define-derived-mode godoc-mode special-mode "Godoc" + "Major mode for showing Go documentation." + (view-mode-enter)) + +;;;###autoload +(defun godoc (query) + "Show Go documentation for QUERY, much like M-x man." + (interactive (list (godoc--read-query))) + (unless (string= query "") + (set-process-sentinel + (start-process-shell-command "godoc" (godoc--get-buffer query) + (concat "godoc " query)) + 'godoc--buffer-sentinel) + nil)) + +(defun godoc-at-point (point) + "Show Go documentation for the identifier at POINT. + +`godoc-at-point' requires godef to work. + +Due to a limitation in godoc, it is not possible to differentiate +between functions and methods, which may cause `godoc-at-point' +to display more documentation than desired." + ;; TODO(dominikh): Support executing godoc-at-point on a package + ;; name. + (interactive "d") + (condition-case nil + (let* ((output (godef--call point)) + (file (car output)) + (name-parts (split-string (cadr output) " ")) + (first (car name-parts))) + (if (not (godef--successful-p file)) + (message "%s" (godef--error file)) + (godoc (format "%s %s" + (file-name-directory file) + (if (or (string= first "type") (string= first "const")) + (cadr name-parts) + (car name-parts)))))) + (file-error (message "Could not run godef binary")))) + +(defun go-goto-imports () + "Move point to the block of imports. + +If using + + import ( + \"foo\" + \"bar\" + ) + +it will move point directly behind the last import. + +If using + + import \"foo\" + import \"bar\" + +it will move point to the next line after the last import. + +If no imports can be found, point will be moved after the package +declaration." + (interactive) + ;; FIXME if there's a block-commented import before the real + ;; imports, we'll jump to that one. + + ;; Generally, this function isn't very forgiving. it'll bark on + ;; extra whitespace. It works well for clean code. + (let ((old-point (point))) + (goto-char (point-min)) + (cond + ((re-search-forward "^import ()" nil t) + (backward-char 1) + 'block-empty) + ((re-search-forward "^import ([^)]+)" nil t) + (backward-char 2) + 'block) + ((re-search-forward "\\(^import \\([^\"]+ \\)?\"[^\"]+\"\n?\\)+" nil t) + 'single) + ((re-search-forward "^[[:space:]\n]*package .+?\n" nil t) + (message "No imports found, moving point after package declaration") + 'none) + (t + (goto-char old-point) + (message "No imports or package declaration found. Is this really a Go file?") + 'fail)))) + +(defun go-play-buffer () + "Like `go-play-region', but acts on the entire buffer." + (interactive) + (go-play-region (point-min) (point-max))) + +(defun go-play-region (start end) + "Send the region to the Playground. +If non-nil `go-play-browse-function' is called with the +Playground URL." + (interactive "r") + (let* ((url-request-method "POST") + (url-request-extra-headers + '(("Content-Type" . "application/x-www-form-urlencoded"))) + (url-request-data + (encode-coding-string + (buffer-substring-no-properties start end) + 'utf-8)) + (content-buf (url-retrieve + "http://play.golang.org/share" + (lambda (arg) + (cond + ((equal :error (car arg)) + (signal 'go-play-error (cdr arg))) + (t + (re-search-forward "\n\n") + (let ((url (format "http://play.golang.org/p/%s" + (buffer-substring (point) (point-max))))) + (when go-play-browse-function + (funcall go-play-browse-function url))))))))))) + +;;;###autoload +(defun go-download-play (url) + "Download a paste from the playground and insert it in a Go buffer. +Tries to look for a URL at point." + (interactive (list (read-from-minibuffer "Playground URL: " (ffap-url-p (ffap-string-at-point 'url))))) + (with-current-buffer + (let ((url-request-method "GET") url-request-data url-request-extra-headers) + (url-retrieve-synchronously (concat url ".go"))) + (let ((buffer (generate-new-buffer (concat (car (last (split-string url "/"))) ".go")))) + (goto-char (point-min)) + (re-search-forward "\n\n") + (copy-to-buffer buffer (point) (point-max)) + (kill-buffer) + (with-current-buffer buffer + (go-mode) + (switch-to-buffer buffer))))) + +(defun go-propertize-syntax (start end) + (save-excursion + (goto-char start) + (while (search-forward "\\" end t) + (put-text-property (1- (point)) (point) 'syntax-table (if (= (char-after) ?`) '(1) '(9)))))) + +(defun go-import-add (arg import) + "Add a new IMPORT to the list of imports. + +When called with a prefix ARG asks for an alternative name to +import the package as. + +If no list exists yet, one will be created if possible. + +If an identical import has been commented, it will be +uncommented, otherwise a new import will be added." + + ;; - If there's a matching `// import "foo"`, uncomment it + ;; - If we're in an import() block and there's a matching `"foo"`, uncomment it + ;; - Otherwise add a new import, with the appropriate syntax + (interactive + (list + current-prefix-arg + (replace-regexp-in-string "^[\"']\\|[\"']$" "" (completing-read "Package: " (go--old-completion-list-style (go-packages)))))) + (save-excursion + (let (as line import-start) + (if arg + (setq as (read-from-minibuffer "Import as: "))) + (if as + (setq line (format "%s \"%s\"" as import)) + (setq line (format "\"%s\"" import))) + + (goto-char (point-min)) + (if (re-search-forward (concat "^[[:space:]]*//[[:space:]]*import " line "$") nil t) + (uncomment-region (line-beginning-position) (line-end-position)) + (case (go-goto-imports) + ('fail (message "Could not find a place to add import.")) + ('block-empty + (insert "\n\t" line "\n")) + ('block + (save-excursion + (re-search-backward "^import (") + (setq import-start (point))) + (if (re-search-backward (concat "^[[:space:]]*//[[:space:]]*" line "$") import-start t) + (uncomment-region (line-beginning-position) (line-end-position)) + (insert "\n\t" line))) + ('single (insert "import " line "\n")) + ('none (insert "\nimport (\n\t" line "\n)\n"))))))) + +(defun go-root-and-paths () + (let* ((output (split-string (shell-command-to-string (concat go-command " env GOROOT GOPATH")) + "\n")) + (root (car output)) + (paths (split-string (cadr output) path-separator))) + (append (list root) paths))) + +(defun go--string-prefix-p (s1 s2 &optional ignore-case) + "Return non-nil if S1 is a prefix of S2. +If IGNORE-CASE is non-nil, the comparison is case-insensitive." + (eq t (compare-strings s1 nil nil + s2 0 (length s1) ignore-case))) + +(defun go--directory-dirs (dir) + "Recursively return all subdirectories in DIR." + (if (file-directory-p dir) + (let ((dir (directory-file-name dir)) + (dirs '()) + (files (directory-files dir nil nil t))) + (dolist (file files) + (unless (member file '("." "..")) + (let ((file (concat dir "/" file))) + (if (file-directory-p file) + (setq dirs (append (cons file + (go--directory-dirs file)) + dirs)))))) + dirs) + '())) + + +(defun go-packages () + (sort + (delete-dups + (mapcan + (lambda (topdir) + (let ((pkgdir (concat topdir "/pkg/"))) + (mapcan (lambda (dir) + (mapcar (lambda (file) + (let ((sub (substring file (length pkgdir) -2))) + (unless (or (go--string-prefix-p "obj/" sub) (go--string-prefix-p "tool/" sub)) + (mapconcat #'identity (cdr (split-string sub "/")) "/")))) + (if (file-directory-p dir) + (directory-files dir t "\\.a$")))) + (if (file-directory-p pkgdir) + (go--directory-dirs pkgdir))))) + (go-root-and-paths))) + #'string<)) + +(defun go-unused-imports-lines () + ;; FIXME Technically, -o /dev/null fails in quite some cases (on + ;; Windows, when compiling from within GOPATH). Practically, + ;; however, it has the same end result: There won't be a + ;; compiled binary/archive, and we'll get our import errors when + ;; there are any. + (reverse (remove nil + (mapcar + (lambda (line) + (when (string-match "^\\(.+\\):\\([[:digit:]]+\\): imported and not used: \".+\".*$" line) + (let ((error-file-name (match-string 1 line)) + (error-line-num (match-string 2 line))) + (if (string= (file-truename error-file-name) (file-truename buffer-file-name)) + (string-to-number error-line-num))))) + (split-string (shell-command-to-string + (concat go-command + (if (string-match "_test\.go$" buffer-file-truename) + " test -c" + " build -o /dev/null"))) "\n"))))) + +(defun go-remove-unused-imports (arg) + "Remove all unused imports. +If ARG is non-nil, unused imports will be commented, otherwise +they will be removed completely." + (interactive "P") + (save-excursion + (let ((cur-buffer (current-buffer)) flymake-state lines) + (when (boundp 'flymake-mode) + (setq flymake-state flymake-mode) + (flymake-mode-off)) + (save-some-buffers nil (lambda () (equal cur-buffer (current-buffer)))) + (if (buffer-modified-p) + (message "Cannot operate on unsaved buffer") + (setq lines (go-unused-imports-lines)) + (dolist (import lines) + (go--goto-line import) + (beginning-of-line) + (if arg + (comment-region (line-beginning-position) (line-end-position)) + (go--delete-whole-line))) + (message "Removed %d imports" (length lines))) + (if flymake-state (flymake-mode-on))))) + +(defun godef--find-file-line-column (specifier other-window) + "Given a file name in the format of `filename:line:column', +visit FILENAME and go to line LINE and column COLUMN." + (if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier)) + ;; We've only been given a directory name + (funcall (if other-window #'find-file-other-window #'find-file) specifier) + (let ((filename (match-string 1 specifier)) + (line (string-to-number (match-string 2 specifier))) + (column (string-to-number (match-string 3 specifier)))) + (funcall (if other-window #'find-file-other-window #'find-file) filename) + (go--goto-line line) + (beginning-of-line) + (forward-char (1- column)) + (if (buffer-modified-p) + (message "Buffer is modified, file position might not have been correct"))))) + +(defun godef--call (point) + "Call godef, acquiring definition position and expression +description at POINT." + (if (go--xemacs-p) + (error "godef does not reliably work in XEmacs, expect bad results")) + (if (not (buffer-file-name (go--coverage-origin-buffer))) + (error "Cannot use godef on a buffer without a file name") + (let ((outbuf (get-buffer-create "*godef*")) + (coding-system-for-read 'utf-8) + (coding-system-for-write 'utf-8)) + (with-current-buffer outbuf + (erase-buffer)) + (call-process-region (point-min) + (point-max) + godef-command + nil + outbuf + nil + "-i" + "-t" + "-f" + (file-truename (buffer-file-name (go--coverage-origin-buffer))) + "-o" + (number-to-string (go--position-bytes point))) + (with-current-buffer outbuf + (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))))) + +(defun godef--successful-p (output) + (not (or (string= "-" output) + (string= "godef: no identifier found" output) + (go--string-prefix-p "godef: no declaration found for " output) + (go--string-prefix-p "error finding import path for " output)))) + +(defun godef--error (output) + (cond + ((godef--successful-p output) + nil) + ((string= "-" output) + "godef: expression is not defined anywhere") + (t + output))) + +(defun godef-describe (point) + "Describe the expression at POINT." + (interactive "d") + (condition-case nil + (let ((description (cdr (butlast (godef--call point) 1)))) + (if (not description) + (message "No description found for expression at point") + (message "%s" (mapconcat #'identity description "\n")))) + (file-error (message "Could not run godef binary")))) + +(defun godef-jump (point &optional other-window) + "Jump to the definition of the expression at POINT." + (interactive "d") + (condition-case nil + (let ((file (car (godef--call point)))) + (if (not (godef--successful-p file)) + (message "%s" (godef--error file)) + (push-mark) + (ring-insert find-tag-marker-ring (point-marker)) + (godef--find-file-line-column file other-window))) + (file-error (message "Could not run godef binary")))) + +(defun godef-jump-other-window (point) + (interactive "d") + (godef-jump point t)) + +(defun go--goto-line (line) + (goto-char (point-min)) + (forward-line (1- line))) + +(defun go--line-column-to-point (line column) + (save-excursion + (go--goto-line line) + (forward-char (1- column)) + (point))) + +(defstruct go--covered + start-line start-column end-line end-column covered count) + +(defun go--coverage-file () + "Return the coverage file to use, either by reading it from the +current coverage buffer or by prompting for it." + (if (boundp 'go--coverage-current-file-name) + go--coverage-current-file-name + (read-file-name "Coverage file: " nil nil t))) + +(defun go--coverage-origin-buffer () + "Return the buffer to base the coverage on." + (or (buffer-base-buffer) (current-buffer))) + +(defun go--coverage-face (count divisor) + "Return the intensity face for COUNT when using DIVISOR +to scale it to a range [0,10]. + +DIVISOR scales the absolute cover count to values from 0 to 10. +For DIVISOR = 0 the count will always translate to 8." + (let* ((norm (cond + ((= count 0) + -0.1) ;; Uncovered code, set to -0.1 so n becomes 0. + ((= divisor 0) + 0.8) ;; covermode=set, set to 0.8 so n becomes 8. + (t + (/ (log count) divisor)))) + (n (1+ (floor (* norm 9))))) ;; Convert normalized count [0,1] to intensity [0,10] + (concat "go-coverage-" (number-to-string n)))) + +(defun go--coverage-make-overlay (range divisor) + "Create a coverage overlay for a RANGE of covered/uncovered code. +Use DIVISOR to scale absolute counts to a [0,10] scale." + (let* ((count (go--covered-count range)) + (face (go--coverage-face count divisor)) + (ov (make-overlay (go--line-column-to-point (go--covered-start-line range) + (go--covered-start-column range)) + (go--line-column-to-point (go--covered-end-line range) + (go--covered-end-column range))))) + + (overlay-put ov 'face face) + (overlay-put ov 'help-echo (format "Count: %d" count)))) + +(defun go--coverage-clear-overlays () + "Remove existing overlays and put a single untracked overlay +over the entire buffer." + (remove-overlays) + (overlay-put (make-overlay (point-min) (point-max)) + 'face + 'go-coverage-untracked)) + +(defun go--coverage-parse-file (coverage-file file-name) + "Parse COVERAGE-FILE and extract coverage information and +divisor for FILE-NAME." + (let (ranges + (max-count 0)) + (with-temp-buffer + (insert-file-contents coverage-file) + (go--goto-line 2) ;; Skip over mode + (while (not (eobp)) + (let* ((parts (split-string (buffer-substring (point-at-bol) (point-at-eol)) ":")) + (file (car parts)) + (rest (split-string (nth 1 parts) "[., ]"))) + + (destructuring-bind + (start-line start-column end-line end-column num count) + (mapcar #'string-to-number rest) + + (when (string= (file-name-nondirectory file) file-name) + (if (> count max-count) + (setq max-count count)) + (push (make-go--covered :start-line start-line + :start-column start-column + :end-line end-line + :end-column end-column + :covered (/= count 0) + :count count) + ranges))) + + (forward-line))) + + (list ranges (if (> max-count 0) (log max-count) 0))))) + +(defun go-coverage (&optional coverage-file) + "Open a clone of the current buffer and overlay it with +coverage information gathered via go test -coverprofile=COVERAGE-FILE. + +If COVERAGE-FILE is nil, it will either be inferred from the +current buffer if it's already a coverage buffer, or be prompted +for." + (interactive) + (let* ((cur-buffer (current-buffer)) + (origin-buffer (go--coverage-origin-buffer)) + (gocov-buffer-name (concat (buffer-name origin-buffer) "")) + (coverage-file (or coverage-file (go--coverage-file))) + (ranges-and-divisor (go--coverage-parse-file + coverage-file + (file-name-nondirectory (buffer-file-name origin-buffer)))) + (cov-mtime (nth 5 (file-attributes coverage-file))) + (cur-mtime (nth 5 (file-attributes (buffer-file-name origin-buffer))))) + + (if (< (float-time cov-mtime) (float-time cur-mtime)) + (message "Coverage file is older than the source file.")) + + (with-current-buffer (or (get-buffer gocov-buffer-name) + (make-indirect-buffer origin-buffer gocov-buffer-name t)) + (set (make-local-variable 'go--coverage-current-file-name) coverage-file) + + (save-excursion + (go--coverage-clear-overlays) + (dolist (range (car ranges-and-divisor)) + (go--coverage-make-overlay range (cadr ranges-and-divisor)))) + + (if (not (eq cur-buffer (current-buffer))) + (display-buffer (current-buffer) `(,go-coverage-display-buffer-func)))))) + +(provide 'go-mode) + +;;; go-mode.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/emacs-helm.sh b/emacs.d/elpa/helm-20141016.2217/emacs-helm.sh deleted file mode 100755 index fe9a2aa..0000000 --- a/emacs.d/elpa/helm-20141016.2217/emacs-helm.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - - -## Copyright (C) 2012 Thierry Volpiatto -## -## 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: - -# Preconfigured Emacs with a basic helm configuration. -# Useful to start quickly an emacs -Q with helm. -# Run it from this directory. - -TMP="/tmp/helm-cfg.el" -EMACS=emacs - -case $1 in - -P) - shift 1 - declare EMACS=$1 - shift 1 - ;; - -h) - echo "Usage: ${0##*/} [-P} Emacs path [-h} help [--] EMACS ARGS" - exit 2 - ;; -esac - -cd $(dirname "$0") - -# Check if autoload file exists. -# It is maybe in a different directory if -# emacs-helm.sh is a symlink. -LS=$(ls -l $0 | awk '{print $11}') -if [ ! -z $LS ]; then - AUTO_FILE="$(dirname $LS)/helm-autoloads.el" -else - AUTO_FILE="helm-autoloads.el" -fi -if [ ! -e "$AUTO_FILE" ]; then - echo No autoloads found, please run make first to generate autoload file - exit 2 -fi - - -cat > $TMP <\`helm-find-files'\n\ -;; - \`occur'(M-s o) =>\`helm-occur'\n\ -;; - \`list-buffers'(C-x C-b) =>\`helm-buffers-list'\n\ -;; - \`completion-at-point'(M-tab) =>\`helm-lisp-completion-at-point'[1]\n\ -;; - \`dabbrev-expand'(M-/) =>\`helm-dabbrev'\n\n\ -;; Some others native emacs commands are \"helmized\" by \`helm-mode'.\n\ -;; [1] Coming with emacs-24.4 \`completion-at-point' is \"helmized\" by \`helm-mode'\n\ -;; which provide helm completion in many other places like \`shell-mode'.\n\ -;; You will find embeded help for most helm commands with \`C-c ?'.\n\ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")) - -(setq default-frame-alist '((vertical-scroll-bars . nil) - (tool-bar-lines . 0) - (menu-bar-lines . 0) - (fullscreen . nil))) -(blink-cursor-mode -1) -(add-to-list 'load-path (file-name-directory (file-truename "$0"))) -(require 'helm-config) -(helm-mode 1) -(define-key global-map [remap find-file] 'helm-find-files) -(define-key global-map [remap occur] 'helm-occur) -(define-key global-map [remap list-buffers] 'helm-buffers-list) -(define-key global-map [remap dabbrev-expand] 'helm-dabbrev) -(unless (boundp 'completion-in-region-function) - (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point) - (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)) -(add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP")))) -EOF - -$EMACS -Q -l $TMP $@ - diff --git a/emacs.d/elpa/helm-20141016.2217/helm-adaptive.el b/emacs.d/elpa/helm-20141016.2217/helm-adaptive.el deleted file mode 100644 index 0532474..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-adaptive.el +++ /dev/null @@ -1,243 +0,0 @@ -;;; helm-adaptive.el --- Adaptive Sorting of Candidates. -*- lexical-binding: t -*- - -;; Original Author: Tamas Patrovics - -;; Copyright (C) 2007 Tamas Patrovics -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) - - -(defgroup helm-adapt nil - "Adaptative sorting of candidates for Helm." - :group 'helm) - -(defcustom helm-adaptive-history-file - "~/.emacs.d/helm-adaptive-history" - "Path of file where history information is stored." - :type 'string - :group 'helm-adapt) - -(defcustom helm-adaptive-history-length 50 - "Maximum number of candidates stored for a source." - :type 'number - :group 'helm-adapt) - - -;; Internal -(defvar helm-adaptive-done nil - "nil if history information is not yet stored for the current -selection.") - -(defvar helm-adaptive-history nil - "Contains the stored history information. -Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)") - -(defun helm-adaptive-done-reset () - (setq helm-adaptive-done nil)) - -(define-minor-mode helm-adaptive-mode - "Toggle adaptive sorting in all sources." - :group 'helm-adapt - :require 'helm-adaptive - :global t - (if helm-adaptive-mode - (progn - (unless helm-adaptive-history - (helm-adaptive-maybe-load-history)) - (add-hook 'kill-emacs-hook 'helm-adaptive-save-history) - ;; Should run at beginning of `helm-initial-setup'. - (add-hook 'helm-before-initialize-hook 'helm-adaptive-done-reset) - ;; Should run at beginning of `helm-exit-minibuffer'. - (add-hook 'helm-before-action-hook 'helm-adaptive-store-selection) - ;; Should run at beginning of `helm-select-action'. - (add-hook 'helm-select-action-hook 'helm-adaptive-store-selection)) - (helm-adaptive-save-history) - (setq helm-adaptive-history nil) - (remove-hook 'kill-emacs-hook 'helm-adaptive-save-history) - (remove-hook 'helm-before-initialize-hook 'helm-adaptive-done-reset) - (remove-hook 'helm-before-action-hook 'helm-adaptive-store-selection) - (remove-hook 'helm-select-action-hook 'helm-adaptive-store-selection))) - -(defun helm-adapt-use-adaptive-p (&optional source-name) - "Return current source only if it use adaptive history, nil otherwise." - (when helm-adaptive-mode - (let* ((source (or source-name (helm-get-current-source))) - (adapt-source (or (assoc-default 'filtered-candidate-transformer - (assoc (assoc-default 'type source) - helm-type-attributes)) - (assoc-default 'candidate-transformer - (assoc (assoc-default 'type source) - helm-type-attributes)) - (assoc-default 'filtered-candidate-transformer source) - (assoc-default 'candidate-transformer source)))) - (if (listp adapt-source) - (and (member 'helm-adaptive-sort adapt-source) source) - (and (eq adapt-source 'helm-adaptive-sort) source))))) - -(defun helm-adaptive-store-selection () - "Store history information for the selected candidate." - (unless helm-adaptive-done - (setq helm-adaptive-done t) - (let ((source (helm-adapt-use-adaptive-p))) - (when source - (let* ((source-name (or (assoc-default 'type source) - (assoc-default 'name source))) - (source-info (or (assoc source-name helm-adaptive-history) - (progn - (push (list source-name) helm-adaptive-history) - (car helm-adaptive-history)))) - (selection (helm-get-selection)) - (selection-info (progn - (setcdr source-info - (cons - (let ((found (assoc selection (cdr source-info)))) - (if (not found) - ;; new entry - (list selection) - ;; move entry to the beginning of the - ;; list, so that it doesn't get - ;; trimmed when the history is - ;; truncated - (setcdr source-info - (delete found (cdr source-info))) - found)) - (cdr source-info))) - (cadr source-info))) - (pattern-info (progn - (setcdr selection-info - (cons - (let ((found (assoc helm-pattern (cdr selection-info)))) - (if (not found) - ;; new entry - (cons helm-pattern 0) - - ;; move entry to the beginning of the - ;; list, so if two patterns used the - ;; same number of times then the one - ;; used last appears first in the list - (setcdr selection-info - (delete found (cdr selection-info))) - found)) - (cdr selection-info))) - (cadr selection-info)))) - - ;; increase usage count - (setcdr pattern-info (1+ (cdr pattern-info))) - - ;; truncate history if needed - (if (> (length (cdr selection-info)) helm-adaptive-history-length) - (setcdr selection-info - (cl-subseq (cdr selection-info) 0 helm-adaptive-history-length)))))))) - -(defun helm-adaptive-maybe-load-history () - "Load `helm-adaptive-history-file' which contain `helm-adaptive-history'. -Returns nil if `helm-adaptive-history-file' doesn't exist." - (when (file-readable-p helm-adaptive-history-file) - (load-file helm-adaptive-history-file))) - -(defun helm-adaptive-save-history (&optional arg) - "Save history information to file given by `helm-adaptive-history-file'." - (interactive "p") - (with-temp-buffer - (insert - ";; -*- mode: emacs-lisp -*-\n" - ";; History entries used for helm adaptive display.\n") - (prin1 `(setq helm-adaptive-history ',helm-adaptive-history) - (current-buffer)) - (insert ?\n) - (write-region (point-min) (point-max) helm-adaptive-history-file nil - (unless arg 'quiet)))) - -(defun helm-adaptive-sort (candidates source) - "Sort the CANDIDATES for SOURCE by usage frequency. -This is a filtered candidate transformer you can use with the -`filtered-candidate-transformer' attribute." - (let* ((source-name (or (assoc-default 'type source) - (assoc-default 'name source))) - (source-info (assoc source-name helm-adaptive-history))) - (if source-info - (let ((usage - ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT) - ;; pairs - (mapcar (lambda (candidate-info) - (let ((count 0)) - (cl-dolist (pattern-info (cdr candidate-info)) - (if (not (equal (car pattern-info) - helm-pattern)) - (cl-incf count (cdr pattern-info)) - - ;; if current pattern is equal to the previously - ;; used one then this candidate has priority - ;; (that's why its count is boosted by 10000) and - ;; it only has to compete with other candidates - ;; which were also selected with the same pattern - (setq count (+ 10000 (cdr pattern-info))) - (cl-return))) - (cons (car candidate-info) count))) - (cdr source-info)))) - (if (and usage (consp usage)) - ;; sort the list in descending order, so candidates with highest - ;; priorty come first - (progn - (setq usage (sort usage (lambda (first second) - (> (cdr first) (cdr second))))) - - ;; put those candidates first which have the highest usage count - (cl-loop for (info . _freq) in usage - for member = (cl-member info candidates - :test 'helm-adaptive-compare) - when member collect (car member) into sorted - and do - (setq candidates (cl-remove info candidates - :test 'helm-adaptive-compare)) - finally return (append sorted candidates))) - (message "Your `%s' is maybe corrupted or too old, \ -you should reinitialize it with `helm-reset-adaptive-history'" - helm-adaptive-history-file) - (sit-for 1) - candidates)) - ;; if there is no information stored for this source then do nothing - candidates))) - -;;;###autoload -(defun helm-reset-adaptive-history () - "Delete all `helm-adaptive-history' and his file. -Useful when you have a old or corrupted `helm-adaptive-history-file'." - (interactive) - (when (y-or-n-p "Really delete all your `helm-adaptive-history'? ") - (setq helm-adaptive-history nil) - (delete-file helm-adaptive-history-file))) - -(defun helm-adaptive-compare (x y) - "Compare candidates X and Y taking into account that the -candidate can be in (DISPLAY . REAL) format." - (equal (if (listp x) (cdr x) x) - (if (listp y) (cdr y) y))) - - -(provide 'helm-adaptive) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-adaptive.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-aliases.el b/emacs.d/elpa/helm-20141016.2217/helm-aliases.el deleted file mode 100644 index 22fffdb..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-aliases.el +++ /dev/null @@ -1,897 +0,0 @@ -;;; helm-aliases.el --- Helm aliases for helm obsoletes functions. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) - - -;;; Helper functions to create aliases with old helm definitions -;; prefixed with "helm-c-" -;; -(defun helm-alias-p (sym) - (cond ((boundp sym) - (not (eq (indirect-variable sym) sym))) - ((fboundp sym) - (symbolp (symbol-function sym))) - (t nil))) - -(defun helm-check-conflicting-prefixes () - (cl-loop for s in (all-completions "helm-c-" obarray) - for rep = (replace-regexp-in-string "helm-c-" "helm-" s) - when (or (and (not (helm-alias-p (intern s))) (fboundp (intern rep))) - (and (not (helm-alias-p (intern s))) (boundp (intern rep)))) - collect rep)) - -(defun helm-collect-functions-with-bad-prefix () - (cl-loop for s in (all-completions "helm-c-" obarray) - for sym = (intern s) - when (and (not (helm-alias-p sym)) (fboundp sym)) - collect s)) - -(defun helm-collect-vars-with-bad-prefix () - (cl-loop for s in (all-completions "helm-c-" obarray) - for sym = (intern s) - when (and (not (helm-alias-p sym)) (boundp sym)) - collect s)) - -(defun helm-insert-fn-aliases () - (cl-loop for s in (helm-collect-functions-with-bad-prefix) - for rep = (replace-regexp-in-string "helm-c-" "helm-" s) - do (insert (format "(defalias '%s '%s)\n(make-obsolete '%s '%s \"1.5.1\")\n" s rep s rep)))) - -(defun helm-insert-var-aliases () - (cl-loop for s in (helm-collect-vars-with-bad-prefix) - for rep = (replace-regexp-in-string "helm-c-" "helm-" s) - do (insert (format "(defvaralias '%s '%s)\n(make-obsolete-variable '%s '%s \"1.5.1\")\n" s rep s rep)))) - - -;;; Alias old functions prefixed with "helm-c-" -;; -;; -(defalias 'helm-c-etags-default-action 'helm-etags-default-action) -(make-obsolete 'helm-c-etags-default-action 'helm-etags-default-action "1.5.1") -(defalias 'helm-c-show-info-in-mode-line 'helm-show-info-in-mode-line) -(make-obsolete 'helm-c-show-info-in-mode-line 'helm-show-info-in-mode-line "1.5.1") -(defalias 'helm-c-gentoo-eshell-action 'helm-gentoo-eshell-action) -(make-obsolete 'helm-c-gentoo-eshell-action 'helm-gentoo-eshell-action "1.5.1") -(defalias 'helm-c-grep-highlight-match 'helm-grep-highlight-match) -(make-obsolete 'helm-c-grep-highlight-match 'helm-grep-highlight-match "1.5.1") -(defalias 'helm-c-apropos 'helm-apropos) -(make-obsolete 'helm-c-apropos 'helm-apropos "1.5.1") -(defalias 'helm-c-grep-guess-extensions 'helm-grep-guess-extensions) -(make-obsolete 'helm-c-grep-guess-extensions 'helm-grep-guess-extensions "1.5.1") -(defalias 'helm-c-highlight-w3m-bookmarks 'helm-highlight-w3m-bookmarks) -(make-obsolete 'helm-c-highlight-w3m-bookmarks 'helm-highlight-w3m-bookmarks "1.5.1") -(defalias 'helm-c-emms-files-modifier 'helm-emms-files-modifier) -(make-obsolete 'helm-c-emms-files-modifier 'helm-emms-files-modifier "1.5.1") -(defalias 'helm-c-apt-reinstall 'helm-apt-reinstall) -(make-obsolete 'helm-c-apt-reinstall 'helm-apt-reinstall "1.5.1") -(defalias 'helm-c-bbdb-compose-mail 'helm-bbdb-compose-mail) -(make-obsolete 'helm-c-bbdb-compose-mail 'helm-bbdb-compose-mail "1.5.1") -(defalias 'helm-c-gentoo-init-list 'helm-gentoo-init-list) -(make-obsolete 'helm-c-gentoo-init-list 'helm-gentoo-init-list "1.5.1") -(defalias 'helm-c-gentoo-get-world 'helm-gentoo-get-world) -(make-obsolete 'helm-c-gentoo-get-world 'helm-gentoo-get-world "1.5.1") -(defalias 'helm-c-reset-adaptive-history 'helm-reset-adaptive-history) -(make-obsolete 'helm-c-reset-adaptive-history 'helm-reset-adaptive-history "1.5.1") -(defalias 'helm-adaptative-mode 'helm-adaptive-mode) -(make-obsolete 'helm-adaptative-mode 'helm-adaptive-mode "1.6.2") -(defalias 'helm-c-highlight-bookmark 'helm-highlight-bookmark) -(make-obsolete 'helm-c-highlight-bookmark 'helm-highlight-bookmark "1.5.1") -(defalias 'helm-c-locate-init 'helm-locate-init) -(make-obsolete 'helm-c-locate-init 'helm-locate-init "1.5.1") -(defalias 'helm-c-delete-file 'helm-delete-file) -(make-obsolete 'helm-c-delete-file 'helm-delete-file "1.5.1") -(defalias 'helm-c-regexp-persistent-action 'helm-regexp-persistent-action) -(make-obsolete 'helm-c-regexp-persistent-action 'helm-regexp-persistent-action "1.5.1") -(defalias 'helm-c-grep-split-line 'helm-grep-split-line) -(make-obsolete 'helm-c-grep-split-line 'helm-grep-split-line "1.5.1") -(defalias 'helm-c-filtered-candidate-transformer-file-line-1 'helm-filtered-candidate-transformer-file-line-1) -(make-obsolete 'helm-c-filtered-candidate-transformer-file-line-1 'helm-filtered-candidate-transformer-file-line-1 "1.5.1") -(defalias 'helm-c-info-display-to-real 'helm-info-display-to-real) -(make-obsolete 'helm-c-info-display-to-real 'helm-info-display-to-real "1.5.1") -(defalias 'helm-c-symbolify 'helm-symbolify) -(make-obsolete 'helm-c-symbolify 'helm-symbolify "1.5.1") -(defalias 'helm-c-zgrep-buffers 'helm-zgrep-buffers) -(make-obsolete 'helm-c-zgrep-buffers 'helm-zgrep-buffers "1.5.1") -(defalias 'helm-c-apt-persistent-action 'helm-apt-persistent-action) -(make-obsolete 'helm-c-apt-persistent-action 'helm-apt-persistent-action "1.5.1") -(defalias 'helm-c-pdfgrep-init 'helm-pdfgrep-init) -(make-obsolete 'helm-c-pdfgrep-init 'helm-pdfgrep-init "1.5.1") -(defalias 'helm-c-walk-directory 'helm-walk-directory) -(make-obsolete 'helm-c-walk-directory 'helm-walk-directory "1.5.1") -(defalias 'helm-c-grep-init 'helm-grep-init) -(make-obsolete 'helm-c-grep-init 'helm-grep-init "1.5.1") -(defalias 'helm-c-ucs-forward-char 'helm-ucs-forward-char) -(make-obsolete 'helm-c-ucs-forward-char 'helm-ucs-forward-char "1.5.1") -(defalias 'helm-c-complete-file-name-at-point 'helm-complete-file-name-at-point) -(make-obsolete 'helm-c-complete-file-name-at-point 'helm-complete-file-name-at-point "1.5.1") -(defalias 'helm-c-timer-real-to-display 'helm-timer-real-to-display) -(make-obsolete 'helm-c-timer-real-to-display 'helm-timer-real-to-display "1.5.1") -(defalias 'helm-c-ucs-init 'helm-ucs-init) -(make-obsolete 'helm-c-ucs-init 'helm-ucs-init "1.5.1") -(defalias 'helm-c-bookmark-run-delete 'helm-bookmark-run-delete) -(make-obsolete 'helm-c-bookmark-run-delete 'helm-bookmark-run-delete "1.5.1") -(defalias 'helm-c-uniq-list 'helm-uniq-list) -(make-obsolete 'helm-c-uniq-list 'helm-uniq-list "1.5.1") -(defalias 'helm-c-pp-bookmarks 'helm-pp-bookmarks) -(make-obsolete 'helm-c-pp-bookmarks 'helm-pp-bookmarks "1.5.1") -(defalias 'helm-c-gentoo-get-url 'helm-gentoo-get-url) -(make-obsolete 'helm-c-gentoo-get-url 'helm-gentoo-get-url "1.5.1") -(defalias 'helm-c-top-sh-persistent-action 'helm-top-sh-persistent-action) -(make-obsolete 'helm-c-top-sh-persistent-action 'helm-top-sh-persistent-action "1.5.1") -(defalias 'helm-c-gentoo-get-use 'helm-gentoo-get-use) -(make-obsolete 'helm-c-gentoo-get-use 'helm-gentoo-get-use "1.5.1") -(defalias 'helm-c-grep-action 'helm-grep-action) -(make-obsolete 'helm-c-grep-action 'helm-grep-action "1.5.1") -(defalias 'helm-c-file-buffers 'helm-file-buffers) -(make-obsolete 'helm-c-file-buffers 'helm-file-buffers "1.5.1") -(defalias 'helm-c-google-suggest-fetch 'helm-google-suggest-fetch) -(make-obsolete 'helm-c-google-suggest-fetch 'helm-google-suggest-fetch "1.5.1") -(defalias 'helm-c-arrange-type-attribute 'helm-arrange-type-attribute) -(make-obsolete 'helm-c-arrange-type-attribute 'helm-arrange-type-attribute "1.5.1") -(defalias 'helm-c-bookmark-w3m-setup-alist 'helm-bookmark-w3m-setup-alist) -(make-obsolete 'helm-c-bookmark-w3m-setup-alist 'helm-bookmark-w3m-setup-alist "1.5.1") -(defalias 'helm-c-yahoo-suggest-action 'helm-yahoo-suggest-action) -(make-obsolete 'helm-c-yahoo-suggest-action 'helm-yahoo-suggest-action "1.5.1") -(defalias 'helm-c-buffer-query-replace-1 'helm-buffer-query-replace-1) -(make-obsolete 'helm-c-buffer-query-replace-1 'helm-buffer-query-replace-1 "1.5.1") -(defalias 'helm-c-make-info-source 'helm-make-info-source) -(make-obsolete 'helm-c-make-info-source 'helm-make-info-source "1.5.1") -(defalias 'helm-c-open-dired 'helm-open-dired) -(make-obsolete 'helm-c-open-dired 'helm-open-dired "1.5.1") -(defalias 'helm-c-w3m-bookmarks-get-value 'helm-w3m-bookmarks-get-value) -(make-obsolete 'helm-c-w3m-bookmarks-get-value 'helm-w3m-bookmarks-get-value "1.5.1") -(defalias 'helm-c-kill-ring-transformer 'helm-kill-ring-transformer) -(make-obsolete 'helm-c-kill-ring-transformer 'helm-kill-ring-transformer "1.5.1") -(defalias 'helm-c-etags-init 'helm-etags-init) -(make-obsolete 'helm-c-etags-init 'helm-etags-init "1.5.1") -(defalias 'helm-c-w3m-rename-bookmark 'helm-w3m-rename-bookmark) -(make-obsolete 'helm-c-w3m-rename-bookmark 'helm-w3m-rename-bookmark "1.5.1") -(defalias 'helm-c-advice-update-current-display-string 'helm-advice-update-current-display-string) -(make-obsolete 'helm-c-advice-update-current-display-string 'helm-advice-update-current-display-string "1.5.1") -(defalias 'helm-c-regexp-get-line 'helm-regexp-get-line) -(make-obsolete 'helm-c-regexp-get-line 'helm-regexp-get-line "1.5.1") -(defalias 'helm-c-grep-run-other-window-action 'helm-grep-run-other-window-action) -(make-obsolete 'helm-c-grep-run-other-window-action 'helm-grep-run-other-window-action "1.5.1") -(defalias 'helm-c-regexp-kill-new 'helm-regexp-kill-new) -(make-obsolete 'helm-c-regexp-kill-new 'helm-regexp-kill-new "1.5.1") -(defalias 'helm-c-goto-line-with-adjustment 'helm-goto-line-with-adjustment) -(make-obsolete 'helm-c-goto-line-with-adjustment 'helm-goto-line-with-adjustment "1.5.1") -(defalias 'helm-c-grep-run-default-action 'helm-grep-run-default-action) -(make-obsolete 'helm-c-grep-run-default-action 'helm-grep-run-default-action "1.5.1") -(defalias 'helm-c-define-info-index-sources 'helm-define-info-index-sources) -(make-obsolete 'helm-c-define-info-index-sources 'helm-define-info-index-sources "1.5.1") -(defalias 'helm-c-transform-file-browse-url 'helm-transform-file-browse-url) -(make-obsolete 'helm-c-transform-file-browse-url 'helm-transform-file-browse-url "1.5.1") -(defalias 'helm-c-shell-command-if-needed 'helm-shell-command-if-needed) -(make-obsolete 'helm-c-shell-command-if-needed 'helm-shell-command-if-needed "1.5.1") -(defalias 'helm-c-kill-regexp-as-sexp 'helm-kill-regexp-as-sexp) -(make-obsolete 'helm-c-kill-regexp-as-sexp 'helm-kill-regexp-as-sexp "1.5.1") -(defalias 'helm-c-goto-next-or-prec-file 'helm-goto-next-or-prec-file) -(make-obsolete 'helm-c-goto-next-or-prec-file 'helm-goto-next-or-prec-file "1.5.1") -(defalias 'helm-c-insert-file-name-completion-at-point 'helm-insert-file-name-completion-at-point) -(make-obsolete 'helm-c-insert-file-name-completion-at-point 'helm-insert-file-name-completion-at-point "1.5.1") -(defalias 'helm-c-point-file-in-dired 'helm-point-file-in-dired) -(make-obsolete 'helm-c-point-file-in-dired 'helm-point-file-in-dired "1.5.1") -(defalias 'helm-c-action-file-line-goto 'helm-action-file-line-goto) -(make-obsolete 'helm-c-action-file-line-goto 'helm-action-file-line-goto "1.5.1") -(defalias 'helm-c-info-goto 'helm-info-goto) -(make-obsolete 'helm-c-info-goto 'helm-info-goto "1.5.1") -(defalias 'helm-c-apt-install 'helm-apt-install) -(make-obsolete 'helm-c-apt-install 'helm-apt-install "1.5.1") -(defalias 'helm-c-skip-boring-buffers 'helm-skip-boring-buffers) -(make-obsolete 'helm-c-skip-boring-buffers 'helm-skip-boring-buffers "1.5.1") -(defalias 'helm-c-register-candidates 'helm-register-candidates) -(make-obsolete 'helm-c-register-candidates 'helm-register-candidates "1.5.1") -(defalias 'helm-c-find-function 'helm-find-function) -(make-obsolete 'helm-c-find-function 'helm-find-function "1.5.1") -(defalias 'helm-c-apt-display-to-real 'helm-apt-display-to-real) -(make-obsolete 'helm-c-apt-display-to-real 'helm-apt-display-to-real "1.5.1") -(defalias 'helm-c-yaoddmuse-action-transformer 'helm-yaoddmuse-action-transformer) -(make-obsolete 'helm-c-yaoddmuse-action-transformer 'helm-yaoddmuse-action-transformer "1.5.1") -(defalias 'helm-c-org-keywords-init 'helm-org-keywords-init) -(make-obsolete 'helm-c-org-keywords-init 'helm-org-keywords-init "1.5.1") -(defalias 'helm-c-xrandr-screen 'helm-xrandr-screen) -(make-obsolete 'helm-c-xrandr-screen 'helm-xrandr-screen "1.5.1") -(defalias 'helm-c-position 'helm-position) -(make-obsolete 'helm-c-position 'helm-position "1.5.1") -(defalias 'helm-c-imenu-candidates 'helm-imenu-candidates) -(make-obsolete 'helm-c-imenu-candidates 'helm-imenu-candidates "1.5.1") -(defalias 'helm-c-bbdb-candidates 'helm-bbdb-candidates) -(make-obsolete 'helm-c-bbdb-candidates 'helm-bbdb-candidates "1.5.1") -(defalias 'helm-c-ucs-persistent-forward 'helm-ucs-persistent-forward) -(make-obsolete 'helm-c-ucs-persistent-forward 'helm-ucs-persistent-forward "1.5.1") -(defalias 'helm-c-basename 'helm-basename) -(make-obsolete 'helm-c-basename 'helm-basename "1.5.1") -(defalias 'helm-c-files-in-all-dired-candidates 'helm-files-in-all-dired-candidates) -(make-obsolete 'helm-c-files-in-all-dired-candidates 'helm-files-in-all-dired-candidates "1.5.1") -(defalias 'helm-c-action-line-goto 'helm-action-line-goto) -(make-obsolete 'helm-c-action-line-goto 'helm-action-line-goto "1.5.1") -(defalias 'helm-c-grep-other-window 'helm-grep-other-window) -(make-obsolete 'helm-c-grep-other-window 'helm-grep-other-window "1.5.1") -(defalias 'helm-c-yahoo-suggest-fetch 'helm-yahoo-suggest-fetch) -(make-obsolete 'helm-c-yahoo-suggest-fetch 'helm-yahoo-suggest-fetch "1.5.1") -(defalias 'helm-c-external-commands-list-1 'helm-external-commands-list-1) -(make-obsolete 'helm-c-external-commands-list-1 'helm-external-commands-list-1 "1.5.1") -(defalias 'helm-c-buffers-list-persistent-action 'helm-buffers-list-persistent-action) -(make-obsolete 'helm-c-buffers-list-persistent-action 'helm-buffers-list-persistent-action "1.5.1") -(defalias 'helm-c-show-completion-init-overlay 'helm-show-completion-init-overlay) -(make-obsolete 'helm-c-show-completion-init-overlay 'helm-show-completion-init-overlay "1.5.1") -(defalias 'helm-c-shadow-boring-files 'helm-shadow-boring-files) -(make-obsolete 'helm-c-shadow-boring-files 'helm-shadow-boring-files "1.5.1") -(defalias 'helm-c-bookmark-local-files-setup-alist 'helm-bookmark-local-files-setup-alist) -(make-obsolete 'helm-c-bookmark-local-files-setup-alist 'helm-bookmark-local-files-setup-alist "1.5.1") -(defalias 'helm-c-highlight-local-use 'helm-highlight-local-use) -(make-obsolete 'helm-c-highlight-local-use 'helm-highlight-local-use "1.5.1") -(defalias 'helm-c-w3m-delete-bookmark 'helm-w3m-delete-bookmark) -(make-obsolete 'helm-c-w3m-delete-bookmark 'helm-w3m-delete-bookmark "1.5.1") -(defalias 'helm-c-skip-current-file 'helm-skip-current-file) -(make-obsolete 'helm-c-skip-current-file 'helm-skip-current-file "1.5.1") -(defalias 'helm-c-goto-next-file 'helm-goto-next-file) -(make-obsolete 'helm-c-goto-next-file 'helm-goto-next-file "1.5.1") -(defalias 'helm-c-info-init 'helm-info-init) -(make-obsolete 'helm-c-info-init 'helm-info-init "1.5.1") -(defalias 'helm-c-query-replace-args 'helm-query-replace-args) -(make-obsolete 'helm-c-query-replace-args 'helm-query-replace-args "1.5.1") -(defalias 'helm-c-bookmark-info-setup-alist 'helm-bookmark-info-setup-alist) -(make-obsolete 'helm-c-bookmark-info-setup-alist 'helm-bookmark-info-setup-alist "1.5.1") -(defalias 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute) -(make-obsolete 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute "1.5.1") -(defalias 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward) -(make-obsolete 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward "1.5.1") -(defalias 'helm-c-info-pages-init 'helm-info-pages-init) -(make-obsolete 'helm-c-info-pages-init 'helm-info-pages-init "1.5.1") -(defalias 'helm-c-grep-save-results 'helm-grep-save-results) -(make-obsolete 'helm-c-grep-save-results 'helm-grep-save-results "1.5.1") -(defalias 'helm-c-read-file-name 'helm-read-file-name) -(make-obsolete 'helm-c-read-file-name 'helm-read-file-name "1.5.1") -(defalias 'helm-c-org-keywords-insert 'helm-org-keywords-insert) -(make-obsolete 'helm-c-org-keywords-insert 'helm-org-keywords-insert "1.5.1") -(defalias 'helm-c-call-interactively 'helm-call-interactively) -(make-obsolete 'helm-c-call-interactively 'helm-call-interactively "1.5.1") -(defalias 'helm-c-adaptative-compare 'helm-adaptive-compare) -(make-obsolete 'helm-c-adaptative-compare 'helm-adaptive-compare "1.5.1") -(defalias 'helm-c-filtered-candidate-transformer-file-line 'helm-filtered-candidate-transformer-file-line) -(make-obsolete 'helm-c-filtered-candidate-transformer-file-line 'helm-filtered-candidate-transformer-file-line "1.5.1") -(defalias 'helm-c-buffer-list 'helm-buffer-list) -(make-obsolete 'helm-c-buffer-list 'helm-buffer-list "1.5.1") -(defalias 'helm-c-gentoo-get-local-use 'helm-gentoo-get-local-use) -(make-obsolete 'helm-c-gentoo-get-local-use 'helm-gentoo-get-local-use "1.5.1") -(defalias 'helm-c-thing-before-point 'helm-thing-before-point) -(make-obsolete 'helm-c-thing-before-point 'helm-thing-before-point "1.5.1") -(defalias 'helm-c-ratpoison-commands-display-to-real 'helm-ratpoison-commands-display-to-real) -(make-obsolete 'helm-c-ratpoison-commands-display-to-real 'helm-ratpoison-commands-display-to-real "1.5.1") -(defalias 'helm-c-imenu-default-action 'helm-imenu-default-action) -(make-obsolete 'helm-c-imenu-default-action 'helm-imenu-default-action "1.5.1") -(defalias 'helm-c-describe-function 'helm-describe-function) -(make-obsolete 'helm-c-describe-function 'helm-describe-function "1.5.1") -(defalias 'helm-c-colors-get-name 'helm-colors-get-name) -(make-obsolete 'helm-c-colors-get-name 'helm-colors-get-name "1.5.1") -(defalias 'helm-c-bookmark-help 'helm-bookmark-help) -(make-obsolete 'helm-c-bookmark-help 'helm-bookmark-help "1.5.1") -(defalias 'helm-c-ucs-persistent-delete 'helm-ucs-persistent-delete) -(make-obsolete 'helm-c-ucs-persistent-delete 'helm-ucs-persistent-delete "1.5.1") -(defalias 'helm-c-set-variable 'helm-set-variable) -(make-obsolete 'helm-c-set-variable 'helm-set-variable "1.5.1") -(defalias 'helm-c-w3m-browse-bookmark 'helm-w3m-browse-bookmark) -(make-obsolete 'helm-c-w3m-browse-bookmark 'helm-w3m-browse-bookmark "1.5.1") -(defalias 'helm-c-grep-save-results-1 'helm-grep-save-results-1) -(make-obsolete 'helm-c-grep-save-results-1 'helm-grep-save-results-1 "1.5.1") -(defalias 'helm-c-adaptative-maybe-load-history 'helm-adaptive-maybe-load-history) -(make-obsolete 'helm-c-adaptative-maybe-load-history 'helm-adaptive-maybe-load-history "1.5.1") -(defalias 'helm-c-w32-pathname-transformer 'helm-w32-pathname-transformer) -(make-obsolete 'helm-c-w32-pathname-transformer 'helm-w32-pathname-transformer "1.5.1") -(defalias 'helm-c-top-display-to-real 'helm-top-display-to-real) -(make-obsolete 'helm-c-top-display-to-real 'helm-top-display-to-real "1.5.1") -(defalias 'helm-c-open-file-externally 'helm-open-file-externally) -(make-obsolete 'helm-c-open-file-externally 'helm-open-file-externally "1.5.1") -(defalias 'helm-c-colors-get-rgb 'helm-colors-get-rgb) -(make-obsolete 'helm-c-colors-get-rgb 'helm-colors-get-rgb "1.5.1") -(defalias 'helm-c-org-headline-refile 'helm-org-headline-refile) -(make-obsolete 'helm-c-org-headline-refile 'helm-org-headline-refile "1.5.1") -(defalias 'helm-c-stumpwm-commands-init 'helm-stumpwm-commands-init) -(make-obsolete 'helm-c-stumpwm-commands-init 'helm-stumpwm-commands-init "1.5.1") -(defalias 'helm-c-highlight-world 'helm-highlight-world) -(make-obsolete 'helm-c-highlight-world 'helm-highlight-world "1.5.1") -(defalias 'helm-c-top-sh 'helm-top-sh) -(make-obsolete 'helm-c-top-sh 'helm-top-sh "1.5.1") -(defalias 'helm-c-bbdb-get-record 'helm-bbdb-get-record) -(make-obsolete 'helm-c-bbdb-get-record 'helm-bbdb-get-record "1.5.1") -(defalias 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action) -(make-obsolete 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action "1.5.1") -(defalias 'helm-c-latex-math-candidates 'helm-latex-math-candidates) -(make-obsolete 'helm-c-latex-math-candidates 'helm-latex-math-candidates "1.5.1") -(defalias 'helm-c-ucs-backward-char 'helm-ucs-backward-char) -(make-obsolete 'helm-c-ucs-backward-char 'helm-ucs-backward-char "1.5.1") -(defalias 'helm-c-calculate-ucs-max-len 'helm-calculate-ucs-max-len) -(make-obsolete 'helm-c-calculate-ucs-max-len 'helm-calculate-ucs-max-len "1.5.1") -(defalias 'helm-c-etags-mtime 'helm-etags-mtime) -(make-obsolete 'helm-c-etags-mtime 'helm-etags-mtime "1.5.1") -(defalias 'helm-c-google-suggest-action 'helm-google-suggest-action) -(make-obsolete 'helm-c-google-suggest-action 'helm-google-suggest-action "1.5.1") -(defalias 'helm-c-org-headline-insert-link-to-headline 'helm-org-headline-insert-link-to-headline) -(make-obsolete 'helm-c-org-headline-insert-link-to-headline 'helm-org-headline-insert-link-to-headline "1.5.1") -(defalias 'helm-c-bbdb-create-contact 'helm-bbdb-create-contact) -(make-obsolete 'helm-c-bbdb-create-contact 'helm-bbdb-create-contact "1.5.1") -(defalias 'helm-c-elisp-library-scan-init 'helm-elisp-library-scan-init) -(make-obsolete 'helm-c-elisp-library-scan-init 'helm-elisp-library-scan-init "1.5.1") -(defalias 'helm-c-apt-refresh 'helm-apt-refresh) -(make-obsolete 'helm-c-apt-refresh 'helm-apt-refresh "1.5.1") -(defalias 'helm-c-kill-regexp 'helm-kill-regexp) -(make-obsolete 'helm-c-kill-regexp 'helm-kill-regexp "1.5.1") -(defalias 'helm-c-gentoo-default-action 'helm-gentoo-default-action) -(make-obsolete 'helm-c-gentoo-default-action 'helm-gentoo-default-action "1.5.1") -(defalias 'helm-c-grep-buffers-1 'helm-grep-buffers-1) -(make-obsolete 'helm-c-grep-buffers-1 'helm-grep-buffers-1 "1.5.1") -(defalias 'helm-c-adaptative-store-selection 'helm-adaptive-store-selection) -(make-obsolete 'helm-c-adaptative-store-selection 'helm-adaptive-store-selection "1.5.1") -(defalias 'helm-c-browse-url 'helm-browse-url) -(make-obsolete 'helm-c-browse-url 'helm-browse-url "1.5.1") -(defalias 'helm-c-google-suggest-emacs-lisp 'helm-google-suggest-emacs-lisp) -(make-obsolete 'helm-c-google-suggest-emacs-lisp 'helm-google-suggest-emacs-lisp "1.5.1") -(defalias 'helm-c-ucs-persistent-insert 'helm-ucs-persistent-insert) -(make-obsolete 'helm-c-ucs-persistent-insert 'helm-ucs-persistent-insert "1.5.1") -(defalias 'helm-c-xrandr-output 'helm-xrandr-output) -(make-obsolete 'helm-c-xrandr-output 'helm-xrandr-output "1.5.1") -(defalias 'helm-c-kill-ring-action 'helm-kill-ring-action) -(make-obsolete 'helm-c-kill-ring-action 'helm-kill-ring-action "1.5.1") -(defalias 'helm-c-org-keywords-candidates 'helm-org-keywords-candidates) -(make-obsolete 'helm-c-org-keywords-candidates 'helm-org-keywords-candidates "1.5.1") -(defalias 'helm-c-bookmark-jump 'helm-bookmark-jump) -(make-obsolete 'helm-c-bookmark-jump 'helm-bookmark-jump "1.5.1") -(defalias 'helm-c-shadow-boring-buffers 'helm-shadow-boring-buffers) -(make-obsolete 'helm-c-shadow-boring-buffers 'helm-shadow-boring-buffers "1.5.1") -(defalias 'helm-c-buffer-match-major-mode 'helm-buffer-match-major-mode) -(make-obsolete 'helm-c-buffer-match-major-mode 'helm-buffer-match-major-mode "1.5.1") -(defalias 'helm-c-highlight-bookmark-su 'helm-highlight-bookmark-su) -(make-obsolete 'helm-c-highlight-bookmark-su 'helm-highlight-bookmark-su "1.5.1") -(defalias 'helm-c-grep-other-frame 'helm-grep-other-frame) -(make-obsolete 'helm-c-grep-other-frame 'helm-grep-other-frame "1.5.1") -(defalias 'helm-c-jabber-online-contacts 'helm-jabber-online-contacts) -(make-obsolete 'helm-c-jabber-online-contacts 'helm-jabber-online-contacts "1.5.1") -(defalias 'helm-c-apt-purge 'helm-apt-purge) -(make-obsolete 'helm-c-apt-purge 'helm-apt-purge "1.5.1") -(defalias 'helm-c-adaptative-sort 'helm-adaptive-sort) -(make-obsolete 'helm-c-adaptative-sort 'helm-adaptive-sort "1.5.1") -(defalias 'helm-c-bmkext-addressbook-setup-alist 'helm-bmkext-addressbook-setup-alist) -(make-obsolete 'helm-c-bmkext-addressbook-setup-alist 'helm-bmkext-addressbook-setup-alist "1.5.1") -(defalias 'helm-c-bbdb-collect-mail-addresses 'helm-bbdb-collect-mail-addresses) -(make-obsolete 'helm-c-bbdb-collect-mail-addresses 'helm-bbdb-collect-mail-addresses "1.5.1") -(defalias 'helm-c-bmkext-filter-setup-alist 'helm-bmkext-filter-setup-alist) -(make-obsolete 'helm-c-bmkext-filter-setup-alist 'helm-bmkext-filter-setup-alist "1.5.1") -(defalias 'helm-c-grep-buffers 'helm-grep-buffers) -(make-obsolete 'helm-c-grep-buffers 'helm-grep-buffers "1.5.1") -(defalias 'helm-c-apt-init 'helm-apt-init) -(make-obsolete 'helm-c-apt-init 'helm-apt-init "1.5.1") -(defalias 'helm-c-grep-run-save-buffer 'helm-grep-run-save-buffer) -(make-obsolete 'helm-c-grep-run-save-buffer 'helm-grep-run-save-buffer "1.5.1") -(defalias 'helm-c-ggs-set-number-result 'helm-ggs-set-number-result) -(make-obsolete 'helm-c-ggs-set-number-result 'helm-ggs-set-number-result "1.5.1") -(defalias 'helm-c-grep-prepare-candidates 'helm-grep-prepare-candidates) -(make-obsolete 'helm-c-grep-prepare-candidates 'helm-grep-prepare-candidates "1.5.1") -(defalias 'helm-c-grep-jump-elscreen 'helm-grep-jump-elscreen) -(make-obsolete 'helm-c-grep-jump-elscreen 'helm-grep-jump-elscreen "1.5.1") -(defalias 'helm-c-show-completion-display-function 'helm-show-completion-display-function) -(make-obsolete 'helm-c-show-completion-display-function 'helm-show-completion-display-function "1.5.1") -(defalias 'helm-c-find-variable 'helm-find-variable) -(make-obsolete 'helm-c-find-variable 'helm-find-variable "1.5.1") -(defalias 'helm-c-build-elvi-list 'helm-build-elvi-list) -(make-obsolete 'helm-c-build-elvi-list 'helm-build-elvi-list "1.5.1") -(defalias 'helm-c-advice-toggle 'helm-advice-toggle) -(make-obsolete 'helm-c-advice-toggle 'helm-advice-toggle "1.5.1") -(defalias 'helm-c-buffers-persistent-kill 'helm-buffers-persistent-kill) -(make-obsolete 'helm-c-buffers-persistent-kill 'helm-buffers-persistent-kill "1.5.1") -(defalias 'helm-c-register-action-transformer 'helm-register-action-transformer) -(make-obsolete 'helm-c-register-action-transformer 'helm-register-action-transformer "1.5.1") -(defalias 'helm-c-kill-ring-candidates 'helm-kill-ring-candidates) -(make-obsolete 'helm-c-kill-ring-candidates 'helm-kill-ring-candidates "1.5.1") -(defalias 'helm-c-bbdb-view-person-action 'helm-bbdb-view-person-action) -(make-obsolete 'helm-c-bbdb-view-person-action 'helm-bbdb-view-person-action "1.5.1") -(defalias 'helm-c-generic-browser 'helm-generic-browser) -(make-obsolete 'helm-c-generic-browser 'helm-generic-browser "1.5.1") -(defalias 'helm-c-top-init 'helm-top-init) -(make-obsolete 'helm-c-top-init 'helm-top-init "1.5.1") -(defalias 'helm-c-ucs-delete-backward 'helm-ucs-delete-backward) -(make-obsolete 'helm-c-ucs-delete-backward 'helm-ucs-delete-backward "1.5.1") -(defalias 'helm-c-firefox-bookmarks-get-value 'helm-firefox-bookmarks-get-value) -(make-obsolete 'helm-c-firefox-bookmarks-get-value 'helm-firefox-bookmarks-get-value "1.5.1") -(defalias 'helm-c-apt-generic-action 'helm-apt-generic-action) -(make-obsolete 'helm-c-apt-generic-action 'helm-apt-generic-action "1.5.1") -(defalias 'helm-c-pdfgrep-action-1 'helm-pdfgrep-action-1) -(make-obsolete 'helm-c-pdfgrep-action-1 'helm-pdfgrep-action-1 "1.5.1") -(defalias 'helm-c-buffer-query-replace-regexp 'helm-buffer-query-replace-regexp) -(make-obsolete 'helm-c-buffer-query-replace-regexp 'helm-buffer-query-replace-regexp "1.5.1") -(defalias 'helm-c-apropos-init 'helm-apropos-init) -(make-obsolete 'helm-c-apropos-init 'helm-apropos-init "1.5.1") -(defalias 'helm-c-emms-play-current-playlist 'helm-emms-play-current-playlist) -(make-obsolete 'helm-c-emms-play-current-playlist 'helm-emms-play-current-playlist "1.5.1") -(defalias 'helm-c-kill-new 'helm-kill-new) -(make-obsolete 'helm-c-kill-new 'helm-kill-new "1.5.1") -(defalias 'helm-c-bookmark-gnus-setup-alist 'helm-bookmark-gnus-setup-alist) -(make-obsolete 'helm-c-bookmark-gnus-setup-alist 'helm-bookmark-gnus-setup-alist "1.5.1") -(defalias 'helm-c-quit-and-execute-action 'helm-quit-and-execute-action) -(make-obsolete 'helm-c-quit-and-execute-action 'helm-quit-and-execute-action "1.5.1") -(defalias 'helm-c-build-info-index-command 'helm-build-info-index-command) -(make-obsolete 'helm-c-build-info-index-command 'helm-build-info-index-command "1.5.1") -(defalias 'helm-c-gentoo-setup-cache 'helm-gentoo-setup-cache) -(make-obsolete 'helm-c-gentoo-setup-cache 'helm-gentoo-setup-cache "1.5.1") -(defalias 'helm-c-ratpoison-commands-init 'helm-ratpoison-commands-init) -(make-obsolete 'helm-c-ratpoison-commands-init 'helm-ratpoison-commands-init "1.5.1") -(defalias 'helm-c-etags-select 'helm-etags-select) -(make-obsolete 'helm-c-etags-select 'helm-etags-select "1.5.1") -(defalias 'helm-c-etags-create-buffer 'helm-etags-create-buffer) -(make-obsolete 'helm-c-etags-create-buffer 'helm-etags-create-buffer "1.5.1") -(defalias 'helm-c-yahoo-suggest-set-candidates 'helm-yahoo-suggest-set-candidates) -(make-obsolete 'helm-c-yahoo-suggest-set-candidates 'helm-yahoo-suggest-set-candidates "1.5.1") -(defalias 'helm-c-org-keywords-show-help 'helm-org-keywords-show-help) -(make-obsolete 'helm-c-org-keywords-show-help 'helm-org-keywords-show-help "1.5.1") -(defalias 'helm-c-highlight-files 'helm-highlight-files) -(make-obsolete 'helm-c-highlight-files 'helm-highlight-files "1.5.1") -(defalias 'helm-c-get-pid-from-process-name 'helm-get-pid-from-process-name) -(make-obsolete 'helm-c-get-pid-from-process-name 'helm-get-pid-from-process-name "1.5.1") -(defalias 'helm-c-insert-latex-math 'helm-insert-latex-math) -(make-obsolete 'helm-c-insert-latex-math 'helm-insert-latex-math "1.5.1") -(defalias 'helm-c-buffer-query-replace 'helm-buffer-query-replace) -(make-obsolete 'helm-c-buffer-query-replace 'helm-buffer-query-replace "1.5.1") -(defalias 'helm-c-bmkext-run-edit 'helm-bmkext-run-edit) -(make-obsolete 'helm-c-bmkext-run-edit 'helm-bmkext-run-edit "1.5.1") -(defalias 'helm-c-skip-boring-files 'helm-skip-boring-files) -(make-obsolete 'helm-c-skip-boring-files 'helm-skip-boring-files "1.5.1") -(defalias 'helm-c-transform-file-load-el 'helm-transform-file-load-el) -(make-obsolete 'helm-c-transform-file-load-el 'helm-transform-file-load-el "1.5.1") -(defalias 'helm-c-ucs-insert-char 'helm-ucs-insert-char) -(make-obsolete 'helm-c-ucs-insert-char 'helm-ucs-insert-char "1.5.1") -(defalias 'helm-c-gentoo-setup-use-flags-cache 'helm-gentoo-setup-use-flags-cache) -(make-obsolete 'helm-c-gentoo-setup-use-flags-cache 'helm-gentoo-setup-use-flags-cache "1.5.1") -(defalias 'helm-c-buffer-help 'helm-buffer-help) -(make-obsolete 'helm-c-buffer-help 'helm-buffer-help "1.5.1") -(defalias 'helm-c-current-directory 'helm-current-directory) -(make-obsolete 'helm-c-current-directory 'helm-current-directory "1.5.1") -(defalias 'helm-c-highlight-firefox-bookmarks 'helm-highlight-firefox-bookmarks) -(make-obsolete 'helm-c-highlight-firefox-bookmarks 'helm-highlight-firefox-bookmarks "1.5.1") -(defalias 'helm-c-find-file-or-marked 'helm-find-file-or-marked) -(make-obsolete 'helm-c-find-file-or-marked 'helm-find-file-or-marked "1.5.1") -(defalias 'helm-c-query-replace-regexp 'helm-query-replace-regexp) -(make-obsolete 'helm-c-query-replace-regexp 'helm-query-replace-regexp "1.5.1") -(defalias 'helm-c-describe-variable 'helm-describe-variable) -(make-obsolete 'helm-c-describe-variable 'helm-describe-variable "1.5.1") -(defalias 'helm-c-advice-persistent-action 'helm-advice-persistent-action) -(make-obsolete 'helm-c-advice-persistent-action 'helm-advice-persistent-action "1.5.1") -(defalias 'helm-c-show-completion 'helm-show-completion) -(make-obsolete 'helm-c-show-completion 'helm-show-completion "1.5.1") -(defalias 'helm-c-google-suggest-set-candidates 'helm-google-suggest-set-candidates) -(make-obsolete 'helm-c-google-suggest-set-candidates 'helm-google-suggest-set-candidates "1.5.1") -(defalias 'helm-c-grep-persistent-action 'helm-grep-persistent-action) -(make-obsolete 'helm-c-grep-persistent-action 'helm-grep-persistent-action "1.5.1") -(defalias 'helm-c-open-file-with-default-tool 'helm-open-file-with-default-tool) -(make-obsolete 'helm-c-open-file-with-default-tool 'helm-open-file-with-default-tool "1.5.1") -(defalias 'helm-c-run-external-command 'helm-run-external-command) -(make-obsolete 'helm-c-run-external-command 'helm-run-external-command "1.5.1") -(defalias 'helm-c-bookmark-images-setup-alist 'helm-bookmark-images-setup-alist) -(make-obsolete 'helm-c-bookmark-images-setup-alist 'helm-bookmark-images-setup-alist "1.5.1") -(defalias 'helm-c-apt-candidate-transformer 'helm-apt-candidate-transformer) -(make-obsolete 'helm-c-apt-candidate-transformer 'helm-apt-candidate-transformer "1.5.1") -(defalias 'helm-c-grep-run-persistent-action 'helm-grep-run-persistent-action) -(make-obsolete 'helm-c-grep-run-persistent-action 'helm-grep-run-persistent-action "1.5.1") -(defalias 'helm-c-highlight-buffers 'helm-highlight-buffers) -(make-obsolete 'helm-c-highlight-buffers 'helm-highlight-buffers "1.5.1") -(defalias 'helm-c-man-default-action 'helm-man-default-action) -(make-obsolete 'helm-c-man-default-action 'helm-man-default-action "1.5.1") -(defalias 'helm-c-advice-candidates 'helm-advice-candidates) -(make-obsolete 'helm-c-advice-candidates 'helm-advice-candidates "1.5.1") -(defalias 'helm-c-stumpwm-commands-execute 'helm-stumpwm-commands-execute) -(make-obsolete 'helm-c-stumpwm-commands-execute 'helm-stumpwm-commands-execute "1.5.1") -(defalias 'helm-c-ucs-help 'helm-ucs-help) -(make-obsolete 'helm-c-ucs-help 'helm-ucs-help "1.5.1") -(defalias 'helm-c-apt-uninstall 'helm-apt-uninstall) -(make-obsolete 'helm-c-apt-uninstall 'helm-apt-uninstall "1.5.1") -(defalias 'helm-c-bookmark-run-jump-other-window 'helm-bookmark-run-jump-other-window) -(make-obsolete 'helm-c-bookmark-run-jump-other-window 'helm-bookmark-run-jump-other-window "1.5.1") -(defalias 'helm-c-elisp-library-scan-list 'helm-elisp-library-scan-list) -(make-obsolete 'helm-c-elisp-library-scan-list 'helm-elisp-library-scan-list "1.5.1") -(defalias 'helm-c-switch-to-buffer 'helm-switch-to-buffer) -(make-obsolete 'helm-c-switch-to-buffer 'helm-switch-to-buffer "1.5.1") -(defalias 'helm-c-bookmark-man-setup-alist 'helm-bookmark-man-setup-alist) -(make-obsolete 'helm-c-bookmark-man-setup-alist 'helm-bookmark-man-setup-alist "1.5.1") -(defalias 'helm-c-etags-find-tag-file-directory 'helm-etags-find-tag-file-directory) -(make-obsolete 'helm-c-etags-find-tag-file-directory 'helm-etags-find-tag-file-directory "1.5.1") -(defalias 'helm-c-xrandr-info 'helm-xrandr-info) -(make-obsolete 'helm-c-xrandr-info 'helm-xrandr-info "1.5.1") -(defalias 'helm-c-stringify 'helm-stringify) -(make-obsolete 'helm-c-stringify 'helm-stringify "1.5.1") -(defalias 'helm-c-goto-precedent-file 'helm-goto-precedent-file) -(make-obsolete 'helm-c-goto-precedent-file 'helm-goto-precedent-file "1.5.1") -(defalias 'helm-c-apt-cache-show 'helm-apt-cache-show) -(make-obsolete 'helm-c-apt-cache-show 'helm-apt-cache-show "1.5.1") -(defalias 'helm-c-etags-file-modified-p 'helm-etags-file-modified-p) -(make-obsolete 'helm-c-etags-file-modified-p 'helm-etags-file-modified-p "1.5.1") -(defalias 'helm-c-display-to-real-numbered-line 'helm-display-to-real-numbered-line) -(make-obsolete 'helm-c-display-to-real-numbered-line 'helm-display-to-real-numbered-line "1.5.1") -(defalias 'helm-c-etags-get-tag-file 'helm-etags-get-tag-file) -(make-obsolete 'helm-c-etags-get-tag-file 'helm-etags-get-tag-file "1.5.1") -(defalias 'helm-c-highlight-not-logged 'helm-highlight-not-logged) -(make-obsolete 'helm-c-highlight-not-logged 'helm-highlight-not-logged "1.5.1") -(defalias 'helm-c-pdfgrep-action 'helm-pdfgrep-action) -(make-obsolete 'helm-c-pdfgrep-action 'helm-pdfgrep-action "1.5.1") -(defalias 'helm-c-adaptative-save-history 'helm-adaptive-save-history) -(make-obsolete 'helm-c-adaptative-save-history 'helm-adaptive-save-history "1.5.1") -(defalias 'helm-c-get-first-line-documentation 'helm-get-first-line-documentation) -(make-obsolete 'helm-c-get-first-line-documentation 'helm-get-first-line-documentation "1.5.1") -(defalias 'helm-approximate-candidate-number 'helm-get-candidate-number) -(make-obsolete 'helm-approximate-candidate-number 'helm-get-candidate-number "1.5.5") - - -;;; variables -;; -;; -(defvaralias 'helm-c-bbdb-name 'helm-bbdb-name) -(make-obsolete-variable 'helm-c-bbdb-name 'helm-bbdb-name "1.5.1") -(defvaralias 'helm-c-pdfgrep-default-command 'helm-pdfgrep-default-command) -(make-obsolete-variable 'helm-c-pdfgrep-default-command 'helm-pdfgrep-default-command "1.5.1") -(defvaralias 'helm-c-source-time-world 'helm-source-time-world) -(make-obsolete-variable 'helm-c-source-time-world 'helm-source-time-world "1.5.1") -(defvaralias 'helm-c-grep-default-command 'helm-grep-default-command) -(make-obsolete-variable 'helm-c-grep-default-command 'helm-grep-default-command "1.5.1") -(defvaralias 'helm-c-default-info-index-list 'helm-default-info-index-list) -(make-obsolete-variable 'helm-c-default-info-index-list 'helm-default-info-index-list "1.5.1") -(defvaralias 'helm-c-etags-tag-file-dir 'helm-etags-tag-file-dir) -(make-obsolete-variable 'helm-c-etags-tag-file-dir 'helm-etags-tag-file-dir "1.5.1") -(defvaralias 'helm-c-source-man-pages 'helm-source-man-pages) -(make-obsolete-variable 'helm-c-source-man-pages 'helm-source-man-pages "1.5.1") -(defvaralias 'helm-c-source-bookmark-info 'helm-source-bookmark-info) -(make-obsolete-variable 'helm-c-source-bookmark-info 'helm-source-bookmark-info "1.5.1") -(defvaralias 'helm-c-file-cache-files 'helm-file-cache-files) -(make-obsolete-variable 'helm-c-file-cache-files 'helm-file-cache-files "1.5.1") -(defvaralias 'helm-c-ucs-map 'helm-ucs-map) -(make-obsolete-variable 'helm-c-ucs-map 'helm-ucs-map "1.5.1") -(defvaralias 'helm-c-show-completion-min-window-height 'helm-show-completion-min-window-height) -(make-obsolete-variable 'helm-c-show-completion-min-window-height 'helm-show-completion-min-window-height "1.5.1") -(defvaralias 'helm-c-adaptative-history 'helm-adaptive-history) -(make-obsolete-variable 'helm-c-adaptative-history 'helm-adaptive-history "1.5.1") -(defvaralias 'helm-c-source-bookmarks-local 'helm-source-bookmarks-local) -(make-obsolete-variable 'helm-c-source-bookmarks-local 'helm-source-bookmarks-local "1.5.1") -(defvaralias 'helm-c-grep-map 'helm-grep-map) -(make-obsolete-variable 'helm-c-grep-map 'helm-grep-map "1.5.1") -(defvaralias 'helm-c-source-session 'helm-source-session) -(make-obsolete-variable 'helm-c-source-session 'helm-source-session "1.5.1") -(defvaralias 'helm-c-source-org-headline 'helm-source-org-headline) -(make-obsolete-variable 'helm-c-source-org-headline 'helm-source-org-headline "1.5.1") -(defvaralias 'helm-c-source-minibuffer-history 'helm-source-minibuffer-history) -(make-obsolete-variable 'helm-c-source-minibuffer-history 'helm-source-minibuffer-history "1.5.1") -(defvaralias 'helm-c-source-files-in-current-dir 'helm-source-files-in-current-dir) -(make-obsolete-variable 'helm-c-source-files-in-current-dir 'helm-source-files-in-current-dir "1.5.1") -(defvaralias 'helm-c-source-etags-select 'helm-source-etags-select) -(make-obsolete-variable 'helm-c-source-etags-select 'helm-source-etags-select "1.5.1") -(defvaralias 'helm-c-gentoo-use-flags 'helm-gentoo-use-flags) -(make-obsolete-variable 'helm-c-gentoo-use-flags 'helm-gentoo-use-flags "1.5.1") -(defvaralias 'helm-c-show-completion-overlay 'helm-show-completion-overlay) -(make-obsolete-variable 'helm-c-show-completion-overlay 'helm-show-completion-overlay "1.5.1") -(defvaralias 'helm-c-buffer-help-message 'helm-buffer-help-message) -(make-obsolete-variable 'helm-c-buffer-help-message 'helm-buffer-help-message "1.5.1") -(defvaralias 'helm-c-ucs-max-len 'helm-ucs-max-len) -(make-obsolete-variable 'helm-c-ucs-max-len 'helm-ucs-max-len "1.5.1") -(defvaralias 'helm-c-imenu-index-filter 'helm-imenu-index-filter) -(make-obsolete-variable 'helm-c-imenu-index-filter 'helm-imenu-index-filter "1.5.1") -(defvaralias 'helm-c-org-keywords-info-location 'helm-org-keywords-info-location) -(make-obsolete-variable 'helm-c-org-keywords-info-location 'helm-org-keywords-info-location "1.5.1") -(defvaralias 'helm-c-kill-ring-max-lines-number 'helm-kill-ring-max-lines-number) -(make-obsolete-variable 'helm-c-kill-ring-max-lines-number 'helm-kill-ring-max-lines-number "1.5.1") -(defvaralias 'helm-c-source-apt 'helm-source-apt) -(make-obsolete-variable 'helm-c-source-apt 'helm-source-apt "1.5.1") -(defvaralias 'helm-c-bookmark-map 'helm-bookmark-map) -(make-obsolete-variable 'helm-c-bookmark-map 'helm-bookmark-map "1.5.1") -(defvaralias 'helm-c-source-xfonts 'helm-source-xfonts) -(make-obsolete-variable 'helm-c-source-xfonts 'helm-source-xfonts "1.5.1") -(defvaralias 'helm-c-source-kill-ring 'helm-source-kill-ring) -(make-obsolete-variable 'helm-c-source-kill-ring 'helm-source-kill-ring "1.5.1") -(defvaralias 'helm-c-home-url 'helm-home-url) -(make-obsolete-variable 'helm-c-home-url 'helm-home-url "1.5.1") -(defvaralias 'helm-c-etags-cache 'helm-etags-cache) -(make-obsolete-variable 'helm-c-etags-cache 'helm-etags-cache "1.5.1") -(defvaralias 'helm-c-source-latex-math 'helm-source-latex-math) -(make-obsolete-variable 'helm-c-source-latex-math 'helm-source-latex-math "1.5.1") -(defvaralias 'helm-c-source-bookmark-files&dirs 'helm-source-bookmark-files&dirs) -(make-obsolete-variable 'helm-c-source-bookmark-files&dirs 'helm-source-bookmark-files&dirs "1.5.1") -(defvaralias 'helm-c-source-emms-dired 'helm-source-emms-dired) -(make-obsolete-variable 'helm-c-source-emms-dired 'helm-source-emms-dired "1.5.1") -(defvaralias 'helm-c-source-firefox-bookmarks 'helm-source-firefox-bookmarks) -(make-obsolete-variable 'helm-c-source-firefox-bookmarks 'helm-source-firefox-bookmarks "1.5.1") -(defvaralias 'helm-c-source-ratpoison-commands 'helm-source-ratpoison-commands) -(make-obsolete-variable 'helm-c-source-ratpoison-commands 'helm-source-ratpoison-commands "1.5.1") -(defvaralias 'helm-c-apt-show-command 'helm-apt-show-command) -(make-obsolete-variable 'helm-c-apt-show-command 'helm-apt-show-command "1.5.1") -(defvaralias 'helm-c-pdfgrep-default-function 'helm-pdfgrep-default-function) -(make-obsolete-variable 'helm-c-pdfgrep-default-function 'helm-pdfgrep-default-function "1.5.1") -(defvaralias 'helm-c-source-register 'helm-source-register) -(make-obsolete-variable 'helm-c-source-register 'helm-source-register "1.5.1") -(defvaralias 'helm-c-boring-buffer-regexp-list 'helm-boring-buffer-regexp-list) -(make-obsolete-variable 'helm-c-boring-buffer-regexp-list 'helm-boring-buffer-regexp-list "1.5.1") -(defvaralias 'helm-c-source-locate 'helm-source-locate) -(make-obsolete-variable 'helm-c-source-locate 'helm-source-locate "1.5.1") -(defvaralias 'helm-c-source-advice 'helm-source-advice) -(make-obsolete-variable 'helm-c-source-advice 'helm-source-advice "1.5.1") -(defvaralias 'helm-c-source-yaoddmuse-emacswiki-edit-or-view 'helm-source-yaoddmuse-emacswiki-edit-or-view) -(make-obsolete-variable 'helm-c-source-yaoddmuse-emacswiki-edit-or-view 'helm-source-yaoddmuse-emacswiki-edit-or-view "1.5.1") -(defvaralias 'helm-c-ucs-mode-line-string 'helm-ucs-mode-line-string) -(make-obsolete-variable 'helm-c-ucs-mode-line-string 'helm-ucs-mode-line-string "1.5.1") -(defvaralias 'helm-c-xfonts-cache 'helm-xfonts-cache) -(make-obsolete-variable 'helm-c-xfonts-cache 'helm-xfonts-cache "1.5.1") -(defvaralias 'helm-c-source-yahoo-suggest 'helm-source-yahoo-suggest) -(make-obsolete-variable 'helm-c-source-yahoo-suggest 'helm-source-yahoo-suggest "1.5.1") -(defvaralias 'helm-c-rzgrep-cache 'helm-rzgrep-cache) -(make-obsolete-variable 'helm-c-rzgrep-cache 'helm-rzgrep-cache "1.5.1") -(defvaralias 'helm-c-source-org-keywords 'helm-source-org-keywords) -(make-obsolete-variable 'helm-c-source-org-keywords 'helm-source-org-keywords "1.5.1") -(defvaralias 'helm-c-pdfgrep-map 'helm-pdfgrep-map) -(make-obsolete-variable 'helm-c-pdfgrep-map 'helm-pdfgrep-map "1.5.1") -(defvaralias 'helm-c-source-lacarte 'helm-source-lacarte) -(make-obsolete-variable 'helm-c-source-lacarte 'helm-source-lacarte "1.5.1") -(defvaralias 'helm-c-apt-search-command 'helm-apt-search-command) -(make-obsolete-variable 'helm-c-apt-search-command 'helm-apt-search-command "1.5.1") -(defvaralias 'helm-c-default-external-file-browser 'helm-default-external-file-browser) -(make-obsolete-variable 'helm-c-default-external-file-browser 'helm-default-external-file-browser "1.5.1") -(defvaralias 'helm-c-source-evaluation-result 'helm-source-evaluation-result) -(make-obsolete-variable 'helm-c-source-evaluation-result 'helm-source-evaluation-result "1.5.1") -(defvaralias 'helm-c-yahoo-suggest-search-url 'helm-yahoo-suggest-search-url) -(make-obsolete-variable 'helm-c-yahoo-suggest-search-url 'helm-yahoo-suggest-search-url "1.5.1") -(defvaralias 'helm-c-source-occur 'helm-source-occur) -(make-obsolete-variable 'helm-c-source-occur 'helm-source-occur "1.5.1") -(defvaralias 'helm-c-source-calculation-result 'helm-source-calculation-result) -(make-obsolete-variable 'helm-c-source-calculation-result 'helm-source-calculation-result "1.5.1") -(defvaralias 'helm-c-default-zgrep-command 'helm-default-zgrep-command) -(make-obsolete-variable 'helm-c-default-zgrep-command 'helm-default-zgrep-command "1.5.1") -(defvaralias 'helm-c-show-info-in-mode-line-delay 'helm-show-info-in-mode-line-delay) -(make-obsolete-variable 'helm-c-show-info-in-mode-line-delay 'helm-show-info-in-mode-line-delay "1.5.1") -(defvaralias 'helm-c-source-ido-virtual-buffers 'helm-source-ido-virtual-buffers) -(make-obsolete-variable 'helm-c-source-ido-virtual-buffers 'helm-source-ido-virtual-buffers "1.5.1") -(defvaralias 'helm-c-source-yaoddmuse-emacswiki-post-library 'helm-source-yaoddmuse-emacswiki-post-library) -(make-obsolete-variable 'helm-c-source-yaoddmuse-emacswiki-post-library 'helm-source-yaoddmuse-emacswiki-post-library "1.5.1") -(defvaralias 'helm-c-source-top 'helm-source-top) -(make-obsolete-variable 'helm-c-source-top 'helm-source-top "1.5.1") -(defvaralias 'helm-c-source-colors 'helm-source-colors) -(make-obsolete-variable 'helm-c-source-colors 'helm-source-colors "1.5.1") -(defvaralias 'helm-c-read-file-map 'helm-read-file-map) -(make-obsolete-variable 'helm-c-read-file-map 'helm-read-file-map "1.5.1") -(defvaralias 'helm-c-source-file-cache 'helm-source-file-cache) -(make-obsolete-variable 'helm-c-source-file-cache 'helm-source-file-cache "1.5.1") -(defvaralias 'helm-c-google-suggest-default-browser-function 'helm-google-suggest-default-browser-function) -(make-obsolete-variable 'helm-c-google-suggest-default-browser-function 'helm-google-suggest-default-browser-function "1.5.1") -(defvaralias 'helm-c-external-programs-associations 'helm-external-programs-associations) -(make-obsolete-variable 'helm-c-external-programs-associations 'helm-external-programs-associations "1.5.1") -(defvaralias 'helm-c-source-complex-command-history 'helm-source-complex-command-history) -(make-obsolete-variable 'helm-c-source-complex-command-history 'helm-source-complex-command-history "1.5.1") -(defvaralias 'helm-c-cached-imenu-candidates 'helm-cached-imenu-candidates) -(make-obsolete-variable 'helm-c-cached-imenu-candidates 'helm-cached-imenu-candidates "1.5.1") -(defvaralias 'helm-c-gentoo-buffer 'helm-gentoo-buffer) -(make-obsolete-variable 'helm-c-gentoo-buffer 'helm-gentoo-buffer "1.5.1") -(defvaralias 'helm-c-external-commands-list 'helm-external-commands-list) -(make-obsolete-variable 'helm-c-external-commands-list 'helm-external-commands-list "1.5.1") -(defvaralias 'helm-c-source-ucs 'helm-source-ucs) -(make-obsolete-variable 'helm-c-source-ucs 'helm-source-ucs "1.5.1") -(defvaralias 'helm-c-adaptative-history-length 'helm-adaptive-history-length) -(make-obsolete-variable 'helm-c-adaptative-history-length 'helm-adaptive-history-length "1.5.1") -(defvaralias 'helm-c-source-customize-face 'helm-source-customize-face) -(make-obsolete-variable 'helm-c-source-customize-face 'helm-source-customize-face "1.5.1") -(defvaralias 'helm-c-source-bookmarks-ssh 'helm-source-bookmarks-ssh) -(make-obsolete-variable 'helm-c-source-bookmarks-ssh 'helm-source-bookmarks-ssh "1.5.1") -(defvaralias 'helm-c-eldoc-in-minibuffer-show-fn 'helm-eldoc-in-minibuffer-show-fn) -(make-obsolete-variable 'helm-c-eldoc-in-minibuffer-show-fn 'helm-eldoc-in-minibuffer-show-fn "1.5.1") -(defvaralias 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url) -(make-obsolete-variable 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url "1.5.1") -(defvaralias 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook) -(make-obsolete-variable 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook "1.5.1") -(defvaralias 'helm-c-source-ctags 'helm-source-ctags) -(make-obsolete-variable 'helm-c-source-ctags 'helm-source-ctags "1.5.1") -(defvaralias 'helm-c-source-eev-anchor 'helm-source-eev-anchor) -(make-obsolete-variable 'helm-c-source-eev-anchor 'helm-source-eev-anchor "1.5.1") -(defvaralias 'helm-c-apt-installed-packages 'helm-apt-installed-packages) -(make-obsolete-variable 'helm-c-apt-installed-packages 'helm-apt-installed-packages "1.5.1") -(defvaralias 'helm-c-apt-all-packages 'helm-apt-all-packages) -(make-obsolete-variable 'helm-c-apt-all-packages 'helm-apt-all-packages "1.5.1") -(defvaralias 'helm-c-find-files-doc-header 'helm-find-files-doc-header) -(make-obsolete-variable 'helm-c-find-files-doc-header 'helm-find-files-doc-header "1.5.1") -(defvaralias 'helm-c-source-imenu 'helm-source-imenu) -(make-obsolete-variable 'helm-c-source-imenu 'helm-source-imenu "1.5.1") -(defvaralias 'helm-c-grep-default-function 'helm-grep-default-function) -(make-obsolete-variable 'helm-c-grep-default-function 'helm-grep-default-function "1.5.1") -(defvaralias 'helm-c-top-command 'helm-top-command) -(make-obsolete-variable 'helm-c-top-command 'helm-top-command "1.5.1") -(defvaralias 'helm-c-source-bookmark-man 'helm-source-bookmark-man) -(make-obsolete-variable 'helm-c-source-bookmark-man 'helm-source-bookmark-man "1.5.1") -(defvaralias 'helm-c-source-stumpwm-commands 'helm-source-stumpwm-commands) -(make-obsolete-variable 'helm-c-source-stumpwm-commands 'helm-source-stumpwm-commands "1.5.1") -(defvaralias 'helm-c-source-idle-time-timers 'helm-source-idle-time-timers) -(make-obsolete-variable 'helm-c-source-idle-time-timers 'helm-source-idle-time-timers "1.5.1") -(defvaralias 'helm-c-turn-on-show-completion 'helm-turn-on-show-completion) -(make-obsolete-variable 'helm-c-turn-on-show-completion 'helm-turn-on-show-completion "1.5.1") -(defvaralias 'helm-c-esh-help-message 'helm-esh-help-message) -(make-obsolete-variable 'helm-c-esh-help-message 'helm-esh-help-message "1.5.1") -(defvaralias 'helm-c-register-max-offset 'helm-register-max-offset) -(make-obsolete-variable 'helm-c-register-max-offset 'helm-register-max-offset "1.5.1") -(defvaralias 'helm-c-source-bookmark-set 'helm-source-bookmark-set) -(make-obsolete-variable 'helm-c-source-bookmark-set 'helm-source-bookmark-set "1.5.1") -(defvaralias 'helm-c-source-file-name-history 'helm-source-file-name-history) -(make-obsolete-variable 'helm-c-source-file-name-history 'helm-source-file-name-history "1.5.1") -(defvaralias 'helm-c-file-cache-initialized-p 'helm-file-cache-initialized-p) -(make-obsolete-variable 'helm-c-file-cache-initialized-p 'helm-file-cache-initialized-p "1.5.1") -(defvaralias 'helm-c-grep-max-length-history 'helm-grep-max-length-history) -(make-obsolete-variable 'helm-c-grep-max-length-history 'helm-grep-max-length-history "1.5.1") -(defvaralias 'helm-c-source-jabber-contacts 'helm-source-jabber-contacts) -(make-obsolete-variable 'helm-c-source-jabber-contacts 'helm-source-jabber-contacts "1.5.1") -(defvaralias 'helm-c-grep-use-ioccur-style-keys 'helm-grep-use-ioccur-style-keys) -(make-obsolete-variable 'helm-c-grep-use-ioccur-style-keys 'helm-grep-use-ioccur-style-keys "1.5.1") -(defvaralias 'helm-c-ctags-modes 'helm-ctags-modes) -(make-obsolete-variable 'helm-c-ctags-modes 'helm-ctags-modes "1.5.1") -(defvaralias 'helm-c-source-moccur 'helm-source-moccur) -(make-obsolete-variable 'helm-c-source-moccur 'helm-source-moccur "1.5.1") -(defvaralias 'helm-c-source-w3m-bookmarks 'helm-source-w3m-bookmarks) -(make-obsolete-variable 'helm-c-source-w3m-bookmarks 'helm-source-w3m-bookmarks "1.5.1") -(defvaralias 'helm-c-locate-command 'helm-locate-command) -(make-obsolete-variable 'helm-c-locate-command 'helm-locate-command "1.5.1") -(defvaralias 'helm-c-etags-tag-file-name 'helm-etags-tag-file-name) -(make-obsolete-variable 'helm-c-etags-tag-file-name 'helm-etags-tag-file-name "1.5.1") -(defvaralias 'helm-c-source-bookmarks-su 'helm-source-bookmarks-su) -(make-obsolete-variable 'helm-c-source-bookmarks-su 'helm-source-bookmarks-su "1.5.1") -(defvaralias 'helm-c-source-emms-streams 'helm-source-emms-streams) -(make-obsolete-variable 'helm-c-source-emms-streams 'helm-source-emms-streams "1.5.1") -(defvaralias 'helm-c-buffer-map 'helm-buffer-map) -(make-obsolete-variable 'helm-c-buffer-map 'helm-buffer-map "1.5.1") -(defvaralias 'helm-c-source-files-in-all-dired 'helm-source-files-in-all-dired) -(make-obsolete-variable 'helm-c-source-files-in-all-dired 'helm-source-files-in-all-dired "1.5.1") -(defvaralias 'helm-c-source-eshell-history 'helm-source-eshell-history) -(make-obsolete-variable 'helm-c-source-eshell-history 'helm-source-eshell-history "1.5.1") -(defvaralias 'helm-c-source-absolute-time-timers 'helm-source-absolute-time-timers) -(make-obsolete-variable 'helm-c-source-absolute-time-timers 'helm-source-absolute-time-timers "1.5.1") -(defvaralias 'helm-c-source-findutils 'helm-source-findutils) -(make-obsolete-variable 'helm-c-source-findutils 'helm-source-findutils "1.5.1") -(defvaralias 'helm-c-ucs-help-message 'helm-ucs-help-message) -(make-obsolete-variable 'helm-c-ucs-help-message 'helm-ucs-help-message "1.5.1") -(defvaralias 'helm-c-source-find-files 'helm-source-find-files) -(make-obsolete-variable 'helm-c-source-find-files 'helm-source-find-files "1.5.1") -(defvaralias 'helm-c-source-recentf 'helm-source-recentf) -(make-obsolete-variable 'helm-c-source-recentf 'helm-source-recentf "1.5.1") -(defvaralias 'helm-c-cache-world 'helm-cache-world) -(make-obsolete-variable 'helm-c-cache-world 'helm-cache-world "1.5.1") -(defvaralias 'helm-c-source-picklist 'helm-source-picklist) -(make-obsolete-variable 'helm-c-source-picklist 'helm-source-picklist "1.5.1") -(defvaralias 'helm-c-source-buffer-not-found 'helm-source-buffer-not-found) -(make-obsolete-variable 'helm-c-source-buffer-not-found 'helm-source-buffer-not-found "1.5.1") -(defvaralias 'helm-c-source-xrandr-change-resolution 'helm-source-xrandr-change-resolution) -(make-obsolete-variable 'helm-c-source-xrandr-change-resolution 'helm-source-xrandr-change-resolution "1.5.1") -(defvaralias 'helm-c-source-bookmark-w3m 'helm-source-bookmark-w3m) -(make-obsolete-variable 'helm-c-source-bookmark-w3m 'helm-source-bookmark-w3m "1.5.1") -(defvaralias 'helm-c-google-suggest-url 'helm-google-suggest-url) -(make-obsolete-variable 'helm-c-google-suggest-url 'helm-google-suggest-url "1.5.1") -(defvaralias 'helm-c-source-semantic 'helm-source-semantic) -(make-obsolete-variable 'helm-c-source-semantic 'helm-source-semantic "1.5.1") -(defvaralias 'helm-c-source-mark-ring 'helm-source-mark-ring) -(make-obsolete-variable 'helm-c-source-mark-ring 'helm-source-mark-ring "1.5.1") -(defvaralias 'helm-c-source-fixme 'helm-source-fixme) -(make-obsolete-variable 'helm-c-source-fixme 'helm-source-fixme "1.5.1") -(defvaralias 'helm-c-grep-preferred-ext 'helm-grep-preferred-ext) -(make-obsolete-variable 'helm-c-grep-preferred-ext 'helm-grep-preferred-ext "1.5.1") -(defvaralias 'helm-c-source-gentoo 'helm-source-gentoo) -(make-obsolete-variable 'helm-c-source-gentoo 'helm-source-gentoo "1.5.1") -(defvaralias 'helm-c-source-bookmarks 'helm-source-bookmarks) -(make-obsolete-variable 'helm-c-source-bookmarks 'helm-source-bookmarks "1.5.1") -(defvaralias 'helm-c-source-elisp-library-scan 'helm-source-elisp-library-scan) -(make-obsolete-variable 'helm-c-source-elisp-library-scan 'helm-source-elisp-library-scan "1.5.1") -(defvaralias 'helm-c-source-info-pages 'helm-source-info-pages) -(make-obsolete-variable 'helm-c-source-info-pages 'helm-source-info-pages "1.5.1") -(defvaralias 'helm-c-source-bookmark-gnus 'helm-source-bookmark-gnus) -(make-obsolete-variable 'helm-c-source-bookmark-gnus 'helm-source-bookmark-gnus "1.5.1") -(defvaralias 'helm-c-source-elscreen 'helm-source-elscreen) -(make-obsolete-variable 'helm-c-source-elscreen 'helm-source-elscreen "1.5.1") -(defvaralias 'helm-c-source-emacs-source-defun 'helm-source-emacs-source-defun) -(make-obsolete-variable 'helm-c-source-emacs-source-defun 'helm-source-emacs-source-defun "1.5.1") -(defvaralias 'helm-c-source-emacs-lisp-toplevels 'helm-source-emacs-lisp-toplevels) -(make-obsolete-variable 'helm-c-source-emacs-lisp-toplevels 'helm-source-emacs-lisp-toplevels "1.5.1") -(defvaralias 'helm-c-etags-mtime-alist 'helm-etags-mtime-alist) -(make-obsolete-variable 'helm-c-etags-mtime-alist 'helm-etags-mtime-alist "1.5.1") -(defvaralias 'helm-c-info-pages 'helm-info-pages) -(make-obsolete-variable 'helm-c-info-pages 'helm-info-pages "1.5.1") -(defvaralias 'helm-c-grep-default-recurse-command 'helm-grep-default-recurse-command) -(make-obsolete-variable 'helm-c-grep-default-recurse-command 'helm-grep-default-recurse-command "1.5.1") -(defvaralias 'helm-c-yaoddmuse-ew-cache 'helm-yaoddmuse-ew-cache) -(make-obsolete-variable 'helm-c-yaoddmuse-ew-cache 'helm-yaoddmuse-ew-cache "1.5.1") -(defvaralias 'helm-c-source-google-suggest 'helm-source-google-suggest) -(make-obsolete-variable 'helm-c-source-google-suggest 'helm-source-google-suggest "1.5.1") -(defvaralias 'helm-c-etags-tag-file-search-limit 'helm-etags-tag-file-search-limit) -(make-obsolete-variable 'helm-c-etags-tag-file-search-limit 'helm-etags-tag-file-search-limit "1.5.1") -(defvaralias 'helm-c-w3m-bookmarks-alist 'helm-w3m-bookmarks-alist) -(make-obsolete-variable 'helm-c-w3m-bookmarks-alist 'helm-w3m-bookmarks-alist "1.5.1") -(defvaralias 'helm-c-source-ff-file-name-history 'helm-source-ff-file-name-history) -(make-obsolete-variable 'helm-c-source-ff-file-name-history 'helm-source-ff-file-name-history "1.5.1") -(defvaralias 'helm-c-source-buffers-list 'helm-source-buffers-list) -(make-obsolete-variable 'helm-c-source-buffers-list 'helm-source-buffers-list "1.5.1") -(defvaralias 'helm-c-cached-imenu-alist 'helm-cached-imenu-alist) -(make-obsolete-variable 'helm-c-cached-imenu-alist 'helm-cached-imenu-alist "1.5.1") -(defvaralias 'helm-c-source-emacs-lisp-expectations 'helm-source-emacs-lisp-expectations) -(make-obsolete-variable 'helm-c-source-emacs-lisp-expectations 'helm-source-emacs-lisp-expectations "1.5.1") -(defvaralias 'helm-c-source-rd-headline 'helm-source-rd-headline) -(make-obsolete-variable 'helm-c-source-rd-headline 'helm-source-rd-headline "1.5.1") -(defvaralias 'helm-c-source-tracker-search 'helm-source-tracker-search) -(make-obsolete-variable 'helm-c-source-tracker-search 'helm-source-tracker-search "1.5.1") -(defvaralias 'helm-c-yaoddmuse-cache-file 'helm-yaoddmuse-cache-file) -(make-obsolete-variable 'helm-c-yaoddmuse-cache-file 'helm-yaoddmuse-cache-file "1.5.1") -(defvaralias 'helm-c-google-suggest-default-function 'helm-google-suggest-default-function) -(make-obsolete-variable 'helm-c-google-suggest-default-function 'helm-google-suggest-default-function "1.5.1") -(defvaralias 'helm-c-imenu-delimiter 'helm-imenu-delimiter) -(make-obsolete-variable 'helm-c-imenu-delimiter 'helm-imenu-delimiter "1.5.1") -(defvaralias 'helm-c-source-emacs-process 'helm-source-emacs-process) -(make-obsolete-variable 'helm-c-source-emacs-process 'helm-source-emacs-process "1.5.1") -(defvaralias 'helm-c-firefox-bookmarks-alist 'helm-firefox-bookmarks-alist) -(make-obsolete-variable 'helm-c-firefox-bookmarks-alist 'helm-firefox-bookmarks-alist "1.5.1") -(defvaralias 'helm-c-etags-map 'helm-etags-map) -(make-obsolete-variable 'helm-c-etags-map 'helm-etags-map "1.5.1") -(defvaralias 'helm-c-grep-history 'helm-grep-history) -(make-obsolete-variable 'helm-c-grep-history 'helm-grep-history "1.5.1") -(defvaralias 'helm-c-cached-imenu-tick 'helm-cached-imenu-tick) -(make-obsolete-variable 'helm-c-cached-imenu-tick 'helm-cached-imenu-tick "1.5.1") -(defvaralias 'helm-c-source-esh 'helm-source-esh) -(make-obsolete-variable 'helm-c-source-esh 'helm-source-esh "1.5.1") -(defvaralias 'helm-c-source-global-mark-ring 'helm-source-global-mark-ring) -(make-obsolete-variable 'helm-c-source-global-mark-ring 'helm-source-global-mark-ring "1.5.1") -(defvaralias 'helm-c-man-pages 'helm-man-pages) -(make-obsolete-variable 'helm-c-man-pages 'helm-man-pages "1.5.1") -(defvaralias 'helm-c-adaptative-done 'helm-adaptive-done) -(make-obsolete-variable 'helm-c-adaptative-done 'helm-adaptive-done "1.5.1") -(defvaralias 'helm-c-source-bbdb 'helm-source-bbdb) -(make-obsolete-variable 'helm-c-source-bbdb 'helm-source-bbdb "1.5.1") -(defvaralias 'helm-c-source-regexp 'helm-source-regexp) -(make-obsolete-variable 'helm-c-source-regexp 'helm-source-regexp "1.5.1") -(defvaralias 'helm-c-boring-file-regexp-list 'helm-boring-file-regexp-list) -(make-obsolete-variable 'helm-c-boring-file-regexp-list 'helm-boring-file-regexp-list "1.5.1") -(defvaralias 'helm-c-show-completion-use-special-display 'helm-show-completion-use-special-display) -(make-obsolete-variable 'helm-c-show-completion-use-special-display 'helm-show-completion-use-special-display "1.5.1") -(defvaralias 'helm-c-apt-query 'helm-apt-query) -(make-obsolete-variable 'helm-c-apt-query 'helm-apt-query "1.5.1") -(defvaralias 'helm-c-pdfgrep-default-read-command 'helm-pdfgrep-default-read-command) -(make-obsolete-variable 'helm-c-pdfgrep-default-read-command 'helm-pdfgrep-default-read-command "1.5.1") -(defvaralias 'helm-c-source-bookmark-images 'helm-source-bookmark-images) -(make-obsolete-variable 'helm-c-source-bookmark-images 'helm-source-bookmark-images "1.5.1") -(defvaralias 'helm-c-source-mac-spotlight 'helm-source-mac-spotlight) -(make-obsolete-variable 'helm-c-source-mac-spotlight 'helm-source-mac-spotlight "1.5.1") -(defvaralias 'helm-c-yahoo-suggest-url 'helm-yahoo-suggest-url) -(make-obsolete-variable 'helm-c-yahoo-suggest-url 'helm-yahoo-suggest-url "1.5.1") -(defvaralias 'helm-c-source-oddmuse-headline 'helm-source-oddmuse-headline) -(make-obsolete-variable 'helm-c-source-oddmuse-headline 'helm-source-oddmuse-headline "1.5.1") -(defvaralias 'helm-c-cache-gentoo 'helm-cache-gentoo) -(make-obsolete-variable 'helm-c-cache-gentoo 'helm-cache-gentoo "1.5.1") -(defvaralias 'helm-c-zgrep-recurse-flag 'helm-zgrep-recurse-flag) -(make-obsolete-variable 'helm-c-zgrep-recurse-flag 'helm-zgrep-recurse-flag "1.5.1") -(defvaralias 'helm-c-source-use-flags 'helm-source-use-flags) -(make-obsolete-variable 'helm-c-source-use-flags 'helm-source-use-flags "1.5.1") -(defvaralias 'helm-c-moccur-map 'helm-moccur-map) -(make-obsolete-variable 'helm-c-moccur-map 'helm-moccur-map "1.5.1") -(defvaralias 'helm-c-adaptative-history-file 'helm-adaptive-history-file) -(make-obsolete-variable 'helm-c-adaptative-history-file 'helm-adaptive-history-file "1.5.1") -(defvaralias 'helm-c-grep-default-directory-fn 'helm-grep-default-directory-fn) -(make-obsolete-variable 'helm-c-grep-default-directory-fn 'helm-grep-default-directory-fn "1.5.1") -(defvaralias 'helm-c-apt-input-history 'helm-apt-input-history) -(make-obsolete-variable 'helm-c-apt-input-history 'helm-apt-input-history "1.5.1") -(defvaralias 'helm-c-source-emms-files 'helm-source-emms-files) -(make-obsolete-variable 'helm-c-source-emms-files 'helm-source-emms-files "1.5.1") -(defvaralias 'helm-async-be-async 'dired-async-be-async) -(make-obsolete-variable 'helm-async-be-async 'dired-async-be-async "1.5.9") - - -(provide 'helm-aliases) - -;;; helm-aliases.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-apt.el b/emacs.d/elpa/helm-20141016.2217/helm-apt.el deleted file mode 100644 index 7d06e95..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-apt.el +++ /dev/null @@ -1,292 +0,0 @@ -;;; helm-apt.el --- Helm interface for Debian/Ubuntu packages (apt-*) -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-external) - -(declare-function term-line-mode "term") -(declare-function term-char-mode "term") -(declare-function term-send-input "term") -(declare-function term-send-eof "term") - - -(defgroup helm-apt nil - "Apt related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-apt-cache-show-function 'helm-apt-cache-show-1 - "Function of one argument used to show apt package. -Default is `helm-apt-cache-show-1' but you can use `apt-utils-show-package-1' -from `apt-utils.el' to have something more enhanced. -If nil default `helm-apt-cache-show-1' will be used." - :type 'function - :group 'helm-apt) - -(defface helm-apt-installed - '((t (:foreground "green"))) - "Face used for apt installed candidates." - :group 'helm-apt) - -(defface helm-apt-deinstalled - '((t (:foreground "DimGray"))) - "Face used for apt deinstalled candidates." - :group 'helm-apt) - - -(defvar helm-apt-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-apt-help) - (define-key map (kbd "M-I") 'helm-apt-show-only-installed) - (define-key map (kbd "M-U") 'helm-apt-show-only-not-installed) - (define-key map (kbd "M-D") 'helm-apt-show-only-deinstalled) - (define-key map (kbd "M-A") 'helm-apt-show-all) - map)) - - -(defvar helm-source-apt - `((name . "APT") - (init . helm-apt-init) - (candidates-in-buffer) - (candidate-transformer . helm-apt-candidate-transformer) - (display-to-real . helm-apt-display-to-real) - (update . helm-apt-refresh) - (keymap . ,helm-apt-map) - (mode-line . helm-apt-mode-line) - (action - ("Show package description" . helm-apt-cache-show) - ("Install package" . helm-apt-install) - ("Reinstall package" . helm-apt-reinstall) - ("Remove package" . helm-apt-uninstall) - ("Purge package" . helm-apt-purge)) - (persistent-action . helm-apt-persistent-action) - (persistent-help . "Show package description"))) - -;;; Internals vars -(defvar helm-apt-search-command "apt-cache search '%s'") -(defvar helm-apt-show-command "apt-cache show '%s'") -(defvar helm-apt-installed-packages nil) -(defvar helm-apt-all-packages nil) -(defvar helm-apt-input-history nil) -(defvar helm-apt-show-only 'all) -(defvar helm-apt-term-buffer nil) -(defvar helm-apt-default-archs nil) - -(defun helm-apt-refresh () - "Refresh installed candidates list." - (setq helm-apt-installed-packages nil) - (setq helm-apt-all-packages nil)) - -(defun helm-apt-persistent-action (candidate) - "Persistent action for APT source." - (helm-apt-cache-show candidate)) - -(defun helm-apt--installed-package-name (name) - (cl-loop for arch in helm-apt-default-archs - thereis (or (assoc-default - name helm-apt-installed-packages) - (assoc-default - (format "%s:%s" name arch) - helm-apt-installed-packages)))) - -(defun helm-apt-candidate-transformer (candidates) - "Show installed CANDIDATES and the ones to deinstall in a different color." - (cl-loop for cand in candidates - for name = (helm-apt-display-to-real cand) - for deinstall = (string= - (helm-apt--installed-package-name name) - "deinstall") - for install = (string= - (helm-apt--installed-package-name name) - "install") - for show = (cond ((and deinstall - (memq helm-apt-show-only '(all deinstalled))) - (propertize cand 'face 'helm-apt-deinstalled)) - ((and install - (memq helm-apt-show-only '(all installed))) - (propertize cand 'face 'helm-apt-installed)) - ((and (eq helm-apt-show-only 'noinstalled) - (not install)) cand) - ((eq helm-apt-show-only 'all) cand)) - when show collect show)) - -(defun helm-apt-show-only-installed () - (interactive) - (when helm-alive-p - (setq helm-apt-show-only 'installed) - (helm-update))) - -(defun helm-apt-show-only-not-installed () - (interactive) - (when helm-alive-p - (setq helm-apt-show-only 'noinstalled) - (helm-update))) - -(defun helm-apt-show-only-deinstalled () - (interactive) - (when helm-alive-p - (setq helm-apt-show-only 'deinstalled) - (helm-update))) - -(defun helm-apt-show-all () - (interactive) - (when helm-alive-p - (setq helm-apt-show-only 'all) - (helm-update))) - -(defun helm-apt-init () - "Initialize list of debian packages." - (let ((query "")) - (unless (and helm-apt-installed-packages - helm-apt-all-packages) - (message "Loading package list...") - (setq helm-apt-installed-packages - (with-temp-buffer - (call-process-shell-command "dpkg --get-selections" - nil (current-buffer)) - (cl-loop for i in (split-string (buffer-string) "\n" t) - for p = (split-string i) - collect (cons (car p) (cadr p))))) - (helm-init-candidates-in-buffer - 'global - (setq helm-apt-all-packages - (with-temp-buffer - (call-process-shell-command - (format helm-apt-search-command query) - nil (current-buffer)) - (buffer-string)))) - (message "Loading package list done") - (sit-for 0.5)))) - -(defun helm-apt-display-to-real (line) - "Return only name of a debian package. -LINE is displayed like: -package name - description." - (car (split-string line " - "))) - -(defvar helm-apt-show-current-package nil) -(define-derived-mode helm-apt-show-mode - special-mode "helm-apt-show" - "Mode to display infos on apt packages.") - -(defun helm-apt-cache-show (package) - "Show information on apt package PACKAGE." - (if (and (functionp helm-apt-cache-show-function) - (not (eq helm-apt-cache-show-function - 'helm-apt-cache-show))) - ;; A function, call it. - (funcall helm-apt-cache-show-function package) - ;; nil or whatever use default. - (helm-apt-cache-show-1 package))) - -(defun helm-apt-cache-show-1 (package) - (let* ((command (format helm-apt-show-command package)) - (buf (get-buffer-create "*helm apt show*"))) - (helm-switch-to-buffer buf) - (unless (string= package helm-apt-show-current-package) - (let ((inhibit-read-only t)) - (erase-buffer) - (save-excursion - (call-process-shell-command - command nil (current-buffer) t)))) - (helm-apt-show-mode) - (set (make-local-variable 'helm-apt-show-current-package) - package))) - -(defun helm-apt-install (_package) - "Run 'apt-get install' shell command on PACKAGE." - (helm-apt-generic-action :action 'install)) - -(defun helm-apt-reinstall (_package) - "Run 'apt-get install --reinstall' shell command on PACKAGE." - (helm-apt-generic-action :action 'reinstall)) - -(defun helm-apt-uninstall (_package) - "Run 'apt-get remove' shell command on PACKAGE." - (helm-apt-generic-action :action 'uninstall)) - -(defun helm-apt-purge (_package) - "Run 'apt-get purge' shell command on PACKAGE." - (helm-apt-generic-action :action 'purge)) - -(cl-defun helm-apt-generic-action (&key action) - "Run 'apt-get ACTION'. -Support install, remove and purge actions." - (if (and helm-apt-term-buffer - (buffer-live-p (get-buffer helm-apt-term-buffer))) - (switch-to-buffer helm-apt-term-buffer) - (ansi-term (getenv "SHELL") "term apt") - (setq helm-apt-term-buffer (buffer-name))) - (term-line-mode) - (let ((command (cl-case action - (install "sudo apt-get install ") - (reinstall "sudo apt-get install --reinstall ") - (uninstall "sudo apt-get remove ") - (purge "sudo apt-get purge ") - (t (error "Unknown action")))) - (beg (point)) - end - (cand-list (mapconcat #'(lambda (x) (format "'%s'" x)) - (helm-marked-candidates) " "))) - (goto-char (point-max)) - (insert (concat command cand-list)) - (setq end (point)) - (if (y-or-n-p (format "%s package(s)" (symbol-name action))) - (progn - (setq helm-external-commands-list nil) - (setq helm-apt-installed-packages nil) - (term-char-mode) (term-send-input)) - (delete-region beg end)))) - -;;;###autoload -(defun helm-apt (arg) - "Preconfigured `helm' : frontend of APT package manager. -With a prefix arg reload cache." - (interactive "P") - (setq helm-apt-show-only 'all) - (unless helm-apt-default-archs - (setq helm-apt-default-archs - (append (split-string - (shell-command-to-string - "dpkg --print-architecture") - "\n" t) - (split-string - (shell-command-to-string - "dpkg --print-foreign-architectures") - "\n" t)))) - (let ((query (read-string "Search Package: " nil 'helm-apt-input-history))) - (when arg (helm-apt-refresh)) - (helm :sources 'helm-source-apt - :prompt "Search Package: " - :input query - :buffer "*helm apt*" - :history 'helm-apt-input-history))) - - -(provide 'helm-apt) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-apt.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-autoloads.el b/emacs.d/elpa/helm-20141016.2217/helm-autoloads.el deleted file mode 100644 index 984f635..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-autoloads.el +++ /dev/null @@ -1,1302 +0,0 @@ -;;; helm-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "helm" "helm.el" (21570 22531 0 0)) -;;; Generated autoloads from helm.el - -(autoload 'helm-define-multi-key "helm" "\ -In KEYMAP, define key sequence KEY for function list FUNCTIONS. -Each function run sequentialy each time the key KEY is pressed. -If DELAY is specified switch back to initial function of FUNCTIONS list -after DELAY seconds. -The functions in FUNCTIONS list are functions with no args. -e.g - (defun foo () - (message \"Run foo\")) - (defun bar () - (message \"Run bar\")) - (defun baz () - (message \"Run baz\")) - -\(helm-define-multi-key global-map \" q\" '(foo bar baz) 2) - -Each time \" q\" is pressed the next function is executed, if you wait -More than 2 seconds, next hit will run again the first function and so on. - -\(fn KEYMAP KEY FUNCTIONS &optional DELAY)" nil nil) - -(autoload 'helm-multi-key-defun "helm" "\ -Define NAME as a multi-key command running FUNS. -After DELAY seconds the FUNS list is reinitialised. -See `helm-define-multi-key'. - -\(fn NAME DOCSTRING FUNS &optional DELAY)" nil t) - -(put 'helm-multi-key-defun 'lisp-indent-function '2) - -(autoload 'helm-define-key-with-subkeys "helm" "\ -Allow defining a KEY without having to type its prefix again on next calls. -Arg MAP is the keymap to use, SUBKEY is the initial long keybinding to -call COMMAND. -Arg OTHER-SUBKEYS is an unquoted alist specifying other short keybindings -to use once started. -e.g: - -\(helm-define-key-with-subkeys global-map - (kbd \"C-x v n\") ?n 'git-gutter:next-hunk ((?p . 'git-gutter:previous-hunk))) - - -In this example, `C-x v n' will run `git-gutter:next-hunk' subsequent hit on \"n\" -will run this command again and subsequent hit on \"p\" will run `git-gutter:previous-hunk'. - -Arg MENU is a string to display in minibuffer to describe SUBKEY and OTHER-SUBKEYS. -Arg EXIT-FN specify a function to run on exit. - -Any other keys pressed run their assigned command defined in MAP and exit the loop. - -\(fn MAP KEY SUBKEY COMMAND &optional OTHER-SUBKEYS MENU EXIT-FN)" nil t) - -(autoload 'helm-debug-open-last-log "helm" "\ -Open helm log file of last helm session. -If `helm-last-log-file' is nil, switch to `helm-debug-buffer' . - -\(fn)" t nil) - -(autoload 'helm "helm" "\ -Main function to execute helm sources. - -Keywords supported: -:sources :input :prompt :resume :preselect -:buffer :keymap :default :history :allow-nest - -Extra LOCAL-VARS keywords are supported, see below. - -PLIST is a list like (:key1 val1 :key2 val2 ...) or -\(&optional sources input prompt resume - preselect buffer keymap default history). - -Basic keywords are the following: - -:sources - -A list of sources used for this session. It also accepts a -symbol, interpreted as a variable of a helm source -i.e (a symbol can be passed instead of a list of sources). -It also accepts an alist representing a helm source, which is -detected by (assq 'name ANY-SOURCES). -NOTE: In this case the source is embedded in the helm command and -have no symbol name, so it is not reachable from outside. -It will be referenced in `helm-sources' as a whole alist. - -:input - -Temporary value of `helm-pattern', ie. initial input of minibuffer. - -:prompt - -Prompt other than \"pattern: \". - -:resume - -If t, Resurrect previously instance of `helm'. Skip the initialization. -If 'noresume, this instance of `helm' cannot be resumed. - -:preselect - -Initially selected candidate. Specified by exact candidate or a regexp. - -:buffer - -`helm-buffer' instead of *helm*. - -:keymap - -`helm-map' for current `helm' session. - -:default - -A default argument that will be inserted in minibuffer with \\\\[next-history-element]. -When nil or not present `thing-at-point' will be used instead. -If `helm-maybe-use-default-as-input' is non--nil display will be -updated using :default arg as input unless :input is specified, -which in this case will take precedence on :default -This is a string or a list, in this case the car of the list will -be used as initial default input, but you will be able to cycle in this -list with \\\\[next-history-element]. - -:history - -By default all minibuffer input is pushed to `minibuffer-history', -if an argument HISTORY is provided, input will be pushed to HISTORY. -History element should be a symbol. - -:allow-nest - -Allow running this helm command within a running helm session. - -Of course, conventional arguments are supported, the two are same. - -\(helm :sources sources :input input :prompt prompt :resume resume - :preselect preselect :buffer buffer :keymap keymap :default default - :history history) - -and - -\(helm sources input prompt resume preselect buffer keymap default history) - -are the same. - -However the use of non keyword args is deprecated and should not be used. - -Other keywords are interpreted as local variables of this helm session. -The `helm-' prefix can be omitted. For example, - -\(helm :sources 'helm-source-buffers-list - :buffer \"*buffers*\" :candidate-number-limit 10) - -means starting helm session with `helm-source-buffers' -source in *buffers* buffer and set variable `helm-candidate-number-limit' -to 10 as session local variable. - -\(fn &key SOURCES INPUT PROMPT RESUME PRESELECT BUFFER KEYMAP DEFAULT HISTORY ALLOW-NEST OTHER-LOCAL-VARS)" nil nil) - -(autoload 'helm-other-buffer "helm" "\ -Simplified interface of `helm' with other `helm-buffer'. -Call `helm' with only ANY-SOURCES and ANY-BUFFER as args. - -\(fn ANY-SOURCES ANY-BUFFER)" nil nil) - -;;;*** - -;;;### (autoloads nil "helm-adaptive" "helm-adaptive.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-adaptive.el - -(autoload 'helm-reset-adaptive-history "helm-adaptive" "\ -Delete all `helm-adaptive-history' and his file. -Useful when you have a old or corrupted `helm-adaptive-history-file'. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-apt" "helm-apt.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-apt.el - -(autoload 'helm-apt "helm-apt" "\ -Preconfigured `helm' : frontend of APT package manager. -With a prefix arg reload cache. - -\(fn ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-bbdb" "helm-bbdb.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-bbdb.el - -(autoload 'helm-bbdb "helm-bbdb" "\ -Preconfigured `helm' for BBDB. - -Needs BBDB. - -http://bbdb.sourceforge.net/ - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-bookmark" "helm-bookmark.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-bookmark.el - -(autoload 'helm-bookmarks "helm-bookmark" "\ -Preconfigured `helm' for bookmarks. - -\(fn)" t nil) - -(autoload 'helm-pp-bookmarks "helm-bookmark" "\ -Preconfigured `helm' for bookmarks (pretty-printed). - -\(fn)" t nil) - -(autoload 'helm-filtered-bookmarks "helm-bookmark" "\ -Preconfigured helm for bookmarks (filtered by category). -Optional source `helm-source-bookmark-addressbook' is loaded -only if external library addressbook-bookmark.el is available. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-buffers" "helm-buffers.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-buffers.el - -(autoload 'helm-buffers-list "helm-buffers" "\ -Preconfigured `helm' to list buffers. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-color" "helm-color.el" (21570 22531 0 -;;;;;; 0)) -;;; Generated autoloads from helm-color.el - -(autoload 'helm-colors "helm-color" "\ -Preconfigured `helm' for color. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-command" "helm-command.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-command.el - -(autoload 'helm-M-x "helm-command" "\ -Preconfigured `helm' for Emacs commands. -It is `helm' replacement of regular `M-x' `execute-extended-command'. - -Unlike regular `M-x' emacs vanilla `execute-extended-command' command, -the prefix args if needed, are passed AFTER starting `helm-M-x'. - -You can get help on each command by persistent action. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-config" "helm-config.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-config.el - -(autoload 'helm-configuration "helm-config" "\ -Customize `helm'. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-dabbrev" "helm-dabbrev.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-dabbrev.el - -(autoload 'helm-dabbrev "helm-dabbrev" "\ - - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-elisp" "helm-elisp.el" (21570 22531 0 -;;;;;; 0)) -;;; Generated autoloads from helm-elisp.el - -(autoload 'helm-lisp-completion-at-point "helm-elisp" "\ -Helm lisp symbol completion at point. - -\(fn)" t nil) - -(autoload 'helm-complete-file-name-at-point "helm-elisp" "\ -Complete file name at point. - -\(fn &optional FORCE)" t nil) - -(autoload 'helm-lisp-indent "helm-elisp" "\ - - -\(fn)" t nil) - -(autoload 'helm-lisp-completion-or-file-name-at-point "helm-elisp" "\ -Complete lisp symbol or filename at point. -Filename completion happen if string start after or between a double quote. - -\(fn)" t nil) - -(autoload 'helm-apropos "helm-elisp" "\ -Preconfigured helm to describe commands, functions, variables and faces. - -\(fn)" t nil) - -(autoload 'helm-manage-advice "helm-elisp" "\ -Preconfigured `helm' to disable/enable function advices. - -\(fn)" t nil) - -(autoload 'helm-locate-library "helm-elisp" "\ - - -\(fn)" t nil) - -(autoload 'helm-timers "helm-elisp" "\ -Preconfigured `helm' for timers. - -\(fn)" t nil) - -(autoload 'helm-complex-command-history "helm-elisp" "\ - - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-elisp-package" "helm-elisp-package.el" -;;;;;; (21570 22531 0 0)) -;;; Generated autoloads from helm-elisp-package.el - -(autoload 'helm-list-elisp-packages "helm-elisp-package" "\ - - -\(fn ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-elscreen" "helm-elscreen.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-elscreen.el - -(autoload 'helm-elscreen "helm-elscreen" "\ -Preconfigured helm to list elscreen. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-emms" "helm-emms.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-emms.el - -(autoload 'helm-emms "helm-emms" "\ -Preconfigured `helm' for emms sources. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-eshell" "helm-eshell.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-eshell.el - -(autoload 'helm-esh-pcomplete "helm-eshell" "\ -Preconfigured helm to provide helm completion in eshell. - -\(fn)" t nil) - -(autoload 'helm-eshell-history "helm-eshell" "\ -Preconfigured helm for eshell history. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-eval" "helm-eval.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-eval.el - -(autoload 'helm-eval-expression "helm-eval" "\ -Preconfigured helm for `helm-source-evaluation-result'. - -\(fn ARG)" t nil) - -(autoload 'helm-eval-expression-with-eldoc "helm-eval" "\ -Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support. - -\(fn)" t nil) - -(autoload 'helm-calcul-expression "helm-eval" "\ -Preconfigured helm for `helm-source-calculation-result'. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-external" "helm-external.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-external.el - -(autoload 'helm-run-external-command "helm-external" "\ -Preconfigured `helm' to run External PROGRAM asyncronously from Emacs. -If program is already running exit with error. -You can set your own list of commands with -`helm-external-commands-list'. - -\(fn PROGRAM)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-files" "helm-files.el" (21570 22531 0 -;;;;;; 0)) -;;; Generated autoloads from helm-files.el - -(autoload 'helm-browse-project "helm-files" "\ -Browse files and see status of project with its vcs. -Only hg and git are supported for now. -Fall back to `helm-find-files' if directory is not under -control of one of those vcs. -Need dependencies: - -and -. - -\(fn)" t nil) - -(autoload 'helm-find "helm-files" "\ -Preconfigured `helm' for the find shell command. - -\(fn ARG)" t nil) - -(autoload 'helm-find-files "helm-files" "\ -Preconfigured `helm' for helm implementation of `find-file'. -Called with a prefix arg show history if some. -Don't call it from programs, use `helm-find-files-1' instead. -This is the starting point for nearly all actions you can do on files. - -\(fn ARG)" t nil) - -(autoload 'helm-for-files "helm-files" "\ -Preconfigured `helm' for opening files. -Run all sources defined in `helm-for-files-preferred-list'. - -\(fn)" t nil) - -(autoload 'helm-recentf "helm-files" "\ -Preconfigured `helm' for `recentf'. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-firefox" "helm-firefox.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-firefox.el - -(autoload 'helm-firefox-bookmarks "helm-firefox" "\ -Preconfigured `helm' for firefox bookmark. -You will have to enable html bookmarks in firefox: -open about:config in firefox and double click on this line to enable value to true: - -user_pref(\"browser.bookmarks.autoExportHTML\", false); - -You should have now: - -user_pref(\"browser.bookmarks.autoExportHTML\", true); - -After closing firefox, you will be able to browse you bookmarks. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-font" "helm-font.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-font.el - -(autoload 'helm-select-xfont "helm-font" "\ -Preconfigured `helm' to select Xfont. - -\(fn)" t nil) - -(autoload 'helm-ucs "helm-font" "\ -Preconfigured helm for `ucs-names' math symbols. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-gentoo" "helm-gentoo.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-gentoo.el - -(autoload 'helm-gentoo "helm-gentoo" "\ -Preconfigured `helm' for gentoo linux. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-grep" "helm-grep.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-grep.el - -(autoload 'helm-goto-precedent-file "helm-grep" "\ -Go to precedent file in helm grep/etags buffers. - -\(fn)" t nil) - -(autoload 'helm-goto-next-file "helm-grep" "\ -Go to precedent file in helm grep/etags buffers. - -\(fn)" t nil) - -(autoload 'helm-grep-run-save-buffer "helm-grep" "\ -Run grep save results action from `helm-do-grep-1'. - -\(fn)" t nil) - -(autoload 'helm-grep-mode "helm-grep" "\ -Major mode to provide actions in helm grep saved buffer. - -Special commands: -\\{helm-grep-mode-map} - -\(fn)" t nil) - -(autoload 'helm-gm-next-file "helm-grep" "\ - - -\(fn)" t nil) - -(autoload 'helm-gm-precedent-file "helm-grep" "\ - - -\(fn)" t nil) - -(autoload 'helm-grep-mode-jump "helm-grep" "\ - - -\(fn)" t nil) - -(autoload 'helm-grep-mode-jump-other-window-forward "helm-grep" "\ - - -\(fn)" t nil) - -(autoload 'helm-grep-mode-jump-other-window-backward "helm-grep" "\ - - -\(fn)" t nil) - -(autoload 'helm-grep-mode-jump-other-window "helm-grep" "\ - - -\(fn)" t nil) - -(autoload 'helm-do-grep "helm-grep" "\ -Preconfigured helm for grep. -Contrarily to Emacs `grep', no default directory is given, but -the full path of candidates in ONLY. -That allow to grep different files not only in `default-directory' but anywhere -by marking them (C-). If one or more directory is selected -grep will search in all files of these directories. -You can also use wildcard in the base name of candidate. -If a prefix arg is given use the -r option of grep (recurse). -The prefix arg can be passed before or after start file selection. -See also `helm-do-grep-1'. - -\(fn)" t nil) - -(autoload 'helm-do-zgrep "helm-grep" "\ -Preconfigured helm for zgrep. - -\(fn)" t nil) - -(autoload 'helm-do-pdfgrep "helm-grep" "\ -Preconfigured helm for pdfgrep. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-help" "helm-help.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-help.el - -(autoload 'helm-help "helm-help" "\ -Help of `helm'. - -\(fn)" t nil) - -(autoload 'helm-buffer-help "helm-help" "\ -Help command for helm buffers. - -\(fn)" t nil) - -(autoload 'helm-ff-help "helm-help" "\ -Help command for `helm-find-files'. - -\(fn)" t nil) - -(autoload 'helm-read-file-name-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-generic-file-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-grep-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-pdfgrep-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-etags-help "helm-help" "\ -The help function for etags. - -\(fn)" t nil) - -(autoload 'helm-ucs-help "helm-help" "\ -Help command for `helm-ucs'. - -\(fn)" t nil) - -(autoload 'helm-bookmark-help "helm-help" "\ -Help command for bookmarks. - -\(fn)" t nil) - -(autoload 'helm-esh-help "helm-help" "\ -Help command for `helm-find-files-eshell-command-on-file'. - -\(fn)" t nil) - -(autoload 'helm-buffers-ido-virtual-help "helm-help" "\ -Help command for ido virtual buffers. - -\(fn)" t nil) - -(autoload 'helm-moccur-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-top-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-apt-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-el-package-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-M-x-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-imenu-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-color-help "helm-help" "\ - - -\(fn)" t nil) - -(autoload 'helm-semantic-help "helm-help" "\ - - -\(fn)" t nil) - -(defvar helm-buffer-mode-line-string '("Buffer(s)" "\\\\[helm-buffer-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "String displayed in mode-line in `helm-source-buffers-list'")) - -(defvar helm-color-mode-line-string '("Colors" "\\\\[helm-color-help]:Help/\\[helm-color-run-insert-name]:Insert name/\\[helm-color-run-insert-rgb]:Insert RGB/with shift: Kill")) - -(defvar helm-buffers-ido-virtual-mode-line-string '("Killed Buffer(s)" "\\\\[helm-buffers-ido-virtual-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "String displayed in mode-line in `helm-source-buffers-list'")) - -(defvar helm-ff-mode-line-string "\\\\[helm-ff-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ -String displayed in mode-line in `helm-source-find-files'") - -(defvar helm-read-file-name-mode-line-string "\\\\[helm-read-file-name-help]:Help \\[helm-cr-empty-string]:Empty \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ -String displayed in mode-line in `helm-source-find-files'.") - -(defvar helm-generic-file-mode-line-string "\\\\[helm-generic-file-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend" "\ -String displayed in mode-line in Locate.") - -(defvar helm-grep-mode-line-string "\\\\[helm-grep-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend" "\ -String displayed in mode-line in `helm-do-grep'.") - -(defvar helm-pdfgrep-mode-line-string "\\\\[helm-pdfgrep-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend" "\ -String displayed in mode-line in `helm-do-pdfgrep'.") - -(defvar helm-etags-mode-line-string "\\\\[helm-etags-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ -String displayed in mode-line in `helm-etags-select'.") - -(defvar helm-ucs-mode-line-string "\\\\[helm-ucs-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ -String displayed in mode-line in `helm-ucs'.") - -(defvar helm-bookmark-mode-line-string '("Bookmark(s)" "\\\\[helm-bookmark-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct") "\ -String displayed in mode-line in `helm-source-buffers-list'") - -(defvar helm-occur-mode-line "\\\\[helm-help]:Help \\\\[helm-occur-run-query-replace-regexp]:Query replace regexp \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-moccur-mode-line "\\\\[helm-moccur-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-comp-read-mode-line "\\\\[helm-cr-empty-string]:Empty \\\\[helm-help]:Help \\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct") - -(defvar helm-top-mode-line "\\\\[helm-top-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-apt-mode-line "\\\\[helm-apt-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-el-package-mode-line "\\\\[helm-el-package-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-M-x-mode-line "\\\\[helm-M-x-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-imenu-mode-line "\\\\[helm-imenu-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(defvar helm-semantic-mode-line "\\\\[helm-semantic-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") - -(autoload 'helm-describe-helm-attribute "helm-help" "\ -Display the full documentation of HELM-ATTRIBUTE. -HELM-ATTRIBUTE should be a symbol. - -\(fn HELM-ATTRIBUTE)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-imenu" "helm-imenu.el" (21570 22531 0 -;;;;;; 0)) -;;; Generated autoloads from helm-imenu.el - -(autoload 'helm-imenu "helm-imenu" "\ -Preconfigured `helm' for `imenu'. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-info" "helm-info.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-info.el - -(autoload 'helm-info-at-point "helm-info" "\ -Preconfigured `helm' for searching info at point. -With a prefix-arg insert symbol at point. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-locate" "helm-locate.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-locate.el - -(autoload 'helm-locate-read-file-name "helm-locate" "\ - - -\(fn PROMPT)" nil nil) - -(autoload 'helm-locate "helm-locate" "\ -Preconfigured `helm' for Locate. -Note: you can add locate options after entering pattern. -See 'man locate' for valid options and also `helm-locate-command'. - -You can specify a local database with prefix argument ARG. -With two prefix arg, refresh the current local db or create it -if it doesn't exists. -Many databases can be used: navigate and mark them. -See also `helm-locate-with-db'. - -To create a user specific db, use -\"updatedb -l 0 -o db_path -U directory\". -Where db_path is a filename matched by -`helm-locate-db-file-regexp'. - -\(fn ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-man" "helm-man.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-man.el - -(autoload 'helm-man-woman "helm-man" "\ -Preconfigured `helm' for Man and Woman pages. -With a prefix arg reinitialize the cache. - -\(fn ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-match-plugin" "helm-match-plugin.el" -;;;;;; (21570 22531 0 0)) -;;; Generated autoloads from helm-match-plugin.el - -(defvar helm-match-plugin-mode nil "\ -Non-nil if Helm-Match-Plugin mode is enabled. -See the command `helm-match-plugin-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `helm-match-plugin-mode'.") - -(custom-autoload 'helm-match-plugin-mode "helm-match-plugin" nil) - -(autoload 'helm-match-plugin-mode "helm-match-plugin" "\ -Add more flexible regexp matching for helm. -See `helm-mp-matching-method' for the behavior of each method. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-misc" "helm-misc.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-misc.el - -(autoload 'helm-browse-menubar "helm-misc" "\ -Helm interface to the menubar using lacarte.el. - -\(fn)" t nil) - -(autoload 'helm-world-time "helm-misc" "\ -Preconfigured `helm' to show world time. - -\(fn)" t nil) - -(autoload 'helm-insert-latex-math "helm-misc" "\ -Preconfigured helm for latex math symbols completion. - -\(fn)" t nil) - -(autoload 'helm-eev-anchors "helm-misc" "\ -Preconfigured `helm' for eev anchors. - -\(fn)" t nil) - -(autoload 'helm-ratpoison-commands "helm-misc" "\ -Preconfigured `helm' to execute ratpoison commands. - -\(fn)" t nil) - -(autoload 'helm-stumpwm-commands "helm-misc" "\ - - -\(fn)" t nil) - -(autoload 'helm-mini "helm-misc" "\ -Preconfigured `helm' lightweight version (buffer -> recentf). - -\(fn)" t nil) - -(autoload 'helm-minibuffer-history "helm-misc" "\ -Preconfigured `helm' for `minibuffer-history'. - -\(fn)" t nil) - -(autoload 'helm-comint-input-ring "helm-misc" "\ -Predefined `helm' that provide completion of `comint' history. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-mode" "helm-mode.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-mode.el - -(autoload 'helm-comp-read "helm-mode" "\ -Read a string in the minibuffer, with helm completion. - -It is helm `completing-read' equivalent. - -- PROMPT is the prompt name to use. - -- COLLECTION can be a list, vector, obarray or hash-table. - It can be also a function that receives three arguments: - the values string, predicate and t. See `all-completions' for more details. - -Keys description: - -- TEST: A predicate called with one arg i.e candidate. - -- INITIAL-INPUT: Same as input arg in `helm'. - -- PRESELECT: See preselect arg of `helm'. - -- DEFAULT: This option is used only for compatibility with regular - Emacs `completing-read' (Same as DEFAULT arg of `completing-read'). - -- BUFFER: Name of helm-buffer. - -- MUST-MATCH: Candidate selected must be one of COLLECTION. - -- REVERSE-HISTORY: When non--nil display history source after current - source completion. - -- REQUIRES-PATTERN: Same as helm attribute, default is 0. - -- HISTORY: A list containing specific history, default is nil. - When it is non--nil, all elements of HISTORY are displayed in - a special source before COLLECTION. - -- INPUT-HISTORY: A symbol. the minibuffer input history will be - stored there, if nil or not provided, `minibuffer-history' - will be used instead. - -- CASE-FOLD: Same as `helm-case-fold-search'. - -- DEL-INPUT: Boolean, when non--nil (default) remove the partial - minibuffer input from HISTORY is present. - -- PERSISTENT-ACTION: A function called with one arg i.e candidate. - -- PERSISTENT-HELP: A string to document PERSISTENT-ACTION. - -- MODE-LINE: A string or list to display in mode line. - Default is `helm-comp-read-mode-line'. - -- KEYMAP: A keymap to use in this `helm-comp-read'. - (the keymap will be shared with history source) - -- NAME: The name related to this local source. - -- EXEC-WHEN-ONLY-ONE: Bound `helm-execute-action-at-once-if-one' - to non--nil. (possibles values are t or nil). - -- VOLATILE: Use volatile attribute (enabled by default). - -- SORT: A predicate to give to `sort' e.g `string-lessp'. - -- FC-TRANSFORMER: A `filtered-candidate-transformer' function. - -- MARKED-CANDIDATES: If non--nil return candidate or marked candidates as a list. - -- NOMARK: When non--nil don't allow marking candidates. - -- ALISTP: (default is non--nil) See `helm-comp-read-get-candidates'. - -- CANDIDATES-IN-BUFFER: when non--nil use a source build with - `helm-candidates-in-buffer' which is much faster. - Argument VOLATILE have no effect when CANDIDATES-IN-BUFFER is non--nil. - -Any prefix args passed during `helm-comp-read' invocation will be recorded -in `helm-current-prefix-arg', otherwise if prefix args were given before -`helm-comp-read' invocation, the value of `current-prefix-arg' will be used. -That's mean you can pass prefix args before or after calling a command -that use `helm-comp-read' See `helm-M-x' for example. - -\(fn PROMPT COLLECTION &key TEST INITIAL-INPUT DEFAULT PRESELECT (buffer \"*Helm Completions*\") MUST-MATCH REVERSE-HISTORY (requires-pattern 0) HISTORY INPUT-HISTORY (case-fold helm-comp-read-case-fold-search) (del-input t) (persistent-action nil) (persistent-help \"DoNothing\") (mode-line helm-comp-read-mode-line) (keymap helm-comp-read-map) (name \"Helm Completions\") CANDIDATES-IN-BUFFER EXEC-WHEN-ONLY-ONE QUIT-WHEN-NO-CAND (volatile t) SORT (fc-transformer (quote helm-cr-default-transformer)) MARKED-CANDIDATES NOMARK (alistp t))" nil nil) - -(defvar helm-mode nil "\ -Non-nil if Helm mode is enabled. -See the command `helm-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `helm-mode'.") - -(custom-autoload 'helm-mode "helm-mode" nil) - -(autoload 'helm-mode "helm-mode" "\ -Toggle generic helm completion. - -All functions in Emacs that use `completing-read' -or `read-file-name' and friends will use helm interface -when this mode is turned on. -However you can modify this behavior for functions of your choice -with `helm-completing-read-handlers-alist'. - -Called with a positive arg, turn on unconditionally, with a -negative arg turn off. -You can turn it on with `helm-mode'. - -Some crap emacs functions may not be supported, -e.g `ffap-alternate-file' and maybe others -You can add such functions to `helm-completing-read-handlers-alist' -with a nil value. - -Note: This mode is incompatible with Emacs23. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-net" "helm-net.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-net.el - -(autoload 'helm-surfraw "helm-net" "\ -Preconfigured `helm' to search PATTERN with search ENGINE. - -\(fn PATTERN ENGINE)" t nil) - -(autoload 'helm-google-suggest "helm-net" "\ -Preconfigured `helm' for google search with google suggest. - -\(fn)" t nil) - -(autoload 'helm-yahoo-suggest "helm-net" "\ -Preconfigured `helm' for Yahoo searching with Yahoo suggest. - -\(fn)" t nil) - -(autoload 'helm-wikipedia-suggest "helm-net" "\ -Preconfigured `helm' for Wikipedia lookup with Wikipedia suggest. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-org" "helm-org.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-org.el - -(autoload 'helm-org-keywords "helm-org" "\ -Preconfigured `helm' for org keywords. - -\(fn)" t nil) - -(autoload 'helm-org-headlines "helm-org" "\ -Preconfigured helm to show org headlines. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-regexp" "helm-regexp.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-regexp.el - -(defvar helm-occur-match-plugin-mode t "\ -Non-nil if Helm-Occur-Match-Plugin mode is enabled. -See the command `helm-occur-match-plugin-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `helm-occur-match-plugin-mode'.") - -(custom-autoload 'helm-occur-match-plugin-mode "helm-regexp" nil) - -(autoload 'helm-occur-match-plugin-mode "helm-regexp" "\ -Turn On/Off `helm-match-plugin-mode' only for `helm-m/occur'. - -\(fn &optional ARG)" t nil) - -(autoload 'helm-moccur-run-save-buffer "helm-regexp" "\ -Run grep save results action from `helm-do-grep-1'. - -\(fn)" t nil) - -(autoload 'helm-moccur-mode "helm-regexp" "\ -Major mode to provide actions in helm moccur saved buffer. - -Special commands: -\\{helm-moccur-mode-map} - -\(fn)" t nil) - -(autoload 'helm-regexp "helm-regexp" "\ -Preconfigured helm to build regexps. -`query-replace-regexp' can be run from there against found regexp. - -\(fn)" t nil) - -(autoload 'helm-occur "helm-regexp" "\ -Preconfigured helm for Occur. - -\(fn)" t nil) - -(autoload 'helm-occur-from-isearch "helm-regexp" "\ -Invoke `helm-occur' from isearch. - -\(fn)" t nil) - -(autoload 'helm-multi-occur "helm-regexp" "\ -Preconfigured helm for multi occur. - - BUFFERS is a list of buffers to search through. -With a prefix arg, reverse the behavior of -`helm-moccur-always-search-in-current'. -The prefix arg can be set before calling `helm-multi-occur' -or during the buffer selection. - -\(fn BUFFERS)" t nil) - -(autoload 'helm-multi-occur-from-isearch "helm-regexp" "\ -Invoke `helm-multi-occur' from isearch. - -With a prefix arg, reverse the behavior of -`helm-moccur-always-search-in-current'. -The prefix arg can be set before calling -`helm-multi-occur-from-isearch' or during the buffer selection. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-ring" "helm-ring.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-ring.el - -(autoload 'helm-mark-ring "helm-ring" "\ -Preconfigured `helm' for `helm-source-mark-ring'. - -\(fn)" t nil) - -(autoload 'helm-global-mark-ring "helm-ring" "\ -Preconfigured `helm' for `helm-source-global-mark-ring'. - -\(fn)" t nil) - -(autoload 'helm-all-mark-rings "helm-ring" "\ -Preconfigured `helm' for `helm-source-global-mark-ring' and `helm-source-mark-ring'. - -\(fn)" t nil) - -(autoload 'helm-register "helm-ring" "\ -Preconfigured `helm' for Emacs registers. - -\(fn)" t nil) - -(autoload 'helm-show-kill-ring "helm-ring" "\ -Preconfigured `helm' for `kill-ring'. -It is drop-in replacement of `yank-pop'. - -First call open the kill-ring browser, next calls move to next line. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-semantic" "helm-semantic.el" (21570 22531 -;;;;;; 0 0)) -;;; Generated autoloads from helm-semantic.el - -(autoload 'helm-semantic "helm-semantic" "\ -Preconfigured `helm' for `semantic'. - -\(fn)" t nil) - -(autoload 'helm-semantic-or-imenu "helm-semantic" "\ -Run `helm' with `semantic' or `imenu'. - -If `semantic-mode' is active in the current buffer, then use -semantic for generating tags, otherwise fall back to `imenu'. -Fill in the symbol at point by default. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-sys" "helm-sys.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-sys.el - -(autoload 'helm-top "helm-sys" "\ -Preconfigured `helm' for top command. - -\(fn)" t nil) - -(autoload 'helm-list-emacs-process "helm-sys" "\ -Preconfigured `helm' for emacs process. - -\(fn)" t nil) - -(autoload 'helm-xrandr-set "helm-sys" "\ - - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-tags" "helm-tags.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-tags.el - -(autoload 'helm-etags-select "helm-tags" "\ -Preconfigured helm for etags. -If called with a prefix argument or if any of the tag files have -been modified, reinitialize cache. - -This function aggregates three sources of tag files: - - 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. - 2) `tags-file-name', which is commonly set by `find-tag' command. - 3) `tags-table-list' which is commonly set by `visit-tags-table' command. - -\(fn ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-utils" "helm-utils.el" (21570 22531 0 -;;;;;; 0)) -;;; Generated autoloads from helm-utils.el - -(autoload 'helm-show-all-in-this-source-only "helm-utils" "\ -Show only current source of this helm session with all its candidates. -With a numeric prefix arg show only the ARG number of candidates. - -\(fn ARG)" t nil) - -(autoload 'helm-display-all-sources "helm-utils" "\ -Display all sources previously hidden by `helm-set-source-filter'. - -\(fn)" t nil) - -(autoload 'helm-quit-and-find-file "helm-utils" "\ -Drop into `helm-find-files' from `helm'. -If current selection is a buffer or a file, `helm-find-files' -from its directory. - -\(fn)" t nil) - -(autoload 'helm-w32-shell-execute-open-file "helm-utils" "\ - - -\(fn FILE)" t nil) - -(autoload 'helm-yank-text-at-point "helm-utils" "\ -Yank text at point in `helm-current-buffer' into minibuffer. -If `helm-yank-symbol-first' is non--nil the first yank -grabs the entire symbol. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-w3m" "helm-w3m.el" (21570 22531 0 0)) -;;; Generated autoloads from helm-w3m.el - -(autoload 'helm-w3m-bookmarks "helm-w3m" "\ -Preconfigured `helm' for w3m bookmark. - -Needs w3m and emacs-w3m. - -http://w3m.sourceforge.net/ -http://emacs-w3m.namazu.org/ - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "helm-yaoddmuse" "helm-yaoddmuse.el" (21570 -;;;;;; 22531 0 0)) -;;; Generated autoloads from helm-yaoddmuse.el - -(autoload 'helm-yaoddmuse-cache-pages "helm-yaoddmuse" "\ -Fetch the list of files on emacswiki and create cache file. -If load is non--nil load the file and feed `yaoddmuse-pages-hash'. - -\(fn &optional LOAD)" t nil) - -(autoload 'helm-yaoddmuse-emacswiki-edit-or-view "helm-yaoddmuse" "\ -Preconfigured `helm' to edit or view EmacsWiki page. - -Needs yaoddmuse.el. - -http://www.emacswiki.org/emacs/download/yaoddmuse.el - -\(fn)" t nil) - -(autoload 'helm-yaoddmuse-emacswiki-post-library "helm-yaoddmuse" "\ -Preconfigured `helm' to post library to EmacsWiki. - -Needs yaoddmuse.el. - -http://www.emacswiki.org/emacs/download/yaoddmuse.el - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("helm-aliases.el" "helm-pkg.el" "helm-plugin.el" -;;;;;; "helm-source.el") (21570 22531 790254 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; helm-autoloads.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-bbdb.el b/emacs.d/elpa/helm-20141016.2217/helm-bbdb.el deleted file mode 100644 index abe00a5..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-bbdb.el +++ /dev/null @@ -1,185 +0,0 @@ -;;; helm-bbdb.el --- Helm interface for bbdb -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-mode) - -(defvar bbdb-records) -(defvar bbdb-buffer-name) - -(declare-function bbdb "ext:bbdb-com") -(declare-function bbdb-current-record "ext:bbdb-com") -(declare-function bbdb-redisplay-one-record "ext:bbdb-com") -(declare-function bbdb-record-net "ext:bbdb-com" (string) t) -(declare-function bbdb-current-record "ext:bbdb-com") -(declare-function bbdb-dwim-net-address "ext:bbdb-com") -(declare-function bbdb-records "ext:bbdb-com" - (&optional dont-check-disk already-in-db-buffer)) -(declare-function bbdb-label-completion-list "ext:bbdb" (field)) - -(defgroup helm-bbdb nil - "Commands and function for bbdb." - :group 'helm) - -(defun helm-bbdb-candidates () - "Return a list of all names in the bbdb database. -The format is \"Firstname Lastname\"." - (mapcar (lambda (bbdb-record) - (replace-regexp-in-string - "\\s-+$" "" - (concat (aref bbdb-record 0) " " (aref bbdb-record 1)))) - (bbdb-records))) - -(defun helm-bbdb-read-phone () - "Return a list of vector address objects. -See docstring of `bbdb-create-internal' for more info on address entries." - (cl-loop with loc-list = (cons "[Exit when no more]" - (bbdb-label-completion-list "phones")) - with loc ; Defer count - do (setq loc (helm-comp-read (format "Phone location[%s]: " count) - loc-list - :must-match 'confirm - :default "")) - while (not (string= loc "[Exit when no more]")) - for count from 1 - for phone-number = (helm-read-string (format "Phone number (%s): " loc)) - collect (vector loc phone-number) into phone-list - do (setq loc-list (remove loc loc-list)) - finally return phone-list)) - -;; TODO move this to helm-utils when finish -(defun helm-read-repeat-string (bbdb--prompt &optional count) - "Prompt as many time PROMPT is not empty. -If COUNT is non--nil add a number after each prompt." - (cl-loop with elm - while (not (string= elm "")) - for n from 1 - do (when count - (setq bbdb--prompt (concat bbdb--prompt (int-to-string n) ": "))) - collect (setq elm (helm-read-string bbdb--prompt)) into lis - finally return (remove "" lis))) - -(defun helm-bbdb-read-address () - "Return a list of vector address objects. -See docstring of `bbdb-create-internal' for more info on address entries." - (cl-loop with loc-list = (cons "[Exit when no more]" - (bbdb-label-completion-list "addresses")) - with loc ; Defer count - do (setq loc (helm-comp-read - (format "Address description[%s]: " - (int-to-string count)) - loc-list - :must-match 'confirm - :default "")) - while (not (string= loc "[Exit when no more]")) - for count from 1 - ;; Create vector - for lines = (helm-read-repeat-string "Line" t) - for city = (helm-read-string "City: ") - for state = (helm-read-string "State: ") - for zip = (helm-read-string "ZipCode: ") - for country = (helm-read-string "Country: ") - collect (vector loc lines city state zip country) into address-list - do (setq loc-list (remove loc loc-list)) - finally return address-list)) - -(defun helm-bbdb-create-contact (actions candidate) - "Action transformer for `helm-source-bbdb'. -Returns only an entry to add the current `helm-pattern' as new contact. -All other actions are removed." - (if (string= candidate "*Add to contacts*") - '(("Add to contacts" - . (lambda (actions) - (bbdb-create-internal - (read-from-minibuffer "Name: " helm-bbdb-name) - (read-from-minibuffer "Company: ") - (helm-read-repeat-string "Email " t) - (helm-bbdb-read-address) - (helm-bbdb-read-phone) - (read-from-minibuffer "Note: "))))) - actions)) - -(defun helm-bbdb-get-record (candidate) - "Return record that match CANDIDATE." - (bbdb candidate nil) - (set-buffer "*BBDB*") - (bbdb-current-record)) - -(defvar helm-bbdb-name nil - "Only for internal use.") - -(defvar helm-source-bbdb - '((name . "BBDB") - (candidates . helm-bbdb-candidates) - (action . (("Send a mail" . helm-bbdb-compose-mail) - ("View person's data" . helm-bbdb-view-person-action))) - (filtered-candidate-transformer . (lambda (candidates _source) - (setq helm-bbdb-name helm-pattern) - (if (not candidates) - (list "*Add to contacts*") - candidates))) - (action-transformer . (lambda (actions candidate) - (helm-bbdb-create-contact actions candidate)))) - "Needs BBDB. - -http://bbdb.sourceforge.net/") - -(defvar bbdb-append-records) -(defun helm-bbdb-view-person-action (candidate) - "View BBDB data of single CANDIDATE or marked candidates." - (helm-aif (helm-marked-candidates) - (let ((bbdb-append-records (length it))) - (cl-dolist (i it) - (bbdb-redisplay-one-record (helm-bbdb-get-record i)))) - (bbdb-redisplay-one-record (helm-bbdb-get-record candidate)))) - -(defun helm-bbdb-collect-mail-addresses () - "Return a list of all mail addresses of records in bbdb buffer." - (with-current-buffer bbdb-buffer-name - (cl-loop for i in bbdb-records - if (bbdb-record-net (car i)) - collect (bbdb-dwim-net-address (car i))))) - -(defun helm-bbdb-compose-mail (candidate) - "Compose a mail with all records of bbdb buffer." - (helm-bbdb-view-person-action candidate) - (let* ((address-list (helm-bbdb-collect-mail-addresses)) - (address-str (mapconcat 'identity address-list ",\n "))) - (compose-mail address-str))) - -;;;###autoload -(defun helm-bbdb () - "Preconfigured `helm' for BBDB. - -Needs BBDB. - -http://bbdb.sourceforge.net/" - (interactive) - (helm-other-buffer 'helm-source-bbdb "*helm bbdb*")) - -(provide 'helm-bbdb) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-bbdb ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-bookmark.el b/emacs.d/elpa/helm-20141016.2217/helm-bookmark.el deleted file mode 100644 index aaf1873..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-bookmark.el +++ /dev/null @@ -1,788 +0,0 @@ -;;; helm-bookmark.el --- Helm for Emacs regular Bookmarks. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'bookmark) -(require 'helm) -(require 'helm-utils) -(require 'helm-info) -(require 'helm-adaptive) - -(declare-function addressbook-bookmark-edit "ext:addressbook-bookmark.el" (bookmark)) - - -(defgroup helm-bookmark nil - "Predefined configurations for `helm.el'." - :group 'helm) - -(defcustom helm-bookmark-show-location nil - "Show location of bookmark on display." - :group 'helm-bookmark - :type 'boolean) - - -(defface helm-bookmark-info - '((t (:foreground "green"))) - "Face used for W3m Emacs bookmarks (not w3m bookmarks)." - :group 'helm-bookmark) - -(defface helm-bookmark-w3m - '((t (:foreground "yellow"))) - "Face used for W3m Emacs bookmarks (not w3m bookmarks)." - :group 'helm-bookmark) - -(defface helm-bookmark-gnus - '((t (:foreground "magenta"))) - "Face used for Gnus bookmarks." - :group 'helm-bookmark) - -(defface helm-bookmark-man - '((t (:foreground "Orange4"))) - "Face used for Woman/man bookmarks." - :group 'helm-bookmark) - -(defface helm-bookmark-file - '((t (:foreground "Deepskyblue2"))) - "Face used for file bookmarks." - :group 'helm-bookmark) - -(defface helm-bookmark-directory - '((t (:inherit helm-ff-directory))) - "Face used for file bookmarks." - :group 'helm-bookmark) - -(defface helm-bookmark-addressbook - '((t (:foreground "tomato"))) - "Face used for addressbook bookmarks." - :group 'helm-bookmark) - - -(defvar helm-bookmark-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c o") 'helm-bookmark-run-jump-other-window) - (define-key map (kbd "C-d") 'helm-bookmark-run-delete) - (define-key map (kbd "C-]") 'helm-bookmark-toggle-filename) - (define-key map (kbd "M-e") 'helm-bookmark-run-edit) - (define-key map (kbd "C-c ?") 'helm-bookmark-help) - map) - "Generic Keymap for emacs bookmark sources.") - -(defclass helm-source-basic-bookmarks (helm-source-in-buffer helm-type-bookmark) - ((init :initform (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global - (bookmark-all-names)))) - (filtered-candidate-transformer :initform 'helm-bookmark-transformer) - (search :initform 'helm-bookmark-search-fn))) - -(defvar helm-source-bookmarks - (helm-make-source "Bookmarks" 'helm-source-basic-bookmarks) - "See (info \"(emacs)Bookmarks\").") - -(defun helm-bookmark-transformer (candidates _source) - (cl-loop for i in candidates - for loc = (bookmark-location i) - for len = (string-width i) - for trunc = (if (> len bookmark-bmenu-file-column) - (helm-substring i bookmark-bmenu-file-column) - i) - for sep = (make-string (- (+ bookmark-bmenu-file-column 2) - (length trunc)) - ? ) - if helm-bookmark-show-location - collect (cons (concat trunc sep (if (listp loc) (car loc) loc)) i) - else collect i)) - -(defun helm-bookmark-match-fn (candidate) - "Match function for bookmark sources using `candidates'." - (if helm-bookmark-show-location - ;; match only location, match-plugin will match also name. - (string-match helm-pattern (bookmark-location candidate)) - (string-match helm-pattern candidate))) - -(defun helm-bookmark-toggle-filename () - "Toggle bookmark location visibility." - (interactive) - (with-helm-alive-p - (let* ((real (helm-get-selection helm-buffer)) - (trunc (if (> (string-width real) bookmark-bmenu-file-column) - (helm-substring real bookmark-bmenu-file-column) - real)) - (loc (bookmark-location real))) - (setq helm-bookmark-show-location (not helm-bookmark-show-location)) - (helm-force-update (if helm-bookmark-show-location - (concat (regexp-quote trunc) - " +" - (regexp-quote - (if (listp loc) (car loc) loc))) - real))))) - -(defun helm-bookmark-jump (candidate) - "Jump to bookmark from keyboard." - (let ((current-prefix-arg helm-current-prefix-arg) - non-essential) - (bookmark-jump candidate))) - -(defun helm-bookmark-jump-other-window (candidate) - (let (non-essential) - (bookmark-jump-other-window candidate))) - - -;;; bookmark-set -;; -(defvar helm-source-bookmark-set - '((name . "Set Bookmark") - (dummy) - (action . bookmark-set)) - "See (info \"(emacs)Bookmarks\").") - - -;;; Colorize bookmarks by category -;; -(defvar helm-source-pp-bookmarks - '((name . "PP-Bookmarks") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (cl-loop for b in (bookmark-all-names) collect - (propertize b 'location (bookmark-location b)))))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark)) - "See (info \"(emacs)Bookmarks\").") - -(defun helm-bookmark-search-fn (pattern) - "Search function for bookmark sources using `candidates-in-buffer'. -Should be used with `helm-pp-bookmark-match-fn' as `match-part' function." - (if helm-bookmark-show-location - (helm-aif (next-single-property-change (point) 'location) - (goto-char it)) - (re-search-forward pattern nil t))) - -(defun helm-pp-bookmark-match-fn (candidate) - "Search function for bookmark sources using `candidates-in-buffer'. -Should be used with `helm-bookmark-search-fn' as `search' function." - (helm-aif (and helm-bookmark-show-location - (bookmark-location candidate)) - ;; Match against bookmark-name and location. - (concat candidate " " it) - ;; Match against bookmark-name. - candidate)) - - -;;; Predicates -;; -(defconst helm-bookmark--non-file-filename " - no file -" - "Name to use for `filename' entry, for non-file bookmarks.") - -(defun helm-bookmark-gnus-bookmark-p (bookmark) - "Return non-nil if BOOKMARK is a Gnus bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-gnus) - (eq (bookmark-get-handler bookmark) 'gnus-summary-bookmark-jump) - (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-gnus))) - -(defun helm-bookmark-w3m-bookmark-p (bookmark) - "Return non-nil if BOOKMARK is a W3m bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-w3m) - (eq (bookmark-get-handler bookmark) 'bookmark-w3m-bookmark-jump) - (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-w3m))) - -(defun helm-bookmark-woman-bookmark-p (bookmark) - "Return non-nil if BOOKMARK is a Woman bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-woman) - (eq (bookmark-get-handler bookmark) 'woman-bookmark-jump) - (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-woman))) - -(defun helm-bookmark-man-bookmark-p (bookmark) - "Return non-nil if BOOKMARK is a Man bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-man) - (eq (bookmark-get-handler bookmark) 'Man-bookmark-jump) - (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-man))) - -(defun helm-bookmark-woman-man-bookmark-p (bookmark) - "Return non-nil if BOOKMARK is a Man or Woman bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (or (helm-bookmark-man-bookmark-p bookmark) - (helm-bookmark-woman-bookmark-p bookmark))) - -(defun helm-bookmark-info-bookmark-p (bookmark) - "Return non-nil if BOOKMARK is an Info bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (eq (bookmark-get-handler bookmark) 'Info-bookmark-jump)) - -(defun helm-bookmark-image-bookmark-p (bookmark) - "Return non-nil if BOOKMARK bookmarks an image file." - (if (stringp bookmark) - (assoc 'image-type (assoc bookmark bookmark-alist)) - (assoc 'image-type bookmark))) - -(defun helm-bookmark-file-p (bookmark) - "Return non-nil if BOOKMARK bookmarks a file or directory. -BOOKMARK is a bookmark name or a bookmark record. -This excludes bookmarks of a more specific kind (Info, Gnus, and W3m)." - (let* ((filename (bookmark-get-filename bookmark)) - (isnonfile (equal filename helm-bookmark--non-file-filename))) - (and filename (not isnonfile) (not (bookmark-get-handler bookmark))))) - -(defun helm-bookmark-addressbook-p (bookmark) - "Return non--nil if BOOKMARK is a contact recorded with addressbook-bookmark. -BOOKMARK is a bookmark name or a bookmark record." - (if (listp bookmark) - (string= (assoc-default 'type bookmark) "addressbook") - (string= (assoc-default - 'type (assoc bookmark bookmark-alist)) "addressbook"))) - -(defun helm-bookmark-uncategorized-bookmark-p (bookmark) - "Return non--nil if BOOKMARK match no known category." - (and (not (helm-bookmark-addressbook-p bookmark)) - (not (helm-bookmark-gnus-bookmark-p bookmark)) - (not (helm-bookmark-w3m-bookmark-p bookmark)) - (not (helm-bookmark-woman-man-bookmark-p bookmark)) - (not (helm-bookmark-info-bookmark-p bookmark)) - (not (helm-bookmark-image-bookmark-p bookmark)) - (not (helm-bookmark-file-p bookmark)) - (not (helm-bookmark-addressbook-p bookmark)))) - -(defun helm-bookmark-filter-setup-alist (fn) - "Return a filtered `bookmark-alist' sorted alphabetically." - (cl-loop with alist = (cl-loop for b in bookmark-alist - when (funcall fn b) collect b) - for bmk in alist - for name = (car bmk) - collect (propertize name 'location (bookmark-location name)))) - - -;;; Bookmark handlers -;; -(defvar w3m-async-exec) -(defun helm-bookmark-jump-w3m (bookmark) - "Jump to W3m bookmark BOOKMARK, setting a new tab. -If `browse-url-browser-function' is set to something else -than `w3m-browse-url' use it." - (require 'helm-net) - (let ((file (or (bookmark-prop-get bookmark 'filename) - (bookmark-prop-get bookmark 'url))) - (buf (generate-new-buffer-name "*w3m*")) - (w3m-async-exec nil) - (really-use-w3m (equal browse-url-browser-function 'w3m-browse-url))) - (helm-browse-url file really-use-w3m) - (when really-use-w3m - (bookmark-default-handler - `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))) - -;; All bookmarks recorded with the handler provided with w3m -;; (`bookmark-w3m-bookmark-jump') will use our handler which open -;; the bookmark in a new tab or in an external browser depending -;; on `browse-url-browser-function'. -(defalias 'bookmark-w3m-bookmark-jump 'helm-bookmark-jump-w3m) - -;; Provide compatibility with old handlers provided in external -;; packages bookmark-extensions.el and bookmark+. -(defalias 'bmkext-jump-woman 'woman-bookmark-jump) -(defalias 'bmkext-jump-man 'Man-bookmark-jump) -(defalias 'bmkext-jump-w3m 'helm-bookmark-jump-w3m) -(defalias 'bmkext-jump-gnus 'gnus-summary-bookmark-jump) -(defalias 'bookmarkp-jump-gnus 'gnus-summary-bookmark-jump) -(defalias 'bookmarkp-jump-w3m 'helm-bookmark-jump-w3m) -(defalias 'bookmarkp-jump-woman 'woman-bookmark-jump) -(defalias 'bookmarkp-jump-man 'Man-bookmark-jump) - - -;;;; Filtered bookmark sources - -;;; W3m bookmarks. -;; -(defvar helm-source-bookmark-w3m - '((name . "Bookmark W3m") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-w3m-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-w3m-setup-alist () - "Specialized filter function for bookmarks w3m." - (helm-bookmark-filter-setup-alist 'helm-bookmark-w3m-bookmark-p)) - -;;; Images -;; -(defvar helm-source-bookmark-images - '((name . "Bookmark Images") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-images-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-images-setup-alist () - "Specialized filter function for images bookmarks." - (helm-bookmark-filter-setup-alist 'helm-bookmark-image-bookmark-p)) - -;;; Woman Man -;; -(defvar helm-source-bookmark-man - '((name . "Bookmark Woman&Man") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-man-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-man-setup-alist () - "Specialized filter function for bookmarks w3m." - (helm-bookmark-filter-setup-alist 'helm-bookmark-woman-man-bookmark-p)) - -;;; Gnus -;; -(defvar helm-source-bookmark-gnus - '((name . "Bookmark Gnus") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-gnus-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-gnus-setup-alist () - "Specialized filter function for bookmarks gnus." - (helm-bookmark-filter-setup-alist 'helm-bookmark-gnus-bookmark-p)) - -;;; Info -;; -(defvar helm-source-bookmark-info - '((name . "Bookmark Info") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-info-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-info-setup-alist () - "Specialized filter function for bookmarks info." - (helm-bookmark-filter-setup-alist 'helm-bookmark-info-bookmark-p)) - -;;; Files and directories -;; -(defvar helm-source-bookmark-files&dirs - '((name . "Bookmark Files&Directories") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-local-files-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-local-files-setup-alist () - "Specialized filter function for bookmarks locals files." - (helm-bookmark-filter-setup-alist 'helm-bookmark-file-p)) - -;;; Addressbook. -;; -;; -(defvar helm-source-bookmark-addressbook - '((name . "Bookmark Addressbook") - (init . (lambda () - (require 'addressbook-bookmark nil t) - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global - (helm-bookmark-addressbook-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (persistent-action - . (lambda (candidate) - (let ((bmk (helm-bookmark-get-bookmark-from-name - candidate))) - (bookmark--jump-via bmk 'switch-to-buffer)))) - (persistent-help . "Show contact - Prefix with C-u to append") - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (action . (("Show Contact(s)" - . (lambda (candidate) - (let* ((contacts (helm-marked-candidates)) - (current-prefix-arg helm-current-prefix-arg)) - (bookmark-jump - (helm-bookmark-get-bookmark-from-name (car contacts))) - (helm-aif (cdr contacts) - (let ((current-prefix-arg '(4))) - (cl-loop for bmk in it do - (bookmark-jump - (helm-bookmark-get-bookmark-from-name bmk)))))))) - ("Send Mail" - . (lambda (candidate) - (let* ((contacts (helm-marked-candidates)) - (bmk (helm-bookmark-get-bookmark-from-name - (car contacts))) - (append (message-buffers))) - (if append - (addressbook-set-mail-buffer-1 bmk 'append) - (addressbook-set-mail-buffer-1 bmk)) - (setq contacts (cdr contacts)) - (when contacts - (cl-loop for bmk in contacts do - (addressbook-set-mail-buffer-1 bmk 'append)))))) - ("Edit Bookmark" - . (lambda (candidate) - (let ((bmk (helm-bookmark-get-bookmark-from-name - candidate))) - (addressbook-bookmark-edit - (assoc bmk bookmark-alist))))) - ("Delete bookmark(s)" . helm-delete-marked-bookmarks) - ("Insert Email at point" - . (lambda (candidate) - (let* ((bmk (helm-bookmark-get-bookmark-from-name - candidate)) - (mlist (split-string - (assoc-default - 'email (assoc bmk bookmark-alist)) - ", "))) - (insert - (if (> (length mlist) 1) - (helm-comp-read - "Insert Mail Address: " mlist :must-match t) - (car mlist)))))) - ("Show annotation" - . (lambda (candidate) - (let ((bmk (helm-bookmark-get-bookmark-from-name - candidate))) - (bookmark-show-annotation bmk)))) - ("Edit annotation" - . (lambda (candidate) - (let ((bmk (helm-bookmark-get-bookmark-from-name - candidate))) - (bookmark-edit-annotation bmk)))) - ("Show Google map" - . (lambda (candidate) - (let* ((bmk (helm-bookmark-get-bookmark-from-name - candidate)) - (full-bmk (assoc bmk bookmark-alist))) - (addressbook-google-map full-bmk)))))))) - -(defun helm-bookmark-addressbook-setup-alist () - "Specialized filter function for addressbook bookmarks." - (helm-bookmark-filter-setup-alist 'helm-bookmark-addressbook-p)) - -(defvar helm-source-bookmark-uncategorized - '((name . "Bookmark uncategorized") - (init . (lambda () - (bookmark-maybe-load-default-file) - (helm-init-candidates-in-buffer - 'global (helm-bookmark-uncategorized-setup-alist)))) - (candidates-in-buffer) - (search helm-bookmark-search-fn) - (match-part . helm-pp-bookmark-match-fn) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-bookmark) - (type . bookmark))) - -(defun helm-bookmark-uncategorized-setup-alist () - "Specialized filter function for uncategorized bookmarks." - (helm-bookmark-filter-setup-alist 'helm-bookmark-uncategorized-bookmark-p)) - -;;; Transformer -;; - -(defun helm-highlight-bookmark (bookmarks _source) - "Used as `filtered-candidate-transformer' to colorize bookmarks. -Work both with standard Emacs bookmarks and bookmark-extensions.el." - (let ((non-essential t)) - (cl-loop for i in bookmarks - for isfile = (bookmark-get-filename i) - for handlerp = (and (fboundp 'bookmark-get-handler) - (bookmark-get-handler i)) - for isw3m = (and (fboundp 'helm-bookmark-w3m-bookmark-p) - (helm-bookmark-w3m-bookmark-p i)) - for isgnus = (and (fboundp 'helm-bookmark-gnus-bookmark-p) - (helm-bookmark-gnus-bookmark-p i)) - for isman = (and (fboundp 'helm-bookmark-man-bookmark-p) ; Man - (helm-bookmark-man-bookmark-p i)) - for iswoman = (and (fboundp 'helm-bookmark-woman-bookmark-p) ; Woman - (helm-bookmark-woman-bookmark-p i)) - for isannotation = (bookmark-get-annotation i) - for isabook = (string= (bookmark-prop-get i 'type) - "addressbook") - for isinfo = (eq handlerp 'Info-bookmark-jump) - for loc = (bookmark-location i) - for len = (string-width i) - for trunc = (if (and helm-bookmark-show-location - (> len bookmark-bmenu-file-column)) - (helm-substring - i bookmark-bmenu-file-column) - i) - ;; Add a * if bookmark have annotation - if (and isannotation (not (string-equal isannotation ""))) - do (setq trunc (concat "*" (if helm-bookmark-show-location trunc i))) - for sep = (and helm-bookmark-show-location - (make-string (- (+ bookmark-bmenu-file-column 2) - (string-width trunc)) - ? )) - for bmk = (cond ( ;; info buffers - isinfo - (propertize trunc 'face 'helm-bookmark-info - 'help-echo isfile)) - ( ;; w3m buffers - isw3m - (propertize trunc 'face 'helm-bookmark-w3m - 'help-echo isfile)) - ( ;; gnus buffers - isgnus - (propertize trunc 'face 'helm-bookmark-gnus - 'help-echo isfile)) - ( ;; Man Woman - (or iswoman isman) - (propertize trunc 'face 'helm-bookmark-man - 'help-echo isfile)) - ( ;; Addressbook - isabook - (propertize trunc 'face 'helm-bookmark-addressbook)) - ( ;; directories - (and isfile - ;; This is needed because `non-essential' - ;; is not working on Emacs-24.2 and the behavior - ;; of tramp seems to have changed since previous - ;; versions (Need to reenter password even if a - ;; first connection have been established, - ;; probably when host is named differently - ;; i.e machine/localhost) - (not (file-remote-p isfile)) - (file-directory-p isfile)) - (propertize trunc 'face 'helm-bookmark-directory - 'help-echo isfile)) - ( ;; regular files - t - (propertize trunc 'face 'helm-bookmark-file - 'help-echo isfile))) - collect (if helm-bookmark-show-location - (cons (concat bmk sep (if (listp loc) (car loc) loc)) - i) - (cons bmk i))))) - -(defun helm-bookmark-edit-bookmark (bookmark-name) - "Edit bookmark's name and file name, and maybe save them. -BOOKMARK-NAME is the current (old) name of the bookmark to be renamed." - (let ((bmk (helm-bookmark-get-bookmark-from-name bookmark-name)) - (handler (bookmark-prop-get bookmark-name 'handler))) - (if (eq handler 'addressbook-bookmark-jump) - (addressbook-bookmark-edit - (assoc bmk bookmark-alist)) - (helm-bookmark-edit-bookmark-1 bookmark-name handler)))) - -(defun helm-bookmark-edit-bookmark-1 (bookmark-name handler) - (let* ((helm--reading-passwd-or-string t) - (bookmark-fname (bookmark-get-filename bookmark-name)) - (bookmark-loc (bookmark-prop-get bookmark-name 'location)) - (new-name (read-from-minibuffer "Name: " bookmark-name)) - (new-loc (read-from-minibuffer "FileName or Location: " - (or bookmark-fname - (if (consp bookmark-loc) - (car bookmark-loc) - bookmark-loc)))) - (docid (and (eq handler 'mu4e-bookmark-jump) - (read-number "Docid: " (cdr bookmark-loc))))) - (when docid - (setq new-loc (cons new-loc docid))) - (when (and (not (equal new-name "")) (not (equal new-loc "")) - (y-or-n-p "Save changes? ")) - (if bookmark-fname - (progn - (helm-bookmark-rename bookmark-name new-name 'batch) - (bookmark-set-filename new-name new-loc)) - (bookmark-prop-set - (bookmark-get-bookmark bookmark-name) 'location new-loc) - (helm-bookmark-rename bookmark-name new-name 'batch)) - (helm-bookmark-maybe-save-bookmark) - (list new-name new-loc)))) - -(defun helm-bookmark-maybe-save-bookmark () - "Increment save counter and maybe save `bookmark-alist'." - (setq bookmark-alist-modification-count (1+ bookmark-alist-modification-count)) - (when (bookmark-time-to-save-p) (bookmark-save))) - -(defun helm-bookmark-rename (old &optional new batch) - "Change bookmark's name from OLD to NEW. -Interactively: - If called from the keyboard, then prompt for OLD. - If called from the menubar, select OLD from a menu. -If NEW is nil, then prompt for its string value. - -If BATCH is non-nil, then do not rebuild the menu list. - -While the user enters the new name, repeated `C-w' inserts consecutive -words from the buffer into the new bookmark name." - (interactive (list (bookmark-completing-read "Old bookmark name"))) - (bookmark-maybe-historicize-string old) - (bookmark-maybe-load-default-file) - (save-excursion (skip-chars-forward " ") (setq bookmark-yank-point (point))) - (setq bookmark-current-buffer (current-buffer)) - (let ((newname (or new (read-from-minibuffer - "New name: " nil - (let ((now-map (copy-keymap minibuffer-local-map))) - (define-key now-map "\C-w" 'bookmark-yank-word) - now-map) - nil 'bookmark-history)))) - (bookmark-set-name old newname) - (setq bookmark-current-bookmark newname) - (unless batch (bookmark-bmenu-surreptitiously-rebuild-list)) - (helm-bookmark-maybe-save-bookmark) newname)) - -(defun helm-bookmark-run-edit () - "Run `helm-bookmark-edit-bookmark' from keyboard." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-bookmark-edit-bookmark))) - - -;;; Bookmarks attributes -;; -(define-helm-type-attribute 'bookmark - `((coerce . helm-bookmark-get-bookmark-from-name) - (action . ,(helm-make-actions - "Jump to bookmark" 'helm-bookmark-jump - "Jump to BM other window" 'helm-bookmark-jump-other-window - "Bookmark edit annotation" 'bookmark-edit-annotation - "Bookmark show annotation" 'bookmark-show-annotation - "Delete bookmark(s)" 'helm-delete-marked-bookmarks - "Edit Bookmark" 'helm-bookmark-edit-bookmark - "Rename bookmark" 'helm-bookmark-rename - "Relocate bookmark" 'bookmark-relocate)) - (keymap . ,helm-bookmark-map) - (mode-line . helm-bookmark-mode-line-string)) - "Bookmark name.") - - -(defun helm-bookmark-run-jump-other-window () - "Jump to bookmark from keyboard." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'bookmark-jump-other-window))) - -(defun helm-bookmark-run-delete () - "Delete bookmark from keyboard." - (interactive) - (with-helm-alive-p - (when (y-or-n-p "Delete bookmark(s)?") - (helm-quit-and-execute-action 'helm-delete-marked-bookmarks)))) - -(defun helm-bookmark-get-bookmark-from-name (bmk) - "Return bookmark name even if it is a bookmark with annotation. -e.g prepended with *." - (let ((bookmark (replace-regexp-in-string "\\`\\*" "" bmk))) - (if (assoc bookmark bookmark-alist) bookmark bmk))) - -(defun helm-delete-marked-bookmarks (_ignore) - "Delete this bookmark or all marked bookmarks." - (cl-dolist (i (helm-marked-candidates)) - (bookmark-delete (helm-bookmark-get-bookmark-from-name i) - 'batch))) - - -;;;###autoload -(defun helm-bookmarks () - "Preconfigured `helm' for bookmarks." - (interactive) - (helm :sources '(helm-source-bookmarks - helm-source-bookmark-set) - :buffer "*helm bookmarks*" - :default (buffer-name helm-current-buffer))) - -;;;###autoload -(defun helm-pp-bookmarks () - "Preconfigured `helm' for bookmarks (pretty-printed)." - (interactive) - (helm :sources '(helm-source-pp-bookmarks - helm-source-bookmark-set) - :buffer "*helm pp bookmarks*" - :default (buffer-name helm-current-buffer))) - -;;;###autoload -(defun helm-filtered-bookmarks () - "Preconfigured helm for bookmarks (filtered by category). -Optional source `helm-source-bookmark-addressbook' is loaded -only if external library addressbook-bookmark.el is available." - (interactive) - (helm :sources (append '(helm-source-bookmark-files&dirs - helm-source-bookmark-info - helm-source-bookmark-gnus - helm-source-bookmark-man - helm-source-bookmark-images - helm-source-bookmark-w3m) - (and (locate-library "addressbook-bookmark") - (list 'helm-source-bookmark-addressbook)) - (list helm-source-bookmark-uncategorized - 'helm-source-bookmark-set)) - :prompt "Search Bookmark: " - :buffer "*helm filtered bookmarks*" - :default (list (thing-at-point 'symbol) - (buffer-name helm-current-buffer)))) - -(provide 'helm-bookmark) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-bookmark.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-buffers.el b/emacs.d/elpa/helm-20141016.2217/helm-buffers.el deleted file mode 100644 index 9c71558..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-buffers.el +++ /dev/null @@ -1,794 +0,0 @@ -;;; helm-buffers.el --- helm support for buffers. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-elscreen) -(require 'helm-grep) -(require 'helm-plugin) -(require 'helm-regexp) - -(declare-function ido-make-buffer-list "ido" (default)) - -(defgroup helm-buffers nil - "Buffers related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-boring-buffer-regexp-list - '("\\` " "\\*helm" "\\*helm-mode" "\\*Echo Area" "\\*Minibuf") - "The regexp list that match boring buffers. -Buffer candidates matching these regular expression will be -filtered from the list of candidates if the -`helm-skip-boring-buffers' candidate transformer is used." - :type '(repeat (choice regexp)) - :group 'helm-buffers) - -(defcustom helm-buffers-favorite-modes '(lisp-interaction-mode - emacs-lisp-mode - text-mode - org-mode) - "List of preferred mode to open new buffers with." - :type '(repeat (choice function)) - :group 'helm-buffers) - -(defcustom helm-buffer-max-length 20 - "Max length of buffer names before truncate. -When disabled (nil) use the longest buffer-name length found." - :group 'helm-buffers - :type '(choice (const :tag "Disabled" nil) - (integer :tag "Length before truncate"))) - -(defcustom helm-buffer-details-flag t - "Always show details in buffer list when non--nil." - :group 'helm-buffers - :type 'boolean) - -(defcustom helm-buffers-fuzzy-matching nil - "Fuzzy matching buffer names when non--nil. -Only buffer names are fuzzy matched when this is enabled, -`major-mode' matching is not affected by this." - :group 'helm-buffers - :type 'boolean) - - -;;; Faces -;; -;; -(defface helm-buffer-saved-out - '((t (:foreground "red" :background "black"))) - "Face used for buffer files modified outside of emacs." - :group 'helm-buffers) - -(defface helm-buffer-not-saved - '((t (:foreground "Indianred2"))) - "Face used for buffer files not already saved on disk." - :group 'helm-buffers) - -(defface helm-buffer-size - '((((background dark)) :foreground "RosyBrown") - (((background light)) :foreground "SlateGray")) - "Face used for buffer size." - :group 'helm-buffers) - -(defface helm-buffer-process - '((t (:foreground "Sienna3"))) - "Face used for process status in buffer." - :group 'helm-buffers) - -(defface helm-buffer-directory - '((t (:foreground "DarkRed" :background "LightGray"))) - "Face used for directories in `helm-buffers-list'." - :group 'helm-buffers) - -(defface helm-buffer-file - '((t :inherit font-lock-type-face)) - "Face for buffer file names in `helm-buffers-list'." - :group 'helm-buffers) - - -;;; Buffers keymap -;; -(defvar helm-buffer-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-buffer-help) - ;; No need to have separate command for grep and zgrep - ;; as we don't use recursivity for buffers. - ;; So use zgrep for both as it is capable to handle non--compressed files. - (define-key map (kbd "M-g s") 'helm-buffer-run-zgrep) - (define-key map (kbd "C-s") 'helm-buffers-run-multi-occur) - (define-key map (kbd "C-c o") 'helm-buffer-switch-other-window) - (define-key map (kbd "C-c C-o") 'helm-buffer-switch-other-frame) - (define-key map (kbd "C-c =") 'helm-buffer-run-ediff) - (define-key map (kbd "M-=") 'helm-buffer-run-ediff-merge) - (define-key map (kbd "C-=") 'helm-buffer-diff-persistent) - (define-key map (kbd "M-U") 'helm-buffer-revert-persistent) - (define-key map (kbd "C-c d") 'helm-buffer-run-kill-persistent) - (define-key map (kbd "M-D") 'helm-buffer-run-kill-buffers) - (define-key map (kbd "C-x C-s") 'helm-buffer-save-persistent) - (define-key map (kbd "C-M-%") 'helm-buffer-run-query-replace-regexp) - (define-key map (kbd "M-%") 'helm-buffer-run-query-replace) - (define-key map (kbd "M-m") 'helm-toggle-all-marks) - (define-key map (kbd "M-a") 'helm-mark-all) - (define-key map (kbd "C-]") 'helm-toggle-buffers-details) - (define-key map (kbd "C-c a") 'helm-buffers-toggle-show-hidden-buffers) - (define-key map (kbd "") 'helm-buffers-mark-similar-buffers) - map) - "Keymap for buffer sources in helm.") - -(defvar helm-buffers-ido-virtual-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-buffers-ido-virtual-help) - (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) - (define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame) - (define-key map (kbd "M-g s") 'helm-ff-run-grep) - (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) - (define-key map (kbd "M-D") 'helm-ff-run-delete-file) - (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) - map)) - - -(defvar helm-buffers-list-cache nil) -(defvar helm-buffer-max-len-mode nil) -(defclass helm-source-buffers (helm-source-sync helm-type-buffer) - ((init :initform (lambda () - ;; Issue #51 Create the list before `helm-buffer' creation. - (setq helm-buffers-list-cache (helm-buffer-list)) - (let ((result (cl-loop for b in helm-buffers-list-cache - maximize (length b) into len-buf - maximize (length (with-current-buffer b - (symbol-name major-mode))) - into len-mode - finally return (cons len-buf len-mode)))) - (unless helm-buffer-max-length - (setq helm-buffer-max-length (car result))) - (unless helm-buffer-max-len-mode - ;; If a new buffer is longer that this value - ;; this value will be updated - (setq helm-buffer-max-len-mode (cdr result)))))) - (candidates :initform helm-buffers-list-cache) - (matchplugin :initform nil) - (match :initform 'helm-buffers-list--match-fn) - (persistent-action :initform 'helm-buffers-list-persistent-action) - (keymap :initform helm-buffer-map) - (volatile :initform t) - (mode-line :initform helm-buffer-mode-line-string) - (persistent-help - :initform - "Show this buffer / C-u \\[helm-execute-persistent-action]: Kill this buffer"))) - -(defvar helm-source-buffers-list (helm-make-source "Buffers" 'helm-source-buffers)) - -(defvar helm-source-buffer-not-found - (helm-build-dummy-source - "Create buffer" - :action (lambda (candidate) - (let ((mjm (and helm-current-prefix-arg - (intern-soft (helm-comp-read - "Major-mode: " - helm-buffers-favorite-modes)))) - (buffer (get-buffer-create candidate))) - (if mjm - (with-current-buffer buffer (funcall mjm)) - (set-buffer-major-mode buffer)) - (helm-switch-to-buffer buffer))))) - -(defvar ido-temp-list) -(defvar ido-ignored-list) -(defvar ido-process-ignore-lists) - -(defvar helm-source-ido-virtual-buffers - `((name . "Ido virtual buffers") - (candidates . (lambda () - (let (ido-temp-list - ido-ignored-list - (ido-process-ignore-lists t)) - (when ido-use-virtual-buffers - (ido-add-virtual-buffers-to-list) - ido-virtual-buffers)))) - (keymap . ,helm-buffers-ido-virtual-map) - (mode-line . helm-buffers-ido-virtual-mode-line-string) - (action . (("Find file" . helm-find-many-files) - ("Find file other window" . find-file-other-window) - ("Find file other frame" . find-file-other-frame) - ("Find file as root" . helm-find-file-as-root) - ("Grep File(s) `C-u recurse'" . helm-find-files-grep) - ("Zgrep File(s) `C-u Recurse'" . helm-ff-zgrep) - ("View file" . view-file) - ("Delete file(s)" . helm-delete-marked-files) - ("Open file externally (C-u to choose)" - . helm-open-file-externally))))) - - -(defvar ido-use-virtual-buffers) -(defun helm-buffer-list () - "Return the current list of buffers. -Currently visible buffers are put at the end of the list. -See `ido-make-buffer-list' for more infos." - (require 'ido) - (let ((ido-process-ignore-lists t) - ido-ignored-list - ido-use-virtual-buffers) - (ido-make-buffer-list nil))) - -(defun helm-buffer-size (buffer) - "Return size of BUFFER." - (with-current-buffer buffer - (save-restriction - (widen) - (helm-file-human-size - (- (position-bytes (point-max)) - (position-bytes (point-min))))))) - -(defun helm-buffer--show-details (buf-name prefix help-echo - size mode dir face1 face2 - proc details type) - (append - (list - (concat prefix - (propertize buf-name 'face face1 - 'help-echo help-echo - 'type type))) - (and details - (list size mode - (propertize - (if proc - (format "(%s %s in `%s')" - (process-name proc) - (process-status proc) dir) - (format "(in `%s')" dir)) - 'face face2))))) - -(defun helm-buffer--details (buffer &optional details) - (let* ((mode (with-current-buffer buffer (format-mode-line mode-name))) - (buf (get-buffer buffer)) - (size (propertize (helm-buffer-size buf) - 'face 'helm-buffer-size)) - (proc (get-buffer-process buf)) - (dir (with-current-buffer buffer (abbreviate-file-name default-directory))) - (file-name (helm-aif (buffer-file-name buf) (abbreviate-file-name it))) - (name (buffer-name buf)) - (name-prefix (when (file-remote-p dir) - (propertize "@ " 'face 'helm-ff-prefix)))) - (cond - ( ;; A dired buffer. - (rassoc buf dired-buffers) - (helm-buffer--show-details - name name-prefix dir size mode dir - 'helm-buffer-directory 'helm-buffer-process nil details 'dired)) - ;; A buffer file modified somewhere outside of emacs.=>red - ((and file-name (file-exists-p file-name) - (not (verify-visited-file-modtime buf))) - (helm-buffer--show-details - name name-prefix file-name size mode dir - 'helm-buffer-saved-out 'helm-buffer-process nil details 'modout)) - ;; A new buffer file not already saved on disk.=>indianred2 - ((and file-name (not (verify-visited-file-modtime buf))) - (helm-buffer--show-details - name name-prefix file-name size mode dir - 'helm-buffer-not-saved 'helm-buffer-process nil details 'notsaved)) - ;; A buffer file modified and not saved on disk.=>orange - ((and file-name (buffer-modified-p buf)) - (helm-buffer--show-details - name name-prefix file-name size mode dir - 'helm-ff-symlink 'helm-buffer-process nil details 'mod)) - ;; A buffer file not modified and saved on disk.=>green - (file-name - (helm-buffer--show-details - name name-prefix file-name size mode dir - 'helm-buffer-file 'helm-buffer-process nil details 'filebuf)) - ;; Any non--file buffer.=>grey italic - (t - (helm-buffer--show-details - name (and proc name-prefix) dir size mode dir - 'italic 'helm-buffer-process proc details 'nofile))))) - -(defun helm-highlight-buffers (buffers _source) - "Transformer function to highlight BUFFERS list. -Should be called after others transformers i.e (boring buffers)." - (cl-loop for i in buffers - for (name size mode meta) = (if helm-buffer-details-flag - (helm-buffer--details i 'details) - (helm-buffer--details i)) - for truncbuf = (if (> (string-width name) helm-buffer-max-length) - (helm-substring-by-width - name helm-buffer-max-length) - (concat name (make-string - (- (+ helm-buffer-max-length 3) - (string-width name)) ? ))) - for len = (length mode) - when (> len helm-buffer-max-len-mode) - do (setq helm-buffer-max-len-mode len) - for fmode = (concat (make-string - (- (max helm-buffer-max-len-mode len) len) ? ) - mode) - ;; The max length of a number should be 1023.9X where X is the - ;; units, this is 7 characters. - for formatted-size = (and size (format "%7s" size)) - collect (cons (if helm-buffer-details-flag - (concat truncbuf "\t" formatted-size - " " fmode " " meta) - name) - i))) - -(defun helm-buffer--get-preselection (buffer-name) - (concat "^" - (if (and (null helm-buffer-details-flag) - (numberp helm-buffer-max-length) - (> (string-width buffer-name) - helm-buffer-max-length)) - (regexp-quote - (helm-substring-by-width - buffer-name helm-buffer-max-length)) - (concat (regexp-quote buffer-name) - (if helm-buffer-details-flag - "$" "[[:blank:]]+"))))) - -(defun helm-toggle-buffers-details () - (interactive) - (let ((preselect (helm-buffer--get-preselection - (helm-get-selection)))) - (when helm-alive-p - (setq helm-buffer-details-flag (not helm-buffer-details-flag)) - (helm-force-update preselect)))) - -(defun helm-buffers-sort-transformer (candidates _source) - (if (string= helm-pattern "") - candidates - (sort candidates - #'(lambda (s1 s2) - (< (string-width s1) (string-width s2)))))) - -(defun helm-buffers-mark-similar-buffers-1 () - (with-helm-window - (let ((type (get-text-property - 0 'type (helm-get-selection nil 'withprop)))) - (save-excursion - (goto-char (helm-get-previous-header-pos)) - (helm-next-line) - (let* ((next-head (helm-get-next-header-pos)) - (end (and next-head - (save-excursion - (goto-char next-head) - (forward-line -1) - (point)))) - (maxpoint (or end (point-max)))) - (while (< (point) maxpoint) - (helm-mark-current-line) - (let ((cand (helm-get-selection nil 'withprop))) - (when (and (not (helm-this-visible-mark)) - (eq (get-text-property 0 'type cand) type)) - (helm-make-visible-mark))) - (forward-line 1) (end-of-line)))) - (helm-mark-current-line) - (message "%s candidates marked" (length helm-marked-candidates))))) - -(defun helm-buffers-mark-similar-buffers () - "Mark All buffers that have same property `type' than current. -i.e same color." - (interactive) - (let ((marked (helm-marked-candidates))) - (if (and (>= (length marked) 1) - (with-helm-window helm-visible-mark-overlays)) - (helm-unmark-all) - (helm-buffers-mark-similar-buffers-1)))) - - -;;; match functions -;; -(defun helm-buffer--match-mjm (pattern mjm) - (when (string-match "\\`\\*" pattern) - (setq pattern (split-string (substring pattern 1) ",")) - (cl-loop for pat in pattern - if (string-match "\\`!" pat) - collect (string-match (substring pat 1) mjm) into neg - else collect (string-match pat mjm) into pos - finally return - (or (and pos (cl-loop for i in pos - thereis (numberp i))) - (and neg (not (cl-loop for i in neg - thereis (numberp i)))))))) - -(defun helm-buffer--match-pattern (pattern candidate) - (let ((fun (if (and helm-buffers-fuzzy-matching - (not (string-match "\\`\\^" pattern))) - #'helm--mapconcat-candidate - #'identity))) - (if (string-match "\\`!" pattern) - (not (string-match (funcall fun (substring pattern 1)) - candidate)) - (string-match (funcall fun pattern) candidate)))) - -(defun helm-buffers-list--match-fn (candidate) - "Match maybe buffer by major-mode. -If you give a major-mode or partial major-mode, -it will list all buffers of this major-mode and/or buffers with name -matching this major-mode. -If you add a space after major-mode and then a space, -it will match all buffers of the major-mode -before space matching pattern after space. -If you give a pattern which doesn't match a major-mode, it will search buffer -with name matching pattern." - (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate)) - (buf (get-buffer cand)) - (buf-fname (buffer-file-name buf))) - (when buf - (with-current-buffer buf - (let ((mjm (format-mode-line mode-name)) - (split (split-string helm-pattern))) - (cond ((string-match "^@" helm-pattern) ; match inside. - (or (helm-buffers-match-inside cand split) - (helm-buffer--match-pattern helm-pattern cand))) - ;; Continue showing buffer after mjm matching and a space. - ((string-match "\\`\\*.*\\s-$" helm-pattern) - (helm-buffer--match-mjm (car split) mjm)) - ((and (string-match "\\s-[@]" helm-pattern) (cdr split)) - (and (or (helm-buffer--match-mjm (car split) mjm) - (and buf-fname - (string-match "\\`/" helm-pattern) - (string-match - (substring (car split) 1) - (helm-basedir buf-fname))) - (helm-buffer--match-pattern (car split) cand)) - (helm-buffers-match-inside cand (cdr split)))) - ;; Continue showing buffers after entering @ after a space. - ((string-match "\\s-[@]" helm-pattern) - (or (helm-buffer--match-mjm (car split) mjm) - (and buf-fname - (string-match "\\`/" helm-pattern) - (string-match - (substring (car split) 1) - (helm-basedir buf-fname))) - (helm-buffer--match-pattern (car split) cand))) - ;; Match on major-mode and multiple patterns. - ((and (string-match "\\`\\*" helm-pattern) (cdr split)) - (and (helm-buffer--match-mjm (car split) mjm) - (cl-loop for i in (cdr split) always - (helm-buffer--match-pattern i cand)))) - ;; Match only on major-mode. - ((string-match "\\`\\*" helm-pattern) - (helm-buffer--match-mjm (car split) mjm)) - ;; Match on dir of buffer-file-name and multiple patterns. - ((and (string-match "\\`/" helm-pattern) buf-fname (cdr split)) - ;; Exact match for this is better to match end of dir [1]. - (and (string-match - (substring (car split) 1) (helm-basedir buf-fname)) - (cl-loop for i in (cdr split) always - (helm-buffer--match-pattern i cand)))) - ;; Match only on dir of buffer-file-name. - ((and (string-match "\\`/" helm-pattern) buf-fname) - ;; [1] same. - (string-match - (substring (car split) 1) (helm-basedir buf-fname))) - ;; Normal string matching on multiple patterns. - ((string-match "\\s-" helm-pattern) - (cl-loop for i in split always - (helm-buffer--match-pattern i cand))) - ;; Normal string matching. - (t (helm-buffer--match-pattern helm-pattern cand)))))))) - -(defun helm-buffers-match-inside (candidate lst) - (cl-loop for i in lst always - (cond ((string-match "\\`[\\]@" i) - (helm-buffer--match-pattern i candidate)) - ((string-match "\\`@\\(.*\\)" i) - (save-excursion - (let ((str (match-string 1 i))) - (goto-char (point-min)) - (re-search-forward str nil t)))) - (t (helm-buffer--match-pattern i candidate))))) - - -(defun helm-buffer-query-replace-1 (&optional regexp-flag) - "Query replace in marked buffers. -If REGEXP-FLAG is given use `query-replace-regexp'." - (let ((fn (if regexp-flag 'query-replace-regexp 'query-replace)) - (prompt (if regexp-flag "Query replace regexp" "Query replace")) - (bufs (helm-marked-candidates)) - (helm--reading-passwd-or-string t)) - (cl-loop with replace = (query-replace-read-from prompt regexp-flag) - with tostring = (unless (consp replace) - (query-replace-read-to - replace prompt regexp-flag)) - for buf in bufs - do - (save-window-excursion - (helm-switch-to-buffer buf) - (save-excursion - (let ((case-fold-search t)) - (goto-char (point-min)) - (if (consp replace) - (apply fn (list (car replace) (cdr replace))) - (apply fn (list replace tostring))))))))) - -(defun helm-buffer-query-replace-regexp (_candidate) - (helm-buffer-query-replace-1 'regexp)) - -(defun helm-buffer-query-replace (_candidate) - (helm-buffer-query-replace-1)) - -(defun helm-buffer-toggle-diff (candidate) - "Toggle diff buffer CANDIDATE with it's file." - (let (helm-persistent-action-use-special-display) - (helm-aif (get-buffer-window "*Diff*") - (progn (kill-buffer "*Diff*") - (set-window-buffer it helm-current-buffer)) - (diff-buffer-with-file (get-buffer candidate))))) - -(defun helm-buffer-diff-persistent () - "Toggle diff buffer without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'diff-action 'helm-buffer-toggle-diff) - (helm-execute-persistent-action 'diff-action))) - -(defun helm-revert-buffer (candidate) - (with-current-buffer candidate - (helm-aif (buffer-file-name) - (and (file-exists-p it) (revert-buffer t t))))) - -(defun helm-revert-marked-buffers (_ignore) - (mapc 'helm-revert-buffer (helm-marked-candidates))) - -(defun helm-buffer-revert-and-update (_candidate) - (let ((marked (helm-marked-candidates)) - (preselect (helm-get-selection nil t))) - (cl-loop for buf in marked do (helm-revert-buffer buf)) - (when (> (length marked) 1) (helm-unmark-all)) - (helm-force-update (regexp-quote preselect)))) - -(defun helm-buffer-revert-persistent () - "Revert buffer without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'revert-action '(helm-buffer-revert-and-update . never-split)) - (helm-execute-persistent-action 'revert-action))) - -(defun helm-buffer-save-and-update (_candidate) - (let ((marked (helm-marked-candidates)) - (preselect (helm-get-selection nil t)) - (enable-recursive-minibuffers t)) - (cl-loop for buf in marked do - (with-current-buffer (get-buffer buf) - (when (buffer-file-name) (save-buffer)))) - (when (> (length marked) 1) (helm-unmark-all)) - (helm-force-update (regexp-quote preselect)))) - -(defun helm-buffer-save-persistent () - "Save buffer without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'save-action '(helm-buffer-save-and-update . never-split)) - (helm-execute-persistent-action 'save-action))) - -(defun helm-buffer-run-kill-persistent () - "Kill buffer without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'kill-action '(helm-buffers-persistent-kill . never-split)) - (helm-execute-persistent-action 'kill-action))) - -(defun helm-kill-marked-buffers (_ignore) - (mapc 'kill-buffer (helm-marked-candidates))) - -(defun helm-buffer-run-kill-buffers () - "Run kill buffer action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-kill-marked-buffers))) - -(defun helm-buffer-run-grep () - "Run Grep action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-grep-buffers))) - -(defun helm-buffer-run-zgrep () - "Run Grep action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-zgrep-buffers))) - -(defun helm-buffer-run-query-replace-regexp () - "Run Query replace regexp action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-buffer-query-replace-regexp))) - -(defun helm-buffer-run-query-replace () - "Run Query replace action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-buffer-query-replace))) - -(defun helm-buffer-switch-other-window () - "Run switch to other window action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'switch-to-buffer-other-window))) - -(defun helm-buffer-switch-other-frame () - "Run switch to other frame action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'switch-to-buffer-other-frame))) - -(defun helm-buffer-switch-to-elscreen () - "Run switch to elscreen action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-buffer-on-elscreen))) - -(defun helm-buffer-run-ediff () - "Run ediff action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ediff-marked-buffers))) - -(defun helm-buffer-run-ediff-merge () - "Run ediff action from `helm-source-buffers-list'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ediff-marked-buffers-merge))) - -(defun helm-buffers-persistent-kill (buffer) - "Persistent action to kill buffer." - (with-current-buffer (get-buffer buffer) - (if (and (buffer-modified-p) - (buffer-file-name (current-buffer))) - (progn - (save-buffer) - (kill-buffer buffer)) - (kill-buffer buffer))) - (helm-delete-current-selection) - (when (helm-empty-source-p) (helm-next-source)) - (with-helm-temp-hook 'helm-after-persistent-action-hook - (helm-force-update (regexp-quote (helm-get-selection nil t))))) - -(defun helm-buffers-list-persistent-action (candidate) - (if current-prefix-arg - (helm-buffers-persistent-kill candidate) - (helm-switch-to-buffer candidate))) - -(defun helm-ediff-marked-buffers (_candidate &optional merge) - "Ediff 2 marked buffers or CANDIDATE and `helm-current-buffer'. -With optional arg MERGE call `ediff-merge-buffers'." - (let ((lg-lst (length (helm-marked-candidates))) - buf1 buf2) - (cl-case lg-lst - (0 - (error "Error:You have to mark at least 1 buffer")) - (1 - (setq buf1 helm-current-buffer - buf2 (cl-first (helm-marked-candidates)))) - (2 - (setq buf1 (cl-first (helm-marked-candidates)) - buf2 (cl-second (helm-marked-candidates)))) - (t - (error "Error:To much buffers marked!"))) - (if merge - (ediff-merge-buffers buf1 buf2) - (ediff-buffers buf1 buf2)))) - -(defun helm-ediff-marked-buffers-merge (candidate) - "Ediff merge `helm-current-buffer' with CANDIDATE. -See `helm-ediff-marked-buffers'." - (helm-ediff-marked-buffers candidate t)) - -(defun helm-multi-occur-as-action (_candidate) - "Multi occur action for `helm-source-buffers-list'. -Can be used by any source that list buffers." - (let ((helm-moccur-always-search-in-current - (if helm-current-prefix-arg - (not helm-moccur-always-search-in-current) - helm-moccur-always-search-in-current)) - (buffers (helm-marked-candidates)) - (input (cl-loop for i in (split-string helm-pattern " " t) - thereis (and (string-match "\\`@\\(.*\\)" i) - (match-string 1 i))))) - (helm-multi-occur-1 buffers input))) - -(defun helm-buffers-run-multi-occur () - "Run `helm-multi-occur-as-action' by key." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-multi-occur-as-action))) - -(defun helm-buffers-toggle-show-hidden-buffers () - (interactive) - (with-helm-alive-p - (let ((filter-attrs (helm-attr 'filtered-candidate-transformer - helm-source-buffers-list))) - (if (memq 'helm-shadow-boring-buffers filter-attrs) - (helm-attrset 'filtered-candidate-transformer - (cons 'helm-skip-boring-buffers - (remove 'helm-shadow-boring-buffers - filter-attrs)) - helm-source-buffers-list t) - (helm-attrset 'filtered-candidate-transformer - (cons 'helm-shadow-boring-buffers - (remove 'helm-skip-boring-buffers - filter-attrs)) - helm-source-buffers-list t)) - (helm-force-update)))) - - -;;; Candidate Transformers -;; -;; -(defun helm-skip-boring-buffers (buffers _source) - (helm-skip-entries buffers helm-boring-buffer-regexp-list)) - -(defun helm-shadow-boring-buffers (buffers _source) - "Buffers matching `helm-boring-buffer-regexp' will be -displayed with the `file-name-shadow' face if available." - (helm-shadow-entries buffers helm-boring-buffer-regexp-list)) - - -(define-helm-type-attribute 'buffer - `((action - . ,(helm-make-actions - "Switch to buffer" 'helm-switch-to-buffer - (lambda () (and (locate-library "popwin") "Switch to buffer in popup window")) - 'popwin:popup-buffer - "Switch to buffer other window" 'switch-to-buffer-other-window - "Switch to buffer other frame" 'switch-to-buffer-other-frame - (lambda () (and (locate-library "elscreen") "Display buffer in Elscreen")) - 'helm-find-buffer-on-elscreen - "Query replace regexp" 'helm-buffer-query-replace-regexp - "Query replace" 'helm-buffer-query-replace - "View buffer" 'view-buffer - "Display buffer" 'display-buffer - "Grep buffers (C-u grep all buffers)" 'helm-zgrep-buffers - "Multi occur buffer(s)" 'helm-multi-occur-as-action - "Revert buffer(s)" 'helm-revert-marked-buffers - "Insert buffer" 'insert-buffer - "Kill buffer(s)" 'helm-kill-marked-buffers - "Diff with file" 'diff-buffer-with-file - "Ediff Marked buffers" 'helm-ediff-marked-buffers - "Ediff Merge marked buffers" (lambda (candidate) - (helm-ediff-marked-buffers candidate t)))) - (persistent-help . "Show this buffer") - (filtered-candidate-transformer helm-skip-boring-buffers - helm-buffers-sort-transformer - helm-highlight-buffers)) - "Buffer or buffer name.") - -;;;###autoload -(defun helm-buffers-list () - "Preconfigured `helm' to list buffers." - (interactive) - (helm :sources '(helm-source-buffers-list - helm-source-ido-virtual-buffers - helm-source-buffer-not-found) - :buffer "*helm buffers*" - :keymap helm-buffer-map - :truncate-lines t)) - -(provide 'helm-buffers) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-buffers.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-color.el b/emacs.d/elpa/helm-20141016.2217/helm-color.el deleted file mode 100644 index e7f751d..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-color.el +++ /dev/null @@ -1,163 +0,0 @@ -;;; helm-color.el --- colors and faces -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) - -;;; Customize Face -;; -;; -(defun helm-custom-faces-init () - "Initialize buffer for `helm-source-customize-face'." - (unless (helm-candidate-buffer) - (save-selected-window - (list-faces-display) - (message nil)) - (helm-init-candidates-in-buffer - 'global - (with-current-buffer (get-buffer "*Faces*") - (buffer-substring - (next-single-char-property-change (point-min) 'face) - (point-max)))) - (kill-buffer "*Faces*"))) - -(defvar helm-source-customize-face - '((name . "Customize Face") - (init . helm-custom-faces-init) - (candidates-in-buffer) - (get-line . buffer-substring) - (action . (("Customize" - . (lambda (line) - (customize-face (intern (car (split-string line)))))) - ("Copy name" - . (lambda (line) - (kill-new (car (split-string line " " t)))))))) - "See (info \"(emacs)Faces\")") - -;;; Colors browser -;; -;; -(defun helm-colors-init () - (unless (helm-candidate-buffer) - (save-selected-window - (list-colors-display) - (message nil)) - (helm-init-candidates-in-buffer - 'global - (with-current-buffer (get-buffer "*Colors*") - (buffer-string))) - (kill-buffer "*Colors*"))) - -(defun helm-color-insert-name (candidate) - (with-helm-current-buffer - (insert (helm-colors-get-name candidate)))) - -(defun helm-color-kill-name (candidate) - (kill-new (helm-colors-get-name candidate))) - -(defun helm-color-insert-rgb (candidate) - (with-helm-current-buffer - (insert (helm-colors-get-rgb candidate)))) - -(defun helm-color-kill-rgb (candidate) - (kill-new (helm-colors-get-rgb candidate))) - -(defun helm-color-run-insert-name () - "Insert name of color from `helm-source-colors'" - (interactive) - (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-insert-name))) - -(defun helm-color-run-kill-name () - "Kill name of color from `helm-source-colors'" - (interactive) - (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-kill-name))) - -(defun helm-color-run-insert-rgb () - "Insert RGB of color from `helm-source-colors'" - (interactive) - (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-insert-rgb))) - -(defun helm-color-run-kill-rgb () - "Kill RGB of color from `helm-source-colors'" - (interactive) - (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-kill-rgb))) - -(defvar helm-color-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c n") 'helm-color-run-insert-name) - (define-key map (kbd "C-c N") 'helm-color-run-kill-name) - (define-key map (kbd "C-c r") 'helm-color-run-insert-rgb) - (define-key map (kbd "C-c R") 'helm-color-run-kill-rgb) - (define-key map (kbd "C-c ?") 'helm-color-help) - map)) - -(defvar helm-source-colors - `((name . "Colors") - (init . helm-colors-init) - (candidates-in-buffer) - (get-line . buffer-substring) - (keymap . ,helm-color-map) - (persistent-help . "Kill entry in RGB format.") - (persistent-action . helm-color-kill-rgb) - (mode-line . helm-color-mode-line-string) - (action - ("Copy Name (C-c N)" . helm-color-kill-name) - ("Copy RGB (C-c R)" . helm-color-kill-rgb) - ("Insert Name (C-c n)" . helm-color-insert-name) - ("Insert RGB (C-c r)" . helm-color-insert-rgb)))) - -(defun helm-colors-get-name (candidate) - "Get color name." - (replace-regexp-in-string - " " "" - (with-temp-buffer - (insert (capitalize candidate)) - (goto-char (point-min)) - (search-forward-regexp "\\s-\\{2,\\}") - (delete-region (point) (point-max)) - (buffer-string)))) - -(defun helm-colors-get-rgb (candidate) - "Get color RGB." - (replace-regexp-in-string - " " "" - (with-temp-buffer - (insert (capitalize candidate)) - (goto-char (point-max)) - (search-backward-regexp "\\s-\\{2,\\}") - (delete-region (point) (point-min)) - (buffer-string)))) - -;;;###autoload -(defun helm-colors () - "Preconfigured `helm' for color." - (interactive) - (helm-other-buffer - '(helm-source-colors helm-source-customize-face) - "*helm colors*")) - -(provide 'helm-color) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-color.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-command.el b/emacs.d/elpa/helm-20141016.2217/helm-command.el deleted file mode 100644 index 57631cd..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-command.el +++ /dev/null @@ -1,200 +0,0 @@ -;;; helm-command.el --- Helm execute-exended-command. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-mode) -(require 'helm-elisp) - - -(defgroup helm-command nil - "Emacs command related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-M-x-requires-pattern 0 - "Value of requires-pattern for `helm-M-x'. -Show all candidates on startup when 0 (default)." - :group 'helm-command - :type 'boolean) - -(defcustom helm-M-x-always-save-history nil - "`helm-M-x' Save command in `extended-command-history' even when it fail." - :group 'helm-command - :type 'boolean) - -(defcustom helm-M-x-reverse-history nil - "The history source of `helm-M-x' appear in second position when non--nil." - :group 'helm-command - :type 'boolean) - - -;;; Faces -;; -;; -(defface helm-M-x-key '((t (:foreground "orange" :underline t))) - "Face used in helm-M-x to show keybinding." - :group 'helm-command) - - -(defvar helm-M-x-input-history nil) - -(defvar helm-M-x-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-M-x-help) - map) - "Keymap for `helm-M-x'.") - - -(cl-defun helm-M-x-get-major-mode-command-alist (mode-map) - "Return alist of MODE-MAP." - (cl-loop for key being the key-seqs of mode-map using (key-bindings com) - for str-key = (key-description key) - for ismenu = (string-match "" str-key) - unless ismenu collect (cons str-key com))) - -(defun helm-get-mode-map-from-mode (mode) - "Guess the mode-map name according to MODE. -Some modes don't use conventional mode-map name -so we need to guess mode-map name. e.g python-mode ==> py-mode-map. -Return nil if no mode-map found." - (cl-loop ;; Start with a conventional mode-map name. - with mode-map = (intern-soft (format "%s-map" mode)) - with mode-string = (symbol-name mode) - with mode-name = (replace-regexp-in-string "-mode" "" mode-string) - while (not mode-map) - for count downfrom (length mode-name) - ;; Return when no result after parsing entire string. - when (eq count 0) return nil - for sub-name = (substring mode-name 0 count) - do (setq mode-map (intern-soft (format "%s-map" (concat sub-name "-mode")))) - finally return mode-map)) - -(defun helm-M-x-current-mode-map-alist () - "Return mode-map alist of current `major-mode'." - (let ((map (helm-get-mode-map-from-mode major-mode))) - (when (and map (boundp map)) - (helm-M-x-get-major-mode-command-alist (symbol-value map))))) - - -(defun helm-M-x-transformer (candidates _source) - "filtered-candidate-transformer to show bindings in emacs commands. -Show global bindings and local bindings according to current `major-mode'." - (with-helm-current-buffer - (cl-loop with local-map = (helm-M-x-current-mode-map-alist) - for cand in candidates - for local-key = (car (rassq cand local-map)) - for key = (substitute-command-keys (format "\\[%s]" cand)) - collect - (cons (cond ((and (string-match "^M-x" key) local-key) - (format "%s (%s)" - cand (propertize - local-key - 'face 'helm-M-x-key))) - ((string-match "^M-x" key) cand) - (t (format "%s (%s)" - cand (propertize - key - 'face 'helm-M-x-key)))) - cand) - into ls - finally return - (sort ls #'helm-generic-sort-fn)))) - -(defun helm-M-x--notify-prefix-arg () - ;; Notify a prefix-arg set AFTER calling M-x. - (when prefix-arg - (with-helm-window - (helm-display-mode-line (helm-get-current-source) 'force)))) - -;;;###autoload -(defun helm-M-x () - "Preconfigured `helm' for Emacs commands. -It is `helm' replacement of regular `M-x' `execute-extended-command'. - -Unlike regular `M-x' emacs vanilla `execute-extended-command' command, -the prefix args if needed, are passed AFTER starting `helm-M-x'. - -You can get help on each command by persistent action." - (interactive) - (let* ((history (cl-loop for i in extended-command-history - when (commandp (intern i)) collect i)) - command sym-com in-help help-cand - (helm--mode-line-display-prefarg t) - (pers-help #'(lambda (candidate) - (let ((hbuf (get-buffer (help-buffer)))) - (if (and in-help (string= candidate help-cand) - (null helm-persistent-action-use-special-display)) - (progn - ;; When M-x is started from a help buffer, - ;; Don't kill it as it is helm-current-buffer. - (unless (equal hbuf helm-current-buffer) - (kill-buffer hbuf) - (set-window-buffer (get-buffer-window hbuf) - helm-current-buffer)) - (setq in-help nil)) - (helm-describe-function candidate) - (setq in-help t)) - (setq help-cand candidate)))) - (tm (run-at-time 1 0.1 'helm-M-x--notify-prefix-arg))) - (setq current-prefix-arg nil) - (unwind-protect - (setq command (helm-comp-read - "M-x " obarray - :test 'commandp - :requires-pattern helm-M-x-requires-pattern - :name "Emacs Commands" - :buffer "*helm M-x*" - :persistent-action pers-help - :persistent-help "Describe this command" - :history history - :reverse-history helm-M-x-reverse-history - :del-input nil - :mode-line helm-M-x-mode-line - :must-match t - :nomark t - :keymap helm-M-x-map - :candidates-in-buffer t - :fc-transformer 'helm-M-x-transformer)) - (cancel-timer tm) - (setq helm--mode-line-display-prefarg nil)) - (setq sym-com (intern command)) - (setq current-prefix-arg helm-current-prefix-arg) - ;; Avoid having `this-command' set to *exit-minibuffer. - (setq this-command sym-com - ;; Handle C-x z (repeat) Issue #322 - real-this-command sym-com) - (let ((prefix-arg current-prefix-arg)) - ;; This ugly construct is to save history even on error. - (unless helm-M-x-always-save-history - (command-execute sym-com 'record)) - (setq extended-command-history - (cons command (delete command history))) - (when helm-M-x-always-save-history - (command-execute sym-com 'record))))) - -(provide 'helm-command) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-command.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-config.el b/emacs.d/elpa/helm-20141016.2217/helm-config.el deleted file mode 100644 index 30b68d4..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-config.el +++ /dev/null @@ -1,231 +0,0 @@ -;;; helm-config.el --- Applications library for `helm.el' -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - - -;;; Require -;; -;; -(require 'easymenu) -(require 'helm-aliases) -(require 'async-bytecomp nil t) - - -(defgroup helm-config nil - "Various configurations for Helm." - :group 'helm) - -(defcustom helm-command-prefix-key "C-x c" - "The key `helm-command-prefix' is bound to in the global map." - :type '(choice (string :tag "Key") (const :tag "no binding")) - :group 'helm-config - :set - (lambda (var key) - (when (and (boundp var) (symbol-value var)) - (define-key (current-global-map) - (read-kbd-macro (symbol-value var)) nil)) - (when key - (define-key (current-global-map) - (read-kbd-macro key) 'helm-command-prefix)) - (set var key))) - -(defcustom helm-minibuffer-history-key "C-r" - "The key `helm-minibuffer-history' is bound to in minibuffer local maps." - :type '(choice (string :tag "Key") (const :tag "no binding")) - :group 'helm-config - :set - (lambda (var key) - (cl-dolist (map '(minibuffer-local-completion-map - minibuffer-local-filename-completion-map - minibuffer-local-filename-must-match-map ; Emacs 23.1.+ - minibuffer-local-isearch-map - minibuffer-local-map - minibuffer-local-must-match-filename-map ; Older Emacsen - minibuffer-local-must-match-map - minibuffer-local-ns-map)) - (when (and (boundp map) (keymapp (symbol-value map))) - (when (and (boundp var) (symbol-value var)) - (define-key (symbol-value map) - (read-kbd-macro (symbol-value var)) nil)) - (when key - (define-key (symbol-value map) - (read-kbd-macro key) 'helm-minibuffer-history)))) - (set var key))) - -;;; Command Keymap -;; -;; -(defvar helm-command-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "a") 'helm-apropos) - (define-key map (kbd "e") 'helm-etags-select) - (define-key map (kbd "l") 'helm-locate) - (define-key map (kbd "s") 'helm-surfraw) - (define-key map (kbd "r") 'helm-regexp) - (define-key map (kbd "w") 'helm-w3m-bookmarks) - (define-key map (kbd "x") 'helm-firefox-bookmarks) - (define-key map (kbd "#") 'helm-emms) - (define-key map (kbd "m") 'helm-man-woman) - (define-key map (kbd "t") 'helm-top) - (define-key map (kbd "/") 'helm-find) - (define-key map (kbd "i") 'helm-semantic-or-imenu) - (define-key map (kbd "") 'helm-lisp-completion-at-point) - (define-key map (kbd "p") 'helm-list-emacs-process) - (define-key map (kbd "C-x r b") 'helm-filtered-bookmarks) - (define-key map (kbd "M-y") 'helm-show-kill-ring) - (define-key map (kbd "C-c ") 'helm-all-mark-rings) - (define-key map (kbd "C-x C-f") 'helm-find-files) - (define-key map (kbd "f") 'helm-for-files) - (define-key map (kbd "C-:") 'helm-eval-expression-with-eldoc) - (define-key map (kbd "C-,") 'helm-calcul-expression) - (define-key map (kbd "M-x") 'helm-M-x) - (define-key map (kbd "M-s o") 'helm-occur) - (define-key map (kbd "M-g s") 'helm-do-grep) - (define-key map (kbd "c") 'helm-colors) - (define-key map (kbd "F") 'helm-select-xfont) - (define-key map (kbd "8") 'helm-ucs) - (define-key map (kbd "C-c f") 'helm-recentf) - (define-key map (kbd "C-c g") 'helm-google-suggest) - (define-key map (kbd "h i") 'helm-info-at-point) - (define-key map (kbd "h r") 'helm-info-emacs) - (define-key map (kbd "h g") 'helm-info-gnus) - (define-key map (kbd "C-x C-b") 'helm-buffers-list) - (define-key map (kbd "C-x r i") 'helm-register) - (define-key map (kbd "C-c C-x") 'helm-run-external-command) - (define-key map (kbd "b") 'helm-resume) - map)) - -;; Don't override the keymap we just defined with an empty -;; keymap. This also protect bindings changed by the user. -(defvar helm-command-prefix) -(define-prefix-command 'helm-command-prefix) -(fset 'helm-command-prefix helm-command-map) -(setq helm-command-prefix helm-command-map) - - -;;; Menu -;; -;; -(easy-menu-add-item - nil '("Tools") - '("Helm" - ["Find any Files/Buffers" helm-for-files t] - ["Helm Everywhere (Toggle)" helm-mode t] - ["Helm resume" helm-resume t] - "----" - ("Files" - ["Find files" helm-find-files t] - ["Recent Files" helm-recentf t] - ["Locate" helm-locate t] - ["Search Files with find" helm-find t] - ["Bookmarks" helm-filtered-bookmarks t]) - ("Buffers" - ["Find buffers" helm-buffers-list t]) - ("Commands" - ["Emacs Commands" helm-M-x t] - ["Externals Commands" helm-run-external-command t]) - ("Help" - ["Helm Apropos" helm-apropos t]) - ("Info" - ["Info at point" helm-info-at-point t] - ["Emacs Manual index" helm-info-emacs t] - ["Gnus Manual index" helm-info-gnus t]) - ("Org" - ["Org keywords" helm-org-keywords t] - ["Org headlines" helm-org-headlines t]) - ("Tools" - ["Occur" helm-occur t] - ["Grep" helm-do-grep t] - ["Etags" helm-etags-select t] - ["Lisp complete at point" helm-lisp-completion-at-point t] - ["Browse Kill ring" helm-show-kill-ring t] - ["Browse register" helm-register t] - ["Mark Ring" helm-all-mark-rings t] - ["Regexp handler" helm-regexp t] - ["Colors & Faces" helm-colors t] - ["Show xfonts" helm-select-xfont t] - ["Ucs Symbols" helm-ucs t] - ["Imenu" helm-imenu t] - ["Semantic or Imenu" helm-semantic-or-imenu t] - ["Google Suggest" helm-google-suggest t] - ["Eval expression" helm-eval-expression-with-eldoc t] - ["Calcul expression" helm-calcul-expression t] - ["Man pages" helm-man-woman t] - ["Top externals process" helm-top t] - ["Emacs internals process" helm-list-emacs-process t]) - "----" - ["Preferred Options" helm-configuration t]) - "Spell Checking") - -(easy-menu-add-item nil '("Tools") '("----") "Spell Checking") - - -;;;###autoload -(defun helm-configuration () - "Customize `helm'." - (interactive) - (customize-group "helm")) - - -;;; Fontlock -(cl-dolist (mode '(emacs-lisp-mode lisp-interaction-mode)) - (font-lock-add-keywords - mode - '(("(\\<\\(with-helm-after-update-hook\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-temp-hook\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-window\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-quittable\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-current-buffer\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-buffer\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-show-completion\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-default-directory\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-display-same-window\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(with-helm-restore-variables\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(define-helm-type-attribute\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-multi-key-defun\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-while-no-input\\)\\>" 1 font-lock-keyword-face) - ("(\\<\\(helm-aif\\)\\>" 1 font-lock-keyword-face)))) - - -;;; Compatibility emacs-24.4+ -;; Inlined from Emacs trunk. -(defalias 'function-put - ;; We don't want people to just use `put' because we can't conveniently - ;; hook into `put' to remap old properties to new ones. But for now, there's - ;; no such remapping, so we just call `put'. - #'(lambda (f prop value) (put f prop value)) - "Set function F's property PROP to VALUE. -The namespace for PROP is shared with symbols. -So far, F can only be a symbol, not a lambda expression.") - - -;;; Load the autoload file -;; It should have been generated either by -;; package.el or the make file. - -(load "helm-autoloads") - -(provide 'helm-config) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-config.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-dabbrev.el b/emacs.d/elpa/helm-20141016.2217/helm-dabbrev.el deleted file mode 100644 index 8092dc8..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-dabbrev.el +++ /dev/null @@ -1,321 +0,0 @@ -;;; helm-dabbrev.el --- Helm implementation of dabbrev. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'helm) -(require 'helm-elisp) ; For show-completion. - -(defgroup helm-dabbrev nil - "Dabbrev related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-dabbrev-always-search-all t - "Always search in all buffers when non--nil." - :group 'helm-dabbrev - :type 'boolean) - -(defcustom helm-dabbrev-max-length-result 20 - "Max length of candidates before searching in all buffers. -If number of candidates found in current-buffer is <= to this, -search in all buffers. -Have no effect when `helm-dabbrev-always-search-all' is non--nil." - :group 'helm-dabbrev - :type 'integer) - -(defcustom helm-dabbrev-ignored-buffers-regexps - '("\\*helm" "\\*Messages" "\\*Echo Area" "\\*Buffer List") - "List of regexps matching names of buffers that helm-dabbrev should not check." - :group 'helm-dabbrev - :type '(repeat regexp)) - -(defcustom helm-dabbrev-major-mode-assoc - '((emacs-lisp-mode . lisp-interaction-mode)) - "Major mode association alist. -This allow helm-dabbrev searching in buffers with the associated `major-mode'. -e.g \(emacs-lisp-mode . lisp-interaction-mode\) -will allow searching in the lisp-interaction-mode buffer when `current-buffer' -is an `emacs-lisp-mode' buffer and vice versa i.e -no need to provide \(lisp-interaction-mode . emacs-lisp-mode\) association." - :type '(alist :key-type symbol :value-type symbol) - :group 'helm-dabbrev) - -(defcustom helm-dabbrev-lineno-around 30 - "Search first in this number of lines before an after point." - :group 'helm-dabbrev - :type 'integer) - -(defcustom helm-dabbrev-cycle-thresold nil - "Number of time helm-dabbrev cycle before displaying helm completion. -When nil or 0 disable cycling." - :group 'helm-dabbrev - :type '(choice (const :tag "Cycling disabled" nil) integer)) - -(defcustom helm-dabbrev-case-fold-search 'smart - "Set `case-fold-search' in `helm-dabbrev'. -Same as `helm-case-fold-search' but for `helm-dabbrev'. -Note that this is not affecting searching in helm buffer, -but the initial search for all candidates in buffer(s)." - :group 'helm-dabbrev - :type '(choice (const :tag "Ignore case" t) - (const :tag "Respect case" nil) - (other :tag "Smart" 'smart))) - - -(defvar helm-dabbrev-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-/") 'helm-next-line) - (define-key map (kbd "M-:") 'helm-previous-line) - map)) - -;; Internal -(defvar helm-dabbrev--exclude-current-buffer-flag nil) -(defvar helm-dabbrev--cache nil) -(defvar helm-dabbrev--data nil) -(defvar helm-dabbrev--regexp "\\s-\\|\t\\|[(\[\{\"'`=<$;]\\|\\s\\\\|^") -(cl-defstruct helm-dabbrev-info dabbrev limits iterator) - - -(defun helm-dabbrev--buffer-list () - (cl-loop with lst = (buffer-list) - for buf in (if helm-dabbrev--exclude-current-buffer-flag - (cdr lst) lst) - unless (cl-loop for r in helm-dabbrev-ignored-buffers-regexps - thereis (string-match r (buffer-name buf))) - collect buf)) - -(defun helm-dabbrev--same-major-mode-p (start-buffer) - ;; START-BUFFER is the current-buffer where we start searching. - ;; Determine the major-mode of START-BUFFER as `cur-maj-mode'. - ;; Each time the loop go in another buffer we try to find if its - ;; `major-mode' is: - ;; - same as the `cur-maj-mode' - ;; - derived from `cur-maj-mode' - ;; - have an assoc entry (major-mode . cur-maj-mode) - ;; - have an rassoc entry (cur-maj-mode . major-mode) - ;; - check if one of these entries inherit from another one in - ;; `helm-dabbrev-major-mode-assoc'. - (let* ((cur-maj-mode (with-current-buffer start-buffer major-mode)) - (c-assoc-mode (assq cur-maj-mode helm-dabbrev-major-mode-assoc)) - (c-rassoc-mode (rassq cur-maj-mode helm-dabbrev-major-mode-assoc)) - (o-assoc-mode (assq major-mode helm-dabbrev-major-mode-assoc)) - (o-rassoc-mode (rassq major-mode helm-dabbrev-major-mode-assoc)) - (cdr-c-assoc-mode (cdr c-assoc-mode)) - (cdr-o-assoc-mode (cdr o-assoc-mode))) - (or (eq major-mode cur-maj-mode) - (derived-mode-p cur-maj-mode) - (or (eq cdr-c-assoc-mode major-mode) - (eq (car c-rassoc-mode) major-mode) - (eq (cdr (assq cdr-c-assoc-mode helm-dabbrev-major-mode-assoc)) - major-mode) - (eq (car (rassq cdr-c-assoc-mode helm-dabbrev-major-mode-assoc)) - major-mode)) - (or (eq cdr-o-assoc-mode cur-maj-mode) - (eq (car o-rassoc-mode) cur-maj-mode) - (eq (cdr (assq cdr-o-assoc-mode helm-dabbrev-major-mode-assoc)) - cur-maj-mode) - (eq (car (rassq cdr-o-assoc-mode helm-dabbrev-major-mode-assoc)) - cur-maj-mode))))) - -(defun helm-dabbrev--collect (str limit ignore-case all) - (let* ((case-fold-search ignore-case) - (buffer1 (current-buffer)) ; start buffer. - (minibuf (minibufferp buffer1)) - result pos-before pos-after - (search-and-store - #'(lambda (pattern direction) - (while (cl-case direction - (1 (search-forward pattern nil t)) - (-1 (search-backward pattern nil t)) - (2 (let ((pos - (save-excursion - (forward-line - helm-dabbrev-lineno-around) - (point)))) - (setq pos-after pos) - (search-forward pattern pos t))) - (-2 (let ((pos - (save-excursion - (forward-line - (- helm-dabbrev-lineno-around)) - (point)))) - (setq pos-before pos) - (search-backward pattern pos t)))) - (let* ((match-1 (helm-aif (thing-at-point 'symbol) - ;; `thing-at-point' returns - ;; the quote outside of e-lisp mode, - ;; e.g in message mode, - ;; `foo' => foo' - ;; but in e-lisp like modes: - ;; `foo' => foo - ;; so remove it [1]. - (replace-regexp-in-string - "[']\\'" "" (substring-no-properties it)))) - (match-2 (helm-aif (thing-at-point 'filename) - ;; Same as in [1]. - (replace-regexp-in-string - "[']\\'" "" (substring-no-properties it)))) - (lst (if (string= match-1 match-2) - (list match-1) - (list match-1 match-2)))) - (cl-loop for match in lst - unless (or (string= str match) - (member match result)) - do (push match result))))))) - (cl-loop for buf in (if all (helm-dabbrev--buffer-list) - (list (current-buffer))) - - do (with-current-buffer buf - (when (or minibuf ; check against all buffers when in minibuffer. - (helm-dabbrev--same-major-mode-p buffer1)) - (save-excursion - ;; Start searching before thing before point. - (goto-char (- (point) (length str))) - ;; Search the last 30 lines before point. - (funcall search-and-store str -2)) ; store pos [1] - (save-excursion - ;; Search the next 30 lines after point. - (funcall search-and-store str 2)) ; store pos [2] - (save-excursion - ;; Search all before point. - (goto-char pos-before) ; start from [1] - (funcall search-and-store str -1)) - (save-excursion - ;; Search all after point. - (goto-char pos-after) ; start from [2] - (funcall search-and-store str 1)))) - when (> (length result) limit) return (nreverse result) - finally return (nreverse result)))) - -(defun helm-dabbrev--get-candidates (abbrev) - (cl-assert abbrev nil "[No Match]") - (with-current-buffer (current-buffer) - (let* ((dabbrev-get #'(lambda (str all-bufs) - (helm-dabbrev--collect - str helm-candidate-number-limit - (cl-case helm-dabbrev-case-fold-search - (smart (helm-set-case-fold-search-1 abbrev)) - (t helm-dabbrev-case-fold-search)) - all-bufs))) - (lst (funcall dabbrev-get abbrev helm-dabbrev-always-search-all))) - (if (and (not helm-dabbrev-always-search-all) - (<= (length lst) helm-dabbrev-max-length-result)) - ;; Search all but don't recompute current-buffer. - (let ((helm-dabbrev--exclude-current-buffer-flag t)) - (append lst (funcall dabbrev-get abbrev 'all-bufs))) - lst)))) - -(defvar helm-source-dabbrev - `((name . "Dabbrev Expand") - (init . (lambda () - (helm-init-candidates-in-buffer 'global - helm-dabbrev--cache))) - (candidates-in-buffer) - (persistent-action . (lambda (_candidate) (ignore))) - (persistent-help . "DoNothing") - (keymap . ,helm-dabbrev-map) - (action . helm-dabbrev-default-action))) - -(defun helm-dabbrev-default-action (candidate) - (with-helm-current-buffer - (let* ((limits (helm-bounds-of-thing-before-point - helm-dabbrev--regexp)) - (beg (car limits)) - (end (point))) - (run-with-timer - 0.01 nil - 'helm-insert-completion-at-point - beg end candidate)))) - -;;;###autoload -(defun helm-dabbrev () - (interactive) - (let ((dabbrev (helm-thing-before-point nil helm-dabbrev--regexp)) - (limits (helm-bounds-of-thing-before-point helm-dabbrev--regexp)) - (enable-recursive-minibuffers t) - (cycling-disabled-p (or (null helm-dabbrev-cycle-thresold) - (zerop helm-dabbrev-cycle-thresold))) - (helm-execute-action-at-once-if-one t) - (helm-quit-if-no-candidate - #'(lambda () - (message "[Helm-dabbrev: No expansion found]")))) - (cl-assert (and (stringp dabbrev) (not (string= dabbrev ""))) - nil "[Helm-dabbrev: Nothing found before point]") - (when (and - ;; have been called at least once. - (helm-dabbrev-info-p helm-dabbrev--data) - ;; But user have moved with some other command - ;; in the meaning time. - (not (eq last-command 'helm-dabbrev))) - (setq helm-dabbrev--data nil)) - (when cycling-disabled-p - (setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev))) - (unless (or cycling-disabled-p - (helm-dabbrev-info-p helm-dabbrev--data)) - (setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev)) - (setq helm-dabbrev--data (make-helm-dabbrev-info - :dabbrev dabbrev - :limits limits - :iterator - (helm-iter-list - (cl-loop for i in helm-dabbrev--cache when - (and i (string-match - (concat "^" (regexp-quote dabbrev)) i)) - collect i into selection - when (and selection - (= (length selection) - helm-dabbrev-cycle-thresold)) - ;; When selection len reach - ;; `helm-dabbrev-cycle-thresold' - ;; return selection. - return selection - ;; selection len never reach - ;; `helm-dabbrev-cycle-thresold' - ;; return selection. - finally return selection))))) - (let ((iter (and (helm-dabbrev-info-p helm-dabbrev--data) - (helm-dabbrev-info-iterator helm-dabbrev--data))) - deactivate-mark) - (helm-aif (and iter (helm-iter-next iter)) - (progn - (helm-insert-completion-at-point (car limits) (cdr limits) it) - ;; Move already tried candidates to end of list. - (setq helm-dabbrev--cache (append (remove it helm-dabbrev--cache) - (list it)))) - (unless cycling-disabled-p - (delete-region (car limits) (point)) - (setq dabbrev (helm-dabbrev-info-dabbrev helm-dabbrev--data) - limits (helm-dabbrev-info-limits helm-dabbrev--data)) - (setq helm-dabbrev--data nil) - (insert dabbrev)) - (with-helm-show-completion (car limits) (cdr limits) - (helm :sources 'helm-source-dabbrev - :buffer "*helm dabbrev*" - :input (concat "^" dabbrev " ") - :resume 'noresume - :allow-nest t)))))) - -(provide 'helm-dabbrev) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-dabbrev.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-elisp-package.el b/emacs.d/elpa/helm-20141016.2217/helm-elisp-package.el deleted file mode 100644 index c20010b..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-elisp-package.el +++ /dev/null @@ -1,170 +0,0 @@ -;;; helm-elisp-package.el --- helm interface for package.el -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'package) - -;; internals vars -(defvar helm-el-package--show-only 'all) -(defvar helm-el-package--initialized-p nil) - -(defun helm-el-package--init () - (when (null package-alist) - (setq helm-el-package--show-only 'all)) - (save-selected-window - (list-packages helm-el-package--initialized-p) - (setq helm-el-package--initialized-p t) - (message nil)) - (helm-init-candidates-in-buffer - 'global - (with-current-buffer (get-buffer "*Packages*") - (buffer-string))) - (setq helm-el-package--show-only 'all) - (kill-buffer "*Packages*")) - -(defun helm-el-package-describe (candidate) - (let ((id (get-text-property 0 'tabulated-list-id candidate))) - (describe-package (if (fboundp 'package-desc-name) - (package-desc-name id) - (car id))))) - -(defun helm-el-package-install (_candidate) - (cl-loop with mkd = (helm-marked-candidates) - for p in mkd - for id = (get-text-property 0 'tabulated-list-id p) - do (package-install - (if (fboundp 'package-desc-name) - (package-desc-name id) - (car id))) - and collect (if (fboundp 'package-desc-full-name) - id - (car id)) - into installed-list - finally do (if (fboundp 'package-desc-full-name) - (message (format "%d packages installed:\n(%s)" - (length installed-list) - (mapconcat #'package-desc-full-name - installed-list ", "))) - (message (format "%d packages installed:\n(%s)" - (length installed-list) - (mapconcat 'symbol-name installed-list ", ")))))) - -(defun helm-el-package-uninstall (_candidate) - (cl-loop with mkd = (helm-marked-candidates) - for p in mkd - for id = (get-text-property 0 'tabulated-list-id p) - do - (condition-case-unless-debug err - (with-no-warnings - (if (fboundp 'package-desc-full-name) - ;; emacs 24.4 - (package-delete id) - ;; emacs 24.3 - (package-delete (symbol-name (car id)) - (package-version-join (cdr id))))) - (error (message (cadr err)))) - and collect (if (fboundp 'package-desc-full-name) - id - (cons (symbol-name (car id)) - (package-version-join (cdr id)))) - into delete-list - finally do (if (fboundp 'package-desc-full-name) - ;; emacs 24.4 - (message (format "%d packages deleted:\n(%s)" - (length delete-list) - (mapconcat #'package-desc-full-name - delete-list ", "))) - ;; emacs 24.3 - (message (format "%d packages deleted:\n(%s)" - (length delete-list) - (mapconcat (lambda (x) - (concat (car x) "-" (cdr x))) - delete-list ", "))) - ;; emacs 24.3 doesn't update - ;; its `package-alist' after deleting. - (cl-loop for p in package-alist - when (assq (symbol-name (car p)) delete-list) - do (setq package-alist (delete p package-alist)))))) - -(defun helm-el-package--transformer (candidates _source) - (cl-loop for c in candidates - for id = (get-text-property 0 'tabulated-list-id c) - for installed-p = (assq (if (fboundp 'package-desc-name) - (package-desc-name id) - (car id)) - package-alist) - for cand = (cons c (car (split-string c))) - when (or (and installed-p - (eq helm-el-package--show-only 'installed)) - (and (not installed-p) - (eq helm-el-package--show-only 'uninstalled)) - (eq helm-el-package--show-only 'all)) - collect cand)) - -(defun helm-el-package-show-installed () - (interactive) - (with-helm-alive-p - (setq helm-el-package--show-only 'installed) - (helm-update))) - -(defun helm-el-package-show-all () - (interactive) - (with-helm-alive-p - (setq helm-el-package--show-only 'all) - (helm-update))) - -(defun helm-el-package-show-uninstalled () - (interactive) - (with-helm-alive-p - (setq helm-el-package--show-only 'uninstalled) - (helm-update))) - -(defvar helm-el-package-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-I") 'helm-el-package-show-installed) - (define-key map (kbd "M-U") 'helm-el-package-show-uninstalled) - (define-key map (kbd "M-A") 'helm-el-package-show-all) - (define-key map (kbd "C-c ?") 'helm-el-package-help) - map)) - -(defvar helm-source-list-el-package - `((name . "list packages") - (init . helm-el-package--init) - (get-line . buffer-substring) - (match-part . (lambda (c) (car (split-string c)))) - (filtered-candidate-transformer . helm-el-package--transformer) - (candidates-in-buffer) - (mode-line . helm-el-package-mode-line) - (keymap . ,helm-el-package-map) - (candidate-number-limit . 9999) - (action . (("Describe" . helm-el-package-describe) - ("Install" . helm-el-package-install) - ("Uninstall" . helm-el-package-uninstall))))) - -;;;###autoload -(defun helm-list-elisp-packages (arg) - (interactive "P") - (when arg (setq helm-el-package--initialized-p nil)) - (helm :sources 'helm-source-list-el-package - :buffer "*helm list packages*")) - -(provide 'helm-elisp-package) - -;;; helm-elisp-package.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-elisp.el b/emacs.d/elpa/helm-20141016.2217/helm-elisp.el deleted file mode 100644 index a71a4e6..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-elisp.el +++ /dev/null @@ -1,777 +0,0 @@ -;;; helm-elisp.el --- Elisp symbols completion for helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-info) -(require 'helm-eval) -(require 'helm-files) -(require 'advice) - - -(defgroup helm-elisp nil - "Elisp related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-turn-on-show-completion t - "Display candidate in buffer while moving selection when non--nil." - :group 'helm-elisp - :type 'boolean) - -(defcustom helm-show-completion-use-special-display t - "A special display will be used in lisp completion if non--nil. -All functions that are wrapped in macro `with-helm-show-completion' -will be affected." - :group 'helm-elisp - :type 'boolean) - -(defcustom helm-show-completion-min-window-height 7 - "Minimum completion window height used in show completion. -This is used in macro `with-helm-show-completion'." - :group 'helm-elisp - :type 'integer) - -(defcustom helm-lisp-quoted-function-list - '(funcall apply mapc cl-mapc mapcar cl-mapcar - callf callf2 cl-callf cl-callf2 fset - fboundp fmakunbound symbol-function) - "List of function where quoted function completion happen. -e.g give only function names after \(funcall '." - :group 'helm-elisp - :type '(repeat (choice symbol))) - -(defcustom helm-lisp-unquoted-function-list - '(function defadvice) - "List of function where unquoted function completion happen. -e.g give only function names after \(function ." - :group 'helm-elisp - :type '(repeat (choice symbol))) - - -;;; Faces -;; -;; -(defface helm-lisp-show-completion - '((t (:background "DarkSlateGray"))) - "Face used for showing candidates in `helm-lisp-completion'." - :group 'helm-elisp) - -(defface helm-lisp-completion-info - '((t (:foreground "red"))) - "Face used for showing info in `helm-lisp-completion'." - :group 'helm-elisp) - - -;;; Show completion. -;; -;; Provide show completion with macro `with-helm-show-completion'. - -(defvar helm-show-completion-overlay nil) -;; Called each time cursor move in helm-buffer. -(defun helm-show-completion () - (with-helm-current-buffer - (overlay-put helm-show-completion-overlay - 'display (helm-get-selection)))) - -(defun helm-show-completion-init-overlay (beg end) - (when (and helm-turn-on-show-completion beg end) - (setq helm-show-completion-overlay (make-overlay beg end)) - (overlay-put helm-show-completion-overlay - 'face 'helm-lisp-show-completion))) - -(defun helm-show-completion-display-function (buffer &rest _args) - "A special resized helm window is used depending on position in BUFFER." - (with-selected-window (selected-window) - (if (window-dedicated-p) - (helm-default-display-buffer buffer) - (let* ((screen-size (+ (count-screen-lines (window-start) (point) t) - 1 ; mode-line - (if header-line-format 1 0))) ; header-line - (def-size (- (window-height) - helm-show-completion-min-window-height)) - (upper-height (max window-min-height (min screen-size def-size))) - split-window-keep-point) - (recenter -1) - (set-window-buffer (if (active-minibuffer-window) - (minibuffer-selected-window) - (split-window nil upper-height)) - buffer))))) - -(defmacro with-helm-show-completion (beg end &rest body) - "Show helm candidate in an overlay at point. -BEG and END are the beginning and end position of the current completion -in `helm-current-buffer'. -BODY is an helm call where we want to enable show completion. -If `helm-turn-on-show-completion' is nil just do nothing." - (declare (indent 2) (debug t)) - `(let ((helm-move-selection-after-hook - (and helm-turn-on-show-completion - (append (list 'helm-show-completion) - helm-move-selection-after-hook)))) - (with-helm-temp-hook 'helm-after-initialize-hook - (with-helm-buffer - (set (make-local-variable 'helm-display-function) - (if helm-show-completion-use-special-display - 'helm-show-completion-display-function - 'helm-default-display-buffer)))) - (unwind-protect - (progn - (helm-show-completion-init-overlay ,beg ,end) - ,@body) - (when (and helm-turn-on-show-completion - helm-show-completion-overlay - (overlayp helm-show-completion-overlay)) - (delete-overlay helm-show-completion-overlay))))) - - -;;; Lisp symbol completion. -;; -;; -(defun helm-lisp-completion--predicate-at-point (beg) - ;; Return a predicate for `all-completions'. - (let ((fn-sym-p (lambda () - (or - (and (eq (char-before) ?\ ) - (save-excursion - (skip-syntax-backward " " (point-at-bol)) - (memq (symbol-at-point) - helm-lisp-unquoted-function-list))) - (and (eq (char-before) ?\') - (save-excursion - (forward-char -1) - (eq (char-before) ?\#))))))) - (save-excursion - (goto-char beg) - (if (or - ;; Complete on all symbols in non--lisp modes (logs mail etc..) - (not (memq major-mode '(emacs-lisp-mode - lisp-interaction-mode - inferior-emacs-lisp-mode))) - (not (or (funcall fn-sym-p) - (and (eq (char-before) ?\') - (save-excursion - (forward-char (if (funcall fn-sym-p) -2 -1)) - (skip-syntax-backward " " (point-at-bol)) - (memq (symbol-at-point) - helm-lisp-quoted-function-list))) - (eq (char-before) ?\())) ; no paren before str. - ;; Looks like we are in a let statement. - (condition-case nil - (progn (up-list -2) (forward-char 1) - (eq (char-after) ?\()) - (error nil))) - (lambda (sym) - (or (boundp sym) (fboundp sym) (symbol-plist sym))) - #'fboundp)))) - -(defun helm-thing-before-point (&optional limits regexp) - "Return symbol name before point. -If REGEXP is specified return what REGEXP find before point. -By default match the beginning of symbol before point. -With LIMITS arg specified return the beginning and end position -of symbol before point." - (save-excursion - (let (beg - (end (point)) - (boundary (field-beginning nil nil (point-at-bol)))) - (if (re-search-backward (or regexp "\\_<") boundary t) - (setq beg (match-end 0)) - (setq beg boundary)) - (unless (= beg end) - (if limits - (cons beg end) - (buffer-substring-no-properties beg end)))))) - -(defun helm-bounds-of-thing-before-point (&optional regexp) - "Get the beginning and end position of `helm-thing-before-point'. -Return a cons \(beg . end\)." - (helm-thing-before-point 'limits regexp)) - -(defun helm-insert-completion-at-point (beg end str) - ;; When there is no space after point - ;; we are completing inside a symbol or - ;; after a partial symbol with the next arg aside - ;; without space, in this case mark the region. - ;; deleting it would remove the - ;; next arg which is unwanted. - (delete-region beg end) - (insert str) - (let ((pos (cdr (or (bounds-of-thing-at-point 'symbol) - ;; needed for helm-dabbrev. - (bounds-of-thing-at-point 'filename))))) - (when (and pos (< (point) pos)) - (push-mark pos t t)))) - -(defvar helm-lisp-completion--cache nil) -(defvar helm-lgst-len nil) -;;;###autoload -(defun helm-lisp-completion-at-point () - "Helm lisp symbol completion at point." - (interactive) - (setq helm-lgst-len 0) - (let* ((target (helm-thing-before-point)) - (beg (car (helm-bounds-of-thing-before-point))) - (end (point)) - (pred (and beg (helm-lisp-completion--predicate-at-point beg))) - (loc-vars (and (fboundp 'lisp--local-variables) - (ignore-errors - (mapcar #'symbol-name (lisp--local-variables))))) - (glob-syms (and target pred (all-completions target obarray pred))) - (candidates (append loc-vars glob-syms)) - (helm-quit-if-no-candidate t) - (helm-execute-action-at-once-if-one t) - (enable-recursive-minibuffers t) - (helm-match-plugin-enabled - (member 'helm-compile-source--match-plugin - helm-compile-source-functions))) - (setq helm-lisp-completion--cache (cl-loop for sym in candidates - for len = (length sym) - when (> len helm-lgst-len) - do (setq helm-lgst-len len) - collect sym)) - (if candidates - (with-helm-show-completion beg end - ;; Overlay is initialized now in helm-current-buffer. - (helm - :sources `((name . "Lisp completion") - (init . (lambda () - (helm-init-candidates-in-buffer 'global - helm-lisp-completion--cache))) - (candidates-in-buffer) - (persistent-action . helm-lisp-completion-persistent-action) - (nomark) - (persistent-help . "Show brief doc in mode-line") - (filtered-candidate-transformer . helm-lisp-completion-transformer) - (action . (lambda (candidate) - (with-helm-current-buffer - (run-with-timer - 0.01 nil - 'helm-insert-completion-at-point - ,beg ,end candidate))))) - :input (if helm-match-plugin-enabled (concat target " ") target) - :resume 'noresume - :buffer "*helm lisp completion*" - :allow-nest t)) - (message "[No Match]")))) - -(defun helm-lisp-completion-persistent-action (candidate) - (let ((cursor-in-echo-area t) - mode-line-in-non-selected-windows) - (helm-show-info-in-mode-line - (propertize - (helm-get-first-line-documentation - (intern candidate)) - 'face 'helm-lisp-completion-info)))) - -(defun helm-lisp-completion-transformer (candidates _source) - "Helm candidates transformer for lisp completion." - (cl-loop for c in candidates - for sym = (intern c) - for annot = (cl-typecase sym - (command " (Com)") - (fbound " (Fun)") - (bound " (Var)") - (face " (Face)")) - for spaces = (make-string (- helm-lgst-len (length c)) ? ) - collect (cons (concat c spaces annot) c) into lst - finally return (sort lst #'helm-generic-sort-fn))) - -(defun helm-get-first-line-documentation (sym) - "Return first line documentation of symbol SYM. -If SYM is not documented, return \"Not documented\"." - (let ((doc (cond ((fboundp sym) - (documentation sym t)) - ((boundp sym) - (documentation-property sym 'variable-documentation t)) - ((facep sym) - (face-documentation sym)) - (t nil)))) - (if (and doc (not (string= doc "")) - ;; `documentation' return "\n\n(args...)" - ;; for CL-style functions. - (not (string-match-p "^\n\n" doc))) - (car (split-string doc "\n")) - "Not documented"))) - -;;; File completion. -;; -;; Complete file name at point. - -;;;###autoload -(defun helm-complete-file-name-at-point (&optional force) - "Complete file name at point." - (interactive) - (require 'helm-mode) - (let* ((tap (thing-at-point 'filename)) - beg - (init (and tap - (or force - (save-excursion - (end-of-line) - (search-backward tap (point-at-bol) t) - (setq beg (point)) - (looking-back "[^'`( ]"))) - (expand-file-name - (substring-no-properties tap)))) - (end (point)) - (helm-quit-if-no-candidate t) - (helm-execute-action-at-once-if-one t) - completion) - (with-helm-show-completion beg end - (setq completion (helm-read-file-name "FileName: " - :initial-input init))) - (when (and completion (not (string= completion ""))) - (delete-region beg end) (insert (if (string-match "^~" tap) - (abbreviate-file-name completion) - completion))))) - -;;;###autoload -(defun helm-lisp-indent () - ;; It is meant to use with `helm-define-multi-key' which - ;; does not support args for functions yet, so use `current-prefix-arg' - ;; for now instead of (interactive "P"). - (interactive) - (let ((tab-always-indent (or (eq tab-always-indent 'complete) - tab-always-indent))) - (indent-for-tab-command current-prefix-arg))) - -;;;###autoload -(defun helm-lisp-completion-or-file-name-at-point () - "Complete lisp symbol or filename at point. -Filename completion happen if string start after or between a double quote." - (interactive) - (let* ((tap (thing-at-point 'filename))) - (if (and tap (save-excursion - (end-of-line) - (search-backward tap (point-at-bol) t) - (looking-back "[^'`( ]"))) - (helm-complete-file-name-at-point) - (helm-lisp-completion-at-point)))) - -(helm-multi-key-defun helm-multi-lisp-complete-at-point - "Multi key function for completion in emacs lisp buffers. -First call indent, second complete symbol, third complete fname." - '(helm-lisp-indent - helm-lisp-completion-at-point - helm-complete-file-name-at-point) - 0.3) - - -;;; Apropos -;; -;; -(defun helm-apropos-init (test default) - "Init candidates buffer for `helm-apropos' sources." - (require 'helm-help) - (with-current-buffer (helm-candidate-buffer 'global) - (goto-char (point-min)) - (let ((default-symbol (and (stringp default) - (intern-soft default)))) - (when (and default-symbol (funcall test default-symbol)) - (insert (concat default "\n"))) - (cl-loop with all = (all-completions "" obarray test) - for sym in all - for s = (intern sym) - unless (or (and default (string= sym default)) - (keywordp s)) - do (insert (concat sym "\n")))))) - -(defun helm-def-source--emacs-variables (&optional default) - (helm-build-in-buffer-source - "Variables" - :init `(lambda () - (helm-apropos-init 'boundp ,default)) - :filtered-candidate-transformer - (lambda (candidates _source) - (if (string= helm-pattern "") - candidates - (sort candidates #'helm-generic-sort-fn))) - :nomark t - :action '(("Describe Variable" . helm-describe-variable) - ("Find Variable" . helm-find-variable) - ("Info lookup" . helm-info-lookup-symbol) - ("Set variable" . helm-set-variable)))) - -(defun helm-def-source--emacs-faces (&optional default) - (helm-build-in-buffer-source - "Faces" - :init `(lambda () - (helm-apropos-init 'facep ,default)) - :nomark t - :filtered-candidate-transformer - '((lambda (candidates _source) - (if (string= helm-pattern "") - candidates - (sort candidates #'helm-generic-sort-fn))) - (lambda (candidates _source) - (cl-loop for c in candidates - collect (propertize c 'face (intern c))))) - :action (lambda (candidate) - (describe-face (intern candidate))))) - -(defun helm-def-source--helm-attributes (&optional _default) - (helm-build-sync-source - "Helm attributes" - :candidates (lambda () - (mapcar 'symbol-name helm-attributes)) - :nomark t - :action (lambda (candidate) - (let (special-display-buffer-names - special-display-regexps - helm-persistent-action-use-special-display) - (with-output-to-temp-buffer "*Help*" - (princ (get (intern candidate) 'helm-attrdoc))))))) - -(defun helm-def-source--emacs-commands (&optional default) - (helm-build-in-buffer-source - "Commands" - :init `(lambda () - (helm-apropos-init 'commandp ,default)) - :filtered-candidate-transformer - (lambda (candidates _source) - (if (string= helm-pattern "") - candidates - (sort candidates #'helm-generic-sort-fn))) - :nomark t - :action '(("Describe Function" . helm-describe-function) - ("Find Function" . helm-find-function) - ("Info lookup" . helm-info-lookup-symbol)))) - -(defun helm-def-source--emacs-functions (&optional default) - (helm-build-in-buffer-source - "Functions" - :init `(lambda () - (helm-apropos-init #'(lambda (x) - (and (fboundp x) - (not (commandp x)))) - ,default)) - :filtered-candidate-transformer - (lambda (candidates _source) - (if (string= helm-pattern "") - candidates - (sort candidates #'helm-generic-sort-fn))) - :nomark t - :action '(("Describe Function" . helm-describe-function) - ("Find Function" . helm-find-function) - ("Info lookup" . helm-info-lookup-symbol)))) - -(defun helm-info-lookup-symbol (candidate) - (let ((helm-execute-action-at-once-if-one t) - (helm-quit-if-no-candidate - `(lambda () - (message "`%s' Not Documented as a symbol" ,candidate)))) - (helm :sources '(helm-source-info-elisp - helm-source-info-cl - helm-source-info-eieio) - :resume 'noresume - :buffer "*helm lookup*" - :input candidate))) - -;;;###autoload -(defun helm-apropos () - "Preconfigured helm to describe commands, functions, variables and faces." - (interactive) - (let ((default (thing-at-point 'symbol))) - (helm :sources - (mapcar (lambda (func) - (funcall func default)) - '(helm-def-source--emacs-commands - helm-def-source--emacs-functions - helm-def-source--emacs-variables - helm-def-source--emacs-faces - helm-def-source--helm-attributes)) - :buffer "*helm apropos*" - :preselect (and default (concat "\\_<" (regexp-quote default) "\\_>"))))) - - -;;; Advices -;; -;; -(defvar helm-source-advice - '((name . "Function Advice") - (candidates . helm-advice-candidates) - (action ("Toggle Enable/Disable" . helm-advice-toggle)) - (persistent-action . helm-advice-persistent-action) - (nomark) - (multiline) - (persistent-help . "Describe function / C-u C-j: Toggle advice"))) - -(defun helm-advice-candidates () - (cl-loop for (fname) in ad-advised-functions - for function = (intern fname) - append - (cl-loop for class in ad-advice-classes append - (cl-loop for advice in (ad-get-advice-info-field function class) - for enabled = (ad-advice-enabled advice) - collect - (cons (format - "%s %s %s" - (if enabled "Enabled " "Disabled") - (propertize fname 'face 'font-lock-function-name-face) - (ad-make-single-advice-docstring advice class nil)) - (list function class advice)))))) - -(defun helm-advice-persistent-action (func-class-advice) - (if current-prefix-arg - (helm-advice-toggle func-class-advice) - (describe-function (car func-class-advice)))) - -(defun helm-advice-toggle (func-class-advice) - (cl-destructuring-bind (function _class advice) func-class-advice - (cond ((ad-advice-enabled advice) - (ad-advice-set-enabled advice nil) - (message "Disabled")) - (t - (ad-advice-set-enabled advice t) - (message "Enabled"))) - (ad-activate function) - (and helm-in-persistent-action - (helm-advice-update-current-display-string)))) - -(defun helm-advice-update-current-display-string () - (helm-edit-current-selection - (let ((newword (cond ((looking-at "Disabled") "Enabled") - ((looking-at "Enabled") "Disabled")))) - (when newword - (delete-region (point) (progn (forward-word 1) (point))) - (insert newword))))) - -;;;###autoload -(defun helm-manage-advice () - "Preconfigured `helm' to disable/enable function advices." - (interactive) - (helm-other-buffer 'helm-source-advice "*helm advice*")) - - -;;; Locate elisp library -;; -;; -(defvar helm-source-locate-library - `((name . "Elisp libraries (Scan)") - (init . (helm-locate-library-scan-init)) - (candidates-in-buffer) - (candidate-number-limit . 9999) - (keymap . ,helm-generic-files-map) - (type . file))) - -(defun helm-locate-library-scan-init () - "Init helm buffer status." - (helm-init-candidates-in-buffer - 'global (helm-locate-library-scan-list))) - -(defun helm-locate-library-scan-list () - (cl-loop for dir in load-path - when (file-directory-p dir) - append (directory-files dir t (concat (regexp-opt (get-load-suffixes)) - "\\'")) - into lst - finally return (helm-fast-remove-dups lst :test 'equal))) - -;;;###autoload -(defun helm-locate-library () - (interactive) - (helm :sources 'helm-source-locate-library - :buffer "*helm locate library*")) - -(defun helm-set-variable (var) - "Set value to VAR interactively." - (let* ((sym (helm-symbolify var)) - (val (symbol-value sym))) - (set sym (eval-minibuffer (format "Set `%s': " var) - (if (or (stringp val) (memq val '(nil t))) - (prin1-to-string val) - (format "'%s" (prin1-to-string val))))))) - - -;;; Type attributes -;; -;; -(let ((actions '(("Describe command" . describe-function) - ("Add command to kill ring" . helm-kill-new) - ("Go to command's definition" . find-function) - ("Debug on entry" . debug-on-entry) - ("Cancel debug on entry" . cancel-debug-on-entry) - ("Trace function" . trace-function) - ("Trace function (background)" . trace-function-background) - ("Untrace function" . untrace-function)))) - (define-helm-type-attribute 'command - `((action ("Call interactively" . helm-call-interactively) - ,@actions) - (coerce . helm-symbolify) - (persistent-action . describe-function)) - "Command. (string or symbol)") - - (define-helm-type-attribute 'function - `((action . ,actions) - (action-transformer helm-transform-function-call-interactively) - (candidate-transformer helm-mark-interactive-functions) - (coerce . helm-symbolify)) - "Function. (string or symbol)")) - -(define-helm-type-attribute 'variable - '((action - ("Describe variable" . describe-variable) - ("Add variable to kill ring" . helm-kill-new) - ("Go to variable's definition" . find-variable) - ("Set variable" . helm-set-variable)) - (coerce . helm-symbolify)) - "Variable.") - -(defun helm-btf--usable-p () - "Return t if current version of `backtrace-frame' accept 2 arguments." - (condition-case nil - (and (backtrace-frame 1 'condition-case) t) - (wrong-number-of-arguments nil))) - -(if (helm-btf--usable-p) ; Check if BTF accept more than one arg. - ;; Emacs 24.4. - (dont-compile - (defvar helm-sexp--last-sexp nil) - ;; This wont work compiled. - (defun helm-sexp-eval-1 () - (interactive) - (unwind-protect - (progn - ;; Trick called-interactively-p into thinking that `cand' is - ;; an interactive call, See `repeat-complex-command'. - (add-hook 'called-interactively-p-functions - #'helm-complex-command-history--called-interactively-skip) - (eval (read helm-sexp--last-sexp))) - (remove-hook 'called-interactively-p-functions - #'helm-complex-command-history--called-interactively-skip))) - - (defun helm-complex-command-history--called-interactively-skip (i _frame1 frame2) - (and (eq 'eval (cadr frame2)) - (eq 'helm-sexp-eval-1 - (cadr (backtrace-frame (+ i 2) #'called-interactively-p))) - 1)) - - (defun helm-sexp-eval (_candidate) - (call-interactively #'helm-sexp-eval-1))) - ;; Emacs 24.3 - (defun helm-sexp-eval (cand) - (let ((sexp (read cand))) - (condition-case err - (if (> (length (remove nil sexp)) 1) - (eval sexp) - (apply 'call-interactively sexp)) - (error (message "Evaluating gave an error: %S" err) - nil))))) - -(define-helm-type-attribute 'sexp - '((action - ("Eval" . (lambda (candidate) - (and (boundp 'helm-sexp--last-sexp) - (setq helm-sexp--last-sexp candidate)) - (helm-run-after-quit 'helm-sexp-eval candidate))) - ("Edit and eval" . - (lambda (cand) - (minibuffer-with-setup-hook - (lambda () (insert cand)) - (call-interactively #'eval-expression))))) - (persistent-action . helm-sexp-eval)) - "Sexp.") - -(define-helm-type-attribute 'timer - '((action - ("Cancel Timer" . (lambda (_timer) - (let ((mkd (helm-marked-candidates))) - (cl-loop for timer in mkd - do (cancel-timer timer))))) - ("Describe Function" . (lambda (tm) (describe-function (timer--function tm)))) - ("Find Function" . (lambda (tm) (find-function (timer--function tm))))) - (persistent-action . (lambda (tm) (describe-function (timer--function tm)))) - (persistent-help . "Describe Function")) - "Timer.") - - -;;; Elisp Timers. -;; -;; -(defvar helm-source-absolute-time-timers - '((name . "Absolute Time Timers") - (candidates . timer-list) - (filtered-candidate-transformer - . (lambda (candidates _source) - (cl-loop for timer in candidates - collect (cons (helm-elisp--format-timer timer) timer)))) - (allow-dups) - (volatile) - (type . timer))) - -(defvar helm-source-idle-time-timers - '((name . "Idle Time Timers") - (candidates . timer-idle-list) - (allow-dups) - (volatile) - (filtered-candidate-transformer - . (lambda (candidates _source) - (cl-loop for timer in candidates - collect (cons (helm-elisp--format-timer timer) timer)))) - (type . timer))) - -(defun helm-elisp--format-timer (timer) - (format "%s repeat=%s %s(%s)" - (let ((time (timer--time timer))) - (if (timer--idle-delay timer) - (format-time-string "idle-for=%5s" time) - (format-time-string "%m/%d %T" time))) - (or (timer--repeat-delay timer) "nil") - (mapconcat 'identity (split-string - (prin1-to-string (timer--function timer)) - "\n") " ") - (mapconcat 'prin1-to-string (timer--args timer) " "))) - -;;;###autoload -(defun helm-timers () - "Preconfigured `helm' for timers." - (interactive) - (helm-other-buffer '(helm-source-absolute-time-timers - helm-source-idle-time-timers) - "*helm timers*")) - - -;;; Complex command history -;; -;; -(defvar helm-source-complex-command-history - '((name . "Complex Command History") - (candidates . (lambda () - ;; Use cdr to avoid adding - ;; `helm-complex-command-history' here. - (cl-loop for i in command-history - unless (equal i '(helm-complex-command-history)) - collect (prin1-to-string i)))) - (type . sexp))) - -;;;###autoload -(defun helm-complex-command-history () - (interactive) - (helm :sources 'helm-source-complex-command-history - :buffer "*helm complex commands*")) - -(provide 'helm-elisp) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-elisp.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-elscreen.el b/emacs.d/elpa/helm-20141016.2217/helm-elscreen.el deleted file mode 100644 index 92fa5a7..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-elscreen.el +++ /dev/null @@ -1,79 +0,0 @@ -;;; helm-elscreen.el -- Elscreen support -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) - -(declare-function elscreen-find-screen-by-buffer "ext:elscreen.el" (buffer &optional create)) -(declare-function elscreen-find-file "ext:elscreen.el" (filename)) -(declare-function elscreen-goto "ext:elscreen.el" (screen)) - -(defun helm-find-buffer-on-elscreen (candidate) - "Open buffer in new screen, if marked buffers open all in elscreens." - (helm-require-or-error 'elscreen 'helm-find-buffer-on-elscreen) - (helm-aif (helm-marked-candidates) - (cl-dolist (i it) - (let ((target-screen (elscreen-find-screen-by-buffer - (get-buffer i) 'create))) - (elscreen-goto target-screen))) - (let ((target-screen (elscreen-find-screen-by-buffer - (get-buffer candidate) 'create))) - (elscreen-goto target-screen)))) - -(defun helm-elscreen-find-file (file) - (helm-require-or-error 'elscreen 'helm-elscreen-find-file) - (elscreen-find-file file)) - -(defvar helm-source-elscreen - '((name . "Elscreen") - (candidates - . (lambda () - (if (cdr (elscreen-get-screen-to-name-alist)) - (sort - (cl-loop for sname in (elscreen-get-screen-to-name-alist) - append (list (format "[%d] %s" (car sname) (cdr sname)))) - #'(lambda (a b) (compare-strings a nil nil b nil nil)))))) - (action - . (("Change Screen" . - (lambda (candidate) - (elscreen-goto (- (aref candidate 1) (aref "0" 0))))) - ("Kill Screen(s)" . - (lambda (candidate) - (cl-dolist (i (helm-marked-candidates)) - (elscreen-goto (- (aref i 1) (aref "0" 0))) - (elscreen-kill)))) - ("Only Screen" . - (lambda (candidate) - (elscreen-goto (- (aref candidate 1) (aref "0" 0))) - (elscreen-kill-others))))))) - -;;;###autoload -(defun helm-elscreen () - "Preconfigured helm to list elscreen." - (interactive) - (helm-other-buffer 'helm-source-elscreen "*Helm Elscreen*")) - -(provide 'helm-elscreen) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-elscreen.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-emms.el b/emacs.d/elpa/helm-20141016.2217/helm-emms.el deleted file mode 100644 index a4b35de..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-emms.el +++ /dev/null @@ -1,186 +0,0 @@ -;;; helm-emms.el --- Emms for Helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) - -(declare-function emms-streams "ext:emms-streams") -(declare-function emms-stream-delete-bookmark "ext:emms-streams") -(declare-function emms-stream-add-bookmark "ext:emms-streams" (name url fd type)) -(declare-function emms-stream-save-bookmarks-file "ext:emms-streams") -(declare-function emms-stream-quit "ext:emms-streams") -(declare-function with-current-emms-playlist "ext:emms" (&rest body)) -(declare-function emms-playlist-tracks-in-region "ext:emms" (beg end)) -(declare-function emms-playlist-first "ext:emms") -(declare-function emms-playlist-mode-play-smart "ext:emms-playlist-mode") - - -(defgroup helm-emms nil - "Predefined configurations for `helm.el'." - :group 'helm) - -(defface helm-emms-playlist - '((t (:foreground "Springgreen4" :underline t))) - "Face used for tracks in current emms playlist." - :group 'helm-emms) - - -(defvar emms-stream-list) -(defun helm-emms-stream-edit-bookmark (elm) - "Change the information of current emms-stream bookmark from helm." - (let* ((cur-buf helm-current-buffer) - (bookmark (assoc elm emms-stream-list)) - (name (read-from-minibuffer "Description: " - (nth 0 bookmark))) - (url (read-from-minibuffer "URL: " - (nth 1 bookmark))) - (fd (read-from-minibuffer "Feed Descriptor: " - (int-to-string (nth 2 bookmark)))) - (type (read-from-minibuffer "Type (url, streamlist, or lastfm): " - (format "%s" (car (last bookmark)))))) - (save-window-excursion - (emms-streams) - (when (re-search-forward (concat "^" name) nil t) - (forward-line 0) - (emms-stream-delete-bookmark) - (emms-stream-add-bookmark name url (string-to-number fd) type) - (emms-stream-save-bookmarks-file) - (emms-stream-quit) - (helm-switch-to-buffer cur-buf))))) - -(defun helm-emms-stream-delete-bookmark (_candidate) - "Delete emms-streams bookmarks from helm." - (let* ((cands (helm-marked-candidates)) - (bmks (cl-loop for bm in cands collect - (car (assoc bm emms-stream-list)))) - (bmk-reg (mapconcat 'regexp-quote bmks "\\|^"))) - (when (y-or-n-p (format "Really delete radios\n -%s: ? " - (mapconcat 'identity bmks "\n -"))) - (save-window-excursion - (emms-streams) - (goto-char (point-min)) - (cl-loop while (re-search-forward bmk-reg nil t) - do (progn (forward-line 0) - (emms-stream-delete-bookmark)) - finally do (progn - (emms-stream-save-bookmarks-file) - (emms-stream-quit))))))) - -(defvar helm-source-emms-streams - '((name . "Emms Streams") - (init . (lambda () - (emms-stream-init))) - (candidates . (lambda () - (mapcar 'car emms-stream-list))) - (action . (("Play" . (lambda (elm) - (let* ((stream (assoc elm emms-stream-list)) - (fn (intern (concat "emms-play-" (symbol-name (car (last stream)))))) - (url (cl-second stream))) - (funcall fn url)))) - ("Delete" . helm-emms-stream-delete-bookmark) - ("Edit" . helm-emms-stream-edit-bookmark))) - (filtered-candidate-transformer . helm-adaptive-sort))) - -;; Don't forget to set `emms-source-file-default-directory' -(defvar helm-source-emms-dired - '((name . "Music Directory") - (candidates . (lambda () - (cddr (directory-files emms-source-file-default-directory)))) - (action . - (("Play Directory" . (lambda (item) - (emms-play-directory - (expand-file-name - item - emms-source-file-default-directory)))) - ("Open dired in file's directory" . (lambda (item) - (helm-open-dired - (expand-file-name - item - emms-source-file-default-directory)))))) - (filtered-candidate-transformer . helm-adaptive-sort))) - -(defvar helm-emms-current-playlist nil) -(defun helm-emms-files-modifier (candidates _source) - (cl-loop for i in candidates - if (member (cdr i) helm-emms-current-playlist) - collect (cons (propertize (car i) - 'face 'helm-emms-playlist) - (cdr i)) - into lis - else collect i into lis - finally return (reverse lis))) - -(defun helm-emms-play-current-playlist () - "Play current playlist." - (emms-playlist-first) - (emms-playlist-mode-play-smart)) - -(defvar helm-source-emms-files - '((name . "Emms files") - (init . (lambda () - (setq helm-emms-current-playlist - (with-current-emms-playlist - (cl-loop with cur-list = (emms-playlist-tracks-in-region - (point-min) (point-max)) - for i in cur-list - for name = (assoc-default 'name i) - when name - collect name))))) - (candidates . (lambda () - (cl-loop for v being the hash-values in emms-cache-db - for name = (assoc-default 'name v) - for artist = (or (assoc-default 'info-artist v) "unknown") - for genre = (or (assoc-default 'info-genre v) "unknown") - for tracknum = (or (assoc-default 'info-tracknumber v) "unknown") - for song = (or (assoc-default 'info-title v) "unknown") - for info = (concat artist " - " genre " - " tracknum ": " song) - unless (string-match "^\\(http\\|mms\\):" name) - collect (cons info name)))) - (filtered-candidate-transformer . helm-emms-files-modifier) - (candidate-number-limit . 9999) - (action . (("Play file" . emms-play-file) - ("Add to Playlist and play (C-u clear current)" - . (lambda (candidate) - (with-current-emms-playlist - (when helm-current-prefix-arg - (emms-playlist-current-clear)) - (emms-playlist-new) - (mapc 'emms-add-playlist-file (helm-marked-candidates)) - (unless emms-player-playing-p - (helm-emms-play-current-playlist))))))))) - -;;;###autoload -(defun helm-emms () - "Preconfigured `helm' for emms sources." - (interactive) - (helm :sources '(helm-source-emms-streams - helm-source-emms-files - helm-source-emms-dired) - :buffer "*Helm Emms*")) - - -(provide 'helm-emms) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-emms ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-eshell.el b/emacs.d/elpa/helm-20141016.2217/helm-eshell.el deleted file mode 100644 index d79bdeb..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-eshell.el +++ /dev/null @@ -1,236 +0,0 @@ -;;; helm-eshell.el --- pcomplete and eshell completion for helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;; Enable like this in .emacs: -;; -;; (add-hook 'eshell-mode-hook -;; #'(lambda () -;; (define-key eshell-mode-map [remap pcomplete] 'helm-esh-pcomplete))) -;; - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'helm-elisp) -(require 'helm-regexp) - -(declare-function eshell-read-aliases-list "em-alias") -(declare-function eshell-send-input "esh-mode" (&optional use-region queue-p no-newline)) -(declare-function eshell-bol "esh-mode") -(declare-function eshell-parse-arguments "esh-arg" (beg end)) - -(defvar helm-eshell-history-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-p") 'helm-next-line) - map) - "Keymap for `helm-eshell-history'.") - -(defvar helm-esh-completion-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "TAB") 'helm-next-line) - map) - "Keymap for `helm-esh-pcomplete'.") - -(defvar helm-source-esh - '((name . "Eshell completions") - (init . (lambda () - (setq pcomplete-current-completions nil - pcomplete-last-completion-raw nil) - ;; Eshell-command add this hook in all minibuffers - ;; Remove it for the helm one. (Fixed in Emacs24) - (remove-hook 'minibuffer-setup-hook 'eshell-mode))) - (candidates . helm-esh-get-candidates) - (nomark) - (persistent-action . ignore) - (filtered-candidate-transformer - (lambda (candidates _sources) - (cl-loop for i in (sort candidates 'helm-generic-sort-fn) - collect - (cond ((string-match "\\`~/?" helm-ec-target) - (abbreviate-file-name i)) - ((string-match "\\`/" helm-ec-target) i) - (t - (file-relative-name i)))))) - (action . helm-ec-insert)) - "Helm source for Eshell completion.") - -;; Internal. -(defvar helm-ec-target "") -(defun helm-ec-insert (candidate) - "Replace text at point with CANDIDATE. -The function that call this should set `helm-ec-target' to thing at point." - (let ((pt (point))) - (when (and helm-ec-target - (search-backward helm-ec-target nil t) - (string= (buffer-substring (point) pt) helm-ec-target)) - (delete-region (point) pt))) - (cond ((string-match "\\`~/?" helm-ec-target) - (insert (helm-quote-whitespace (abbreviate-file-name candidate)))) - ((string-match "\\`/" helm-ec-target) - (insert (helm-quote-whitespace candidate))) - (t - (insert (concat (and (string-match "\\`[.]/" helm-ec-target) "./") - (helm-quote-whitespace - (file-relative-name candidate))))))) - -(defun helm-esh-get-candidates () - "Get candidates for eshell completion using `pcomplete'." - (catch 'pcompleted - (with-helm-current-buffer - (let* ((pcomplete-stub) - pcomplete-seen pcomplete-norm-func - pcomplete-args pcomplete-last pcomplete-index - (pcomplete-autolist pcomplete-autolist) - (pcomplete-suffix-list pcomplete-suffix-list) - (table (pcomplete-completions)) - (entry (or (try-completion helm-pattern - (pcomplete-entries)) - helm-pattern))) - (cl-loop ;; expand entry too to be able to compare it with file-cand. - with exp-entry = (and (stringp entry) - (not (string= entry "")) - (file-name-as-directory - (expand-file-name entry default-directory))) - for i in (all-completions pcomplete-stub table) - ;; Transform the related names to abs names. - for file-cand = (and exp-entry - (if (file-remote-p i) i - (expand-file-name - i (file-name-directory entry)))) - ;; Compare them to avoid dups. - for file-entry-p = (and (stringp exp-entry) - (stringp file-cand) - ;; Fix :/tmp/foo/ $ cd foo - (not (file-directory-p file-cand)) - (file-equal-p exp-entry file-cand)) - if (and file-cand (or (file-remote-p file-cand) - (file-exists-p file-cand)) - (not file-entry-p)) - collect file-cand into ls - else - ;; Avoid adding entry here. - unless file-entry-p collect i into ls - finally return - (if (and exp-entry - (file-directory-p exp-entry) - ;; If the car of completion list is - ;; an executable, probably we are in - ;; command completion, so don't add a - ;; possible file related entry here. - (and ls (not (executable-find (car ls)))) - ;; Don't add entry if already in prompt. - (not (file-equal-p exp-entry pcomplete-stub))) - (append (list exp-entry) - ;; Entry should not be here now but double check. - (remove entry ls)) - ls)))))) - -;;; Eshell history. -;; -;; -(defvar helm-source-eshell-history - `((name . "Eshell history") - (init . (lambda () - (let (eshell-hist-ignoredups) - (eshell-write-history eshell-history-file-name t) - (with-current-buffer (helm-candidate-buffer 'global) - (insert-file-contents eshell-history-file-name))) - ;; Same comment as in `helm-source-esh' - (remove-hook 'minibuffer-setup-hook 'eshell-mode))) - (candidates-in-buffer) - (nomark) - (keymap . ,helm-eshell-history-map) - (filtered-candidate-transformer . (lambda (candidates sources) - (reverse candidates))) - (candidate-number-limit . 9999) - (action . (lambda (candidate) - (eshell-kill-input) - (insert candidate)))) - "Helm source for Eshell history.") - -;;;###autoload -(defun helm-esh-pcomplete () - "Preconfigured helm to provide helm completion in eshell." - (interactive) - (let* ((helm-quit-if-no-candidate t) - (helm-execute-action-at-once-if-one t) - (end (point-marker)) - (beg (save-excursion (eshell-bol) (point))) - (args (catch 'eshell-incomplete - (eshell-parse-arguments beg end))) - ;; Use thing-at-point instead of last args value - ;; to exclude possible delimiters e.g "(". - (target (thing-at-point 'symbol)) - (first (car args)) ; Maybe lisp delimiter "(". - last) ; Will be the last but parsed by pcomplete. - (setq helm-ec-target (or target " ") - end (point) - ;; Reset beg for `with-helm-show-completion'. - beg (or (and target (- end (length target))) - ;; Nothing at point. - (progn (insert " ") (point)))) - (cond ((eq first ?\() - (helm-lisp-completion-or-file-name-at-point)) - ;; In eshell `pcomplete-parse-arguments' is called - ;; with `pcomplete-parse-arguments-function' - ;; locally bound to `eshell-complete-parse-arguments' - ;; which is calling `lisp-complete-symbol', - ;; calling it before would popup the - ;; *completions* buffer. - (t (setq last (car (last (ignore-errors - (pcomplete-parse-arguments))))) - (with-helm-show-completion beg end - (helm :sources 'helm-source-esh - :buffer "*helm pcomplete*" - :keymap helm-esh-completion-map - :resume 'noresume - :input (and (stringp last) - (helm-ff-set-pattern last)))))))) - -;;;###autoload -(defun helm-eshell-history () - "Preconfigured helm for eshell history." - (interactive) - (let* ((end (point)) - (beg (save-excursion (eshell-bol) (point))) - (input (buffer-substring beg end)) - flag-empty) - (when (eq beg end) - (insert " ") - (setq flag-empty t) - (setq end (point))) - (unwind-protect - (with-helm-show-completion beg end - (helm :sources 'helm-source-eshell-history - :buffer "*helm eshell history*" - :resume 'noresume - :input input)) - (when (and flag-empty - (looking-back " ")) - (delete-char -1))))) - -(provide 'helm-eshell) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-eshell ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-eval.el b/emacs.d/elpa/helm-20141016.2217/helm-eval.el deleted file mode 100644 index 9fbf0ee..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-eval.el +++ /dev/null @@ -1,177 +0,0 @@ -;;; helm-eval.el --- eval expressions from helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'eldoc) - - -(defgroup helm-eval nil - "Eval related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-eldoc-in-minibuffer-show-fn - 'helm-show-info-in-mode-line - "A function to display eldoc info. -Should take one arg: the string to display." - :group 'helm-eval - :type 'symbol) - -(defcustom helm-show-info-in-mode-line-delay 12 - "Eldoc will show info in mode-line during this delay if user is idle." - :type 'integer - :group 'helm-eval) - - -(declare-function eldoc-current-symbol "eldoc") -(declare-function eldoc-get-fnsym-args-string "eldoc" (sym &optional index)) -(declare-function eldoc-get-var-docstring "eldoc" (sym)) -(declare-function eldoc-fnsym-in-current-sexp "eldoc") - -;;; Evaluation Result -;; -;; -;; Internal -(defvar helm-eldoc-active-minibuffers-list nil) - -(defvar helm-eval-expression-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "") 'helm-eval-new-line-and-indent) - (define-key map (kbd "") 'lisp-indent-line) - (define-key map (kbd "") 'helm-lisp-completion-at-point) - (define-key map (kbd "C-p") 'previous-line) - (define-key map (kbd "C-n") 'next-line) - (define-key map (kbd "") 'previous-line) - (define-key map (kbd "") 'next-line) - (define-key map (kbd "") 'forward-char) - (define-key map (kbd "") 'backward-char) - map)) - -(defvar helm-source-evaluation-result - '((name . "Evaluation Result") - (init . (lambda () (require 'edebug))) - (dummy) - (multiline) - (mode-line . "C-RET: nl-and-indent, tab: reindent, C-tab:complete, C-p/n: next/prec-line.") - (filtered-candidate-transformer . (lambda (candidates _source) - (list - (condition-case nil - (with-helm-current-buffer - (pp-to-string - (if edebug-active - (edebug-eval-expression - (read helm-pattern)) - (eval (read helm-pattern))))) - (error "Error"))))) - (action . (("Copy result to kill-ring" . (lambda (candidate) - (kill-new - (replace-regexp-in-string - "\n" "" candidate)))) - ("copy sexp to kill-ring" . (lambda (candidate) - (kill-new helm-input))))))) - -(defun helm-eval-new-line-and-indent () - (interactive) - (newline) (lisp-indent-line)) - -(defun helm-eldoc-store-minibuffer () - "Store minibuffer buffer name in `helm-eldoc-active-minibuffers-list'." - (with-selected-window (minibuffer-window) - (push (current-buffer) helm-eldoc-active-minibuffers-list))) - -(defun helm-eldoc-show-in-eval () - "Return eldoc in mode-line for current minibuffer input." - (let ((buf (window-buffer (active-minibuffer-window)))) - (condition-case err - (when (member buf helm-eldoc-active-minibuffers-list) - (with-current-buffer buf - (let* ((sym (save-excursion - (unless (looking-back ")\\|\"") - (forward-char -1)) - (eldoc-current-symbol))) - (info-fn (eldoc-fnsym-in-current-sexp)) - (doc (or (eldoc-get-var-docstring sym) - (eldoc-get-fnsym-args-string - (car info-fn) (cadr info-fn))))) - (when doc (funcall helm-eldoc-in-minibuffer-show-fn doc))))) - (error (message "Eldoc in minibuffer error: %S" err) nil)))) - -(defun helm-show-info-in-mode-line (str) - "Display string STR in mode-line." - (save-selected-window - (with-current-buffer helm-buffer - (let ((mode-line-format (concat " " str))) - (force-mode-line-update) - (sit-for helm-show-info-in-mode-line-delay)) - (force-mode-line-update)))) - -;;; Calculation Result -;; -;; -(defvar helm-source-calculation-result - '((name . "Calculation Result") - (dummy) - (filtered-candidate-transformer . (lambda (candidates _source) - (list - (condition-case nil - (calc-eval helm-pattern) - (error "error"))))) - (action ("Copy result to kill-ring" . kill-new)))) - -;;;###autoload -(defun helm-eval-expression (arg) - "Preconfigured helm for `helm-source-evaluation-result'." - (interactive "P") - (helm :sources 'helm-source-evaluation-result - :input (when arg (thing-at-point 'sexp)) - :buffer "*helm eval*" - :history 'read-expression-history - :keymap helm-eval-expression-map)) - -(defvar eldoc-idle-delay) -;;;###autoload -(defun helm-eval-expression-with-eldoc () - "Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support. " - (interactive) - (let ((timer (run-with-idle-timer - eldoc-idle-delay 'repeat - 'helm-eldoc-show-in-eval))) - (unwind-protect - (minibuffer-with-setup-hook - 'helm-eldoc-store-minibuffer - (call-interactively 'helm-eval-expression)) - (and timer (cancel-timer timer)) - (setq helm-eldoc-active-minibuffers-list - (cdr helm-eldoc-active-minibuffers-list))))) - -;;;###autoload -(defun helm-calcul-expression () - "Preconfigured helm for `helm-source-calculation-result'." - (interactive) - (helm-other-buffer 'helm-source-calculation-result "*helm calcul*")) - -(provide 'helm-eval) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-eval.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-external.el b/emacs.d/elpa/helm-20141016.2217/helm-external.el deleted file mode 100644 index bb02a7c..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-external.el +++ /dev/null @@ -1,215 +0,0 @@ -;;; helm-external.el --- Run Externals commands within Emacs with helm completion. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) - - -(defgroup helm-external nil - "External related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-raise-command nil - "A shell command to jump to a window running specific program. -Need external program wmctrl. -This will be use with `format', so use something like \"wmctrl -xa %s\"." - :type 'string - :group 'helm-external) - -(defcustom helm-external-programs-associations nil - "Alist to store externals programs associated with file extension. -This variable overhide setting in .mailcap file. -e.g : '\(\(\"jpg\" . \"gqview\"\) (\"pdf\" . \"xpdf\"\)\) " - :type '(alist :key-type string :value-type string) - :group 'helm-external) - -(defcustom helm-default-external-file-browser "nautilus" - "Default external file browser for your system. -Directories will be opened externally with it when -opening file externally in `helm-find-files'. -Set to nil if you do not have external file browser -or do not want to use it. -Windows users should set that to \"explorer.exe\"." - :group 'helm-external - :type 'string) - - -;;; Internals -(defvar helm-external-command-history nil) -(defvar helm-external-commands-list nil - "A list of all external commands the user can execute. -If this variable is not set by the user, it will be calculated -automatically.") - -(defun helm-external-commands-list-1 (&optional sort) - "Returns a list of all external commands the user can execute. -If `helm-external-commands-list' is non-nil it will -return its contents. Else it calculates all external commands -and sets `helm-external-commands-list'." - (helm-aif helm-external-commands-list - it - (setq helm-external-commands-list - (cl-loop - for dir in (split-string (getenv "PATH") path-separator) - when (and (file-exists-p dir) (file-accessible-directory-p dir)) - for lsdir = (cl-loop for i in (directory-files dir t) - for bn = (file-name-nondirectory i) - when (and (not (member bn completions)) - (not (file-directory-p i)) - (file-executable-p i)) - collect bn) - append lsdir into completions - finally return - (if sort (sort completions 'string-lessp) completions))))) - -(defun helm-run-or-raise (exe &optional file) - "Generic command that run asynchronously EXE. -If EXE is already running just jump to his window if `helm-raise-command' -is non--nil. -When FILE argument is provided run EXE with FILE. -In this case EXE must be provided as \"EXE %s\"." - (let* ((real-com (car (split-string (replace-regexp-in-string - "%s" "" exe)))) - (proc (if file (concat real-com " " file) real-com)) - process-connection-type) - (if (get-process proc) - (if helm-raise-command - (shell-command (format helm-raise-command real-com)) - (error "Error: %s is already running" real-com)) - (when (cl-loop for i in helm-external-commands-list thereis (string= real-com i)) - (message "Starting %s..." real-com) - (if file - (start-process-shell-command - proc nil (format exe (shell-quote-argument - (if (eq system-type 'windows-nt) - (helm-w32-prepare-filename file) - file)))) - (start-process-shell-command proc nil real-com)) - (set-process-sentinel - (get-process proc) - #'(lambda (process event) - (when (and (string= event "finished\n") - helm-raise-command - (not (helm-get-pid-from-process-name real-com))) - (shell-command (format helm-raise-command "emacs"))) - (message "%s process...Finished." process)))) - (setq helm-external-commands-list - (cons real-com - (delete real-com helm-external-commands-list)))))) - -(defun helm-get-mailcap-for-file (filename) - "Get the command to use for FILENAME from mailcap files. -The command is like and is meant to use with `format'." - (mailcap-parse-mailcaps) - (let* ((ext (file-name-extension filename)) - (mime (when ext (mailcap-extension-to-mime ext))) - (result (when mime (mailcap-mime-info mime)))) - ;; If elisp file have no associations in .mailcap - ;; `mailcap-maybe-eval' is returned, in this case just return nil. - (when (stringp result) result))) - -(defun helm-get-default-program-for-file (filename) - "Try to find a default program to open FILENAME. -Try first in `helm-external-programs-associations' and then in mailcap file -if nothing found return nil." - (let* ((ext (file-name-extension filename)) - (def-prog (assoc-default ext helm-external-programs-associations))) - (cond ((and def-prog (not (string= def-prog ""))) - (concat def-prog " %s")) - ((and helm-default-external-file-browser - (file-directory-p filename)) - (concat helm-default-external-file-browser " %s")) - (t (helm-get-mailcap-for-file filename))))) - -(defun helm-open-file-externally (file) - "Open FILE with an external program. -Try to guess which program to use with `helm-get-default-program-for-file'. -If not found or a prefix arg is given query the user which tool to use." - (let* ((fname (expand-file-name file)) - (collection (helm-external-commands-list-1 'sort)) - (def-prog (helm-get-default-program-for-file fname)) - (real-prog-name (if (or helm-current-prefix-arg (not def-prog)) - ;; Prefix arg or no default program. - (prog1 - (helm-comp-read - "Program: " collection - :must-match t - :name "Open file Externally" - :del-input nil - :history helm-external-command-history) - ;; Always prompt to set this program as default. - (setq def-prog nil)) - ;; No prefix arg or default program exists. - (replace-regexp-in-string " %s\\| '%s'" "" def-prog))) - (program (concat real-prog-name " %s"))) - (unless (or def-prog ; Association exists, no need to record it. - ;; Don't try to record non--filenames associations (e.g urls). - (not (file-exists-p fname))) - (when - (y-or-n-p - (format - "Do you want to make `%s' the default program for this kind of files? " - real-prog-name)) - (helm-aif (assoc (file-name-extension fname) - helm-external-programs-associations) - (setq helm-external-programs-associations - (delete it helm-external-programs-associations))) - (push (cons (file-name-extension fname) - (helm-read-string - "Program (Add args maybe and confirm): " real-prog-name)) - helm-external-programs-associations) - (customize-save-variable 'helm-external-programs-associations - helm-external-programs-associations))) - (helm-run-or-raise program file) - (setq helm-external-command-history - (cons real-prog-name - (delete real-prog-name - (cl-loop for i in helm-external-command-history - when (executable-find i) collect i)))))) - -;;;###autoload -(defun helm-run-external-command (program) - "Preconfigured `helm' to run External PROGRAM asyncronously from Emacs. -If program is already running exit with error. -You can set your own list of commands with -`helm-external-commands-list'." - (interactive (list - (helm-comp-read - "RunProgram: " - (helm-external-commands-list-1 'sort) - :must-match t - :del-input nil - :name "External Commands" - :history helm-external-command-history))) - (helm-run-or-raise program) - (setq helm-external-command-history - (cons program (delete program - (cl-loop for i in helm-external-command-history - when (executable-find i) collect i))))) - - -(provide 'helm-external) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-external ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-files.el b/emacs.d/elpa/helm-20141016.2217/helm-files.el deleted file mode 100644 index 1272cde..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-files.el +++ /dev/null @@ -1,2922 +0,0 @@ -;;; helm-files.el --- helm file browser and related. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-external) -(require 'helm-grep) -(require 'helm-match-plugin) -(require 'helm-help) -(require 'helm-locate) -(require 'helm-bookmark) -(require 'helm-tags) -(require 'helm-buffers) -(require 'thingatpt) -(require 'ffap) -(require 'dired-aux) -(require 'dired-x) -(require 'tramp) -(require 'image-dired) - -(declare-function find-library-name "find-func.el" (library)) -(declare-function secure-hash "ext:fns.c" (algorithm object &optional start end binary)) -(declare-function w32-shell-execute "ext:w32fns.c" (operation document &optional parameters show-flag)) -(declare-function gnus-dired-attach "ext:gnus-dired.el" (files-to-attach)) -(declare-function image-dired-display-image "image-dired.el" (file &optional original-size)) -(declare-function image-dired-update-property "image-dired.el" (prop value)) -(declare-function eshell-read-aliases-list "em-alias") -(declare-function eshell-send-input "esh-mode" (&optional use-region queue-p no-newline)) -(declare-function eshell-kill-input "esh-mode") -(declare-function eshell-bol "esh-mode") -(declare-function helm-ls-git-ls "ext:helm-ls-git") -(declare-function helm-hg-find-files-in-project "ext:helm-ls-hg") - - -;;; Type attributes -;; -;; -(define-helm-type-attribute 'file - (helm-build-type-file) - "File name.") - - - -(defgroup helm-files nil - "Files applications and libraries for Helm." - :group 'helm) - -(defcustom helm-boring-file-regexp-list - (mapcar (lambda (f) - (concat - (rx-to-string - (replace-regexp-in-string - "/$" "" f) t) "$")) - completion-ignored-extensions) - "The regexp list matching boring files." - :group 'helm-files - :type '(repeat (choice regexp))) - -(defcustom helm-for-files-preferred-list - '(helm-source-buffers-list - helm-source-recentf - helm-source-bookmarks - helm-source-file-cache - helm-source-files-in-current-dir - helm-source-locate) - "Your preferred sources to find files." - :type '(repeat (choice symbol)) - :group 'helm-files) - -(defcustom helm-tramp-verbose 0 - "Just like `tramp-verbose' but specific to helm. -When set to 0 don't show tramp messages in helm. -If you want to have the default tramp messages set it to 3." - :type 'integer - :group 'helm-files) - -(defcustom helm-ff-auto-update-initial-value nil - "Auto update when only one candidate directory is matched. -Default value when starting `helm-find-files' is nil because -it prevent using to delete char backward and by the way -confuse beginners. -For a better experience with `helm-find-files' set this to non--nil -and use C- to toggle it." - :group 'helm-files - :type 'boolean) - -(defcustom helm-ff-lynx-style-map t - "Use arrow keys to navigate with `helm-find-files'. -You will have to restart Emacs or reeval `helm-find-files-map' -and `helm-read-file-map' for this take effect." - :group 'helm-files - :type 'boolean) - -(defcustom helm-ff-history-max-length 100 - "Number of elements shown in `helm-find-files' history." - :group 'helm-files - :type 'integer) - -(defcustom helm-ff-smart-completion t - "Try to complete filenames smarter when non--nil. -See `helm-ff--transform-pattern-for-completion' for more info." - :group 'helm-files - :type 'boolean) - -(defcustom helm-ff-tramp-not-fancy t - "No colors when listing remote files when set to non--nil. -This make listing much faster, specially on slow machines." - :group 'helm-files - :type 'boolean) - -(defcustom helm-ff-exif-data-program "exiftran" - "Program used to extract exif data of an image file." - :group 'helm-files - :type 'string) - -(defcustom helm-ff-exif-data-program-args "-d" - "Arguments used for `helm-ff-exif-data-program'." - :group 'helm-files - :type 'string) - -(defcustom helm-ff-newfile-prompt-p t - "Whether Prompt or not when creating new file. -This set `ffap-newfile-prompt'." - :type 'boolean - :group 'helm-files) - -(defcustom helm-ff-avfs-directory "~/.avfs" - "The default avfs directory, usually '~/.avfs'. -When this is set you will be able to expand archive filenames with `C-j' -inside an avfs directory mounted with mountavfs. -See ." - :type 'string - :group 'helm-files) - -(defcustom helm-ff-file-compressed-list '("gz" "bz2" "zip" "7z") - "Minimal list of compressed files extension." - :type '(repeat (choice string)) - :group 'helm-files) - -(defcustom helm-ff-printer-list nil - "A list of available printers on your system. -When non--nil let you choose a printer to print file. -Otherwise when nil the variable `printer-name' will be used. -On Unix based systems (lpstat command needed) you don't need to set this, -`helm-ff-find-printers' will find a list of available printers for you." - :type '(repeat (choice string)) - :group 'helm-files) - -(defcustom helm-ff-transformer-show-only-basename t - "Show only basename of candidates in `helm-find-files'. -This can be toggled at anytime from `helm-find-files' with \ -\\\\[helm-ff-run-toggle-basename]." - :type 'boolean - :group 'helm-files) - -(defcustom helm-ff-signal-error-on-dot-files t - "Signal error when file is `.' or `..' on file deletion when non--nil. -Default is non--nil. -WARNING: Setting this to nil is unsafe and can cause deletion of a whole tree." - :group 'helm-files - :type 'boolean) - -(defcustom helm-ff-search-library-in-sexp nil - "Search for library in `require' and `declare-function' sexp." - :group 'helm-files - :type 'boolean) - -(defcustom helm-tooltip-hide-delay 25 - "Hide tooltips automatically after this many seconds." - :group 'helm-files - :type 'integer) - -(defcustom helm-ff-file-name-history-use-recentf nil - "Use `recentf-list' instead of `file-name-history' in `helm-find-files'." - :group 'helm-files - :type 'boolean) - -(defcustom helm-ff-skip-boring-files nil - "Non--nil to skip files matching regexps in `helm-boring-file-regexp-list'. -This take effect in `helm-find-files' and file completion used by `helm-mode' -i.e `helm-read-file-name'." - :group 'helm-files - :type 'boolean) - -(defcustom helm-findutils-skip-boring-files t - "Ignore files matching regexps in `completion-ignored-extensions'." - :group 'helm-files - :type 'boolean) - -(defcustom helm-findutils-search-full-path nil - "Search in full path with shell command find when non--nil. -I.e use the -path/ipath arguments of find instead of -name/iname." - :group 'helm-files - :type 'boolean) - -(defcustom helm-files-save-history-extra-sources '("Find" "Locate") - "Extras source that save candidate to `file-name-history'." - :group 'helm-files - :type '(repeat (choice string))) - -(defcustom helm-find-files-before-init-hook nil - "Hook that run before initialization of `helm-find-files'." - :group 'helm-files - :type 'hook) - -(defcustom helm-find-files-after-init-hook nil - "Hook that run after initialization of `helm-find-files'." - :group 'helm-files - :type 'hook) - - -;;; Faces -;; -;; -(defface helm-ff-prefix - '((t (:background "yellow" :foreground "black"))) - "Face used to prefix new file or url paths in `helm-find-files'." - :group 'helm-files) - -(defface helm-ff-executable - '((t (:foreground "green"))) - "Face used for executable files in `helm-find-files'." - :group 'helm-files) - -(defface helm-ff-directory - '((t (:foreground "DarkRed" :background "LightGray"))) - "Face used for directories in `helm-find-files'." - :group 'helm-files) - -(defface helm-ff-symlink - '((t (:foreground "DarkOrange"))) - "Face used for symlinks in `helm-find-files'." - :group 'helm-files) - -(defface helm-ff-invalid-symlink - '((t (:foreground "black" :background "red"))) - "Face used for invalid symlinks in `helm-find-files'." - :group 'helm-files) - -(defface helm-ff-file - '((t (:inherit font-lock-builtin-face))) - "Face used for file names in `helm-find-files'." - :group 'helm-files) - -(defface helm-history-deleted - '((t (:inherit helm-ff-invalid-symlink))) - "Face used for deleted files in `file-name-history'." - :group 'helm-files) - -(defface helm-history-remote - '((t (:foreground "Indianred1"))) - "Face used for remote files in `file-name-history'." - :group 'helm-files) - - -;;; Helm-find-files - The helm file browser. -;; -;; Keymaps -(defvar helm-find-files-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) - (define-key map (kbd "C-x C-f") 'helm-ff-run-locate) - (define-key map (kbd "C-x C-d") 'helm-ff-run-browse-project) - (define-key map (kbd "C-s") 'helm-ff-run-grep) - (define-key map (kbd "M-g s") 'helm-ff-run-grep) - (define-key map (kbd "M-g p") 'helm-ff-run-pdfgrep) - (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) - (define-key map (kbd "M-.") 'helm-ff-run-etags) - (define-key map (kbd "M-R") 'helm-ff-run-rename-file) - (define-key map (kbd "M-C") 'helm-ff-run-copy-file) - (define-key map (kbd "M-B") 'helm-ff-run-byte-compile-file) - (define-key map (kbd "M-L") 'helm-ff-run-load-file) - (define-key map (kbd "M-S") 'helm-ff-run-symlink-file) - (define-key map (kbd "M-H") 'helm-ff-run-hardlink-file) - (define-key map (kbd "M-D") 'helm-ff-run-delete-file) - (define-key map (kbd "M-K") 'helm-ff-run-kill-buffer-persistent) - (define-key map (kbd "C-c d") 'helm-ff-persistent-delete) - (define-key map (kbd "M-e") 'helm-ff-run-switch-to-eshell) - (define-key map (kbd "C-c i") 'helm-ff-run-complete-fn-at-point) - (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) - (define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame) - (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) - (define-key map (kbd "C-c X") 'helm-ff-run-open-file-with-default-tool) - (define-key map (kbd "M-!") 'helm-ff-run-eshell-command-on-file) - (define-key map (kbd "M-%") 'helm-ff-run-query-replace-on-marked) - (define-key map (kbd "C-=") 'helm-ff-run-ediff-file) - (define-key map (kbd "C-c =") 'helm-ff-run-ediff-merge-file) - (define-key map (kbd "M-p") 'helm-ff-run-switch-to-history) - (define-key map (kbd "C-c h") 'helm-ff-file-name-history) - (define-key map (kbd "M-i") 'helm-ff-properties-persistent) - (define-key map (kbd "C-c ?") 'helm-ff-help) - (define-key map (kbd "C-}") 'helm-narrow-window) - (define-key map (kbd "C-{") 'helm-enlarge-window) - (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) - (define-key map (kbd "C-c ") 'helm-ff-run-toggle-auto-update) - (define-key map (kbd "C-c C-a") 'helm-ff-run-gnus-attach-files) - (define-key map (kbd "C-c p") 'helm-ff-run-print-file) - (define-key map (kbd "C-c /") 'helm-ff-run-find-sh-command) - ;; Next 2 have no effect if candidate is not an image file. - (define-key map (kbd "M-l") 'helm-ff-rotate-left-persistent) - (define-key map (kbd "M-r") 'helm-ff-rotate-right-persistent) - (define-key map (kbd "C-.") 'helm-find-files-up-one-level) - (define-key map (kbd "C-l") 'helm-find-files-up-one-level) - (define-key map (kbd "C-h C-b") 'helm-send-bug-report-from-helm) - (define-key map (kbd "C-c r") 'helm-ff-run-find-file-as-root) - (define-key map (kbd "C-c @") 'helm-ff-run-insert-org-link) - (helm-define-key-with-subkeys map (kbd "DEL") ?\d 'helm-ff-delete-char-backward - nil nil 'helm-ff-delete-char-backward--exit-fn) - (when helm-ff-lynx-style-map - (define-key map (kbd "") 'helm-find-files-up-one-level) - (define-key map (kbd "") 'helm-execute-persistent-action)) - (delq nil map)) - "Keymap for `helm-find-files'.") - -(defvar helm-read-file-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "") 'helm-cr-empty-string) - (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) - (define-key map (kbd "C-.") 'helm-find-files-up-one-level) - (define-key map (kbd "C-l") 'helm-find-files-up-one-level) - (define-key map (kbd "C-c h") 'helm-ff-file-name-history) - (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) - (define-key map (kbd "C-c ?") 'helm-read-file-name-help) - (helm-define-key-with-subkeys map (kbd "DEL") ?\d 'helm-ff-delete-char-backward - nil nil 'helm-ff-delete-char-backward--exit-fn) - (when helm-ff-lynx-style-map - (define-key map (kbd "") 'helm-find-files-up-one-level) - (define-key map (kbd "") 'helm-execute-persistent-action) - (define-key map (kbd "") 'helm-previous-source) - (define-key map (kbd "") 'helm-next-source)) - (delq nil map)) - "Keymap for `helm-read-file-name'.") - -(defvar helm-esh-on-file-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-esh-help) - map) - "Keymap for `helm-find-files-eshell-command-on-file'.") - - -;; Internal. -(defvar helm-find-files-doc-header " (`C-l': Go up one level)" - "*The doc that is inserted in the Name header of a find-files or dired source.") -(defvar helm-ff-auto-update-flag nil - "Internal, flag to turn on/off auto-update in `helm-find-files'. -Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") -(defvar helm-ff-last-expanded nil - "Store last expanded directory or file.") -(defvar helm-ff-default-directory nil) -(defvar helm-ff-history nil) -(defvar helm-ff-cand-to-mark nil) -(defvar helm-ff-url-regexp - "\\`\\(news\\(post\\)?:\\|nntp:\\|mailto:\\|file:\\|\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\):/?/?\\).*" - "Same as `ffap-url-regexp' but match earlier possible url.") -(defvar helm-tramp-file-name-regexp "\\`/\\([^[/:]+\\|[^/]+]\\):") -(defvar helm-marked-buffer-name "*helm marked*") -(defvar helm-ff--auto-update-state nil) -(defvar helm-ff--deleting-char-backward nil) - - -;;; Helm-find-files -;; -;; -(defvar helm-source-find-files nil - "The main source to browse files. -Should not be used among other sources.") - -(defclass helm-source-ffiles (helm-source-sync) - ((header-name - :initform (lambda (name) - (concat name helm-find-files-doc-header))) - (init - :initform (lambda () - (setq helm-ff-auto-update-flag - helm-ff-auto-update-initial-value) - (setq helm-ff--auto-update-state - helm-ff-auto-update-flag) - (helm-set-local-variable 'helm-in-file-completion-p t))) - (candidates :initform 'helm-find-files-get-candidates) - (filtered-candidate-transformer :initform 'helm-ff-sort-candidates) - (filter-one-by-one :initform 'helm-ff-filter-candidate-one-by-one) - (persistent-action :initform 'helm-find-files-persistent-action) - (persistent-help :initform "Hit1 Expand Candidate, Hit2 or (C-u) Find file") - (mode-line :initform helm-ff-mode-line-string) - (volatile :initform t) - (keymap :initform helm-find-files-map) - (nohighlight :initform t) - (candidate-number-limit - :initform 9999) - (action-transformer - :initform 'helm-find-files-action-transformer) - (action - :initform - (helm-make-actions - "Find File" 'helm-find-file-or-marked - "Find file in Dired" 'helm-point-file-in-dired - (lambda () (and (locate-library "elscreen") "Find file in Elscreen")) - 'helm-elscreen-find-file - "View file" 'view-file - "Checksum File" 'helm-ff-checksum - "Query replace on marked" 'helm-ff-query-replace-on-marked - "Serial rename files" 'helm-ff-serial-rename - "Serial rename by symlinking files" 'helm-ff-serial-rename-by-symlink - "Serial rename by copying files" 'helm-ff-serial-rename-by-copying - "Open file with default tool" 'helm-open-file-with-default-tool - "Find file in hex dump" 'hexl-find-file - "Browse project" 'helm-ff-browse-project - "Complete at point `C-c i'" 'helm-insert-file-name-completion-at-point - "Insert as org link `C-c @'" 'helm-files-insert-as-org-link - "Find shell command `C-c /'" 'helm-ff-find-sh-command - "Add marked files to file-cache" 'helm-ff-cache-add-file - "Open file externally `C-c C-x, C-u to choose'" 'helm-open-file-externally - "Grep File(s) `C-s, C-u Recurse'" 'helm-find-files-grep - "Zgrep File(s) `M-g z, C-u Recurse'" 'helm-ff-zgrep - "Switch to Eshell `M-e'" 'helm-ff-switch-to-eshell - "Etags `M-., C-u reload tag file'" 'helm-ff-etags-select - "Eshell command on file(s) `M-!, C-u take all marked as arguments.'" - 'helm-find-files-eshell-command-on-file - "Find file as root `C-x @'" 'helm-find-file-as-root - "Ediff File `C-='" 'helm-find-files-ediff-files - "Ediff Merge File `C-c ='" 'helm-find-files-ediff-merge-files - "Delete File(s) `M-D'" 'helm-delete-marked-files - "Copy file(s) `M-C, C-u to follow'" 'helm-find-files-copy - "Rename file(s) `M-R, C-u to follow'" 'helm-find-files-rename - "Symlink files(s) `M-S, C-u to follow'" 'helm-find-files-symlink - "Relsymlink file(s) `C-u to follow'" 'helm-find-files-relsymlink - "Hardlink file(s) `M-H, C-u to follow'" 'helm-find-files-hardlink - "Find file other window `C-c o'" 'find-file-other-window - "Switch to history `M-p'" 'helm-find-files-switch-to-hist - "Find file other frame `C-c C-o'" 'find-file-other-frame - "Print File `C-c p, C-u to refresh'" 'helm-ff-print - "Locate `C-x C-f, C-u to specify locate db'" 'helm-ff-locate)) - (before-init-hook :initform 'helm-find-files-before-init-hook) - (after-init-hook :initform 'helm-find-files-after-init-hook))) - -(defun helm-dwim-target-directory () - "Return value of `default-directory' of buffer in other window. -If there is only one window return the value ot `default-directory' -for current buffer." - (with-helm-current-buffer - (let ((num-windows (length (remove (get-buffer-window helm-marked-buffer-name) - (window-list))))) - (expand-file-name - (if (> num-windows 1) - (save-selected-window - (other-window 1) - default-directory) - (car helm-ff-history)))))) - -(defun helm-find-files-do-action (action) - "Generic function for creating actions from `helm-source-find-files'. -ACTION must be an action supported by `helm-dired-action'." - (let* ((ifiles (mapcar 'expand-file-name ; Allow modify '/foo/.' -> '/foo' - (helm-marked-candidates :with-wildcard t))) - (cand (helm-get-selection)) ; Target - (prompt (format "%s %s file(s) to: " - (capitalize (symbol-name action)) - (length ifiles))) - (helm-always-two-windows t) - (helm-reuse-last-window-split-state t) - (helm-split-window-default-side - (eq helm-split-window-default-side 'same)) - helm-split-window-in-side-p - (parg helm-current-prefix-arg) - helm-display-source-at-screen-top ; prevent setting window-start. - helm-ff-auto-update-initial-value - (dest (with-helm-display-marked-candidates - helm-marked-buffer-name - (mapcar #'(lambda (f) - (if (file-directory-p f) - (concat (helm-basename f) "/") - (helm-basename f))) - ifiles) - (with-helm-current-buffer - (helm-read-file-name - prompt - :preselect (if helm-ff-transformer-show-only-basename - (helm-basename cand) cand) - :initial-input (helm-dwim-target-directory) - :history (helm-find-files-history :comp-read nil)))))) - (helm-dired-action - dest :files ifiles :action action :follow parg))) - -(defun helm-find-files-copy (_candidate) - "Copy files from `helm-find-files'." - (helm-find-files-do-action 'copy)) - -(defun helm-find-files-rename (_candidate) - "Rename files from `helm-find-files'." - (helm-find-files-do-action 'rename)) - -(defun helm-find-files-symlink (_candidate) - "Symlink files from `helm-find-files'." - (helm-find-files-do-action 'symlink)) - -(defun helm-find-files-relsymlink (_candidate) - "Relsymlink files from `helm-find-files'." - (helm-find-files-do-action 'relsymlink)) - -(defun helm-find-files-hardlink (_candidate) - "Hardlink files from `helm-find-files'." - (helm-find-files-do-action 'hardlink)) - -(defun helm-find-files-byte-compile (_candidate) - "Byte compile elisp files from `helm-find-files'." - (let ((files (helm-marked-candidates :with-wildcard t)) - (parg helm-current-prefix-arg)) - (cl-loop for fname in files - do (byte-compile-file fname parg)))) - -(defun helm-find-files-load-files (_candidate) - "Load elisp files from `helm-find-files'." - (let ((files (helm-marked-candidates :with-wildcard t))) - (cl-loop for fname in files - do (load fname)))) - -(defun helm-find-files-ediff-files-1 (candidate &optional merge) - "Generic function to ediff/merge files in `helm-find-files'." - (let* ((bname (helm-basename candidate)) - (marked (helm-marked-candidates :with-wildcard t)) - (prompt (if merge "Ediff Merge `%s' With File: " - "Ediff `%s' With File: ")) - (fun (if merge 'ediff-merge-files 'ediff-files)) - (input (helm-dwim-target-directory)) - (presel (if helm-ff-transformer-show-only-basename - (helm-basename candidate) - (expand-file-name - (helm-basename candidate) - input)))) - (if (= (length marked) 2) - (funcall fun (car marked) (cadr marked)) - (funcall fun candidate (helm-read-file-name - (format prompt bname) - :initial-input input - :preselect presel))))) - -(defun helm-find-files-ediff-files (candidate) - (helm-find-files-ediff-files-1 candidate)) - -(defun helm-find-files-ediff-merge-files (candidate) - (helm-find-files-ediff-files-1 candidate 'merge)) - -(defun helm-find-files-grep (_candidate) - "Default action to grep files from `helm-find-files'." - (apply 'run-with-timer 0.01 nil - #'helm-do-grep-1 - (helm-marked-candidates :with-wildcard t) - helm-current-prefix-arg)) - -(defun helm-ff-zgrep (_candidate) - "Default action to zgrep files from `helm-find-files'." - (helm-ff-zgrep-1 (helm-marked-candidates :with-wildcard t) helm-current-prefix-arg)) - -(defun helm-ff-pdfgrep (_candidate) - "Default action to pdfgrep files from `helm-find-files'." - (let ((cands (cl-loop for file in (helm-marked-candidates :with-wildcard t) - if (or (string= (file-name-extension file) "pdf") - (string= (file-name-extension file) "PDF")) - collect file)) - (helm-pdfgrep-default-function 'helm-pdfgrep-init)) - (when cands - (helm-do-pdfgrep-1 cands)))) - -(defun helm-ff-etags-select (candidate) - "Default action to jump to etags from `helm-find-files'." - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - (let* ((source-name (assoc-default 'name (helm-get-current-source))) - (default-directory (if (string= source-name "Find Files") - helm-ff-default-directory - (file-name-directory candidate)))) - (helm-etags-select helm-current-prefix-arg))) - -(defun helm-find-files-switch-to-hist (_candidate) - "Switch to helm-find-files history." - (helm-find-files t)) - -(defvar eshell-command-aliases-list nil) -(defvar helm-eshell-command-on-file-input-history nil) -(defun helm-find-files-eshell-command-on-file-1 (&optional map) - "Run `eshell-command' on CANDIDATE or marked candidates. -This is done possibly with an eshell alias, if no alias found, you can type in -an eshell command. - -Basename of CANDIDATE can be a wild-card. -e.g you can do \"eshell-command command *.el\" -Where \"*.el\" is the CANDIDATE. - -It is possible to do eshell-command command -like this: \"command %s some more args\". - -If MAP is given run `eshell-command' on all marked files at once, -Otherwise, run `eshell-command' on each marked files. -In other terms, with a prefix arg do on the three marked files -\"foo\" \"bar\" \"baz\": - -\"eshell-command command foo bar baz\" - -otherwise do - -\"eshell-command command foo\" -\"eshell-command command bar\" -\"eshell-command command baz\" - -Note: -If `eshell' or `eshell-command' have not been run once, -or if you have no eshell aliases `eshell-command-aliases-list' -will not be loaded first time you use this." - (when (or eshell-command-aliases-list - (y-or-n-p "Eshell is not loaded, run eshell-command without alias anyway? ")) - (and eshell-command-aliases-list (eshell-read-aliases-list)) - (let* ((cand-list (helm-marked-candidates :with-wildcard t)) - (default-directory (or helm-ff-default-directory - ;; If candidate is an url *-ff-default-directory is nil - ;; so keep value of default-directory. - default-directory)) - (command (helm-comp-read - "Command: " - (cl-loop for (a . c) in eshell-command-aliases-list - when (string-match "\\(\\$1\\|\\$\\*\\)$" (car c)) - collect (propertize a 'help-echo (car c)) into ls - finally return (sort ls 'string<)) - :buffer "*helm eshell on file*" - :name "Eshell command" - :keymap helm-esh-on-file-map - :mode-line - '("Eshell alias" - "C-c ?: Help, \\[universal-argument]: Insert output at point") - :input-history - 'helm-eshell-command-on-file-input-history)) - (alias-value (car (assoc-default command eshell-command-aliases-list)))) - (when (and (= (length cand-list) 1) - (string-match "[*]" (helm-basename (car cand-list)))) - (setq cand-list (file-expand-wildcards (car cand-list) t))) - (if (or (equal helm-current-prefix-arg '(16)) - (equal map '(16))) - ;; Two time C-u from `helm-comp-read' mean print to current-buffer. - ;; i.e `eshell-command' will use this value. - (setq current-prefix-arg '(16)) - ;; Else reset the value of `current-prefix-arg' - ;; to avoid printing in current-buffer. - (setq current-prefix-arg nil)) - (if (and (or - ;; One prefix-arg have been passed before `helm-comp-read'. - ;; If map have been set with C-u C-u (value == '(16)) - ;; ignore it. - (and map (equal map '(4))) - ;; One C-u from `helm-comp-read'. - (equal helm-current-prefix-arg '(4)) - ;; An alias that finish with $* - (and alias-value - ;; If command is an alias be sure it accept - ;; more than one arg i.e $*. - (string-match "\\$\\*$" alias-value))) - (cdr cand-list)) - - ;; Run eshell-command with ALL marked files as arguments. - ;; This wont work on remote files, because tramp handlers depends - ;; on `default-directory' (limitation). - (let ((mapfiles (mapconcat 'shell-quote-argument cand-list " "))) - (if (string-match "'%s'\\|\"%s\"\\|%s" command) - (eshell-command (format command mapfiles)) ; See [1] - (eshell-command (format "%s %s" command mapfiles)))) - - ;; Run eshell-command on EACH marked files. - ;; To work with tramp handler we have to call - ;; COMMAND on basename of each file, using - ;; its basedir as `default-directory'. - (cl-loop for f in cand-list - for dir = (and (not (string-match ffap-url-regexp f)) - (helm-basedir f)) - for file = (format "'%s'" (if (and dir (file-remote-p dir)) - (helm-basename f) f)) - for com = (if (string-match "'%s'\\|\"%s\"\\|%s" command) - ;; [1] This allow to enter other args AFTER filename - ;; i.e - (format command file) - (format "%s %s" command file)) - do (let ((default-directory (or dir default-directory))) - (eshell-command com))))))) - -(defun helm-find-files-eshell-command-on-file (_candidate) - "Run `eshell-command' on CANDIDATE or marked candidates. -See `helm-find-files-eshell-command-on-file-1' for more info." - (helm-find-files-eshell-command-on-file-1 helm-current-prefix-arg)) - -(defun helm-ff-switch-to-eshell (_candidate) - "Switch to eshell and cd to `helm-ff-default-directory'." - (let ((cd-eshell #'(lambda () - (eshell-kill-input) - (goto-char (point-max)) - (insert - (format "cd '%s'" helm-ff-default-directory)) - (eshell-send-input)))) - (if (get-buffer "*eshell*") - (helm-switch-to-buffer "*eshell*") - (call-interactively 'eshell)) - (unless (get-buffer-process (current-buffer)) - (funcall cd-eshell)))) - -(defun helm-ff-serial-rename-action (method) - "Rename all marked files in `helm-ff-default-directory' with METHOD. -See `helm-ff-serial-rename-1'." - (let* ((helm--reading-passwd-or-string t) - (cands (helm-marked-candidates :with-wildcard t)) - (def-name (car cands)) - (name (helm-read-string "NewName: " - (replace-regexp-in-string - "[0-9]+$" "" - (helm-basename - def-name - (file-name-extension def-name))))) - (start (read-number "StartAtNumber: ")) - (extension (helm-read-string "Extension: " - (file-name-extension (car cands)))) - (dir (expand-file-name - (helm-read-file-name - "Serial Rename to directory: " - :initial-input - (expand-file-name helm-ff-default-directory) - :test 'file-directory-p - :must-match t))) - done) - (with-helm-display-marked-candidates - helm-marked-buffer-name (mapcar 'helm-basename cands) - (if (y-or-n-p - (format "Rename %s file(s) to <%s> like this ?\n%s " - (length cands) dir (format "%s <-> %s%s.%s" - (helm-basename (car cands)) - name start extension))) - (progn - (helm-ff-serial-rename-1 - dir cands name start extension :method method) - (setq done t) - (message nil)))) - (if done - (with-helm-current-buffer (helm-find-files-1 dir)) - (message "Operation aborted")))) - -(defun helm-ff-member-directory-p (file directory) - (let ((dir-file (expand-file-name - (file-name-as-directory (file-name-directory file)))) - (cur-dir (expand-file-name (file-name-as-directory directory)))) - (string= dir-file cur-dir))) - -(cl-defun helm-ff-serial-rename-1 - (directory collection new-name start-at-num extension &key (method 'rename)) - "rename files in COLLECTION to DIRECTORY with the prefix name NEW-NAME. -Rename start at number START-AT-NUM - ex: prefixname-01.jpg. -EXTENSION is the file extension to use, in empty prompt, -reuse the original extension of file. -METHOD can be one of rename, copy or symlink. -Files will be renamed if they are files of current directory, otherwise they -will be treated with METHOD. -Default METHOD is rename." - ;; Maybe remove directories selected by error in collection. - (setq collection (cl-remove-if 'file-directory-p collection)) - (let* ((tmp-dir (file-name-as-directory - (concat (file-name-as-directory directory) - (symbol-name (cl-gensym "tmp"))))) - (fn (cl-case method - (copy 'copy-file) - (symlink 'make-symbolic-link) - (rename 'rename-file) - (t (error "Error: Unknown method %s" method))))) - (make-directory tmp-dir) - (unwind-protect - (progn - ;; Rename all files to tmp-dir with new-name. - ;; If files are not from start directory, use method - ;; to move files to tmp-dir. - (cl-loop for i in collection - for count from start-at-num - for fnum = (if (< count 10) "0%s" "%s") - for nname = (concat tmp-dir new-name (format fnum count) - (if (not (string= extension "")) - (format ".%s" (replace-regexp-in-string - "[.]" "" extension)) - (file-name-extension i 'dot))) - do (if (helm-ff-member-directory-p i directory) - (rename-file i nname) - (funcall fn i nname))) - ;; Now move all from tmp-dir to destination. - (cl-loop with dirlist = (directory-files - tmp-dir t directory-files-no-dot-files-regexp) - for f in dirlist do - (if (file-symlink-p f) - (make-symbolic-link (file-truename f) - (concat (file-name-as-directory directory) - (helm-basename f))) - (rename-file f directory)))) - (delete-directory tmp-dir t)))) - -(defun helm-ff-serial-rename (_candidate) - "Serial rename all marked files to `helm-ff-default-directory'. -Rename only file of current directory, and symlink files coming from -other directories. -See `helm-ff-serial-rename-1'." - (helm-ff-serial-rename-action 'rename)) - -(defun helm-ff-serial-rename-by-symlink (_candidate) - "Serial rename all marked files to `helm-ff-default-directory'. -Rename only file of current directory, and symlink files coming from -other directories. -See `helm-ff-serial-rename-1'." - (helm-ff-serial-rename-action 'symlink)) - -(defun helm-ff-serial-rename-by-copying (_candidate) - "Serial rename all marked files to `helm-ff-default-directory'. -Rename only file of current directory, and copy files coming from -other directories. -See `helm-ff-serial-rename-1'." - (helm-ff-serial-rename-action 'copy)) - -(defun helm-ff-query-replace-on-marked-1 (candidates) - (with-helm-display-marked-candidates - helm-marked-buffer-name - (mapcar 'helm-basename candidates) - (let* ((regexp (read-string "Replace regexp on filename(s): ")) - (str (read-string (format "Replace regexp `%s' with: " regexp)))) - (cl-loop with query = "y" - with count = 0 - for old in candidates - for new = (concat (helm-basedir old) - (replace-regexp-in-string - regexp str - (helm-basename old))) - ;; If `regexp' is not matched in `old' - ;; `replace-regexp-in-string' will - ;; return `old' unmodified. - unless (string= old new) - do (progn - (unless (string= query "!") - (while (not (member - (setq query - (string - (read-key - (propertize - (format - "Replace `%s' by `%s' [!,y,n,q]" - old new) - 'face 'minibuffer-prompt)))) - '("y" "!" "n" "q"))) - (message "Please answer by y,n,! or q") (sit-for 1))) - (when (string= query "q") - (cl-return (message "Operation aborted"))) - (unless (string= query "n") - (rename-file old new) - (cl-incf count))) - finally (message "%d Files renamed" count)))) - ;; This fix the emacs bug where "Emacs-Lisp:" is sent - ;; in minibuffer (not the echo area). - (sit-for 0.1) - (with-current-buffer (window-buffer (minibuffer-window)) - (delete-minibuffer-contents))) - -;; The action. -(defun helm-ff-query-replace-on-marked (_candidate) - (let ((marked (helm-marked-candidates))) - (helm-run-after-quit #'helm-ff-query-replace-on-marked-1 marked))) - -;; The command for `helm-find-files-map'. -(defun helm-ff-run-query-replace-on-marked () - (interactive) - (helm-ff-query-replace-on-marked nil)) - -(defun helm-ff-toggle-auto-update (_candidate) - (setq helm-ff-auto-update-flag (not helm-ff-auto-update-flag)) - (setq helm-ff--auto-update-state helm-ff-auto-update-flag) - (message "[Auto expansion %s]" - (if helm-ff-auto-update-flag "enabled" "disabled"))) - -(defun helm-ff-run-toggle-auto-update () - (interactive) - (with-helm-alive-p - (helm-attrset 'toggle-auto-update '(helm-ff-toggle-auto-update . never-split)) - (helm-execute-persistent-action 'toggle-auto-update))) - -(defun helm-ff-delete-char-backward () - "Disable helm find files auto update and delete char backward." - (interactive) - (setq helm-ff-auto-update-flag nil) - (setq helm-ff--deleting-char-backward t) - (call-interactively - (lookup-key (current-global-map) - (read-kbd-macro "DEL")))) - -(defun helm-ff-delete-char-backward--exit-fn () - (setq helm-ff-auto-update-flag helm-ff--auto-update-state) - (setq helm-ff--deleting-char-backward nil)) - -(defun helm-ff-run-switch-to-history () - "Run Switch to history action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (when (helm-file-completion-source-p) - (helm-quit-and-execute-action 'helm-find-files-switch-to-hist)))) - -(defun helm-ff-run-grep () - "Run Grep action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-grep))) - -(defun helm-ff-run-pdfgrep () - "Run Pdfgrep action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-pdfgrep))) - -(defun helm-ff-run-zgrep () - "Run Grep action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-zgrep))) - -(defun helm-ff-run-copy-file () - "Run Copy file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-copy))) - -(defun helm-ff-run-rename-file () - "Run Rename file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-rename))) - -(defun helm-ff-run-byte-compile-file () - "Run Byte compile file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-byte-compile))) - -(defun helm-ff-run-load-file () - "Run Load file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-load-files))) - -(defun helm-ff-run-eshell-command-on-file () - "Run eshell command on file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action - 'helm-find-files-eshell-command-on-file))) - -(defun helm-ff-run-ediff-file () - "Run Ediff file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-ediff-files))) - -(defun helm-ff-run-ediff-merge-file () - "Run Ediff merge file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action - 'helm-find-files-ediff-merge-files))) - -(defun helm-ff-run-symlink-file () - "Run Symlink file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-symlink))) - -(defun helm-ff-run-hardlink-file () - "Run Hardlink file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-files-hardlink))) - -(defun helm-ff-run-delete-file () - "Run Delete file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-delete-marked-files))) - -(defun helm-ff-run-complete-fn-at-point () - "Run complete file name action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action - 'helm-insert-file-name-completion-at-point))) - -(defun helm-ff-run-switch-to-eshell () - "Run switch to eshell action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-switch-to-eshell))) - -(defun helm-ff-run-switch-other-window () - "Run switch to other window action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'find-file-other-window))) - -(defun helm-ff-run-switch-other-frame () - "Run switch to other frame action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'find-file-other-frame))) - -(defun helm-ff-run-open-file-externally () - "Run open file externally command action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-open-file-externally))) - -(defun helm-ff-run-open-file-with-default-tool () - "Run open file externally command action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-open-file-with-default-tool))) - -(defun helm-ff-locate (candidate) - "Locate action function for `helm-find-files'." - (helm-locate-set-command) - (let ((input (concat (helm-basename - (expand-file-name - candidate - helm-ff-default-directory)) - ;; The locate '-b' option doesn't exists - ;; in everything (es). - (unless (and (eq system-type 'windows-nt) - (string-match "^es" helm-locate-command)) - " -b")))) - (helm-locate-1 helm-current-prefix-arg nil 'from-ff input))) - -(defun helm-ff-run-locate () - "Run locate action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-locate))) - -(defun helm-files-insert-as-org-link (candidate) - (insert (format "[[%s][]]" candidate)) - (goto-char (- (point) 2))) - -(defun helm-ff-run-insert-org-link () - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-files-insert-as-org-link))) - -(defun helm-ff-run-find-file-as-root () - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-find-file-as-root))) - -(defun helm-ff-run-gnus-attach-files () - "Run gnus attach files command action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-gnus-attach-files))) - -(defun helm-ff-run-etags () - "Run Etags command action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-etags-select))) - -(defun helm-ff-print (_candidate) - "Print marked files. -You have to set in order -variables `lpr-command',`lpr-switches' and/or `printer-name'. - -e.g: -\(setq lpr-command \"gtklp\"\) -\(setq lpr-switches '(\"-P\")\) -\(setq printer-name \"Epson-Stylus-Photo-R265\"\) - -Same as `dired-do-print' but for helm." - (when (or helm-current-prefix-arg - (not helm-ff-printer-list)) - (setq helm-ff-printer-list - (helm-ff-find-printers))) - (let* ((file-list (helm-marked-candidates :with-wildcard t)) - (len (length file-list)) - (printer-name (if helm-ff-printer-list - (helm-comp-read - "Printer: " helm-ff-printer-list) - printer-name)) - (command (helm-read-string - (format "Print *%s File(s):\n%s with: " - len - (mapconcat - (lambda (f) (format "- %s\n" f)) - file-list "")) - (when (and lpr-command - (or lpr-switches - printer-name)) - (mapconcat 'identity - (cons lpr-command - (append (if (stringp lpr-switches) - (list lpr-switches) - lpr-switches) - (list printer-name))) - " ")))) - (file-args (mapconcat #'(lambda (x) - (format "'%s'" x)) - file-list " ")) - (cmd-line (concat command " " file-args))) - (if command - (start-process-shell-command "helm-print" nil cmd-line) - (error "Error: Please verify your printer settings in Emacs.")))) - -(defun helm-ff-run-print-file () - "Run Print file action from `helm-source-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-print))) - -(defun helm-ff-checksum (file) - "Calculate the checksum of FILE. -Provide completion on different algorithms to use on Emacs24. -On Emacs23 only 'sha1' is available. -The checksum is copied to kill-ring." - (let ((algo (and (fboundp 'secure-hash) - (intern - (helm-comp-read - "Algorithm: " - '(md5 sha1 sha224 - sha256 sha384 sha512)))))) - (kill-new - (if algo - (with-temp-buffer - (insert-file-contents-literally file) - (secure-hash algo (current-buffer))) - (with-temp-buffer - (insert-file-contents-literally file) - (sha1 (current-buffer))))) - (message "Checksum copied to kill-ring."))) - -(defun helm-ff-toggle-basename (_candidate) - (setq helm-ff-transformer-show-only-basename - (not helm-ff-transformer-show-only-basename)) - (let* ((cand (helm-get-selection nil t)) - (target (if helm-ff-transformer-show-only-basename - (helm-basename cand) cand))) - (helm-force-update (regexp-quote target)))) - -(defun helm-ff-run-toggle-basename () - (interactive) - (with-helm-alive-p - (helm-attrset 'toggle-basename '(helm-ff-toggle-basename . never-split)) - (helm-execute-persistent-action 'toggle-basename))) - -(cl-defun helm-reduce-file-name (fname level &key unix-close expand) - "Reduce FNAME by LEVEL from end or beginning depending LEVEL value. -If LEVEL is positive reduce from end else from beginning. -If UNIX-CLOSE is non--nil close filename with /. -If EXPAND is non--nil expand-file-name." - (let* ((exp-fname (expand-file-name fname)) - (fname-list (split-string (if (or (string= fname "~/") expand) - exp-fname fname) "/" t)) - (len (length fname-list)) - (pop-list (if (< level 0) - (cl-subseq fname-list (* level -1)) - (cl-subseq fname-list 0 (- len level)))) - (result (mapconcat 'identity pop-list "/")) - (empty (string= result ""))) - (when unix-close (setq result (concat result "/"))) - (if (string-match "^~" result) - (if (string= result "~/") "~/" result) - (if (< level 0) - (if empty "../" (concat "../" result)) - (cond ((eq system-type 'windows-nt) - (if empty (expand-file-name "/") ; Expand to "/" or "c:/". - result)) - (empty "/") - (t - (concat "/" result))))))) - -;; Internal -(defvar helm-file-completion-sources - '("Find Files" "Read File Name" "Read File Name History") - "Sources that use the *find-files mechanism can be added here. -Sources generated by `helm-mode' don't need to be added here, it will -be done automatically. -You should not modify this yourself unless you know what you do.") - -(defun helm-file-completion-source-p () - "Return non--nil if current source is a file completion source." - (or (with-helm-buffer helm-in-file-completion-p) - (let ((cur-source (cdr (assoc 'name (helm-get-current-source))))) - (cl-loop for i in helm-file-completion-sources - thereis (string= cur-source i))))) - -(defun helm-find-files-up-one-level (arg) - "Go up one level like unix command `cd ..'. -If prefix numeric arg is given go ARG level up." - (interactive "p") - (with-helm-alive-p - (when (and (helm-file-completion-source-p) - (not (helm-ff-invalid-tramp-name-p))) - (with-helm-window - (when helm-follow-mode - (helm-follow-mode -1) (message nil))) - ;; When going up one level we want to be at the line - ;; corresponding to actual directory, so store this info - ;; in `helm-ff-last-expanded'. - (let ((cur-cand (helm-get-selection)) - (new-pattern (helm-reduce-file-name - helm-pattern arg :unix-close t :expand t))) - (cond ((file-directory-p helm-pattern) - (setq helm-ff-last-expanded helm-ff-default-directory)) - ((file-exists-p helm-pattern) - (setq helm-ff-last-expanded helm-pattern)) - ((and cur-cand (file-exists-p cur-cand)) - (setq helm-ff-last-expanded cur-cand))) - (helm-set-pattern new-pattern helm-suspend-update-flag) - (with-helm-after-update-hook (helm-ff-retrieve-last-expanded)))))) - -(defun helm-ff-retrieve-last-expanded () - "Move overlay to last visited directory `helm-ff-last-expanded'. -This happen after using `helm-find-files-up-one-level', -or hitting C-j on \"..\"." - (when helm-ff-last-expanded - (let ((presel (if helm-ff-transformer-show-only-basename - (helm-basename - (directory-file-name helm-ff-last-expanded)) - (directory-file-name helm-ff-last-expanded)))) - (with-helm-window - (when (re-search-forward (concat "^" (regexp-quote presel) "$") nil t) - (forward-line 0) - (helm-mark-current-line))) - (setq helm-ff-last-expanded nil)))) - -(defun helm-ff-move-to-first-real-candidate () - "When candidate is an incomplete file name move to first real candidate." - (helm-aif (and (helm-file-completion-source-p) - (helm-get-selection)) - (unless (or (and (string-match helm-tramp-file-name-regexp it) - (not (file-remote-p it nil t))) - (file-exists-p it)) - (helm-next-line)))) -(add-hook 'helm-after-update-hook 'helm-ff-move-to-first-real-candidate) - -;;; Auto-update - helm-find-files auto expansion of directories. -;; -;; -(defun helm-ff-update-when-only-one-matched () - "Expand to directory when sole completion. -When only one candidate is remaining and it is a directory, -expand to this directory. -This happen only when `helm-ff-auto-update-flag' is non--nil -or when `helm-pattern' is equal to \"~/\"." - (when (or (and helm-ff-auto-update-flag - (null helm-ff--deleting-char-backward) - (helm-file-completion-source-p) - ;; Issue #295 - ;; File predicates are returning t - ;; with paths like //home/foo. - ;; So check it is not the case by regexp - ;; to allow user to do C-a / to start e.g - ;; entering a tramp method e.g /sudo::. - (not (string-match "\\`//" helm-pattern)) - (not (helm-ff-invalid-tramp-name-p))) - ;; Fix issue #542. - (string= helm-pattern "~/")) - (let* ((history-p (string= (assoc-default - 'name (helm-get-current-source)) - "Read File Name History")) - (pat (if (string-match helm-tramp-file-name-regexp - helm-pattern) - (helm-create-tramp-name helm-pattern) - helm-pattern)) - (completed-p (string= (file-name-as-directory - (expand-file-name pat)) - helm-ff-default-directory)) - (candnum (helm-get-candidate-number))) - (when (and (or - ;; Only one candidate remaining - ;; and at least 2 char in basename. - (and (<= candnum 2) - (>= (string-width (helm-basename helm-pattern)) 2)) - ;; Already completed. - completed-p) - (not history-p)) ; Don't try to auto complete in history. - (with-helm-window - (let ((cur-cand (prog2 - (unless completed-p - ;; Only one non--existing candidate - ;; and one directory candidate, move to it. - (helm-next-line)) - (helm-get-selection)))) - (when (and (stringp cur-cand) - (file-accessible-directory-p cur-cand)) - (if (and (not (helm-dir-is-dot cur-cand)) ; [1] - ;; Maybe we are here because completed-p is true - ;; but check this again to be sure. (Windows fix) - (<= candnum 2)) ; [2] - ;; If after going to next line the candidate - ;; is not one of "." or ".." [1] - ;; and only one candidate is remaining [2], - ;; assume candidate is a new directory to expand, and do it. - (helm-set-pattern (file-name-as-directory cur-cand)) - ;; The candidate is one of "." or ".." - ;; that mean we have entered the last letter of the directory name - ;; in prompt, so expansion is already done, just add the "/" at end - ;; of name unless helm-pattern ends with "." - ;; (i.e we are writing something starting with ".") - (unless (string-match "\\`.*[.]\\{1\\}\\'" helm-pattern) - (helm-set-pattern - ;; Need to expand-file-name to avoid e.g /ssh:host:./ in prompt. - (expand-file-name (file-name-as-directory helm-pattern))))) - (helm-check-minibuffer-input)))))))) - -(defun helm-ff-auto-expand-to-home-or-root () - "Allow expanding to home/user directory or root or text yanked after pattern." - (when (and (helm-file-completion-source-p) - (string-match "/\\./\\|/\\.\\./\\|/~.*/\\|//\\|\\(/[[:alpha:]]:/\\|\\s\\+\\)" - helm-pattern) - (with-current-buffer (window-buffer (minibuffer-window)) (eolp)) - (not (string-match helm-ff-url-regexp helm-pattern))) - (let* ((match (match-string 0 helm-pattern)) - (input (cond ((string= match "/./") default-directory) - ((string= helm-pattern "/../") "/") - (t (expand-file-name - (helm-substitute-in-filename helm-pattern) - ;; [Windows] On UNC paths "/" expand to current machine, - ;; so use the root of current Drive. (i.e "C:/") - (and (memq system-type '(windows-nt ms-dos)) - (getenv "SystemDrive")) ; nil on Unix. - ))))) - (if (file-directory-p input) - (setq helm-ff-default-directory - (setq input (file-name-as-directory input))) - (setq helm-ff-default-directory (file-name-as-directory - (file-name-directory input)))) - (with-helm-window - (helm-set-pattern input) - (helm-check-minibuffer-input))))) - -(defun helm-substitute-in-filename (fname) - "Substitute all parts of FNAME from start up to \"~/\" or \"/\". -On windows system substitute from start up to \"/[[:lower:]]:/\"." - (if (and ffap-url-regexp - (string-match-p ffap-url-regexp fname)) - fname - (with-temp-buffer - (insert fname) - (goto-char (point-min)) - (skip-chars-forward "/") ;; Avoid infloop in UNC paths Issue #424 - (if (re-search-forward "~.*/?\\|//\\|/[[:alpha:]]:/" nil t) - (let ((match (match-string 0))) - (goto-char (if (or (string= match "//") - (string-match-p "/[[:alpha:]]:/" match)) - (1+ (match-beginning 0)) - (match-beginning 0))) - (buffer-substring-no-properties (point) (point-at-eol))) - fname)))) - -(add-hook 'helm-after-update-hook 'helm-ff-update-when-only-one-matched) -(add-hook 'helm-after-update-hook 'helm-ff-auto-expand-to-home-or-root) - -(defun helm-point-file-in-dired (file) - "Put point on filename FILE in dired buffer." - (unless (and ffap-url-regexp - (string-match-p ffap-url-regexp file)) - (let ((target (expand-file-name (helm-substitute-in-filename file)))) - (dired (file-name-directory target)) - (dired-goto-file target)))) - -(defun helm-create-tramp-name (fname) - "Build filename for `helm-pattern' like /su:: or /sudo::." - (apply #'tramp-make-tramp-file-name - (cl-loop with v = (tramp-dissect-file-name fname) - for i across v collect i))) - -(cl-defun helm-ff-tramp-hostnames (&optional (pattern helm-pattern)) - "Get a list of hosts for tramp method found in `helm-pattern'. -Argument PATTERN default to `helm-pattern', it is here only for debugging -purpose." - (when (string-match helm-tramp-file-name-regexp pattern) - (let ((method (match-string 1 pattern)) - (tn (match-string 0 pattern)) - (all-methods (mapcar 'car tramp-methods))) - (helm-fast-remove-dups - (cl-loop for (f . h) in (tramp-get-completion-function method) - append (cl-loop for e in (funcall f (car h)) - for host = (and (consp e) (cadr e)) - when (and host (not (member host all-methods))) - collect (concat tn host))) - :test 'equal)))) - -(defun helm-ff-before-action-hook-fn () - "Exit helm when user try to execute action on an invalid tramp fname." - (let ((cand (helm-get-selection))) - (when (and (helm-file-completion-source-p) - (helm-ff-invalid-tramp-name-p cand) ; Check candidate. - (helm-ff-invalid-tramp-name-p)) ; check helm-pattern. - (error "Error: Unknown file or directory `%s'" cand)))) -(add-hook 'helm-before-action-hook 'helm-ff-before-action-hook-fn) - -(cl-defun helm-ff-invalid-tramp-name-p (&optional (pattern helm-pattern)) - "Return non--nil when PATTERN is an invalid tramp filename." - (string= (helm-ff-set-pattern pattern) - "Invalid tramp file name")) - -(defun helm-ff-set-pattern (pattern) - "Handle tramp filenames in `helm-pattern'." - (let ((methods (mapcar 'car tramp-methods)) - (reg "\\`/\\([^[/:]+\\|[^/]+]\\):.*:") - cur-method tramp-name) - ;; In some rare cases tramp can return a nil input, - ;; so be sure pattern is a string for safety (Issue #476). - (unless pattern (setq pattern "")) - (cond ((string= pattern "") "") - ((string-match "\\`[.]\\{1,2\\}/\\'" pattern) - (expand-file-name pattern)) - ((string-match ".*\\(~?/?[.]\\{1\\}/\\)\\'" pattern) - (expand-file-name default-directory)) - ((and (string-match ".*\\(~//\\|//\\)\\'" pattern) - (not (string-match helm-ff-url-regexp helm-pattern))) - (expand-file-name "/")) ; Expand to "/" or "c:/" - ((string-match "\\`\\(~/\\|.*/~/\\)\\'" pattern) - (expand-file-name "~/")) - ;; Match "/method:maybe_hostname:" - ((and (string-match reg pattern) - (setq cur-method (match-string 1 pattern)) - (member cur-method methods)) - (setq tramp-name (helm-create-tramp-name - (match-string 0 pattern))) - (replace-match tramp-name nil t pattern)) - ;; Match "/hostname:" - ((and (string-match helm-tramp-file-name-regexp pattern) - (setq cur-method (match-string 1 pattern)) - (and cur-method (not (member cur-method methods)))) - (setq tramp-name (helm-create-tramp-name - (match-string 0 pattern))) - (replace-match tramp-name nil t pattern)) - ;; Match "/method:" in this case don't try to connect. - ((and (not (string-match reg pattern)) - (string-match helm-tramp-file-name-regexp pattern) - (member (match-string 1 pattern) methods)) - "Invalid tramp file name") ; Write in helm-buffer. - ;; PATTERN is a directory, end it with "/". - ;; This will make PATTERN not ending yet with "/" - ;; candidate for `helm-ff-default-directory', - ;; allowing `helm-ff-retrieve-last-expanded' to retrieve it - ;; when descending level. - ;; However, we don't add automatically the "/" when - ;; `helm-ff-auto-update-flag' is enabled to avoid quick expansion. - ((and (file-accessible-directory-p pattern) - helm-ff-auto-update-flag) - (file-name-as-directory (expand-file-name pattern))) - ;; Return PATTERN unchanged. - (t pattern)))) - -(defun helm-find-files-get-candidates (&optional require-match) - "Create candidate list for `helm-source-find-files'." - (let* ((path (helm-ff-set-pattern helm-pattern)) - (dir-p (file-accessible-directory-p path)) - basedir - invalid-basedir - non-essential - (tramp-verbose helm-tramp-verbose)) ; No tramp message when 0. - (set-text-properties 0 (length path) nil path) - ;; Issue #118 allow creation of newdir+newfile. - (unless (or - ;; A tramp file name not completed. - (string= path "Invalid tramp file name") - ;; An empty pattern - (string= path "") - ;; Check if base directory of PATH is valid. - (helm-aif (file-name-directory path) - ;; If PATH is a valid directory IT=PATH, - ;; else IT=basedir of PATH. - (file-directory-p it))) - ;; BASEDIR is invalid, that's mean user is starting - ;; to write a non--existing path in minibuffer - ;; probably to create a 'new_dir' or a 'new_dir+new_file'. - (setq invalid-basedir t)) - ;; Don't set now `helm-pattern' if `path' == "Invalid tramp file name" - ;; like that the actual value (e.g /ssh:) is passed to - ;; `helm-ff-tramp-hostnames'. - (unless (or (string= path "Invalid tramp file name") - invalid-basedir) ; Leave helm-pattern unchanged. - (setq helm-ff-auto-update-flag ; [1] - ;; Unless auto update is disabled at startup or - ;; interactively, start auto updating only at third char. - (unless (or (null helm-ff-auto-update-initial-value) - (null helm-ff--auto-update-state) - ;; But don't enable auto update when - ;; deleting backward. - helm-ff--deleting-char-backward) - (or (>= (length (helm-basename path)) 3) dir-p))) - (setq helm-pattern (helm-ff--transform-pattern-for-completion path)) - ;; This have to be set after [1] to allow deleting char backward. - (setq basedir (expand-file-name - (if (and dir-p helm-ff-auto-update-flag) - ;; Add the final "/" to path - ;; when `helm-ff-auto-update-flag' is enabled. - (file-name-as-directory path) - (file-name-directory path)))) - (setq helm-ff-default-directory - (if (string= helm-pattern "") - (expand-file-name "/") ; Expand to "/" or "c:/" - ;; If path is an url *default-directory have to be nil. - (unless (or (string-match helm-ff-url-regexp path) - (and ffap-url-regexp - (string-match ffap-url-regexp path))) - basedir)))) - (cond ((string= path "Invalid tramp file name") - (or (helm-ff-tramp-hostnames) ; Hostnames completion. - (prog2 - ;; `helm-pattern' have not been modified yet. - ;; Set it here to the value of `path' that should be now - ;; "Invalid tramp file name" and set the candidates list - ;; to ("Invalid tramp file name") to make `helm-pattern' - ;; match single candidate "Invalid tramp file name". - (setq helm-pattern path) - ;; "Invalid tramp file name" is now printed - ;; in `helm-buffer'. - (list path)))) - ((or (file-regular-p path) - ;; `ffap-url-regexp' don't match until url is complete. - (string-match helm-ff-url-regexp path) - invalid-basedir - (and (not (file-exists-p path)) (string-match "/$" path)) - (and ffap-url-regexp (string-match ffap-url-regexp path))) - (list path)) - ((string= path "") (helm-ff-directory-files "/" t)) - ((and (file-directory-p path) (not (file-readable-p path))) - (list (format "Opening directory: access denied, `%s'" path))) - ;; A fast expansion of PATH is made only if `helm-ff-auto-update-flag' - ;; is enabled. - ((and dir-p helm-ff-auto-update-flag) - (helm-ff-directory-files path t)) - (t (append (unless (or require-match - ;; When `helm-ff-auto-update-flag' has been - ;; disabled, whe don't want PATH to be added on top - ;; if it is a directory. - dir-p) - (list path)) - (helm-ff-directory-files basedir t)))))) - -(defsubst helm-ff-directory-files (directory &optional full) - "List contents of DIRECTORY. -Argument FULL mean absolute path. -It is same as `directory-files' but always returns the -dotted filename '.' and '..' even on root directories in Windows -systems." - (setq directory (file-name-as-directory - (expand-file-name directory))) - (let ((ls (directory-files - directory full directory-files-no-dot-files-regexp)) - (dot (concat directory ".")) - (dot2 (concat directory ".."))) - (append (list dot dot2) ls))) - -(defun helm-ff-handle-backslash (fname) - ;; Allow creation of filenames containing a backslash. - (cl-loop with bad = '((92 . "")) - for i across fname - for isbad = (assq i bad) - if isbad concat (cdr isbad) - else concat (string i))) - -(defun helm-ff-smart-completion-p () - (and helm-ff-smart-completion - (not (memq helm-mp-matching-method '(multi1 multi3p))))) - -(defun helm-ff--transform-pattern-for-completion (pattern) - "Maybe return PATTERN with it's basename modified as a regexp. -This happen only when `helm-ff-smart-completion' is enabled. -This provide a similar behavior as `ido-enable-flex-matching'. -See also `helm--mapconcat-candidate'. -If PATTERN is an url returns it unmodified. -When PATTERN contain a space fallback to match-plugin. -If basename contain one or more space fallback to match-plugin. -If PATTERN is a valid directory name,return PATTERN unchanged." - ;; handle bad filenames containing a backslash. - (setq pattern (helm-ff-handle-backslash pattern)) - (let ((bn (helm-basename pattern)) - (bd (or (helm-basedir pattern) "")) - (dir-p (file-directory-p pattern)) - (tramp-p (cl-loop for (m . f) in tramp-methods - thereis (string-match m pattern)))) - ;; Always regexp-quote base directory name to handle - ;; crap dirnames such e.g bookmark+ - (cond - ((or (and dir-p tramp-p (string-match ":\\'" pattern)) - (string= pattern "") - (and dir-p (<= (length bn) 2)) - ;; Fix Issue #541 when BD have a subdir similar - ;; to BN, don't switch to match plugin - ;; which will match both. - (and dir-p (string-match (regexp-quote bn) bd))) - ;; Use full PATTERN on e.g "/ssh:host:". - (regexp-quote pattern)) - ;; Prefixing BN with a space call match-plugin completion. - ;; This allow showing all files/dirs matching BN (Issue #518). - ;; FIXME: some match-plugin methods may not work here. - (dir-p (concat (regexp-quote bd) " " (regexp-quote bn))) - ((or (not (helm-ff-smart-completion-p)) - (string-match "\\s-" bn)) ; Fall back to match-plugin. - (concat (regexp-quote bd) bn)) - ((or (string-match "[*][.]?.*" bn) ; Allow entering wilcard. - (string-match "/$" pattern) ; Allow mkdir. - (string-match helm-ff-url-regexp pattern) - (and (string= helm-ff-default-directory "/") tramp-p)) - ;; Don't treat wildcards ("*") as regexp char. - ;; (e.g ./foo/*.el => ./foo/[*].el) - (concat (regexp-quote bd) - (replace-regexp-in-string "[*]" "[*]" bn))) - (t - (setq bn (if (>= (length bn) 2) ; wait 2nd char before concating. - (helm--mapconcat-candidate bn) - (concat ".*" (regexp-quote bn)))) - (concat (regexp-quote bd) bn))))) - -(defun helm-dir-is-dot (dir) - (string-match "\\(?:/\\|\\`\\)\\.\\{1,2\\}\\'" dir)) - -(defun helm-ff-save-history () - "Store the last value of `helm-ff-default-directory' in `helm-ff-history'. -Note that only existing directories are saved here." - (when (and helm-ff-default-directory - (helm-file-completion-source-p) - (file-directory-p helm-ff-default-directory)) - (set-text-properties 0 (length helm-ff-default-directory) - nil helm-ff-default-directory) - (push helm-ff-default-directory helm-ff-history))) -(add-hook 'helm-cleanup-hook 'helm-ff-save-history) - -(defun helm-files-save-file-name-history (&optional force) - "Save selected file to `file-name-history'." - (let ((src-name (assoc-default 'name (helm-get-current-source)))) - (when (or force (helm-file-completion-source-p) - (member src-name helm-files-save-history-extra-sources)) - (let ((mkd (helm-marked-candidates)) - (history-delete-duplicates t)) - (cl-loop for sel in mkd - when (and sel - (file-exists-p sel) - (not (file-directory-p sel))) - do - ;; we use `abbreviate-file-name' here because - ;; other parts of Emacs seems to, - ;; and we don't want to introduce duplicates. - (add-to-history 'file-name-history - (abbreviate-file-name sel))))))) -(add-hook 'helm-exit-minibuffer-hook 'helm-files-save-file-name-history) - -(defun helm-ff-valid-symlink-p (file) - (file-exists-p (file-truename file))) - -(defun helm-get-default-mode-for-file (filename) - "Return the default mode to open FILENAME." - (let ((mode (cl-loop for (r . m) in auto-mode-alist - thereis (and (string-match r filename) m)))) - (or (and (symbolp mode) mode) "Fundamental"))) - -(defun helm-ff-properties (candidate) - "Show file properties of CANDIDATE in a tooltip or message." - (let* ((all (helm-file-attributes candidate)) - (dired-line (helm-file-attributes - candidate :dired t :human-size t)) - (type (cl-getf all :type)) - (mode-type (cl-getf all :mode-type)) - (owner (cl-getf all :uid)) - (owner-right (cl-getf all :user t)) - (group (cl-getf all :gid)) - (group-right (cl-getf all :group)) - (other-right (cl-getf all :other)) - (size (helm-file-human-size (cl-getf all :size))) - (modif (cl-getf all :modif-time)) - (access (cl-getf all :access-time)) - (ext (helm-get-default-program-for-file candidate)) - (tooltip-hide-delay (or helm-tooltip-hide-delay tooltip-hide-delay))) - (if (and (window-system) tooltip-mode) - (tooltip-show - (concat - (helm-basename candidate) "\n" - dired-line "\n" - (format "Mode: %s\n" (helm-get-default-mode-for-file candidate)) - (format "Ext prog: %s\n" (or (and ext (replace-regexp-in-string - " %s" "" ext)) - "Not defined")) - (format "Type: %s: %s\n" type mode-type) - (when (string= type "symlink") - (format "True name: '%s'\n" - (cond ((string-match "^\.#" (helm-basename candidate)) - "Autosave symlink") - ((helm-ff-valid-symlink-p candidate) - (file-truename candidate)) - (t "Invalid Symlink")))) - (format "Owner: %s: %s\n" owner owner-right) - (format "Group: %s: %s\n" group group-right) - (format "Others: %s\n" other-right) - (format "Size: %s\n" size) - (format "Modified: %s\n" modif) - (format "Accessed: %s\n" access))) - (message dired-line) (sit-for 5)))) - -(defun helm-ff-properties-persistent () - "Show properties without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'properties-action '(helm-ff-properties . never-split)) - (helm-execute-persistent-action 'properties-action))) - -(defun helm-ff-persistent-delete () - "Delete current candidate without quitting." - (interactive) - (with-helm-alive-p - (helm-attrset 'quick-delete '(helm-ff-quick-delete . never-split)) - (helm-execute-persistent-action 'quick-delete))) - -(defun helm-ff-dot-file-p (file) - "Check if FILE is `.' or `..'." - (member (helm-basename file) '("." ".."))) - -(defun helm-ff-quick-delete (_candidate) - "Delete file CANDIDATE without quitting." - (let ((marked (helm-marked-candidates))) - (unwind-protect - (save-selected-window - (cl-loop for c in marked do - (progn (helm-preselect (if (and helm-ff-transformer-show-only-basename - (not (helm-ff-dot-file-p c))) - (helm-basename c) c)) - (when (y-or-n-p (format "Really Delete file `%s'? " c)) - (helm-delete-file c helm-ff-signal-error-on-dot-files - 'synchro) - (helm-delete-current-selection) - (message nil))))) - (with-helm-buffer - (setq helm-marked-candidates nil - helm-visible-mark-overlays nil)) - (helm-force-update)))) - -(defun helm-ff-kill-buffer-fname (candidate) - (let ((buf (get-file-buffer candidate))) - (if buf - (progn - (kill-buffer buf) (message "Buffer `%s' killed" buf)) - (message "No buffer to kill")))) - -(defun helm-ff-kill-or-find-buffer-fname (candidate) - "Find file CANDIDATE or kill it's buffer if it is visible. -Never kill `helm-current-buffer'. -Never kill buffer modified. -This is called normally on third hit of \ -\\\\[helm-execute-persistent-action] -in `helm-find-files-persistent-action'." - (let* ((buf (get-file-buffer candidate)) - (buf-name (buffer-name buf)) - (win (get-buffer-window buf)) - (helm--reading-passwd-or-string t)) - (if (and buf win - (not (eq buf (get-buffer helm-current-buffer))) - (not (buffer-modified-p buf))) - (progn - (kill-buffer buf) - (set-window-buffer win helm-current-buffer) - (message "Buffer `%s' killed" buf-name)) - (find-file candidate)))) - -(defun helm-ff-run-kill-buffer-persistent () - "Execute `helm-ff-kill-buffer-fname' whitout quitting." - (interactive) - (with-helm-alive-p - (helm-attrset 'kill-buffer-fname 'helm-ff-kill-buffer-fname) - (helm-execute-persistent-action 'kill-buffer-fname))) - -(defun helm-ff-prefix-filename (fname &optional file-or-symlinkp new-file) - "Return filename FNAME maybe prefixed with [?] or [@]. -If FILE-OR-SYMLINKP is non--nil this mean we assume FNAME is an -existing filename or valid symlink and there is no need to test it. -NEW-FILE when non--nil mean FNAME is a non existing file and -return FNAME prefixed with [?]." - (let* ((prefix-new (propertize - " " 'display - (propertize "[?]" 'face 'helm-ff-prefix))) - (prefix-url (propertize - " " 'display - (propertize "[@]" 'face 'helm-ff-prefix)))) - (cond ((or file-or-symlinkp (file-exists-p fname)) fname) - ((or (string-match helm-ff-url-regexp fname) - (and ffap-url-regexp (string-match ffap-url-regexp fname))) - (concat prefix-url " " fname)) - ((or new-file (not (file-exists-p fname))) - (concat prefix-new " " fname))))) - -(defun helm-ff-sort-candidates (candidates _source) - "Sort function for `helm-source-find-files'. -Return candidates prefixed with basename of `helm-input' first." - (if (or (file-directory-p helm-input) - (null candidates)) - candidates - (let* ((c1 (car candidates)) - (cand1real (if (consp c1) (cdr c1) c1)) - (cand1 (unless (file-exists-p cand1real) - c1)) - (rest-cand (if cand1 (cdr candidates) candidates)) - (all (sort rest-cand - #'(lambda (s1 s2) - (let* ((score (lambda (str) - (if (condition-case _err - (string-match - (concat - "\\_<" - (helm-basename - helm-input)) str) - (invalid-regexp nil)) - 1 0))) - (bn1 (helm-basename (if (consp s1) (cdr s1) s1))) - (bn2 (helm-basename (if (consp s2) (cdr s2) s2))) - (sc1 (funcall score bn1)) - (sc2 (funcall score bn2))) - (cond ((= sc1 sc2) - (< (string-width bn1) - (string-width bn2))) - ((> sc1 sc2)) - (t (string-lessp bn1 bn2)))))))) - (if cand1 (cons cand1 all) all)))) - -(defun helm-ff-filter-candidate-one-by-one (file) - "`filter-one-by-one' Transformer function for `helm-source-find-files'." - ;; Handle boring files - (unless (and helm-ff-skip-boring-files - (cl-loop for r in helm-boring-file-regexp-list - thereis (string-match r file))) - ;; Handle tramp files. - (if (and (string-match helm-tramp-file-name-regexp helm-pattern) - helm-ff-tramp-not-fancy) - (if helm-ff-transformer-show-only-basename - (if (helm-dir-is-dot file) - file - (cons (or (helm-ff-get-host-from-tramp-invalid-fname file) - (helm-basename file)) - file)) - file) - ;; Now highlight. - (let* ((disp (if (and helm-ff-transformer-show-only-basename - (not (helm-dir-is-dot file)) - (not (and ffap-url-regexp - (string-match ffap-url-regexp file))) - (not (string-match helm-ff-url-regexp file))) - (or (helm-ff-get-host-from-tramp-invalid-fname file) - (helm-basename file)) file)) - (attr (file-attributes file)) - (type (car attr))) - - (cond ((string-match "access denied" file) file) - ( ;; A not already saved file. - (and (stringp type) - (not (helm-ff-valid-symlink-p file)) - (not (string-match "^\.#" (helm-basename file)))) - (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-invalid-symlink) t) - file)) - ;; A symlink. - ((stringp type) - (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-symlink) t) - file)) - ;; A directory. - ((eq t type) - (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-directory) t) - file)) - ;; An executable file. - ((and attr (string-match "x" (nth 8 attr))) - (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-executable) t) - file)) - ;; A file. - ((and attr (null type)) - (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-file) t) - file)) - ;; A non--existing file. - (t - (cons (helm-ff-prefix-filename - (propertize disp 'face 'helm-ff-file) nil 'new-file) - file))))))) - -(defun helm-find-files-action-transformer (actions candidate) - "Action transformer for `helm-source-find-files'." - (cond ((with-helm-current-buffer - (eq major-mode 'message-mode)) - (append actions - '(("Gnus attach file(s)" . helm-ff-gnus-attach-files)))) - ((string-match (image-file-name-regexp) candidate) - (append actions - '(("Rotate image right `M-r'" . helm-ff-rotate-image-right) - ("Rotate image left `M-l'" . helm-ff-rotate-image-left)))) - ((string-match "\.el$" (helm-aif (helm-marked-candidates) - (car it) candidate)) - (append actions - '(("Byte compile lisp file(s) `M-B, C-u to load'" - . helm-find-files-byte-compile) - ("Load File(s) `M-L'" . helm-find-files-load-files)))) - ((and (string-match "\.html?$" candidate) - (file-exists-p candidate)) - (append actions - '(("Browse url file" . browse-url-of-file)))) - ((or (string= (file-name-extension candidate) "pdf") - (string= (file-name-extension candidate) "PDF")) - (append actions - '(("Pdfgrep File(s)" . helm-ff-pdfgrep)))) - (t actions))) - -(defun helm-ff-gnus-attach-files (_candidate) - "Run `gnus-dired-attach' on `helm-marked-candidates' or CANDIDATE." - (let ((flist (helm-marked-candidates :with-wildcard t))) - (gnus-dired-attach flist))) - -(defvar image-dired-display-image-buffer) -(defun helm-ff-rotate-current-image-1 (file &optional num-arg) - "Rotate current image at NUM-ARG degrees. -This is a destructive operation on FILE made by external tool mogrify." - (setq file (file-truename file)) ; For symlinked images. - ;; When FILE is not an image-file, do nothing. - (when (string-match (image-file-name-regexp) file) - (if (executable-find "mogrify") - (progn - (shell-command (format "mogrify -rotate %s %s" - (or num-arg 90) - (shell-quote-argument file))) - (when (buffer-live-p image-dired-display-image-buffer) - (kill-buffer image-dired-display-image-buffer)) - (image-dired-display-image file) - (message nil) - (display-buffer (get-buffer image-dired-display-image-buffer))) - (error "mogrify not found")))) - -(defun helm-ff-rotate-image-left (candidate) - "Rotate image file CANDIDATE left. -This affect directly file CANDIDATE." - (helm-ff-rotate-current-image-1 candidate -90)) - -(defun helm-ff-rotate-image-right (candidate) - "Rotate image file CANDIDATE right. -This affect directly file CANDIDATE." - (helm-ff-rotate-current-image-1 candidate)) - -(defun helm-ff-rotate-left-persistent () - "Rotate image left without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'image-action1 'helm-ff-rotate-image-left) - (helm-execute-persistent-action 'image-action1))) - -(defun helm-ff-rotate-right-persistent () - "Rotate image right without quitting helm." - (interactive) - (with-helm-alive-p - (helm-attrset 'image-action2 'helm-ff-rotate-image-right) - (helm-execute-persistent-action 'image-action2))) - -(defun helm-ff-exif-data (candidate) - "Extract exif data from file CANDIDATE using `helm-ff-exif-data-program'." - (if (and helm-ff-exif-data-program - (executable-find helm-ff-exif-data-program)) - (shell-command-to-string (format "%s %s %s" - helm-ff-exif-data-program - helm-ff-exif-data-program-args - candidate)) - (format "No program %s found to extract exif" - helm-ff-exif-data-program))) - -(defun helm-find-files-persistent-action (candidate) - "Open subtree CANDIDATE without quitting helm. -If CANDIDATE is not a directory expand CANDIDATE filename. -If CANDIDATE is alone, open file CANDIDATE filename. -That's mean: -First hit on C-j expand CANDIDATE second hit open file. -If a prefix arg is given or `helm-follow-mode' is on open file." - (let* ((follow (or (buffer-local-value - 'helm-follow-mode - (get-buffer-create helm-buffer)) - helm--temp-follow-flag)) - (new-pattern (helm-get-selection)) - (num-lines-buf (with-current-buffer helm-buffer - (count-lines (point-min) (point-max)))) - (insert-in-minibuffer #'(lambda (fname) - (with-selected-window (minibuffer-window) - (unless follow - (delete-minibuffer-contents) - (set-text-properties 0 (length fname) - nil fname) - (insert fname)))))) - (cond ((and (helm-ff-invalid-tramp-name-p) - (string-match helm-tramp-file-name-regexp candidate)) - ;; First hit insert hostname and - ;; second hit insert ":" and expand. - (if (string= candidate helm-pattern) - (funcall insert-in-minibuffer (concat candidate ":")) - (funcall insert-in-minibuffer candidate))) - ( ;; A symlink directory, expand it's truename. - (and (file-directory-p candidate) (file-symlink-p candidate)) - (funcall insert-in-minibuffer (file-name-as-directory - (file-truename - (expand-file-name candidate))))) - ;; A directory, open it. - ((file-directory-p candidate) - (when (string= (helm-basename candidate) "..") - (setq helm-ff-last-expanded helm-ff-default-directory)) - (funcall insert-in-minibuffer (file-name-as-directory - (expand-file-name candidate)))) - ;; A symlink file, expand to it's true name. (cl-first hit) - ((and (file-symlink-p candidate) (not current-prefix-arg) (not follow)) - (funcall insert-in-minibuffer (file-truename candidate))) - ;; A regular file, expand it, (cl-first hit) - ((and (>= num-lines-buf 3) (not current-prefix-arg) (not follow)) - (funcall insert-in-minibuffer new-pattern)) - ;; An image file and it is the second hit on C-j, - ;; show the file in `image-dired'. - ((string-match (image-file-name-regexp) candidate) - (when (buffer-live-p (get-buffer image-dired-display-image-buffer)) - (kill-buffer image-dired-display-image-buffer)) - (image-dired-display-image candidate) - (message nil) - (helm-switch-to-buffer image-dired-display-image-buffer) - (with-current-buffer image-dired-display-image-buffer - (let ((exif-data (helm-ff-exif-data candidate))) - (setq default-directory helm-ff-default-directory) - (image-dired-update-property 'help-echo exif-data)))) - ;; Allow browsing archive on avfs fs. - ;; Assume volume is already mounted with mountavfs. - ((and helm-ff-avfs-directory - (string-match - (regexp-quote (expand-file-name helm-ff-avfs-directory)) - (file-name-directory candidate)) - (helm-ff-file-compressed-p candidate)) - (funcall insert-in-minibuffer (concat candidate "#"))) - ;; On second hit we open file. - ;; On Third hit we kill it's buffer maybe. - (t - (helm-ff-kill-or-find-buffer-fname candidate))))) - -(defun helm-ff-file-compressed-p (candidate) - "Whether CANDIDATE is a compressed file or not." - (member (file-name-extension candidate) - helm-ff-file-compressed-list)) - -(defun helm-insert-file-name-completion-at-point (candidate) - "Insert file name completion at point." - (with-helm-current-buffer - (if buffer-read-only - (error "Error: Buffer `%s' is read-only" (buffer-name)) - (let* ((end (point)) - (tap (thing-at-point 'filename)) - (guess (and (stringp tap) (substring-no-properties tap))) - (beg (- (point) (length guess))) - (full-path-p (and (stringp guess) - (or (string-match-p (concat "^" (getenv "HOME")) guess) - (string-match-p "^[^\~]" guess))))) - (set-text-properties 0 (length candidate) nil candidate) - (if (and guess (not (string= guess "")) - (string-match-p "^\\(~/\\|/\\|[[:lower:][:upper:]]:/\\)" guess)) - (progn - (delete-region beg end) - (insert (if full-path-p - (expand-file-name candidate) - (abbreviate-file-name candidate)))) - (insert candidate)))))) - -(cl-defun helm-find-files-history (&key (comp-read t)) - "The `helm-find-files' history. -Show the first `helm-ff-history-max-length' elements of -`helm-ff-history' in an `helm-comp-read'." - (let ((history (when helm-ff-history - (helm-fast-remove-dups helm-ff-history - :test 'equal)))) - (when history - (setq helm-ff-history - (if (>= (length history) helm-ff-history-max-length) - (cl-subseq history 0 helm-ff-history-max-length) - history)) - (if comp-read - (helm-comp-read - "Switch to Directory: " - helm-ff-history - :name "Helm Find Files History" - :must-match t) - helm-ff-history)))) - -(defun helm-find-files-1 (fname &optional preselect) - "Find FNAME with `helm' completion. -Like `find-file' but with `helm' support. -Use it for non--interactive calls of `helm-find-files'." - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - (let* ( ;; Be sure we don't erase the precedent minibuffer if some. - (helm-ff-auto-update-initial-value - (and helm-ff-auto-update-initial-value - (not (minibuffer-window-active-p (minibuffer-window))))) - (tap (thing-at-point 'filename)) - (def (and tap (or (file-remote-p tap) - (expand-file-name tap))))) - (unless helm-source-find-files - (setq helm-source-find-files (helm-make-source - "Find Files" 'helm-source-ffiles))) - (helm :sources 'helm-source-find-files - :input fname - :case-fold-search helm-file-name-case-fold-search - :keymap helm-find-files-map - :preselect preselect - :default def - :prompt "Find Files or Url: " - :buffer "*Helm Find Files*"))) - - -(defun helm-find-files-initial-input (&optional input) - "Return INPUT if present, otherwise try to guess it." - (let ((ffap-machine-p-known 'reject)) - (unless (eq major-mode 'image-mode) - (or (and input (or (and (file-remote-p input) input) - (expand-file-name input))) - (helm-find-files-input - (ffap-guesser) - (thing-at-point 'filename)))))) - -(defun helm-find-files-input (file-at-pt thing-at-pt) - "Try to guess a default input for `helm-find-files'." - (let* ((non-essential t) - (remp (or (and file-at-pt (file-remote-p file-at-pt)) - (and thing-at-pt (file-remote-p thing-at-pt)))) - (def-dir (helm-current-directory)) - (urlp (and file-at-pt ffap-url-regexp - (string-match ffap-url-regexp file-at-pt))) - (lib (when helm-ff-search-library-in-sexp - (helm-find-library-at-point))) - (hlink (helm-ff-find-url-at-point)) - (file-p (and file-at-pt - (not (string= file-at-pt "")) - (not remp) - (file-exists-p file-at-pt) - thing-at-pt - (not (string= thing-at-pt "")) - (file-exists-p - (file-name-directory - (expand-file-name thing-at-pt def-dir)))))) - (cond (lib) ; e.g we are inside a require sexp. - (hlink) ; String at point is an hyperlink. - (file-p ; a regular file - (helm-aif (ffap-file-at-point) (expand-file-name it))) - (urlp file-at-pt) ; possibly an url or email. - ((and file-at-pt - (not remp) - (file-exists-p file-at-pt)) - file-at-pt)))) - -(defun helm-ff-find-url-at-point () - "Try to find link to an url in text-property at point." - (let* ((he (get-text-property (point) 'help-echo)) - (ov (overlays-at (point))) - (ov-he (and ov (overlay-get - (car (overlays-at (point))) 'help-echo))) - (w3m-l (get-text-property (point) 'w3m-href-anchor)) - (nt-prop (get-text-property (point) 'nt-link))) - ;; Org link. - (when (and (stringp he) (string-match "^LINK: " he)) - (setq he (replace-match "" t t he))) - (cl-loop for i in (list he ov-he w3m-l nt-prop) - thereis (and (stringp i) ffap-url-regexp (string-match ffap-url-regexp i) i)))) - -(defun helm-find-library-at-point () - "Try to find library path at point. -Find inside `require' and `declare-function' sexp." - (require 'find-func) - (let* ((beg-sexp (save-excursion (search-backward "(" (point-at-bol) t))) - (end-sexp (save-excursion (search-forward ")" (point-at-eol) t))) - (sexp (and beg-sexp end-sexp - (buffer-substring-no-properties - (1+ beg-sexp) (1- end-sexp))))) - (ignore-errors - (cond ((and sexp (string-match "require \'.+[^)]" sexp)) - (find-library-name - (replace-regexp-in-string - "'\\|\)\\|\(" "" - ;; If require use third arg, ignore it, - ;; always use library path found in `load-path'. - (cl-second (split-string (match-string 0 sexp)))))) - ((and sexp (string-match-p "^declare-function" sexp)) - (find-library-name - (replace-regexp-in-string - "\"\\|ext:" "" - (cl-third (split-string sexp))))) - (t nil))))) - - -;;; Handle copy, rename, symlink, relsymlink and hardlink from helm. -;; -;; -(defvar dired-async-be-async) -(cl-defun helm-dired-action (candidate - &key action follow (files (dired-get-marked-files))) - "Execute ACTION on FILES to CANDIDATE. -Where ACTION is a symbol that can be one of: -'copy, 'rename, 'symlink,'relsymlink, 'hardlink. -Argument FOLLOW when non--nil specify to follow FILES to destination for the actions -copy and rename." - (when (get-buffer dired-log-buffer) (kill-buffer dired-log-buffer)) - (let ((fn (cl-case action - (copy 'dired-copy-file) - (rename 'dired-rename-file) - (symlink 'make-symbolic-link) - (relsymlink 'dired-make-relative-symlink) - (hardlink 'dired-hardlink))) - (marker (cl-case action - ((copy rename) dired-keep-marker-copy) - (symlink dired-keep-marker-symlink) - (relsymlink dired-keep-marker-relsymlink) - (hardlink dired-keep-marker-hardlink))) - (dirflag (and (= (length files) 1) - (file-directory-p (car files)) - (not (file-directory-p candidate)))) - ;; When FOLLOW is enabled, disable helm-async. - ;; If it is globally disabled use this nil value. - (dired-async-be-async (and (boundp 'dired-async-be-async) - dired-async-be-async - (not follow)))) - (dired-create-files - fn (symbol-name action) files - ;; CANDIDATE is the destination. - (if (file-directory-p candidate) - ;; When CANDIDATE is a directory, build file-name in this directory. - ;; Else we use CANDIDATE. - #'(lambda (from) - (expand-file-name (file-name-nondirectory from) candidate)) - #'(lambda (_from) candidate)) - marker) - (push (file-name-as-directory - (if (file-directory-p candidate) - (expand-file-name candidate) - (file-name-directory candidate))) - helm-ff-history) - ;; If follow is non--nil we should not be in async mode. - (when (and follow - (not (memq action '(symlink relsymlink hardlink))) - (not (get-buffer dired-log-buffer))) - (let ((target (directory-file-name candidate))) - (unwind-protect - (progn - (setq helm-ff-cand-to-mark - (helm-get-dest-fnames-from-list files candidate dirflag)) - (with-helm-after-update-hook (helm-ff-maybe-mark-candidates)) - (if (and dirflag (eq action 'rename)) - (helm-find-files-1 (file-name-directory target) - (if helm-ff-transformer-show-only-basename - (helm-basename target) target)) - (helm-find-files-1 (file-name-as-directory - (expand-file-name candidate))))) - (setq helm-ff-cand-to-mark nil)))))) - -(defun helm-get-dest-fnames-from-list (flist dest-cand rename-dir-flag) - "Transform filenames of FLIST to abs of DEST-CAND. -If RENAME-DIR-FLAG is non--nil collect the `directory-file-name' of transformed -members of FLIST." - ;; At this point files have been renamed/copied at destination. - ;; That's mean DEST-CAND exists. - (cl-loop - with dest = (expand-file-name dest-cand) - for src in flist - for basename-src = (helm-basename src) - for fname = (cond (rename-dir-flag (directory-file-name dest)) - ((file-directory-p dest) - (concat (file-name-as-directory dest) basename-src)) - (t dest)) - when (file-exists-p fname) - collect fname into tmp-list - finally return (sort tmp-list 'string<))) - -(defun helm-ff-maybe-mark-candidates () - "Mark all candidates of list `helm-ff-cand-to-mark'. -This is used when copying/renaming/symlinking etc... and -following files to destination." - (when (and (string= (assoc-default 'name (helm-get-current-source)) - (assoc-default 'name helm-source-find-files)) - helm-ff-cand-to-mark) - (with-helm-window - (while helm-ff-cand-to-mark - (if (string= (car helm-ff-cand-to-mark) (helm-get-selection)) - (progn - (helm-make-visible-mark) - (helm-next-line) - (setq helm-ff-cand-to-mark (cdr helm-ff-cand-to-mark))) - (helm-next-line))) - (unless (helm-this-visible-mark) - (helm-prev-visible-mark))))) - - -;;; Routines for files -;; -;; -(defun helm-file-buffers (filename) - "Returns a list of buffer names corresponding to FILENAME." - (cl-loop with name = (expand-file-name filename) - for buf in (buffer-list) - for bfn = (buffer-file-name buf) - when (and bfn (string= name bfn)) - collect (buffer-name buf))) - -(defun helm-delete-file (file &optional error-if-dot-file-p synchro) - "Delete the given file after querying the user. -Ask to kill buffers associated with that file, too." - (when (and error-if-dot-file-p - (helm-ff-dot-file-p file)) - (error "Error: Cannot operate on `.' or `..'")) - (let ((buffers (helm-file-buffers file)) - (helm--reading-passwd-or-string t)) - (if (or (< emacs-major-version 24) synchro) - ;; `dired-delete-file' in Emacs versions < 24 - ;; doesn't support delete-by-moving-to-trash - ;; so use `delete-directory' and `delete-file' - ;; that handle it. - (cond ((and (not (file-symlink-p file)) - (file-directory-p file) - (directory-files file t dired-re-no-dot)) - (when (y-or-n-p (format "Recursive delete of `%s'? " file)) - (delete-directory file 'recursive))) - ((and (not (file-symlink-p file)) - (file-directory-p file)) - (delete-directory file)) - (t (delete-file file))) - (dired-delete-file - file dired-recursive-deletes delete-by-moving-to-trash)) - (when buffers - (cl-dolist (buf buffers) - (when (y-or-n-p (format "Kill buffer %s, too? " buf)) - (kill-buffer buf)))))) - -(defun helm-delete-marked-files (_ignore) - (let* ((files (helm-marked-candidates :with-wildcard t)) - (len (length files))) - (with-helm-display-marked-candidates - helm-marked-buffer-name - (mapcar #'(lambda (f) - (if (file-directory-p f) - (concat (helm-basename f) "/") - (helm-basename f))) - files) - (if (not (y-or-n-p (format "Delete *%s File(s)" len))) - (message "(No deletions performed)") - (cl-dolist (i files) - (set-text-properties 0 (length i) nil i) - (helm-delete-file i helm-ff-signal-error-on-dot-files)) - (message "%s File(s) deleted" len))))) - -(defun helm-find-file-or-marked (candidate) - "Open file CANDIDATE or open helm marked files in background." - (let ((marked (helm-marked-candidates :with-wildcard t)) - (url-p (and ffap-url-regexp ; we should have only one candidate. - (string-match ffap-url-regexp candidate))) - (ffap-newfile-prompt helm-ff-newfile-prompt-p) - (find-file-wildcards nil) - (make-dir-fn - #'(lambda (dir &optional helm-ff) - (when (y-or-n-p (format "Create directory `%s'? " dir)) - (let ((dirfname (directory-file-name dir))) - (if (file-exists-p dirfname) - (error - "Mkdir: Unable to create directory `%s': file exists." - (helm-basename dirfname)) - (make-directory dir 'parent))) - (when helm-ff - ;; Allow having this new dir in history - ;; to be able to retrieve it immediately - ;; if we want to e.g copy a file from somewhere in it. - (setq helm-ff-default-directory - (file-name-as-directory dir)) - (push helm-ff-default-directory helm-ff-history)) - (or (and helm-ff (helm-find-files-1 dir)) t)))) - (helm--reading-passwd-or-string t)) - (if (> (length marked) 1) - ;; Open all marked files in background and display - ;; the first one. - (progn - (mapc 'find-file-noselect (cdr marked)) - (find-file (car marked))) - (if (and (not (file-exists-p candidate)) - (not url-p) - (string-match "/$" candidate)) - ;; A a non--existing filename ending with / - ;; Create a directory and jump to it. - (funcall make-dir-fn candidate 'helm-ff) - ;; A non--existing filename NOT ending with / or - ;; an existing filename, create or jump to it. - ;; If the basedir of candidate doesn't exists, - ;; ask for creating it. - (let ((dir (file-name-directory candidate))) - (if (or (and dir (file-directory-p dir)) url-p) - (find-file-at-point (helm-substitute-in-filename - (car marked))) - (and (funcall make-dir-fn dir) - (find-file-at-point candidate)))))))) - -(defun helm-shadow-boring-files (files) - "Files matching `helm-boring-file-regexp' will be -displayed with the `file-name-shadow' face if available." - (helm-shadow-entries files helm-boring-file-regexp-list)) - -(defun helm-skip-boring-files (files) - "Files matching `helm-boring-file-regexp' will be skipped." - (helm-skip-entries files helm-boring-file-regexp-list)) - -(defun helm-skip-current-file (files) - "Current file will be skipped." - (remove (buffer-file-name helm-current-buffer) files)) - -(defun helm-w32-pathname-transformer (args) - "Change undesirable features of windows pathnames to ones more acceptable to -other candidate transformers." - (if (eq system-type 'windows-nt) - (helm-transform-mapcar - (lambda (x) - (replace-regexp-in-string - "/cygdrive/\\(.\\)" "\\1:" - (replace-regexp-in-string "\\\\" "/" x))) - args) - args)) - -(defun helm-transform-file-load-el (actions candidate) - "Add action to load the file CANDIDATE if it is an emacs lisp -file. Else return ACTIONS unmodified." - (if (member (file-name-extension candidate) '("el" "elc")) - (append actions '(("Load Emacs Lisp File" . load-file))) - actions)) - -(defun helm-transform-file-browse-url (actions candidate) - "Add an action to browse the file CANDIDATE if it is a html file or URL. -Else return ACTIONS unmodified." - (let ((browse-action '("Browse with Browser" . browse-url))) - (cond ((string-match "^http\\|^ftp" candidate) - (cons browse-action actions)) - ((string-match "\\.html?$" candidate) - (append actions (list browse-action))) - (t actions)))) - - -;;; List of files gleaned from every dired buffer -;; -;; -(defun helm-files-in-all-dired-candidates () - (save-excursion - (cl-loop for (f . b) in dired-buffers - when (buffer-live-p b) - append (let ((dir (with-current-buffer b dired-directory))) - (if (listp dir) (cdr dir) - (directory-files f t dired-re-no-dot)))))) - -;; (dired '("~/" "~/.emacs.d/.emacs-custom.el" "~/.emacs.d/.emacs.bmk")) - -(defvar helm-source-files-in-all-dired - '((name . "Files in all dired buffer.") - (candidates . helm-files-in-all-dired-candidates) - (type . file))) - - -;;; File Cache -;; -;; -(defvar file-cache-alist) - -(defclass helm-file-cache (helm-source-in-buffer helm-type-file) - ((init :initform (lambda () (require 'filecache))) - (keymap :initform helm-generic-files-map) - (help-message :initform helm-generic-file-help-message) - (mode-line :initform helm-generic-file-mode-line-string))) - -(defvar helm-source-file-cache - (helm-make-source - "File Cache" 'helm-file-cache - :data (lambda () - (cl-loop for item in file-cache-alist append - (cl-destructuring-bind (base &rest dirs) item - (cl-loop for dir in dirs collect - (concat dir base))))))) - -(cl-defun helm-file-cache-add-directory-recursively - (dir &optional match (ignore-dirs t)) - (require 'filecache) - (cl-loop for f in (helm-walk-directory - dir - :path 'full - :directories nil - :match match - :skip-subdirs ignore-dirs) - do (file-cache-add-file f))) - -(defun helm-ff-cache-add-file (_candidate) - (require 'filecache) - (let ((mkd (helm-marked-candidates))) - (mapc 'file-cache-add-file mkd))) - -(defun helm-ff-file-cache-remove-file-1 (file) - "Remove FILE from `file-cache-alist'." - (let ((entry (assoc (helm-basename file) file-cache-alist)) - (dir (helm-basedir file)) - new-entry) - (setq new-entry (remove dir entry)) - (when (= (length entry) 1) - (setq new-entry nil)) - (setq file-cache-alist - (cons new-entry (remove entry file-cache-alist))))) - -(defun helm-ff-file-cache-remove-file (_file) - "Remove marked files from `file-cache-alist.'" - (let ((mkd (helm-marked-candidates))) - (mapc 'helm-ff-file-cache-remove-file-1 mkd))) - -(defun helm-transform-file-cache (actions _candidate) - (let ((source (helm-get-current-source))) - (if (string= (assoc-default 'name source) "File Cache") - (append actions - '(("Remove marked files from file-cache" - . helm-ff-file-cache-remove-file))) - actions))) - - -;;; File name history -;; -;; -(defvar helm-source-file-name-history - `((name . "File Name History") - (candidates . file-name-history) - (persistent-action . ignore) - (filtered-candidate-transformer . helm-file-name-history-transformer) - (action . ,(cdr (helm-get-actions-from-type - helm-source-locate))))) - -(defvar helm-source--ff-file-name-history - '((name . "File name history") - (init . (lambda () - (with-helm-alive-p - (when helm-ff-file-name-history-use-recentf - (require 'recentf) - (or recentf-mode (recentf-mode 1)))))) - (candidates . (lambda () - (if helm-ff-file-name-history-use-recentf - recentf-list - file-name-history))) - (persistent-action . ignore) - (filtered-candidate-transformer . helm-file-name-history-transformer) - (action . (("Find file" - . (lambda (candidate) - (helm-set-pattern - (expand-file-name candidate)) - (with-helm-after-update-hook (helm-exit-minibuffer)))) - ("Find file in helm" - . (lambda (candidate) - (helm-set-pattern - (expand-file-name candidate))))))) - "[Internal] This source is build to be used with `helm-find-files'. -Don't use it in your own code unless you know what you are doing.") - -(defun helm-file-name-history-transformer (candidates _source) - (cl-loop for c in candidates collect - (cond ((file-remote-p c) - (cons (propertize c 'face 'helm-history-remote) c)) - ((file-exists-p c) - (cons (propertize c 'face 'helm-ff-file) c)) - (t (cons (propertize c 'face 'helm-history-deleted) c))))) - -(defun helm-ff-file-name-history () - "Switch to `file-name-history' without quitting `helm-find-files'." - (interactive) - (with-helm-alive-p - (helm :sources 'helm-source--ff-file-name-history - :buffer "*helm-file-name-history*" - :allow-nest t - :resume 'noresume))) - -;;; Recentf files -;; -;; -(defvar helm-source-recentf - `((name . "Recentf") - (init . (lambda () - (require 'recentf) - (recentf-mode 1))) - (candidates . recentf-list) - (match . helm-files-match-only-basename) - (filtered-candidate-transformer . (lambda (candidates _source) - (cl-loop for i in candidates - if helm-ff-transformer-show-only-basename - collect (cons (helm-basename i) i) - else collect i))) - (keymap . ,helm-generic-files-map) - (help-message . helm-generic-file-help-message) - (mode-line . helm-generic-file-mode-line-string) - (action . ,(cdr (helm-get-actions-from-type - helm-source-locate)))) - "See (info \"(emacs)File Conveniences\"). -Set `recentf-max-saved-items' to a bigger value if default is too small.") - -;;; Browse project -;; Need dependencies: -;; -;; -;; Only hg and git are supported for now. - -;;;###autoload -(defun helm-browse-project () - "Browse files and see status of project with its vcs. -Only hg and git are supported for now. -Fall back to `helm-find-files' if directory is not under -control of one of those vcs. -Need dependencies: - -and -." - (interactive) - (cond ((and (fboundp 'helm-ls-git-root-dir) - (helm-ls-git-root-dir)) - (helm-ls-git-ls)) - ((and (fboundp 'helm-hg-root) - (helm-hg-root)) - (helm-hg-find-files-in-project)) - (t (helm-find-files nil)))) - -(defun helm-ff-browse-project (_candidate) - (with-helm-default-directory helm-ff-default-directory - ;; `helm-browse-project' will call `helm-ls-git-ls' - ;; which will set locally `helm-default-directory' - (helm-browse-project))) - -(defun helm-ff-run-browse-project () - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-browse-project))) - -;;; session.el files -;; -;; session (http://emacs-session.sourceforge.net/) is an alternative to -;; recentf that saves recent file history and much more. -(defvar helm-source-session - `((name . "Session") - (candidates . (lambda () - (cl-delete-if-not #'(lambda (f) - (or (string-match helm-tramp-file-name-regexp f) - (file-exists-p f))) - (mapcar 'car session-file-alist)))) - (keymap . ,helm-generic-files-map) - (help-message . helm-generic-file-help-message) - (mode-line . helm-generic-file-mode-line-string) - (action . ,(cdr (helm-get-actions-from-type - helm-source-locate)))) - "File list from emacs-session.") - - -;;; Files in current dir -;; -;; -(defun helm-highlight-files (files) - "A basic transformer for helm files sources. -Colorize only symlinks, directories and files." - (cl-loop for i in files - for disp = (if (and helm-ff-transformer-show-only-basename - (not (helm-dir-is-dot i)) - (not (and ffap-url-regexp - (string-match ffap-url-regexp i))) - (not (string-match helm-ff-url-regexp i))) - (helm-basename i) i) - for type = (car (file-attributes i)) - collect - (cond ((and helm-ff-tramp-not-fancy - (string-match helm-tramp-file-name-regexp i)) - (cons disp i)) - ((stringp type) - (cons (propertize disp - 'face 'helm-ff-symlink - 'help-echo (expand-file-name i)) - i)) - ((eq type t) - (cons (propertize disp - 'face 'helm-ff-directory - 'help-echo (expand-file-name i)) - i)) - (t (cons (propertize disp - 'face 'helm-ff-file - 'help-echo (expand-file-name i)) - i))))) - -(defvar helm-source-files-in-current-dir - `((name . "Files from Current Directory") - (candidates . (lambda () - (with-helm-current-buffer - (let ((dir (helm-current-directory))) - (when (file-accessible-directory-p dir) - (directory-files dir t)))))) - (match . helm-files-match-only-basename) - (keymap . ,helm-generic-files-map) - (help-message . helm-generic-file-help-message) - (mode-line . helm-generic-file-mode-line-string) - (type . file))) - - -;;; External searching file tools. -;; -;; Tracker desktop search -(defvar helm-source-tracker-cand-incomplete nil "Contains incomplete candidate") -(defun helm-source-tracker-transformer (candidates _source) - (helm-log "received: %S" candidates) - (cl-loop for cand in candidates - for path = (when (stringp helm-source-tracker-cand-incomplete) - (caar (helm-highlight-files - (list helm-source-tracker-cand-incomplete)))) - for built = (if (not (stringp cand)) cand - (let ((snippet cand)) - (unless (or (null path) - (string= "" path) - (not (string-match-p - "\\`[[:space:]]*\\.\\.\\." - snippet))) - (let ((complete-candidate - (cons (concat path "\n" snippet) path))) - (setq helm-source-tracker-cand-incomplete nil) - (helm-log "built: %S" complete-candidate) - complete-candidate)))) - when (and (stringp cand) - (string-match "\\`[[:space:]]*file://" cand)) - do (setq helm-source-tracker-cand-incomplete ; save path - (replace-match "" t t cand)) end - collect built)) - -(defvar helm-source-tracker-search - `((name . "Tracker Search") - (candidates-process - . (lambda () - (start-process "tracker-search-process" nil - "tracker-search" - "--disable-color" - "--limit=512" - helm-pattern))) - (filtered-candidate-transformer . helm-source-tracker-transformer) - ;;(multiline) ; https://github.com/emacs-helm/helm/issues/529 - (keymap . ,helm-generic-files-map) - (action . ,(cdr (helm-get-attribute-from-type 'action 'file))) - (action-transformer - helm-transform-file-load-el - helm-transform-file-browse-url) - (requires-pattern . 3)) - "Source for retrieving files matching the current input pattern -with the tracker desktop search.") - -;; Spotlight (MacOS X desktop search) -(defvar helm-source-mac-spotlight - '((name . "mdfind") - (candidates-process - . (lambda () (start-process "mdfind-process" nil "mdfind" helm-pattern))) - (type . file) - (requires-pattern . 3)) - "Source for retrieving files via Spotlight's command line -utility mdfind.") - - -;;; Findutils -;; -;; -(defvar helm-source-findutils - `((name . "Find") - (header-name . (lambda (name) - (concat name " in [" helm-default-directory "]"))) - (candidates-process . helm-find-shell-command-fn) - (filtered-candidate-transformer . helm-findutils-transformer) - (action-transformer helm-transform-file-load-el) - (action . ,(cdr (helm-inherit-attribute-from-source - 'action helm-source-locate))) - (mode-line . helm-generic-file-mode-line-string) - (keymap . ,helm-generic-files-map) - (candidate-number-limit . 9999) - (requires-pattern . 3))) - -(defun helm-findutils-transformer (candidates _source) - (cl-loop for i in candidates - for type = (car (file-attributes i)) - for abs = (expand-file-name i helm-default-directory) - for disp = (if (and helm-ff-transformer-show-only-basename - (not (string-match "[.]\\{1,2\\}$" i))) - (helm-basename i) abs) - collect (cond ((eq t type) - (cons (propertize disp 'face 'helm-ff-directory) abs)) - ((stringp type) - (cons (propertize disp 'face 'helm-ff-symlink) abs)) - (t (cons (propertize disp 'face 'helm-ff-file) abs))))) - -(defun helm-find-shell-command-fn () - "Asynchronously fetch candidates for `helm-find'." - (require 'find-cmd) - (let ((case-fold-search (helm-set-case-fold-search helm-pattern))) - (with-helm-default-directory (helm-default-directory) - (let* (process-connection-type - (pattern (mapconcat 'identity (split-string helm-pattern) "*")) - (ignored-dirs ()) - (ignored-files (when helm-findutils-skip-boring-files - (cl-loop for f in completion-ignored-extensions - if (string-match "/$" f) - do (push (replace-match "" nil t f) - ignored-dirs) - else collect (concat "*" f)))) - (path-or-name (if helm-findutils-search-full-path - '(ipath path) '(iname name))) - (name-or-iname (if case-fold-search - (car path-or-name) (cadr path-or-name))) - (cmd (find-cmd (and ignored-dirs - `(prune (name ,@ignored-dirs))) - (and ignored-files - `(not (name ,@ignored-files))) - `(and (,name-or-iname ,(concat "*" pattern "*")) - (type "d" "f")))) - (proc (start-file-process-shell-command "hfind" helm-buffer cmd))) - (helm-log "Find command:\n%s" cmd) - (prog1 proc - (set-process-sentinel - proc - #'(lambda (process event) - (helm-process-deferred-sentinel-hook - process event (helm-default-directory))))))))) - -(defun helm-find-1 (dir) - (helm :sources 'helm-source-findutils - :buffer "*helm find*" - ;; Make these vars local for further resuming. - :default-directory dir ; reset it when called from elsewhere. - :ff-transformer-show-only-basename nil - :case-fold-search helm-file-name-case-fold-search)) - -;; helm-find-files integration. -(defun helm-ff-find-sh-command (_candidate) - "Run `helm-find' from `helm-find-files'." - (helm-find-1 helm-ff-default-directory)) - -(defun helm-ff-run-find-sh-command () - "Run find shell command action with key from `helm-find-files'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-ff-find-sh-command))) - - -;;; Preconfigured commands -;; -;; -;;;###autoload -(defun helm-find (arg) - "Preconfigured `helm' for the find shell command." - (interactive "P") - (let ((directory - (if arg - (file-name-as-directory - (read-directory-name "DefaultDirectory: ")) - default-directory))) - (helm-find-1 directory))) - -(defvar org-directory) -;;;###autoload -(defun helm-find-files (arg) - "Preconfigured `helm' for helm implementation of `find-file'. -Called with a prefix arg show history if some. -Don't call it from programs, use `helm-find-files-1' instead. -This is the starting point for nearly all actions you can do on files." - (interactive "P") - (let* ((hist (and arg helm-ff-history (helm-find-files-history))) - (default-input (or hist (helm-find-files-initial-input))) - (input (cond ((and (eq major-mode 'org-agenda-mode) - org-directory - (not default-input)) - (expand-file-name org-directory)) - ((and (eq major-mode 'dired-mode) default-input) - (file-name-directory default-input)) - (default-input) - (t (expand-file-name (helm-current-directory))))) - (presel (helm-aif (or hist - (buffer-file-name (current-buffer)) - (and (eq major-mode 'dired-mode) - default-input)) - (if helm-ff-transformer-show-only-basename - (helm-basename it) it)))) - (set-text-properties 0 (length input) nil input) - (helm-find-files-1 input (and presel (concat "^" (regexp-quote presel)))))) - -;;;###autoload -(defun helm-for-files () - "Preconfigured `helm' for opening files. -Run all sources defined in `helm-for-files-preferred-list'." - (interactive) - (let ((helm-ff-transformer-show-only-basename nil)) - (helm-other-buffer helm-for-files-preferred-list "*helm for files*"))) - -;;;###autoload -(defun helm-recentf () - "Preconfigured `helm' for `recentf'." - (interactive) - (let ((helm-ff-transformer-show-only-basename nil)) - (helm-other-buffer 'helm-source-recentf "*helm recentf*"))) - -(provide 'helm-files) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-files.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-firefox.el b/emacs.d/elpa/helm-20141016.2217/helm-firefox.el deleted file mode 100644 index e6f40a7..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-firefox.el +++ /dev/null @@ -1,124 +0,0 @@ -;;; helm-firefox.el --- Firefox bookmarks -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-adaptive) -;; -;; You will have to set firefox to import bookmarks in his html file bookmarks.html. -;; (only for firefox versions >=3) -;; To achieve that, open about:config in firefox and double click on this line to enable value -;; to true: -;; user_pref("browser.bookmarks.autoExportHTML", false); -;; You should have now: -;; user_pref("browser.bookmarks.autoExportHTML", true); -;; NOTE: This is also working in the same way for mozilla aka seamonkey. - - -(defgroup helm-firefox nil - "Helm libraries and applications for Firefox navigator." - :group 'helm) - -(defcustom helm-firefox-default-directory "/.mozilla/firefox/" - "The root directory containing firefox config." - :group 'helm-firefox - :type 'string) - -(defvar helm-firefox-bookmark-url-regexp "\\(https\\|http\\|ftp\\|about\\|file\\)://[^ \"]*") -(defvar helm-firefox-bookmarks-regexp ">\\([^><]+.[^]\\)") - -(defun helm-get-firefox-user-init-dir () - "Guess the default Firefox user directory name." - (let* ((moz-dir (concat (getenv "HOME") helm-firefox-default-directory)) - (moz-user-dir - (with-current-buffer (find-file-noselect (concat moz-dir "profiles.ini")) - (goto-char (point-min)) - (prog1 - (when (search-forward "Path=" nil t) - (buffer-substring-no-properties (point) (point-at-eol))) - (kill-buffer))))) - (file-name-as-directory (concat moz-dir moz-user-dir)))) - -(defun helm-guess-firefox-bookmark-file () - "Return the path of the Firefox bookmarks file." - (concat (helm-get-firefox-user-init-dir) "bookmarks.html")) - -(defvar helm-firefox-bookmarks-alist nil) -(defvar helm-source-firefox-bookmarks - '((name . "Firefox Bookmarks") - (init . (lambda () - (setq helm-firefox-bookmarks-alist - (helm-html-bookmarks-to-alist - (helm-guess-firefox-bookmark-file) - helm-firefox-bookmark-url-regexp - helm-firefox-bookmarks-regexp)))) - (candidates . (lambda () - (mapcar #'car helm-firefox-bookmarks-alist))) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-firefox-bookmarks) - (action . (("Browse Url" - . (lambda (candidate) - (helm-browse-url - (helm-firefox-bookmarks-get-value candidate)))) - ("Copy Url" - . (lambda (candidate) - (let ((url (helm-firefox-bookmarks-get-value - candidate))) - (kill-new url) - (message "`%s' copied to kill-ring" url)))))))) - -(defun helm-firefox-bookmarks-get-value (elm) - (assoc-default elm helm-firefox-bookmarks-alist)) - -(defun helm-highlight-firefox-bookmarks (bookmarks _source) - (cl-loop for i in bookmarks - collect (propertize - i 'face '((:foreground "YellowGreen")) - 'help-echo (helm-firefox-bookmarks-get-value i)))) - -;;;###autoload -(defun helm-firefox-bookmarks () - "Preconfigured `helm' for firefox bookmark. -You will have to enable html bookmarks in firefox: -open about:config in firefox and double click on this line to enable value \ -to true: - -user_pref(\"browser.bookmarks.autoExportHTML\", false); - -You should have now: - -user_pref(\"browser.bookmarks.autoExportHTML\", true); - -After closing firefox, you will be able to browse you bookmarks. -" - (interactive) - (helm-other-buffer 'helm-source-firefox-bookmarks - "*Helm Firefox*")) - - -(provide 'helm-firefox) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-firefox.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-font.el b/emacs.d/elpa/helm-20141016.2217/helm-font.el deleted file mode 100644 index 446880e..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-font.el +++ /dev/null @@ -1,177 +0,0 @@ -;;; helm-font --- Font and ucs selection for Helm -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) - -(defvar helm-ucs-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "") 'helm-ucs-persistent-delete) - (define-key map (kbd "") 'helm-ucs-persistent-backward) - (define-key map (kbd "") 'helm-ucs-persistent-forward) - (define-key map (kbd "") 'helm-ucs-persistent-insert) - (define-key map (kbd "C-c ?") 'helm-ucs-help) - map) - "Keymap for `helm-ucs'.") - - -;;; Xfont selection -;; -;; -(defun helm-persistent-xfont-action (elm) - "Show current font temporarily" - (let ((current-font (cdr (assoc 'font (frame-parameters)))) - (default-font elm)) - (unwind-protect - (progn (set-frame-font default-font 'keep-size) (sit-for 2)) - (set-frame-font current-font)))) - -(defvar helm-xfonts-cache nil) -(defvar helm-source-xfonts - '((name . "X Fonts") - (init . (lambda () - (unless helm-xfonts-cache - (setq helm-xfonts-cache - (x-list-fonts "*"))))) - (candidates . helm-xfonts-cache) - (action . (("Copy to kill ring" . (lambda (elm) - (kill-new elm))) - ("Set Font" . (lambda (elm) - (kill-new elm) - (set-frame-font elm 'keep-size) - (message "New font have been copied to kill ring"))))) - (persistent-action . helm-persistent-xfont-action) - (persistent-help . "Switch to this font temporarily"))) - -;;; ð•Œð•”𕤠ð•Šð•ªð•žð•“ð• ð• ð•”ð• ð•žð•¡ð•ð•–ð•¥ð•šð• ð•Ÿ -;; -;; -(defvar helm-ucs-max-len 0) -(defun helm-calculate-ucs-max-len () - "Calculate the length of longest `ucs-names' candidate." - (cl-loop with count = 0 - for (n . v) in (ucs-names) - for len = (length n) - if (> len count) - do (setq count len) - finally return count)) - -(defun helm-ucs-init () - "Initialize an helm buffer with ucs symbols. -Only math* symbols are collected." - (unless (> helm-ucs-max-len 0) - (setq helm-ucs-max-len - (helm-calculate-ucs-max-len))) - (with-current-buffer (helm-candidate-buffer - (get-buffer-create "*helm ucs*")) - ;; `ucs-names' fn will not run again, data is cached in - ;; var `ucs-names'. - (cl-loop for (n . v) in (ucs-names) - for len = (length n) - for diff = (+ (- helm-ucs-max-len len) 2) - unless (string= "" n) - do (progn (insert (concat - n ":" - (make-string - diff ? ))) - (if (fboundp 'ucs-insert) - (ucs-insert v) - ;; call `insert-char' with nil nil - ;; to shutup byte compiler in 24.1. - (insert-char v nil nil)) - (insert "\n"))))) - -(defun helm-ucs-forward-char (_candidate) - (with-helm-current-buffer - (forward-char 1))) - -(defun helm-ucs-backward-char (_candidate) - (with-helm-current-buffer - (forward-char -1))) - -(defun helm-ucs-delete-backward (_candidate) - (with-helm-current-buffer - (delete-char -1))) - -(defun helm-ucs-insert-char (candidate) - (with-helm-current-buffer - (insert - (replace-regexp-in-string - " " "" - (cadr (split-string candidate ":")))))) - -(defun helm-ucs-persistent-insert () - (interactive) - (with-helm-alive-p - (helm-attrset 'action-insert 'helm-ucs-insert-char) - (helm-execute-persistent-action 'action-insert))) - -(defun helm-ucs-persistent-forward () - (interactive) - (with-helm-alive-p - (helm-attrset 'action-forward 'helm-ucs-forward-char) - (helm-execute-persistent-action 'action-forward))) - -(defun helm-ucs-persistent-backward () - (interactive) - (with-helm-alive-p - (helm-attrset 'action-back 'helm-ucs-backward-char) - (helm-execute-persistent-action 'action-back))) - -(defun helm-ucs-persistent-delete () - (interactive) - (with-helm-alive-p - (helm-attrset 'action-delete 'helm-ucs-delete-backward) - (helm-execute-persistent-action 'action-delete))) - -(defvar helm-source-ucs - '((name . "Ucs names") - (init . helm-ucs-init) - (candidate-number-limit . 9999) - (candidates-in-buffer) - (mode-line . helm-ucs-mode-line-string) - (action . (("Insert" . helm-ucs-insert-char) - ("Forward char" . helm-ucs-forward-char) - ("Backward char" . helm-ucs-backward-char) - ("Delete char backward" . helm-ucs-delete-backward)))) - "Source for collecting `ucs-names' math symbols.") - -;;;###autoload -(defun helm-select-xfont () - "Preconfigured `helm' to select Xfont." - (interactive) - (helm-other-buffer 'helm-source-xfonts "*helm select* xfont")) - -;;;###autoload -(defun helm-ucs () - "Preconfigured helm for `ucs-names' math symbols." - (interactive) - (helm :sources 'helm-source-ucs - :keymap helm-ucs-map)) - -(provide 'helm-font) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-font.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-gentoo.el b/emacs.d/elpa/helm-20141016.2217/helm-gentoo.el deleted file mode 100644 index 075ea8c..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-gentoo.el +++ /dev/null @@ -1,258 +0,0 @@ -;;; helm-gentoo.el --- Helm UI for gentoo portage. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) - -(declare-function term-line-mode "term") -(declare-function term-char-mode "term") -(declare-function term-send-input "term") -(declare-function term-send-eof "term") - - -(defgroup helm-gentoo nil - "Predefined configurations for `helm.el'." - :group 'helm) - -(defface helm-gentoo-match '((t (:foreground "red"))) - "Face for helm-gentoo installed packages." - :group 'traverse-faces) - - -;;; Internals -(defvar helm-gentoo-use-flags nil) -(defvar helm-gentoo-buffer "*helm-gentoo-output*") -(defvar helm-cache-gentoo nil) -(defvar helm-cache-world nil) -(defvar helm-source-gentoo - '((name . "Portage sources") - (init . (lambda () - (get-buffer-create helm-gentoo-buffer) - (unless helm-cache-gentoo - (helm-gentoo-setup-cache)) - (unless helm-cache-world - (setq helm-cache-world (helm-gentoo-get-world))) - (helm-gentoo-init-list))) - (candidates-in-buffer) - (match . identity) - (candidate-transformer helm-highlight-world) - (action . (("Show package" . (lambda (elm) - (helm-gentoo-eshell-action elm "eix"))) - ("Show history" . (lambda (elm) - (if (member elm helm-cache-world) - (helm-gentoo-eshell-action elm "genlop -qe") - (message "No infos on packages not yet installed")))) - ("Copy in kill-ring" . kill-new) - ("insert at point" . insert) - ("Browse HomePage" . (lambda (elm) - (let ((urls (helm-gentoo-get-url elm))) - (browse-url (helm-comp-read "Url: " urls :must-match t))))) - ("Show extra infos" . (lambda (elm) - (if (member elm helm-cache-world) - (helm-gentoo-eshell-action elm "genlop -qi") - (message "No infos on packages not yet installed")))) - ("Show use flags" . (lambda (elm) - (helm-gentoo-default-action elm "equery" "-C" "u") - (font-lock-add-keywords nil '(("^\+.*" . font-lock-variable-name-face))) - (font-lock-mode 1))) - ("Run emerge pretend" . (lambda (elm) - (helm-gentoo-eshell-action elm "emerge -p"))) - ("Emerge" . (lambda (elm) - (helm-gentoo-install elm :action 'install))) - ("Unmerge" . (lambda (elm) - (helm-gentoo-install elm :action 'uninstall))) - ("Show dependencies" . (lambda (elm) - (helm-gentoo-default-action elm "equery" "-C" "d"))) - ("Show related files" . (lambda (elm) - (helm-gentoo-default-action elm "equery" "files"))) - ("Refresh" . (lambda (elm) - (helm-gentoo-setup-cache) - (setq helm-cache-world (helm-gentoo-get-world)))))))) - - -(cl-defun helm-gentoo-install (_candidate &key action) - (setq helm-external-commands-list nil) - (ansi-term (getenv "SHELL") "Gentoo emerge") - (term-line-mode) - (let ((command (cl-case action - (install "sudo emerge -av ") - (uninstall "sudo emerge -avC ") - (t (error "Unknown action")))) - (elms (mapconcat 'identity (helm-marked-candidates) " "))) - (goto-char (point-max)) - (insert (concat command elms)) - (term-char-mode) (term-send-input))) - -(defun helm-gentoo-default-action (elm command &rest args) - "Gentoo default action that use `helm-gentoo-buffer'." - (if (member elm helm-cache-world) - (progn - (helm-switch-to-buffer helm-gentoo-buffer) - (erase-buffer) - (let ((com-list (append args (list elm)))) - (apply #'call-process command nil t nil - com-list))) - (message "No infos on packages not yet installed"))) - -(defvar helm-source-use-flags - '((name . "Use Flags") - (init . (lambda () - (unless helm-gentoo-use-flags - (helm-gentoo-setup-use-flags-cache)) - (helm-gentoo-get-use))) - (candidates-in-buffer) - (match . identity) - (candidate-transformer helm-highlight-local-use) - (action . (("Description" - . (lambda (elm) - (helm-switch-to-buffer helm-gentoo-buffer) - (erase-buffer) - (apply #'call-process "euse" nil t nil - `("-i" - ,elm)) - (font-lock-add-keywords nil `((,elm . font-lock-variable-name-face))) - (font-lock-mode 1))) - ("Enable" - . (lambda (elm) - (helm-gentoo-eshell-action elm "*sudo -p Password: euse -E"))) - ("Disable" - . (lambda (elm) - (helm-gentoo-eshell-action elm "*sudo -p Password: euse -D"))) - ("Remove" - . (lambda (elm) - (helm-gentoo-eshell-action elm "*sudo -p Password: euse -P"))) - ("Show which dep use this flag" - . (lambda (elm) - (helm-switch-to-buffer helm-gentoo-buffer) - (erase-buffer) - (apply #'call-process "equery" nil t nil - `("-C" - "h" - ,elm)))))))) - - - -(defun helm-gentoo-init-list () - "Initialize buffer with all packages in Portage." - (let* ((portage-buf (get-buffer-create "*helm-gentoo*")) - (buf (helm-candidate-buffer portage-buf))) - (with-current-buffer buf - (cl-dolist (i helm-cache-gentoo) - (insert (concat i "\n")))))) - -(defun helm-gentoo-setup-cache () - "Set up `helm-cache-gentoo'" - (setq helm-cache-gentoo - (split-string (with-temp-buffer - (call-process "eix" nil t nil - "--only-names") - (buffer-string))))) - -(defun helm-gentoo-eshell-action (elm command) - (when (get-buffer "*EShell Command Output*") - (kill-buffer "*EShell Command Output*")) - (message "Wait searching...") - (let ((buf-fname (buffer-file-name helm-current-buffer))) - (if (and buf-fname (string-match tramp-file-name-regexp buf-fname)) - (progn - (save-window-excursion - (pop-to-buffer "*scratch*") - (eshell-command (format "%s %s" command elm))) - (pop-to-buffer "*EShell Command Output*")) - (eshell-command (format "%s %s" command elm))))) - -(defun helm-gentoo-get-use () - "Initialize buffer with all use flags." - (let* ((use-buf (get-buffer-create "*helm-gentoo-use*")) - (buf (helm-candidate-buffer use-buf))) - (with-current-buffer buf - (cl-dolist (i helm-gentoo-use-flags) - (insert (concat i "\n")))))) - - -(defun helm-gentoo-setup-use-flags-cache () - "Setup `helm-gentoo-use-flags'" - (setq helm-gentoo-use-flags - (split-string (with-temp-buffer - (call-process "eix" nil t nil - "--print-all-useflags") - (buffer-string))))) - -(defun helm-gentoo-get-url (elm) - "Return a list of urls from eix output." - (cl-loop with url-list = (split-string - (with-temp-buffer - (call-process "eix" nil t nil - elm "--format" "\n") - (buffer-string))) - for i in url-list - when (and (string-match "^http://.*" i) - all - (not (member i all))) - collect i into all - finally return all)) - -(defun helm-gentoo-get-world () - "Return list of all installed package on your system." - (split-string (with-temp-buffer - (call-process "qlist" nil t nil - "-I") - (buffer-string)))) - -(defun helm-gentoo-get-local-use () - (split-string (with-temp-buffer - (call-process "portageq" nil t nil - "envvar" - "USE") - (buffer-string)))) - - -(defun helm-highlight-world (eix) - "Highlight all installed package." - (cl-loop for i in eix - if (member i helm-cache-world) - collect (propertize i 'face 'helm-gentoo-match) - else - collect i)) - -(defun helm-highlight-local-use (use-flags) - (let ((local-uses (helm-gentoo-get-local-use))) - (cl-loop for i in use-flags - if (member i local-uses) - collect (propertize i 'face 'helm-gentoo-match) - else - collect i))) - -;;;###autoload -(defun helm-gentoo () - "Preconfigured `helm' for gentoo linux." - (interactive) - (helm-other-buffer '(helm-source-gentoo - helm-source-use-flags) - "*helm gentoo*")) - - -(provide 'helm-gentoo) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-gentoo.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-grep.el b/emacs.d/elpa/helm-20141016.2217/helm-grep.el deleted file mode 100644 index e17b792..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-grep.el +++ /dev/null @@ -1,1197 +0,0 @@ -;;; helm-grep.el --- Helm Incremental Grep. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'grep) -(require 'helm-regexp) - -;;; load wgrep proxy if it's available -(require 'wgrep-helm nil t) - -(declare-function helm-buffer-list "helm-buffers") -(declare-function helm-elscreen-find-file "helm-elscreen" (file)) -(declare-function View-quit "view") -(declare-function doc-view-goto-page "doc-view" (page)) - - -(defgroup helm-grep nil - "Grep related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-grep-default-command - "grep -a -d skip %e -n%cH -e %p %f" - "Default grep format command for `helm-do-grep-1'. -Where: -'%e' format spec is for --exclude or --include grep options or - ack-grep --type option. (Not mandatory) - -'%c' format spec is for case-fold-search, - whether to use the -i option of grep. (Not mandatory) - When you specify this spec, helm grep will use smartcase - that is when a upcase character is found in pattern case will - be respected and no '-i' option will be used, otherwise, when - no upcase character is found in pattern always use '-i'. - If you don't want this behavior, don't use this spec and - specify or not the '-i' option. - Note that with ack-grep this is not needed, just specify - the '--smart-case' option. - -'%p' format spec is for pattern. (Mandatory) - -'%f' format spec is for filenames. (Mandatory) - -If your grep version doesn't support the --exclude/include args -don't specify the '%e' format spec. - -Helm also support ack-grep and git-grep , -here a default command example for ack-grep: - -\(setq helm-grep-default-command \"ack-grep -Hn --no-group --no-color %e %p %f\" - helm-grep-default-recurse-command \"ack-grep -H --no-group --no-color %e %p %f\") - -You can ommit the %e spec if you don't want to be prompted for types. -`helm-grep-default-command' and `helm-grep-default-recurse-command'are -independents, so you can enable `helm-grep-default-command' with ack-grep -and `helm-grep-default-recurse-command' with grep if you want to be faster -on recursive grep. -NOTE: remote grepping is not available with ack-grep." - :group 'helm-grep - :type 'string) - -(defcustom helm-grep-default-recurse-command - "grep -a -d recurse %e -n%cH -e %p %f" - "Default recursive grep format command for `helm-do-grep-1'. -See `helm-grep-default-command' for format specs and infos about ack-grep." - :group 'helm-grep - :type 'string) - -(defcustom helm-default-zgrep-command - "zgrep -a -n%cH -e %p %f" - "Default command for Zgrep. -See `helm-grep-default-command' for infos on format specs." - :group 'helm-grep - :type 'string) - -(defcustom helm-ack-grep-executable "ack-grep" - "Default ack-grep command." - :group 'helm-grep - :type 'string) - -(defcustom helm-pdfgrep-default-command - "pdfgrep --color never -niH %s %s" - "Default command for pdfgrep." - :group 'helm-grep - :type 'string) - -(defcustom helm-grep-use-ioccur-style-keys t - "Use Arrow keys to jump to occurences." - :group 'helm-grep - :type 'boolean) - -(defcustom helm-pdfgrep-default-read-command nil - "Default command to read pdf files from pdfgrep. -Where '%f' format spec is filename and '%p' is page number. -e.g In Ubuntu you can set it to: - - \"evince --page-label=%p '%f'\" - -If set to nil `doc-view-mode' will be used instead of an external command." - :group 'helm-grep - :type 'string) - -(defcustom helm-grep-max-length-history 100 - "Max number of elements to save in `helm-grep-history'." - :group 'helm-grep - :type 'integer) - -(defcustom helm-zgrep-file-extension-regexp - ".*\\(\\.gz\\|\\.bz\\|\\.xz\\|\\.lzma\\)$" - "Default file extensions zgrep will search in." - :group 'helm-grep - :type 'string) - -(defcustom helm-do-grep-preselect-candidate nil - "When non--nil the file name of current buffer will be selected." - :group 'helm-grep - :type 'boolean) - -(defcustom helm-grep-preferred-ext nil - "This file extension will be preselected for grep." - :group 'helm-grep - :type 'string) - - -;;; Faces -;; -;; -(defface helm-grep-match - '((((background light)) :foreground "#b00000") - (((background dark)) :foreground "gold1")) - "Face used to highlight grep matches." - :group 'helm-grep) - -(defface helm-grep-file - '((t (:foreground "BlueViolet" - :underline t))) - "Face used to highlight grep results filenames." - :group 'helm-grep) - -(defface helm-grep-lineno - '((t (:foreground "Darkorange1"))) - "Face used to highlight grep number lines." - :group 'helm-grep) - -(defface helm-grep-running - '((t (:foreground "Red"))) - "Face used in mode line when grep is running." - :group 'helm-grep) - -(defface helm-grep-finish - '((t (:foreground "Green"))) - "Face used in mode line when grep is finish." - :group 'helm-grep) - -(defface helm-grep-cmd-line - '((t (:inherit diff-added))) - "Face used to highlight grep command line when no results." - :group 'helm-grep) - - -;;; Keymaps -;; -;; -(defvar helm-grep-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-") 'helm-goto-next-file) - (define-key map (kbd "M-") 'helm-goto-precedent-file) - (define-key map (kbd "C-c o") 'helm-grep-run-other-window-action) - (define-key map (kbd "C-c C-o") 'helm-grep-run-other-frame-action) - (define-key map (kbd "C-w") 'helm-yank-text-at-point) - (define-key map (kbd "C-x C-s") 'helm-grep-run-save-buffer) - (when helm-grep-use-ioccur-style-keys - (define-key map (kbd "") 'helm-execute-persistent-action) - (define-key map (kbd "") 'helm-grep-run-default-action)) - (define-key map (kbd "C-c ?") 'helm-grep-help) - (delq nil map)) - "Keymap used in Grep sources.") - -(defvar helm-pdfgrep-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-") 'helm-goto-next-file) - (define-key map (kbd "M-") 'helm-goto-precedent-file) - (define-key map (kbd "C-w") 'helm-yank-text-at-point) - (define-key map (kbd "C-c ?") 'helm-pdfgrep-help) - map) - "Keymap used in pdfgrep.") - -(defvar helm-grep-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") 'helm-grep-mode-jump) - (define-key map (kbd "C-o") 'helm-grep-mode-jump-other-window) - (define-key map (kbd "") 'helm-grep-mode-jump-other-window-forward) - (define-key map (kbd "") 'helm-grep-mode-jump-other-window-backward) - (define-key map (kbd "") 'helm-gm-next-file) - (define-key map (kbd "") 'helm-gm-precedent-file) - map)) - - -;;; Internals vars -;; -;; -(defvar helm-rzgrep-cache (make-hash-table :test 'equal)) -(defvar helm-grep-default-function 'helm-grep-init) -(defvar helm-zgrep-recurse-flag nil) -(defvar helm-grep-history nil) -(defvar helm-grep-last-targets nil) -(defvar helm-grep-include-files nil) -(defvar helm-grep-in-recurse nil) -(defvar helm-grep-use-zgrep nil) -(defvar helm-grep-last-default-directory nil) -(defvar helm-grep-default-directory-fn nil - "A function that should return a directory to expand candidate to. -It is intended to use as a let-bound variable, DON'T set this globaly.") -(defvar helm-pdfgrep-targets nil) -(defvar helm-grep-last-cmd-line nil) -(defvar helm-grep-split-line-regexp "^\\([[:lower:][:upper:]]?:?.*?\\):\\([0-9]+\\):\\(.*\\)") - - -;;; Init -;; -;; -(defun helm-grep-prepare-candidates (candidates) - "Prepare filenames and directories CANDIDATES for grep command line." - ;; If one or more candidate is a directory, search in all files - ;; of this candidate (e.g /home/user/directory/*). - ;; If r option is enabled search also in subdidrectories. - ;; We need here to expand wildcards to support crap windows filenames - ;; as grep doesn't accept quoted wildcards (e.g "dir/*.el"). - (setq candidates (if (file-remote-p default-directory) - ;; Grep don't understand tramp filenames - ;; use the local name. - (mapcar #'(lambda (x) - (file-remote-p x 'localname)) - candidates) - candidates)) - (if helm-zgrep-recurse-flag - (mapconcat 'shell-quote-argument candidates " ") - ;; When candidate is a directory, search in all its files. - ;; NOTE that `file-expand-wildcards' will return also - ;; directories, they will be ignored by grep but not - ;; by ack-grep that will grep all files of this directory - ;; without recursing in their subdirs though, see that as a one - ;; level recursion with ack-grep. - ;; So I leave it as it is, considering it is a feature. [1] - (cl-loop for i in candidates append - (cond ((string-match "^git" helm-grep-default-command) - (list i)) - ;; Candidate is a directory and we use recursion or ack. - ((and (file-directory-p i) - (or helm-grep-in-recurse - ;; ack-grep accept directory [1]. - (helm-grep-use-ack-p))) - (list (expand-file-name i))) - ;; Grep doesn't support directory only when not in recurse. - ((file-directory-p i) - (file-expand-wildcards - (concat (file-name-as-directory (expand-file-name i)) "*") t)) - ;; Candidate is a file or wildcard and we use recursion, use the - ;; current directory instead of candidate. - ((and (or (file-exists-p i) (string-match "[*]" i)) - helm-grep-in-recurse) - (list (expand-file-name - (directory-file-name ; Needed for windoze. - (file-name-directory (directory-file-name i)))))) - ;; Else should be one or more file/directory - ;; possibly marked. - ;; When real is a normal filename without wildcard - ;; file-expand-wildcards returns a list of one file. - ;; wildcards should have been already handled by - ;; helm-read-file-name or helm-find-files but do it from - ;; here too in case we are called from elsewhere. - (t (file-expand-wildcards i t))) into all-files ; [1] - finally return - (if (string-match "^git" helm-grep-default-command) - (mapconcat 'identity all-files " ") - (mapconcat 'shell-quote-argument all-files " "))))) - -(defun helm-grep-command (&optional recursive) - (let* ((com (if recursive - helm-grep-default-recurse-command - helm-grep-default-command)) - (exe (and com (car (split-string com " "))))) - (if (and exe (string= exe "git")) "git-grep" exe))) - -(cl-defun helm-grep-use-ack-p (&key where) - (let ((rec-com (helm-grep-command t)) - (norm-com (helm-grep-command))) - (cl-case where - (default (and norm-com - (string= norm-com helm-ack-grep-executable))) - (recursive (and rec-com - (string= rec-com helm-ack-grep-executable))) - (strict (and norm-com rec-com - (string= rec-com helm-ack-grep-executable) - (string= norm-com helm-ack-grep-executable))) - (t (and (not (and norm-com (string= norm-com "git-grep"))) - (or (and norm-com - (string= norm-com helm-ack-grep-executable)) - (and rec-com - (string= rec-com helm-ack-grep-executable)))))))) - -(defun helm-grep--prepare-cmd-line (only-files &optional include zgrep) - (let* ((default-directory (or helm-default-directory - (expand-file-name helm-ff-default-directory))) - (fnargs (helm-grep-prepare-candidates only-files)) - (ignored-files (unless (helm-grep-use-ack-p) - (mapconcat - #'(lambda (x) - (concat "--exclude=" - (shell-quote-argument x))) - grep-find-ignored-files " "))) - (ignored-dirs (unless (helm-grep-use-ack-p) - (mapconcat - ;; Need grep version >=2.5.4 - ;; of Gnuwin32 on windoze. - #'(lambda (x) - (concat "--exclude-dir=" - (shell-quote-argument x))) - grep-find-ignored-directories " "))) - (exclude (unless (helm-grep-use-ack-p) - (if helm-grep-in-recurse - (concat (or include ignored-files) - " " ignored-dirs) - ignored-files))) - (types (and (helm-grep-use-ack-p) - ;; When %e format spec is not specified - ;; in `helm-grep-default-command' - ;; we need to pass an empty string - ;; to types to avoid error. - (or include ""))) - (smartcase (if (helm-grep-use-ack-p) "" - (unless (let ((case-fold-search nil)) - (string-match-p - "[[:upper:]]" helm-pattern)) "i")))) - (format-spec - helm-grep-default-command - (delq nil - (list (unless zgrep - (if types - (cons ?e types) - (cons ?e exclude))) - (cons ?c (or smartcase "")) - (cons ?p (shell-quote-argument helm-pattern)) - (cons ?f fnargs)))))) - -(defun helm-grep-init (cmd-line) - "Start an asynchronous grep process with CMD-LINE using ZGREP if non--nil." - (let* ((zgrep (string-match "\\`zgrep" cmd-line)) - ;; Use pipe only with grep, zgrep or git-grep. - (process-connection-type (and (not zgrep) (helm-grep-use-ack-p))) - (tramp-verbose helm-tramp-verbose)) - ;; Start grep process. - (helm-log "Starting Grep process in directory `%s'" default-directory) - (helm-log "Command line used was:\n\n%s" - (concat ">>> " (propertize cmd-line 'face 'helm-grep-cmd-line) "\n\n")) - (prog1 ; This function should return the process first. - (start-file-process-shell-command - "grep" helm-buffer cmd-line) - ;; Init sentinel. - (set-process-sentinel - (get-buffer-process helm-buffer) - #'(lambda (process event) - (let ((noresult (= (process-exit-status process) 1))) - (unless noresult - (helm-process-deferred-sentinel-hook - process event helm-ff-default-directory)) - (cond ((and noresult - ;; [FIXME] This is a workaround for zgrep - ;; that exit with code 1 - ;; after a certain amount of results. - (not (with-helm-buffer helm-grep-use-zgrep))) - (with-current-buffer helm-buffer - (insert (concat "* Exit with code 1, no result found," - " Command line was:\n\n " - (propertize helm-grep-last-cmd-line - 'face 'helm-grep-cmd-line))) - (setq mode-line-format - '(" " mode-line-buffer-identification " " - (:eval (format "L%s" (helm-candidate-number-at-point))) " " - (:eval (propertize - (format - "[%s process finished - (no results)] " - (if helm-grep-use-zgrep - "Zgrep" - (capitalize - (if helm-grep-in-recurse - (helm-grep-command t) - (helm-grep-command))))) - 'face 'helm-grep-finish)))))) - ((string= event "finished\n") - (with-helm-window - (setq mode-line-format - '(" " mode-line-buffer-identification " " - (:eval (format "L%s" (helm-candidate-number-at-point))) " " - (:eval (propertize - (format - "[%s process finished - (%s results)] " - (if helm-grep-use-zgrep - "Zgrep" - (capitalize - (if helm-grep-in-recurse - (helm-grep-command t) - (helm-grep-command)))) - (max (1- (count-lines - (point-min) - (point-max))) - 0)) - 'face 'helm-grep-finish)))) - (force-mode-line-update))) - ;; Catch error output in log. - (t (helm-log - "Error: %s %s" - (if helm-grep-use-zgrep "Zgrep" "Grep") - (replace-regexp-in-string "\n" "" event)))))))))) - -(defun helm-grep-collect-candidates () - (let ((cmd-line (helm-grep--prepare-cmd-line - helm-grep-last-targets - helm-grep-include-files - helm-grep-use-zgrep))) - (set (make-local-variable 'helm-grep-last-cmd-line) cmd-line) - (funcall helm-grep-default-function cmd-line))) - - -;;; Actions -;; -;; -(defun helm-grep-action (candidate &optional where mark) - "Define a default action for `helm-do-grep' on CANDIDATE. -WHERE can be one of other-window, elscreen, other-frame." - (let* ((split (helm-grep-split-line candidate)) - (lineno (string-to-number (nth 1 split))) - (loc-fname (or (with-current-buffer - (if (eq major-mode 'helm-grep-mode) - (current-buffer) - helm-buffer) - (get-text-property (point-at-bol) 'help-echo)) - (car split))) - (tramp-method (file-remote-p (or helm-ff-default-directory - default-directory) 'method)) - (tramp-host (file-remote-p (or helm-ff-default-directory - default-directory) 'host)) - (tramp-prefix (concat "/" tramp-method ":" tramp-host ":")) - (fname (if tramp-host - (concat tramp-prefix loc-fname) loc-fname))) - (cl-case where - (other-window (find-file-other-window fname)) - (elscreen (helm-elscreen-find-file fname)) - (other-frame (find-file-other-frame fname)) - (grep (helm-grep-save-results-1)) - (pdf (if helm-pdfgrep-default-read-command - (helm-pdfgrep-action-1 split lineno (car split)) - (find-file (car split)) (doc-view-goto-page lineno))) - (t (find-file fname))) - (unless (or (eq where 'grep) (eq where 'pdf)) - (helm-goto-line lineno)) - (when mark - (set-marker (mark-marker) (point)) - (push-mark (point) 'nomsg)) - ;; Save history - (unless (or helm-in-persistent-action - (eq major-mode 'helm-grep-mode) - (string= helm-pattern "")) - (setq helm-grep-history - (cons helm-pattern - (delete helm-pattern helm-grep-history))) - (when (> (length helm-grep-history) - helm-grep-max-length-history) - (setq helm-grep-history - (delete (car (last helm-grep-history)) - helm-grep-history)))))) - -(defun helm-grep-persistent-action (candidate) - "Persistent action for `helm-do-grep'. -With a prefix arg record CANDIDATE in `mark-ring'." - (if current-prefix-arg - (helm-grep-action candidate nil 'mark) - (helm-grep-action candidate)) - (helm-highlight-current-line)) - -(defun helm-grep-other-window (candidate) - "Jump to result in other window from helm grep." - (helm-grep-action candidate 'other-window)) - -(defun helm-grep-other-frame (candidate) - "Jump to result in other frame from helm grep." - (helm-grep-action candidate 'other-frame)) - -(defun helm-grep-jump-elscreen (candidate) - "Jump to result in elscreen from helm grep." - (helm-grep-action candidate 'elscreen)) - -(defun helm-goto-next-or-prec-file (n &optional type) - "Go to next or precedent candidate file in helm grep/etags buffers. -If N is positive go forward otherwise go backward." - (let* ((allow-mode (or (eq major-mode 'helm-grep-mode) - (eq major-mode 'helm-moccur-mode))) - (sel (if allow-mode - (buffer-substring (point-at-bol) (point-at-eol)) - (helm-get-selection nil t))) - (current-line-list (if (eq type 'etags) - (split-string sel ": +" t) - (helm-grep-split-line sel))) - (current-fname (nth 0 current-line-list)) - (bob-or-eof (if (eq n 1) 'eobp 'bobp)) - (mark-maybe #'(lambda () - (if allow-mode - (ignore) - (helm-mark-current-line))))) - (catch 'break - (while (not (funcall bob-or-eof)) - (forward-line n) ; Go forward or backward depending of n value. - ;; Exit when current-fname is not matched or in `helm-grep-mode' - ;; the line is not a grep line i.e 'fname:num:tag'. - (setq sel (buffer-substring (point-at-bol) (point-at-eol))) - (unless (or (string= current-fname - (car (if (eq type 'etags) - (split-string sel ": +" t) - (helm-grep-split-line sel)))) - (and (eq major-mode 'helm-grep-mode) - (not (get-text-property (point-at-bol) 'help-echo)))) - (funcall mark-maybe) - (throw 'break nil)))) - (cond ((and (> n 0) (eobp)) - (re-search-backward ".") - (forward-line 0) - (funcall mark-maybe)) - ((and (< n 0) (bobp)) - (helm-aif (next-single-property-change (point-at-bol) 'help-echo) - (goto-char it) - (forward-line 1)) - (funcall mark-maybe))))) - -;;;###autoload -(defun helm-goto-precedent-file () - "Go to precedent file in helm grep/etags buffers." - (interactive) - (let ((etagp (when (string= (assoc-default - 'name (helm-get-current-source)) "Etags") - 'etags))) - (with-helm-window - (helm-goto-next-or-prec-file -1 etagp)))) - -;;;###autoload -(defun helm-goto-next-file () - "Go to precedent file in helm grep/etags buffers." - (interactive) - (let ((etagp (when (string= (assoc-default - 'name (helm-get-current-source)) "Etags") - 'etags))) - (with-helm-window - (helm-goto-next-or-prec-file 1 etagp)))) - -(defun helm-grep-run-default-action () - "Run grep default action from `helm-do-grep-1'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-grep-action))) - -(defun helm-grep-run-other-window-action () - "Run grep goto other window action from `helm-do-grep-1'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-grep-other-window))) - -(defun helm-grep-run-other-frame-action () - "Run grep goto other frame action from `helm-do-grep-1'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-grep-other-frame))) - -;;;###autoload -(defun helm-grep-run-save-buffer () - "Run grep save results action from `helm-do-grep-1'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-grep-save-results))) - - -;;; helm-grep-mode -;; -;; -(defun helm-grep-save-results (candidate) - (helm-grep-action candidate 'grep)) - -(defun helm-grep-save-results-1 () - "Save helm grep result in a `helm-grep-mode' buffer." - (let ((buf "*hgrep*") - new-buf) - (when (get-buffer buf) - (setq new-buf (helm-read-string "GrepBufferName: " buf)) - (cl-loop for b in (helm-buffer-list) - when (and (string= new-buf b) - (not (y-or-n-p - (format "Buffer `%s' already exists overwrite? " - new-buf)))) - do (setq new-buf (helm-read-string "GrepBufferName: " "*hgrep "))) - (setq buf new-buf)) - (with-current-buffer (get-buffer-create buf) - (setq buffer-read-only t) - (let ((inhibit-read-only t)) - (erase-buffer) - (insert "-*- mode: helm-grep -*-\n\n" - (format "Grep Results for `%s':\n\n" helm-pattern)) - (save-excursion - (insert (with-current-buffer helm-buffer - (goto-char (point-min)) (forward-line 1) - (buffer-substring (point) (point-max)))))) - (helm-grep-mode) (pop-to-buffer buf)) - (message "Helm Grep Results saved in `%s' buffer" buf))) - -;;;###autoload -(define-derived-mode helm-grep-mode - special-mode "helm-grep" - "Major mode to provide actions in helm grep saved buffer. - -Special commands: -\\{helm-grep-mode-map}" - (set (make-local-variable 'helm-grep-last-cmd-line) - (with-helm-buffer helm-grep-last-cmd-line)) - (set (make-local-variable 'revert-buffer-function) - #'helm-grep-mode--revert-buffer-function)) - -(defun helm-grep-mode--revert-buffer-function (&optional _ignore-auto _noconfirm) - (goto-char (point-min)) - (re-search-forward "^Grep Results for" nil t) - (forward-line 0) - (when (re-search-forward "^$" nil t) - (forward-line 1)) - (let ((inhibit-read-only t)) - (delete-region (point) (point-max))) - (message "Reverting buffer...") - (set-process-sentinel - (start-file-process-shell-command - "hgrep" (generate-new-buffer "*hgrep revert*") helm-grep-last-cmd-line) - (lambda (process event) - (when (string= event "finished\n") - (with-current-buffer (current-buffer) - (let ((inhibit-read-only t)) - (save-excursion - (cl-loop for line in (with-current-buffer (process-buffer process) - (prog1 (split-string (buffer-string) "\n") - (kill-buffer))) - when (string-match helm-grep-split-line-regexp line) - do (insert (propertize - (car (helm-grep-filter-one-by-one line)) - ;; needed for wgrep. - 'helm-realvalue line) - "\n")))) - (message "Reverting buffer done")))))) - -;;;###autoload -(defun helm-gm-next-file () - (interactive) - (helm-goto-next-or-prec-file 1)) - -;;;###autoload -(defun helm-gm-precedent-file () - (interactive) - (helm-goto-next-or-prec-file -1)) - -;;;###autoload -(defun helm-grep-mode-jump () - (interactive) - (let ((candidate (buffer-substring (point-at-bol) (point-at-eol)))) - (condition-case nil - (progn (helm-grep-action candidate) (delete-other-windows)) - (error nil)))) - -(defun helm-grep-mode-jump-other-window-1 (arg) - (let ((candidate (buffer-substring (point-at-bol) (point-at-eol)))) - (condition-case nil - (progn - (save-selected-window - (helm-grep-action candidate 'other-window) - (recenter)) - (forward-line arg)) - (error nil)))) - -;;;###autoload -(defun helm-grep-mode-jump-other-window-forward () - (interactive) - (helm-grep-mode-jump-other-window-1 1)) - -;;;###autoload -(defun helm-grep-mode-jump-other-window-backward () - (interactive) - (helm-grep-mode-jump-other-window-1 -1)) - -;;;###autoload -(defun helm-grep-mode-jump-other-window () - (interactive) - (let ((candidate (buffer-substring (point-at-bol) (point-at-eol)))) - (condition-case nil - (helm-grep-action candidate 'other-window) - (error nil)))) - - -;;; ack-grep types -;; -;; -(defun helm-grep-hack-types () - "Return a list of known ack-grep types." - (with-temp-buffer - ;; "--help-types" works with both 1.96 and 2.1+, while - ;; "--help types" works only with 1.96 Issue #422 - (call-process helm-ack-grep-executable nil t nil "--help-types") - (goto-char (point-min)) - (cl-loop while (re-search-forward - "^ *--\\(\\[no\\]\\)\\([^. ]+\\) *\\(.*\\)" nil t) - collect (cons (concat (match-string 2) - " [" (match-string 3) "]") - (match-string 2)) - collect (cons (concat "no" (match-string 2) - " [" (match-string 3) "]") - (concat "no" (match-string 2)))))) - -(defun helm-grep-ack-types-transformer (candidates _source) - (cl-loop for i in candidates - if (stringp i) - collect (rassoc i helm-grep-ack-types-cache) - else - collect i)) - -(defvar helm-grep-ack-types-cache nil) -(defun helm-grep-read-ack-type () - "Select types for the '--type' argument of ack-grep." - (require 'helm-mode) - (require 'helm-adaptive) - (setq helm-grep-ack-types-cache (helm-grep-hack-types)) - (let ((types (helm-comp-read - "Types: " helm-grep-ack-types-cache - :name "*Ack-grep types*" - :marked-candidates t - :must-match t - :fc-transformer '(helm-adaptive-sort - helm-grep-ack-types-transformer) - :buffer "*helm ack-types*"))) - (mapconcat #'(lambda (type) (concat "--type=" type)) types " "))) - - -;;; grep extensions -;; -;; -(defun helm-grep-guess-extensions (files) - "Try to guess file extensions in FILES list when using grep recurse. -These extensions will be added to command line with --include arg of grep." - (cl-loop with ext-list = (list helm-grep-preferred-ext "*") - with lst = (if (file-directory-p (car files)) - (directory-files - (car files) nil - directory-files-no-dot-files-regexp) - files) - for i in lst - for ext = (file-name-extension i 'dot) - for glob = (and ext (not (string= ext "")) - (concat "*" ext)) - unless (or (not glob) - (and glob-list (member glob glob-list)) - (and glob-list (member glob ext-list)) - (and glob-list (member glob grep-find-ignored-files))) - collect glob into glob-list - finally return (delq nil (append ext-list glob-list)))) - -(defun helm-grep-get-file-extensions (files) - "Try to return a list of file extensions to pass to '--include' arg of grep." - (let* ((all-exts (helm-grep-guess-extensions - (mapcar 'expand-file-name files))) - (extensions (helm-comp-read "Search Only in: " all-exts - :marked-candidates t - :fc-transformer 'helm-adaptive-sort - :buffer "*helm grep exts*" - :name "*helm grep extensions*"))) - (when (listp extensions) ; Otherwise it is empty string returned by C-RET. - ;; If extensions is a list of one string containing spaces, - ;; assume user entered more than one glob separated by space(s) and - ;; split this string to pass it later to mapconcat. - ;; e.g '("*.el *.py") - (cl-loop for i in extensions - append (split-string-and-unquote i " "))))) - - -;;; Set up source -;; -;; -(defvar helm-source-grep nil) -(defun helm-do-grep-1 (targets &optional recurse zgrep exts) - "Launch grep on a list of TARGETS files. -When RECURSE is given use -r option of grep and prompt user -to set the --include args of grep. -You can give more than one arg separated by space. -e.g *.el *.py *.tex. -If you are using ack-grep, you will be prompted for --type -instead. -If prompt is empty '--exclude `grep-find-ignored-files' is used instead. -ZGREP when non--nil use zgrep instead, without prompting for a choice -in recurse, search being made on `helm-zgrep-file-extension-regexp'." - (when (and (helm-grep-use-ack-p) - helm-ff-default-directory - (file-remote-p helm-ff-default-directory)) - (error "Error: Remote operation not supported with ack-grep.")) - (let* ((exts (and recurse - ;; [FIXME] I could handle this from helm-walk-directory. - (not zgrep) ; zgrep doesn't handle -r opt. - (not (helm-grep-use-ack-p :where 'recursive)) - (or exts (helm-grep-get-file-extensions targets)))) - (include-files (and exts - (mapconcat #'(lambda (x) - (concat "--include=" - (shell-quote-argument x))) - (if (> (length exts) 1) - (remove "*" exts) - exts) " "))) - (types (and (not include-files) - (not zgrep) - recurse - (helm-grep-use-ack-p :where 'recursive) - ;; When %e format spec is not specified - ;; ignore types and do not prompt for choice. - (string-match "%e" helm-grep-default-command) - (helm-grep-read-ack-type))) - (follow (and helm-follow-mode-persistent - (assoc-default 'follow helm-source-grep)))) - ;; When called as action from an other source e.g *-find-files - ;; we have to kill action buffer. - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - ;; If `helm-find-files' haven't already started, - ;; give a default value to `helm-ff-default-directory'. - (unless helm-ff-default-directory - (setq helm-ff-default-directory default-directory)) - ;; We need to store these vars locally - ;; to pass infos later to `helm-resume'. - (helm-set-local-variable 'helm-zgrep-recurse-flag (and recurse zgrep) - 'helm-grep-last-targets targets - 'helm-grep-include-files (or include-files types) - 'helm-grep-in-recurse recurse - 'helm-grep-use-zgrep zgrep - 'helm-grep-last-default-directory helm-ff-default-directory - 'helm-grep-default-command - (cond (zgrep helm-default-zgrep-command) - (recurse helm-grep-default-recurse-command) - ;; When resuming the local value of - ;; `helm-grep-default-command' is used, only git-grep - ;; should need this. - (t helm-grep-default-command))) - ;; Setup the source. - (setq helm-source-grep - (helm-build-async-source - (if zgrep "Zgrep" (capitalize (if recurse - (helm-grep-command t) - (helm-grep-command)))) - :header-name (lambda (name) - (concat name "(C-c ? Help)")) - :candidates-process 'helm-grep-collect-candidates - :filter-one-by-one 'helm-grep-filter-one-by-one - :candidate-number-limit 9999 - :nohighlight t - :mode-line helm-grep-mode-line-string - ;; We need to specify keymap here and as :keymap arg [1] - ;; to make it available in further resuming. - :keymap helm-grep-map - :history 'helm-grep-history - :action (helm-make-actions - "Find File" 'helm-grep-action - "Find file other frame" 'helm-grep-other-frame - (lambda () (and (locate-library "elscreen") - "Find file in Elscreen")) - 'helm-grep-jump-elscreen - "Save results in grep buffer" 'helm-grep-save-results - "Find file other window" 'helm-grep-other-window) - :persistent-action 'helm-grep-persistent-action - :persistent-help "Jump to line (`C-u' Record in mark ring)" - :requires-pattern 2 - :follow follow)) - (helm - :sources 'helm-source-grep - :buffer (format "*helm %s*" (if zgrep "zgrep" (helm-grep-command recurse))) - :default-directory helm-ff-default-directory - :keymap helm-grep-map ; [1] - :history 'helm-grep-history - :truncate-lines t))) - - - -;;; zgrep -;; -;; -(defun helm-ff-zgrep-1 (flist recursive) - (unwind-protect - (let* ((def-dir (or helm-ff-default-directory - default-directory)) - (only (if recursive - (or (gethash def-dir helm-rzgrep-cache) - (puthash - def-dir - (helm-walk-directory - def-dir - :directories nil - :path 'full - :match helm-zgrep-file-extension-regexp) - helm-rzgrep-cache)) - flist))) - (helm-do-grep-1 only recursive 'zgrep)) - (setq helm-zgrep-recurse-flag nil))) - - -;;; transformers -;; -;; -(defun helm-grep-split-line (line) - "Split a grep output line." - ;; The output of grep may send a truncated line in this chunk, - ;; so don't split until grep line is valid, that is - ;; once the second part of the line comes with next chunk - ;; send by process. - (when (string-match helm-grep-split-line-regexp line) - ;; Don't use split-string because buffer/file name or string - ;; may contain a ":". - (cl-loop for n from 1 to 3 collect (match-string n line)))) - -(defun helm-grep--filter-candidate-1 (candidate &optional dir) - (let* ((root (or dir (and helm-grep-default-directory-fn - (funcall helm-grep-default-directory-fn)))) - (split (helm-grep-split-line candidate)) - (fname (if (and root split) - (expand-file-name (car split) root) - (car-safe split))) - (lineno (nth 1 split)) - (str (nth 2 split))) - (when (and fname lineno str) - (cons (concat (propertize (file-name-nondirectory fname) - 'face 'helm-grep-file - 'help-echo fname) ":" - (propertize lineno 'face 'helm-grep-lineno) ":" - (helm-grep-highlight-match str)) - candidate)))) - -(defun helm-grep-filter-one-by-one (candidate) - "`filter-one-by-one' transformer function for `helm-do-grep'." - (let ((helm-grep-default-directory-fn - (or helm-grep-default-directory-fn - (lambda () (or helm-ff-default-directory - helm-default-directory - default-directory))))) - (helm-grep--filter-candidate-1 candidate))) - -(defun helm-grep-highlight-match (str &optional multi-match) - "Highlight in string STR all occurences matching `helm-pattern'." - (require 'helm-match-plugin) - (let (beg end) - (condition-case nil - (with-temp-buffer - (insert str) - (goto-char (point-min)) - (cl-loop for reg in (if multi-match - (cl-loop for r in (helm-mp-split-pattern - helm-pattern) - unless (string-match "\\`!" r) - collect r) - (list helm-pattern)) - do - (while (and (re-search-forward reg nil t) - (> (- (setq end (match-end 0)) - (setq beg (match-beginning 0))) 0)) - (add-text-properties beg end '(face helm-grep-match))) - do (goto-char (point-min))) - (buffer-string)) - (error nil)))) - - -;;; Grep from buffer list -;; -;; -(defun helm-grep-buffers-1 (candidate &optional zgrep) - "Run grep on all file--buffers or CANDIDATE if it is a file--buffer. -If one of selected buffers is not a file--buffer, -it is ignored and grep will run on all others file--buffers. -If only one candidate is selected and it is not a file--buffer, -switch to this buffer and run `helm-occur'. -If a prefix arg is given run grep on all buffers ignoring non--file-buffers." - (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg)) - (helm-ff-default-directory - (if (and helm-ff-default-directory - (file-remote-p helm-ff-default-directory)) - default-directory - helm-ff-default-directory)) - (cands (if prefarg - (buffer-list) - (helm-marked-candidates))) - (win-conf (current-window-configuration)) - ;; Non--fname and remote buffers are ignored. - (bufs (cl-loop for buf in cands - for fname = (buffer-file-name (get-buffer buf)) - when (and fname (not (file-remote-p fname))) - collect (expand-file-name fname)))) - (if bufs - (if zgrep - (helm-do-grep-1 bufs nil 'zgrep) - (helm-do-grep-1 bufs)) - ;; bufs is empty, thats mean we have only CANDIDATE - ;; and it is not a buffer-filename, fallback to occur. - (helm-switch-to-buffer candidate) - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - (helm-occur) - (when (eq helm-exit-status 1) - (set-window-configuration win-conf))))) - -(defun helm-grep-buffers (candidate) - "Action to grep buffers." - (helm-grep-buffers-1 candidate)) - -(defun helm-zgrep-buffers (candidate) - "Action to zgrep buffers." - (helm-grep-buffers-1 candidate 'zgrep)) - - -;;; Helm interface for pdfgrep -;; pdfgrep program -;; and a pdf-reader (e.g xpdf) are needed. -;; -(defvar helm-pdfgrep-default-function 'helm-pdfgrep-init) -(defun helm-pdfgrep-init (only-files) - "Start an asynchronous pdfgrep process in ONLY-FILES list." - (let* ((default-directory (or helm-ff-default-directory - default-directory)) - (fnargs (helm-grep-prepare-candidates - (if (file-remote-p default-directory) - (mapcar #'(lambda (x) - (file-remote-p x 'localname)) - only-files) - only-files))) - (cmd-line (format helm-pdfgrep-default-command - helm-pattern - fnargs)) - process-connection-type) - ;; Start pdf grep process. - (helm-log "Starting Pdf Grep process in directory `%s'" default-directory) - (helm-log "Command line used was:\n\n%s" - (concat ">>> " (propertize cmd-line 'face 'helm-grep-cmd-line) "\n\n")) - (prog1 - (start-file-process-shell-command - "pdfgrep" helm-buffer cmd-line) - (message nil) - (set-process-sentinel - (get-buffer-process helm-buffer) - #'(lambda (_process event) - (if (string= event "finished\n") - (with-helm-window - (setq mode-line-format - '(" " mode-line-buffer-identification " " - (:eval (format "L%s" (helm-candidate-number-at-point))) " " - (:eval (propertize - (format "[Pdfgrep Process Finish - %s result(s)] " - (max (1- (count-lines - (point-min) (point-max))) 0)) - 'face 'helm-grep-finish)))) - (force-mode-line-update)) - (helm-log "Error: Pdf grep %s" - (replace-regexp-in-string "\n" "" event)))))))) - -(defun helm-do-pdfgrep-1 (only) - "Launch pdfgrep with a list of ONLY files." - (unless (executable-find "pdfgrep") - (error "Error: No such program `pdfgrep'.")) - (let* (helm-grep-in-recurse) ; recursion is never used in pdfgrep. - ;; When called as action from an other source e.g *-find-files - ;; we have to kill action buffer. - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - (setq helm-pdfgrep-targets only) - (helm - :sources - `(((name . "PdfGrep") - (init . (lambda () - ;; If `helm-find-files' haven't already started, - ;; give a default value to `helm-ff-default-directory'. - (setq helm-ff-default-directory (or helm-ff-default-directory - default-directory)))) - (candidates-process - . (lambda () - (funcall helm-pdfgrep-default-function helm-pdfgrep-targets))) - (filter-one-by-one . helm-grep-filter-one-by-one) - (candidate-number-limit . 9999) - (no-matchplugin) - (nohighlight) - (history . ,'helm-grep-history) - (keymap . ,helm-pdfgrep-map) - (mode-line . helm-pdfgrep-mode-line-string) - (action . helm-pdfgrep-action) - (persistent-help . "Jump to PDF Page") - (requires-pattern . 2))) - :buffer "*helm pdfgrep*" - :history 'helm-grep-history))) - -(defun helm-pdfgrep-action (candidate) - (helm-grep-action candidate 'pdf)) - -(defun helm-pdfgrep-action-1 (_split pageno fname) - (save-selected-window - (start-file-process-shell-command - "pdf-reader" nil - (format-spec helm-pdfgrep-default-read-command - (list (cons ?f fname) (cons ?p pageno)))))) - -;;;###autoload -(defun helm-do-grep () - "Preconfigured helm for grep. -Contrarily to Emacs `grep', no default directory is given, but -the full path of candidates in ONLY. -That allow to grep different files not only in `default-directory' but anywhere -by marking them (C-). If one or more directory is selected -grep will search in all files of these directories. -You can also use wildcard in the base name of candidate. -If a prefix arg is given use the -r option of grep (recurse). -The prefix arg can be passed before or after start file selection. -See also `helm-do-grep-1'." - (interactive) - (require 'helm-mode) - (let* ((preselection (or (dired-get-filename nil t) - (buffer-file-name (current-buffer)))) - (only (helm-read-file-name - "Search in file(s): " - :marked-candidates t - :preselect (and helm-do-grep-preselect-candidate - (if helm-ff-transformer-show-only-basename - (helm-basename preselection) - preselection)))) - (prefarg (or current-prefix-arg helm-current-prefix-arg))) - (helm-do-grep-1 only prefarg))) - -;;;###autoload -(defun helm-do-zgrep () - "Preconfigured helm for zgrep." - (interactive) - (require 'helm-mode) - (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg)) - (preselection (or (dired-get-filename nil t) - (buffer-file-name (current-buffer)))) - (ls (helm-read-file-name - "Search in file(s): " - :marked-candidates t - :preselect (and helm-do-grep-preselect-candidate - (if helm-ff-transformer-show-only-basename - (helm-basename preselection) - preselection))))) - (helm-ff-zgrep-1 ls prefarg))) - -;;;###autoload -(defun helm-do-pdfgrep () - "Preconfigured helm for pdfgrep." - (interactive) - (require 'helm-mode) - (let* ((preselection (or (dired-get-filename nil t) - (buffer-file-name (current-buffer)))) - (only (helm-read-file-name - "Search in file(s): " - :marked-candidates t - :test #'(lambda (file) - (or (string= (file-name-extension file) "pdf") - (string= (file-name-extension file) "PDF") - (file-directory-p file))) - :preselect (and helm-do-grep-preselect-candidate - (if helm-ff-transformer-show-only-basename - (helm-basename preselection) - preselection)))) - (helm-grep-default-function 'helm-pdfgrep-init)) - (helm-do-pdfgrep-1 only))) - - -(provide 'helm-grep) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-grep.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-help.el b/emacs.d/elpa/helm-20141016.2217/helm-help.el deleted file mode 100644 index b559e9b..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-help.el +++ /dev/null @@ -1,1479 +0,0 @@ -;;; helm-help.el --- Help messages for Helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'helm) - -(defgroup helm-help nil - "Embedded help for `helm'." - :group 'helm) - -(defface helm-helper - '((t :inherit helm-header)) - "Face for helm help string in minibuffer." - :group 'helm-help) - - -;;; Global help message - Used by `helm-help' -;; -;; -(defvar helm-help-message - (lambda () - (concat - "\\" - "`helm' is an Emacs incremental completion and selection narrowing framework. - -Narrow the list by typing some pattern, -Multiple patterns are allowed by splitting by space. -Select with natural Emacs operations, choose with RET. - -== Help == -C-h m : Run this generic help for helm. -C-c ? : Run specific helm help for current source. - -== Basic Operations == -C-p, Up: Previous Line -C-n, Down : Next Line -M-v, PageUp : Previous Page -C-v, PageDown : Next Page -Enter : Execute first (default) action / Select -M-< : First Line -M-> : Last Line -M-PageUp, C-M-S-v, C-M-y : Previous Page (other-window) -M-PageDown, C-M-v : Next Page (other-window) - -Tab, C-i : Show action list -Left : Previous Source -Right, C-o : Next Source -C-k : Delete pattern (with prefix arg delete from point to end) -C-j or C-z: Persistent Action (Execute action with helm session kept) - -== Shortcuts For nth Action == - -f1-12: Execute nth 1 to 12 Action(s). - -== Visible Marks == -Visible marks store candidate. Some actions uses marked candidates. - -\\[helm-toggle-visible-mark] : Toggle Visible Mark -\\[helm-prev-visible-mark] : Previous Mark -\\[helm-next-visible-mark] : Next Mark - -== Miscellaneous Commands == -\\[helm-toggle-resplit-window] : Toggle vertical/horizontal split helm window. -\\[helm-quit-and-find-file] : Drop into `find-file'. -\\[helm-delete-current-selection] : Delete selected item (visually). -\\[helm-kill-selection-and-quit] : Kill display value of candidate and quit (with prefix arg kill the real value). -\\[helm-yank-selection] : Yank selection into pattern. -\\[helm-follow-mode] : Toggle automatical execution of persistent action. -\\[helm-follow-action-forward] : Run persistent action and goto next line. -\\[helm-follow-action-backward] : Run persistent action and goto previous line. -\\[helm-force-update] : Recalculate and redisplay candidates. - -== Global Commands == -\\\\[helm-resume] revives last `helm' session. -It is very useful, so you should bind any key.")) - "Detailed help message string for `helm'. -It also accepts function or variable symbol.") - -(defun helm-help-internal (bufname insert-content-fn) - "Show long message during `helm' session in BUFNAME. -INSERT-CONTENT-FN is the function that insert -text to be displayed in BUFNAME." - (let ((winconf (current-frame-configuration))) - (unwind-protect - (progn - (setq helm-suspend-update-flag t) - (switch-to-buffer (get-buffer-create bufname)) - (delete-other-windows) - (erase-buffer) - (funcall insert-content-fn) - (setq cursor-type nil) - (goto-char 1) - (helm-help-event-loop)) - (setq helm-suspend-update-flag nil) - (set-frame-configuration winconf)))) - -(defun helm-help-event-loop () - (let ((prompt (propertize - "[SPC,C-v,down:NextPage b,M-v,up:PrevPage C-s/r:Isearch Other:Exit]" - 'face 'helm-helper)) - (scroll-error-top-bottom t)) - (condition-case _err - (cl-loop for event = (read-key prompt) do - (cl-case event - ((?\C-v ? down) (scroll-up-command helm-scroll-amount)) - ((?\M-v ?b up) (scroll-down-command helm-scroll-amount)) - ((?\C-s) (isearch-forward)) - ((?\C-r) (isearch-backward)) - (t (cl-return)))) - (beginning-of-buffer (message "Beginning of buffer")) - (end-of-buffer (message "End of Buffer"))))) - -;;;###autoload -(defun helm-help () - "Help of `helm'." - (interactive) - (save-selected-window - (helm-help-internal - " *Helm Help*" - (lambda () - (insert (substitute-command-keys - (helm-interpret-value (or (assoc-default - 'help-message - (helm-get-current-source)) - helm-help-message)))))))) - -;;; `helm-buffer-list' help -;; -;; -(defvar helm-buffer-help-message - "== Helm Buffer == -\nTips: - -Completion: - -- Major-mode: - -You can enter a partial name of major-mode (e.g lisp, sh) to narrow down buffers. -To specify the major-mode, prefix it with \"*\" e.g \"*lisp\". -If you want to match all buffers but the ones with a specific major-mode (negation), -prefix the major-mode with \"!\" e.g \"*!lisp\". -If you want to specify more than one major-mode, separate them with \",\", -e.g \"*!lisp,!sh,!fun\" will list all buffers but the ones in lisp-mode, sh-mode and -fundamental-mode. - -Enter then a space and a pattern to narrow down to buffers matching this pattern. - -- Search inside buffers: - -If you enter a space and a pattern prefixed by \"@\" helm will search for text matching -this pattern INSIDE the buffer (i.e not in the name of buffer). -NOTE that if you enter your pattern prefixed with \"@\" but escaped, helm will search a buffer -matching \"@pattern\" but will not search inside. - -- Search by directory name: - -If you prefix the beginning of pattern with \"/\" the match will occur on directory name -of buffer, it is interesting to narrow down to one directory for example, subsequent string -entered after a space will match on buffer-name only. -Note that negation is not supported for matching on buffer-file-name. -You can't cumulate both major-mode matching AND directory matching, choose one or the other. - -- Fuzzy matching: - -Note that if `helm-buffers-fuzzy-matching' is non--nil you will have -fuzzy matching on buffer names (not on directory name matching and major-mode though). -A pattern starting with \"^\" will disable fuzzy matching and will match by exact regexp. - -- Examples: - -if I enter in pattern prompt: -\"*lisp ^helm @moc\" -helm will narrow down the list by selecting only buffers that are in lisp mode, start by helm -and match \"moc\" in their contents. - -if I enter in pattern prompt: -\"*lisp ^helm moc\" -Notice there is no \"@\" this time -helm will look for lisp mode buffers starting by \"helm\" and have \"moc\" in their name. - -if I enter in pattern prompt: -\"*!lisp !helm\" -helm will narrow down to buffers that are not in \"lisp\" mode and that do not match \"helm\" - -if I enter in pattern prompt: -/helm/ w3 -helm will narrow down to buffers that are in any \"helm\" subdirectory and matching w3. - - -- Creating buffers - -When creating a new buffer use \\[universal-argument] to choose a mode for your buffer in a list. -This list is customizable, see `helm-buffers-favorite-modes'. - -- Killing buffers - -You have a command to kill buffer(s) and quit emacs and a command to kill buffers one by one -\(no marked\) without quitting helm. -You can run this persistent kill buffer command either with the regular -`helm-execute-persistent-action' called with a prefix arg (C-u C-j) or with its specific command -`helm-buffer-run-kill-persistent' see binding below. - -- Meaning of colors and prefixes for buffers: - -Remote buffers are prefixed with '@'. -Red => Buffer have its file modified on disk by an external process. -Indianred2 => Buffer exists but its file have been deleted. -Orange => Buffer is modified and its file not saved to disk. -Italic => A non--file buffer. - -\nSpecific commands for `helm-buffers-list': -\\ -\\[helm-buffer-run-zgrep]\t\t->Grep Buffer(s) works as zgrep too (C-u grep all buffers but non--file buffers). -\\[helm-buffers-run-multi-occur]\t\t->Multi Occur buffer or marked buffers. (C-u toggle force searching current-buffer). -\\[helm-buffer-switch-other-window]\t\t->Switch other window. -\\[helm-buffer-switch-other-frame]\t\t->Switch other frame. -\\[helm-buffer-run-query-replace-regexp]\t\t->Query replace regexp in marked buffers. -\\[helm-buffer-run-query-replace]\t\t->Query replace in marked buffers. -\\[helm-buffer-run-ediff]\t\t->Ediff current buffer with candidate. If two marked buffers ediff those buffers. -\\[helm-buffer-run-ediff-merge]\t\t->Ediff merge current buffer with candidate. If two marked buffers ediff merge those buffers. -\\[helm-buffer-diff-persistent]\t\t->Toggle Diff buffer with saved file without quitting. -\\[helm-buffer-revert-persistent]\t\t->Revert buffer without quitting. -\\[helm-buffer-save-persistent]\t\t->Save buffer without quitting. -\\[helm-buffer-run-kill-buffers]\t\t->Delete marked buffers and quit. -\\[helm-buffer-run-kill-persistent]\t\t->Delete buffer without quitting helm. -\\[helm-toggle-all-marks]\t\t->Toggle all marks. -\\[helm-mark-all]\t\t->Mark all. -\\[helm-toggle-buffers-details]\t\t->Toggle details. -\\[helm-buffers-toggle-show-hidden-buffers]\t\t->Show hidden buffers. -\\[helm-buffers-mark-similar-buffers]\t\t->Mark all buffers with same type (color) than current. -\\[helm-buffer-help]\t\t->Display this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-buffer-help () - "Help command for helm buffers." - (interactive) - (let ((helm-help-message helm-buffer-help-message)) - (helm-help))) - -;;; Find files help (`helm-find-files') -;; -;; -(defvar helm-ff-help-message - "== Helm Find Files == -\nTips: -\n- Enter `~/' at end of pattern to quickly reach home directory. - -- Enter `/' at end of pattern to quickly reach root of your file system. - -- Enter `./' at end of pattern to quickly reach `default-directory' (initial start of session). - If you are in `default-directory' move cursor on top. - -- Enter `../' at end of pattern will reach upper directory, moving cursor on top. - NOTE: This different to using `C-l' in that `C-l' don't move cursor on top but stay on previous - subdir name. - -- You can complete with partial basename (start on third char entered) - - e.g \"fob\" or \"fbr\" will complete \"foobar\" - but \"fb\" will wait for a third char for completing. - -- Use `C-u C-j' to watch an image. - -- `C-j' on a filename will expand in helm-buffer to this filename. - Second hit on `C-j' will display buffer filename. - Third hit on `C-j' will kill buffer filename. - NOTE: `C-u C-j' will display buffer directly. - -- To browse images directories turn on `helm-follow-mode' and navigate with arrow keys. - You can also use `helm-follow-action-forward' and `helm-follow-action-backward' - (`C-'). - -- You can turn off/on (toggle) autoupdate completion at any moment with `C-DEL'. - NOTE: On a terminal C- may not work, use in this case C-c . - -- You can create a new directory and a new file at the same time, just write the path in prompt - and press `'. - e.g You can create \"~/new/newnew/newnewnew/my_newfile.txt\". - -- To create a new directory, add a \"/\" at end of new name and press . - -- To create a new file just write the filename not ending with \"/\". - -- You can start a recursive search with Locate of Find (See commands below). - With Locate you can use a local db with a prefix arg; If the localdb doesn't already - exists, you will be prompted for its creation, if it exists and you want to refresh it, - give two prefix args. - -\nSpecific commands for `helm-find-files': -\\ -\\[helm-ff-run-locate]\t\t->Run Locate (C-u to specify locate db, M-n insert basename of candidate) -\\[helm-ff-run-find-sh-command]\t\t->Run Find shell command from this directory. -\\[helm-ff-run-grep]\t\t->Run Grep (C-u Recursive). -\\[helm-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. -\\[helm-ff-run-zgrep]\t\t->Run zgrep (C-u Recursive). -\\[helm-ff-run-etags]\t\t->Run Etags (C-u use thing-at-point `C-u C-u' reload cache) -\\[helm-ff-run-rename-file]\t\t->Rename File (C-u Follow). -\\[helm-ff-run-query-replace-on-marked]\t\t->Query replace on marked files. -\\[helm-ff-run-copy-file]\t\t->Copy File (C-u Follow). -\\[helm-ff-run-byte-compile-file]\t\t->Byte Compile File (C-u Load). -\\[helm-ff-run-load-file]\t\t->Load File. -\\[helm-ff-run-symlink-file]\t\t->Symlink File. -\\[helm-ff-run-hardlink-file]\t\t->Hardlink file. -\\[helm-ff-run-delete-file]\t\t->Delete File. -\\[helm-ff-run-kill-buffer-persistent]\t\t->Kill buffer candidate without quitting. -\\[helm-ff-persistent-delete]\t\t->Delete file without quitting. -\\[helm-ff-run-switch-to-eshell]\t\t->Switch to Eshell. -\\[helm-ff-run-eshell-command-on-file]\t\t->Eshell command on file (C-u Apply on marked files, otherwise treat them sequentially). -\\[helm-ff-run-ediff-file]\t\t->Ediff file. -\\[helm-ff-run-ediff-merge-file]\t\t->Ediff merge file. -\\[helm-ff-run-complete-fn-at-point]\t\t->Complete file name at point. -\\[helm-ff-run-switch-other-window]\t\t->Switch other window. -\\[helm-ff-run-switch-other-frame]\t\t->Switch other frame. -\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). -\\[helm-ff-run-open-file-with-default-tool]\t\t->Open file externally with default tool. -\\[helm-ff-rotate-left-persistent]\t\t->Rotate Image Left. -\\[helm-ff-rotate-right-persistent]\t\t->Rotate Image Right. -\\[helm-find-files-up-one-level]\t\t->Go down precedent directory. -\\[helm-ff-run-switch-to-history]\t\t->Switch to last visited directories history. -\\[helm-ff-file-name-history]\t\t->Switch to file name history. -\\[helm-ff-properties-persistent]\t\t->Show file properties in a tooltip. -\\[helm-mark-all]\t\t->Mark all visibles candidates. -\\[helm-ff-run-toggle-auto-update]\t\t->Toggle auto expansion of directories. -\\[helm-unmark-all]\t\t->Unmark all candidates, visibles and invisibles. -\\[helm-ff-run-gnus-attach-files]\t\t->Gnus attach files to message buffer. -\\[helm-ff-run-print-file]\t\t->Print file, (C-u to refresh printers list). -\\[helm-enlarge-window]\t\t->Enlarge helm window. -\\[helm-narrow-window]\t\t->Narrow helm window. -\\[helm-ff-run-toggle-basename]\t\t->Toggle basename/fullpath. -\\[helm-ff-run-find-file-as-root]\t\t->Find file as root. -\\[helm-ff-run-insert-org-link]\t\t->Insert org link. -\\[helm-ff-help]\t\t->Display this help info. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-ff-help () - "Help command for `helm-find-files'." - (interactive) - (let ((helm-help-message helm-ff-help-message)) - (helm-help))) - -;;; Help for `helm-read-file-name' -;; -;; -(defvar helm-read-file-name-help-message - "== Helm read file name ==\ -\nTips: -\n- Enter `~/' at end of pattern to quickly reach home directory. - -- Enter `/' at end of pattern to quickly reach root of your file system. - -- Enter `./' at end of pattern to quickly reach `default-directory' (initial start of session). - If you are in `default-directory' move cursor on top. - -- Enter `../' at end of pattern will reach upper directory, moving cursor on top. - NOTE: This different to using `C-l' in that `C-l' don't move cursor on top but stay on previous - subdir name. - -- You can complete with partial basename (start on third char entered) - - e.g \"fob\" or \"fbr\" will complete \"foobar\" - but \"fb\" will wait for a third char for completing. - -Persistent actions: - -By default `helm-read-file-name' use the persistent actions of `helm-find-files'. - -- Use `C-u C-j' to watch an image. - -- `C-j' on a filename will expand in helm-buffer to this filename. - Second hit on `C-j' will display buffer filename. - Third hit on `C-j' will kill buffer filename. - NOTE: `C-u C-j' will display buffer directly. - -- To browse images directories turn on `helm-follow-mode' and navigate with arrow keys. - -- When you want to delete backward characters to e.g creating a new file or directory, - autoupdate may keep updating to an existent directory - preventing you to do so, in this case just hit C- and then . - This should not needed when copying/renaming files because autoupdate is disabled - by default in this case. - NOTE: On a terminal C- may not work, use in this case C-c . - -- You can create a new directory and a new file at the same time, just write the path in prompt - and press . - e.g You can create \"~/new/newnew/newnewnew/my_newfile.txt\". - -- To create a new directory, add a \"/\" at end of new name and press . - -- To create a new file just write the filename not ending with \"/\". - -\nSpecific commands for helm-read-file-name: -\\ -\\[helm-find-files-up-one-level]\t\t->Go down precedent directory. -\\[helm-ff-run-toggle-auto-update]\t->Toggle auto expansion of directories. -\\[helm-ff-run-toggle-basename]\t\t->Toggle basename. -\\[helm-ff-file-name-history]\t\t->File name history. -\\[helm-cr-empty-string]\t->Maybe return empty string (unless `must-match'). -\\[helm-next-source]\t->Goto next source. -\\[helm-previous-source]\t->Goto previous source. -\\[helm-read-file-name-help]\t\t->Display this help info. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-read-file-name-help () - (interactive) - (let ((helm-help-message helm-read-file-name-help-message)) - (helm-help))) - -;;; Generic file help - Used by locate. -;; -;; -(defvar helm-generic-file-help-message - "== Helm Generic files Map ==\ - -\nLocate tips: -You can add after writing search pattern any of the locate command line options. -e.g -b, -e, -n ...etc. -See Man locate for more infos. - -Note: -Some other sources (at the moment recentf and file in current directory sources) -support the -b flag for compatibility with locate when they are used with it. - -\nSpecific commands for helm locate and others files sources: -\\ -\\[helm-ff-run-toggle-basename]\t\t->Toggle basename. -\\[helm-ff-run-grep]\t\t->Run grep (C-u recurse). -\\[helm-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. -\\[helm-ff-run-delete-file]\t\t->Delete file. -\\[helm-ff-run-ediff-file]\t\t->Ediff file. -\\[helm-ff-run-ediff-merge-file]\t\t->Ediff merge file. -\\[helm-ff-run-switch-other-window]\t\t->Switch other window. -\\[helm-ff-properties-persistent]\t\t->Show file properties. -\\[helm-ff-run-etags]\t\t->Run etags (C-u use tap, C-u C-u reload DB). -\\[helm-yank-text-at-point]\t\t->Yank text at point. -\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). -\\[helm-ff-run-open-file-with-default-tool]\t\t->Open file externally with default tool. -\\[helm-ff-run-insert-org-link]\t\t->Insert org link. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-generic-file-help () - (interactive) - (let ((helm-help-message helm-generic-file-help-message)) - (helm-help))) - -;;; Grep help -;; -;; -(defvar helm-grep-help-message - "== Helm Grep Map ==\ -\nHelm Grep tips: -You can start grep with a prefix arg to recurse in subdirectories. -You can use wild card when selecting files (e.g *.el) -You can grep in many differents directories by marking files or wild cards. -You can save your results in a grep-mode buffer, see below. - -Grepping on remote file will work only with grep, not ack-grep, but it is -anyway bad supported as tramp doesn't support multiple process running in a -short delay (less than 5s actually), so I strongly advice hitting `C-!' (i.e -suspend process) before entering anything in pattern, and hit again `C-!' when -your regexp is ready to send to remote process. - -\nSpecific commands for Helm Grep: -\\ -\\[helm-goto-next-file]\t->Next File. -\\[helm-goto-precedent-file]\t\t->Precedent File. -\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[helm-grep-run-other-window-action]\t\t->Jump other window. -\\[helm-grep-run-other-frame-action]\t\t->Jump other frame. -\\[helm-grep-run-persistent-action]\t\t->Run persistent action (Same as `C-j'). -\\[helm-grep-run-default-action]\t\t->Run default action (Same as RET). -\\[helm-grep-run-save-buffer]\t\t->Save to a `grep-mode' enabled buffer. -\\[helm-grep-help]\t\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-grep-help () - (interactive) - (let ((helm-help-message helm-grep-help-message)) - (helm-help))) - -;;; Pdf grep help -;; -;; -(defvar helm-pdfgrep-help-message - "== Helm PdfGrep Map ==\ -\nSpecific commands for Pdf Grep: -\\ -\\[helm-goto-next-file]\t->Next File. -\\[helm-goto-precedent-file]\t\t->Precedent File. -\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[helm-pdfgrep-help]\t\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-pdfgrep-help () - (interactive) - (let ((helm-help-message helm-pdfgrep-help-message)) - (helm-help))) - -;;; Etags help -;; -;; -(defvar helm-etags-help-message - "== Helm Etags Map ==\ -\nSpecific commands for Etags: -\\ -\\[helm-goto-next-file]\t->Next File. -\\[helm-goto-precedent-file]\t\t->Precedent File. -\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[helm-etags-help]\t\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-etags-help () - "The help function for etags." - (interactive) - (let ((helm-help-message helm-etags-help-message)) - (helm-help))) - -;;; Ucs help -;; -;; -(defvar helm-ucs-help-message - "== Helm Ucs == -\nSpecific commands for `helm-ucs': -\\ -\\[helm-ucs-persistent-insert]\t->Insert char. -\\[helm-ucs-persistent-forward]\t->Forward char. -\\[helm-ucs-persistent-backward]\t->Backward char. -\\[helm-ucs-persistent-delete]\t->Delete char backward. -\\[helm-ucs-help]\t\t->Show this help. - -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-ucs-help () - "Help command for `helm-ucs'." - (interactive) - (let ((helm-help-message helm-ucs-help-message)) - (helm-help))) - -;;; Bookmark help -;; -;; -(defvar helm-bookmark-help-message - "== Helm bookmark name Map ==\ -\nSpecific commands for bookmarks: -\\ -\\[helm-bookmark-run-jump-other-window]\t\t->Jump other window. -\\[helm-bookmark-run-delete]\t\t->Delete bookmark. -\\[helm-bookmark-run-edit]\t\t->Edit bookmark. -\\[helm-bookmark-toggle-filename]\t\t->Toggle bookmark location visibility. -\\[helm-bookmark-help]\t\t->Run this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-bookmark-help () - "Help command for bookmarks." - (interactive) - (let ((helm-help-message helm-bookmark-help-message)) - (helm-help))) - -;;; Eshell command on file help -;; -;; -(defvar helm-esh-help-message - "== Helm eshell on file == -\nTips: - -- Passing extra args after filename: - -Normally your command or alias will be called with file as argument. - -e.g 'candidate_file' - -But you can also pass an argument or more after 'candidate_file' like this: - - %s [extra_args]\n - -'candidate_file' will be added at '%s' and your command will look at this: - - 'candidate_file' [extra_args] - -- Specify many files as args (marked files): - -e.g file1 file2 ... - -Call `helm-find-files-eshell-command-on-file' with one prefix-arg -Otherwise you can pass one prefix-arg from the command selection buffer. -NOTE: This is not working on remote files. - -With two prefix-arg before starting or from the command selection buffer -the output is printed to your `current-buffer'. - -Note that with no prefix-arg or a prefix-arg value of '(16) (C-u C-u) -the command is called once for each file like this: - - file1 file2 etc... - -\nSpecific commands for `helm-find-files-eshell-command-on-file': -\\ -\\[helm-esh-help]\t\t->Display this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-esh-help () - "Help command for `helm-find-files-eshell-command-on-file'." - (interactive) - (let ((helm-help-message helm-esh-help-message)) - (helm-help))) - -;;; Ido virtual buffer help -;; -;; -(defvar helm-buffers-ido-virtual-help-message - "== Helm ido virtual buffers Map ==\ -\nSpecific commands for ido virtuals buffers: -\\ -\\[helm-ff-run-switch-other-window]\t\t->Switch other window. -\\[helm-ff-run-switch-other-frame]\t\t->Switch other frame. -\\[helm-ff-run-grep]\t\t->Grep file. -\\[helm-ff-run-zgrep]\t\t->Zgrep file. -\\[helm-ff-run-delete-file]\t\t->Delete file. -\\[helm-ff-run-open-file-externally]\t\t->Open file externally. -\\[helm-buffers-ido-virtual-help]\t\t->Display this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-buffers-ido-virtual-help () - "Help command for ido virtual buffers." - (interactive) - (let ((helm-help-message helm-buffers-ido-virtual-help-message)) - (helm-help))) - -;;; Moccur help -;; -;; -(defvar helm-moccur-help-message - "== Helm Moccur Map ==\ -\nHelm Moccur tips: - -\nSpecific commands for Helm Moccur: -\\ -\\[helm-goto-next-file]\t->Next Buffer. -\\[helm-goto-precedent-file]\t\t->Precedent Buffer. -\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. -\\[helm-moccur-run-goto-line-ow]\t\t->Goto line in other window. -\\[helm-moccur-run-goto-line-of]\t\t->Goto line in new frame. -\\[helm-moccur-help]\t\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-moccur-help () - (interactive) - (let ((helm-help-message helm-moccur-help-message)) - (helm-help))) - -;;; Helm Top -;; -;; -(defvar helm-top-help-message - "== Helm Top Map ==\ -\nHelm Top tips: - -\nSpecific commands for Helm Top: -\\ -\\[helm-top-run-sort-by-com]\t->Sort by commands. -\\[helm-top-run-sort-by-cpu]\t->Sort by cpu usage. -\\[helm-top-run-sort-by-user]\t->Sort alphabetically by user. -\\[helm-top-run-sort-by-mem]\t->Sort by memory. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-top-help () - (interactive) - (let ((helm-help-message helm-top-help-message)) - (helm-help))) - -;;; Helm Apt -;; -;; -(defvar helm-apt-help-message - "== Helm Apt Map ==\ -\nHelm Apt tips: - -\nSpecific commands for Helm Apt: -\\ -\\[helm-apt-show-all]\t->Show all packages. -\\[helm-apt-show-only-installed]\t->Show installed packages only. -\\[helm-apt-show-only-not-installed]\t->Show not installed packages only. -\\[helm-apt-show-only-deinstalled]\t-Show deinstalled (not purged yet) packages only.> -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-apt-help () - (interactive) - (let ((helm-help-message helm-apt-help-message)) - (helm-help))) - -;;; Helm elisp package -;; -;; -(defvar helm-el-package-help-message - "== Helm elisp package Map ==\ -\nHelm elisp package tips: - -\nSpecific commands for Helm elisp package: -\\ -\\[helm-el-package-show-all]\t->Show all packages. -\\[helm-el-package-show-installed]\t->Show installed packages only. -\\[helm-el-package-show-uninstalled]\t->Show not installed packages only. -\\[helm-el-package-help]\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-el-package-help () - (interactive) - (let ((helm-help-message helm-el-package-help-message)) - (helm-help))) - -;;; Helm M-x -;; -;; -(defvar helm-M-x-help-message - "== Helm M-x ==\ -\nHelm M-x tips: - -You can get help on any command with persistent action (C-j). - -All the prefix args passed BEFORE running `helm-M-x' are ignored. -When you want to pass prefix args, pass them AFTER starting `helm-M-x', -you will have a prefix arg counter appearing in mode-line notifying you -the amount of prefix args entered. - -\nSpecific commands for Helm M-x: -\\ -\\[helm-M-x-help]\t\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-M-x-help () - (interactive) - (let ((helm-help-message helm-M-x-help-message)) - (helm-help))) - -;;; helm-imenu -;; -;; -(defvar helm-imenu-help-message - "== Helm imenu ==\ -\nHelm imenu tips: - -\nSpecific commands for Helm imenu: -\\ -\\[helm-imenu-help]\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-imenu-help () - (interactive) - (let ((helm-help-message helm-imenu-help-message)) - (helm-help))) - -;;; helm-colors -;; -;; -(defvar helm-colors-help-message - "== Helm colors ==\ -\nSpecific commands for Helm colors: -\\ -\\[helm-color-run-insert-name]\t\tInsert the entry'name. -\\[helm-color-run-kill-name]\t\tKill the entry's name. -\\[helm-color-run-insert-rgb]\t\tInsert entry in RGB format. -\\[helm-color-run-kill-rgb]\t\tKill entry in RGB format. -\\[helm-color-help]\t\tShow this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-color-help () - (interactive) - (let ((helm-help-message helm-colors-help-message)) - (helm-help))) - -;;; helm semantic -;; -;; -(defvar helm-semantic-help-message - "== Helm semantic ==\ -\nHelm semantic tips: - -\nSpecific commands for Helm semantic: -\\ -\\[helm-semantic-help]\t->Show this help. -\n== Helm Map == -\\{helm-map}") - -;;;###autoload -(defun helm-semantic-help () - (interactive) - (let ((helm-help-message helm-semantic-help-message)) - (helm-help))) - - -;;; Mode line strings -;; -;; -;;;###autoload -(defvar helm-buffer-mode-line-string - '("Buffer(s)" "\ -\\\ -\\[helm-buffer-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "String displayed in mode-line in `helm-source-buffers-list'")) - -;;;###autoload -(defvar helm-color-mode-line-string - '("Colors" "\ -\\\ -\\[helm-color-help]:Help/\ -\\[helm-color-run-insert-name]:Insert name/\ -\\[helm-color-run-insert-rgb]:Insert RGB/\ -with shift: Kill")) - -;;;###autoload -(defvar helm-buffers-ido-virtual-mode-line-string - '("Killed Buffer(s)" "\ -\\\ -\\[helm-buffers-ido-virtual-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "String displayed in mode-line in `helm-source-buffers-list'")) - -;;;###autoload -(defvar helm-ff-mode-line-string "\ -\\\ -\\[helm-ff-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "String displayed in mode-line in `helm-source-find-files'") - -;;;###autoload -(defvar helm-read-file-name-mode-line-string "\ -\\\ -\\[helm-read-file-name-help]:Help \ -\\[helm-cr-empty-string]:Empty \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "String displayed in mode-line in `helm-source-find-files'.") - -;;;###autoload -(defvar helm-generic-file-mode-line-string "\ -\\\ -\\[helm-generic-file-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend" - "String displayed in mode-line in Locate.") - -;;;###autoload -(defvar helm-grep-mode-line-string"\ -\\\ -\\[helm-grep-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend" - "String displayed in mode-line in `helm-do-grep'.") - -;;;###autoload -(defvar helm-pdfgrep-mode-line-string "\ -\\\ -\\[helm-pdfgrep-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend" - "String displayed in mode-line in `helm-do-pdfgrep'.") - -;;;###autoload -(defvar helm-etags-mode-line-string "\ -\\\ -\\[helm-etags-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "String displayed in mode-line in `helm-etags-select'.") - -;;;###autoload -(defvar helm-ucs-mode-line-string "\ -\\\ -\\[helm-ucs-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "String displayed in mode-line in `helm-ucs'.") - -;;;###autoload -(defvar helm-bookmark-mode-line-string - '("Bookmark(s)" "\ -\\\ -\\[helm-bookmark-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct") - "String displayed in mode-line in `helm-source-buffers-list'") - -;;;###autoload -(defvar helm-occur-mode-line "\ -\\\ -\\[helm-help]:Help \ -\\\ -\\[helm-occur-run-query-replace-regexp]:Query replace regexp \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-moccur-mode-line "\ -\\\ -\\[helm-moccur-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-comp-read-mode-line "\ -\\\ -\\[helm-cr-empty-string]:Empty \ -\\\ -\\[helm-help]:Help \ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct") - -;;;###autoload -(defvar helm-top-mode-line "\ -\\\ -\\[helm-top-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-apt-mode-line "\ -\\\ -\\[helm-apt-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-el-package-mode-line "\ -\\\ -\\[helm-el-package-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-M-x-mode-line "\ -\\\ -\\[helm-M-x-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-imenu-mode-line "\ -\\\ -\\[helm-imenu-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - -;;;###autoload -(defvar helm-semantic-mode-line "\ -\\\ -\\[helm-semantic-help]:Help \ -\\\ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct \ -\\[helm-toggle-suspend-update]:Tog.suspend") - - -;;; Attribute Documentation -;; -;; -;;;###autoload -(defun helm-describe-helm-attribute (helm-attribute) - "Display the full documentation of HELM-ATTRIBUTE. -HELM-ATTRIBUTE should be a symbol." - (interactive (list (intern - (completing-read - "Describe helm attribute: " - (mapcar 'symbol-name helm-attributes) - nil t)))) - (with-output-to-temp-buffer "*Help*" - (princ (get helm-attribute 'helm-attrdoc)))) - -(helm-document-attribute 'name "mandatory" - " The name of the source. It is also the heading which appears - above the list of matches from the source. Must be unique.") - -(helm-document-attribute 'header-name "optional" - " A function returning the display string of the header. Its - argument is the name of the source. This attribute is useful to - add an additional information with the source name.") - -(helm-document-attribute 'candidates "mandatory if candidates-in-buffer attribute is not provided" - " Specifies how to retrieve candidates from the source. It can - either be a variable name, a function called with no parameters - or the actual list of candidates. - - The list must be a list whose members are strings, symbols - or (DISPLAY . REAL) pairs. - - In case of (DISPLAY . REAL) pairs, the DISPLAY string is shown - in the Helm buffer, but the REAL one is used as action - argument when the candidate is selected. This allows a more - readable presentation for candidates which would otherwise be, - for example, too long or have a common part shared with other - candidates which can be safely replaced with an abbreviated - string for display purposes. - - Note that if the (DISPLAY . REAL) form is used then pattern - matching is done on the displayed string, not on the real - value. - - If the candidates have to be retrieved asynchronously (for - example, by an external command which takes a while to run) - then the function should start the external command - asynchronously and return the associated process object. - Helm will take care of managing the process (receiving the - output from it, killing it if necessary, etc.). The process - should return candidates matching the current pattern (see - variable `helm-pattern'.) - You should use instead `candidates-process' attribute for - async processes, a warning will popup when using async process - in a `candidates' attribute. - - Note that currently results from asynchronous sources appear - last in the helm buffer regardless of their position in - `helm-sources'.") - -(helm-document-attribute 'candidates-process - "Same as `candidates' attributes but for process function." - " You should use this attribute when using a function involving - an async process instead of `candidates'.") - -(helm-document-attribute 'action "mandatory if type attribute is not provided" - " It is a list of (DISPLAY . FUNCTION) pairs or FUNCTION. - FUNCTION is called with one parameter: the selected candidate. - - An action other than the default can be chosen from this list - of actions for the currently selected candidate (by default - with TAB). The DISPLAY string is shown in the completions - buffer and the FUNCTION is invoked when an action is - selected. The first action of the list is the default.") - -(helm-document-attribute 'coerce "optional" - " It's a function called with one argument: the selected - candidate. - - This function is intended for type convertion. In normal case, - the selected candidate (string) is passed to action - function. If coerce function is specified, it is called just - before action function. - - Example: converting string to symbol - (coerce . intern)") - -(helm-document-attribute 'type "optional if action attribute is provided" - " Indicates the type of the items the source returns. - - Merge attributes not specified in the source itself from - `helm-type-attributes'. - - This attribute is implemented by plug-in.") - -(helm-document-attribute 'init "optional" - " Function called with no parameters when helm is started. It - is useful for collecting current state information which can be - used to create the list of candidates later. - - For example, if a source needs to work with the current - directory then it can store its value here, because later - helm does its job in the minibuffer and in the - `helm-buffer' and the current directory can be different - there.") - -(helm-document-attribute 'match "optional" - " List of functions called with one parameter: a candidate. The - function should return non-nil if the candidate matches the - current pattern (see variable `helm-pattern'). - - This attribute allows the source to override the default - pattern matching based on `string-match'. It can be used, for - example, to implement a source for file names and do the - pattern matching on the basename of files, since it's more - likely one is typing part of the basename when searching for a - file, instead of some string anywhere else in its path. - - If the list contains more than one function then the list of - matching candidates from the source is constructed by appending - the results after invoking the first function on all the - potential candidates, then the next function, and so on. The - matching candidates supplied by the first function appear first - in the list of results and then results from the other - functions, respectively. - - This attribute has no effect for asynchronous sources (see - attribute `candidates'), since they perform pattern matching - themselves.") - -(helm-document-attribute 'candidate-transformer "optional" - " It's a function or a list of functions called with one argument - when the completion list from the source is built. The argument - is the list of candidates retrieved from the source. The - function should return a transformed list of candidates which - will be used for the actual completion. If it is a list of - functions, it calls each function sequentially. - - This can be used to transform or remove items from the list of - candidates. - - Note that `candidates' is run already, so the given transformer - function should also be able to handle candidates with (DISPLAY - . REAL) format.") - -(helm-document-attribute 'filtered-candidate-transformer "optional" - " It has the same format as `candidate-transformer', except the - function is called with two parameters: the candidate list and - the source. - - This transformer is run on the candidate list which is already - filtered by the current pattern. While `candidate-transformer' - is run only once, it is run every time the input pattern is - changed. - - It can be used to transform the candidate list dynamically, for - example, based on the current pattern. - - In some cases it may also be more efficent to perform candidate - transformation here, instead of with `candidate-transformer' - even if this transformation is done every time the pattern is - changed. For example, if a candidate set is very large then - `candidate-transformer' transforms every candidate while only - some of them will actually be dislpayed due to the limit - imposed by `helm-candidate-number-limit'. - - Note that `candidates' and `candidate-transformer' is run - already, so the given transformer function should also be able - to handle candidates with (DISPLAY . REAL) format. - - This option has no effect for asynchronous sources. (Not yet, - at least.") - -(helm-document-attribute 'action-transformer "optional" - " It's a function or a list of functions called with two - arguments when the action list from the source is - assembled. The first argument is the list of actions, the - second is the current selection. If it is a list of functions, - it calls each function sequentially. - - The function should return a transformed action list. - - This can be used to customize the list of actions based on the - currently selected candidate.") - -(helm-document-attribute 'pattern-transformer "optional" - " It's a function or a list of functions called with one argument - before computing matches. Its argument is `helm-pattern'. - Functions should return transformed `helm-pattern'. - - It is useful to change interpretation of `helm-pattern'.") - -(helm-document-attribute 'delayed "optional" - " Candidates from the source are shown only if the user stops - typing and is idle for `helm-idle-delay' seconds. - If a value is given to delayed attr, this value is used instead only - if it is > to `helm-idle-delay'.") - -(helm-document-attribute 'volatile "optional" - " Indicates the source assembles the candidate list dynamically, - so it shouldn't be cached within a single Helm - invocation. It is only applicable to synchronous sources, - because asynchronous sources are not cached.") - -(helm-document-attribute 'requires-pattern "optional" - " If present matches from the source are shown only if the - pattern is not empty. Optionally, it can have an integer - parameter specifying the required length of input which is - useful in case of sources with lots of candidates.") - -(helm-document-attribute 'persistent-action "optional" - " Can be a either a Function called with one parameter (the - selected candidate) or a cons cell where first element is this - same function and second element a symbol (e.g never-split) - that inform `helm-execute-persistent-action'to not split his - window to execute this persistent action.") - -(helm-document-attribute 'candidates-in-buffer "optional" - " Shortcut attribute for making and narrowing candidates using - buffers. This newly-introduced attribute prevents us from - forgetting to add volatile and match attributes. - - See docstring of `helm-candidates-in-buffer'. - - (candidates-in-buffer) is equivalent of three attributes: - (candidates . helm-candidates-in-buffer) - (volatile) - (match identity) - - (candidates-in-buffer . candidates-function) is equivalent of: - (candidates . candidates-function) - (volatile) - (match identity) - - This attribute is implemented by plug-in.") - -(helm-document-attribute 'search "optional" - " List of functions like `re-search-forward' or `search-forward'. - Buffer search function used by `helm-candidates-in-buffer'. - By default, `helm-candidates-in-buffer' uses - `re-search-forward'. This attribute is meant to be used with - (candidates . helm-candidates-in-buffer) or - (candidates-in-buffer) in short.") - -(helm-document-attribute 'search-from-end "optional" - " Make `helm-candidates-in-buffer' search from the end of buffer. - If this attribute is specified, `helm-candidates-in-buffer' - uses `re-search-backward' instead.") - -(helm-document-attribute 'get-line "optional" - " A function like `buffer-substring-no-properties' or `buffer-substring'. - This function converts point of line-beginning and point of line-end, - which represents a candidate computed by `helm-candidates-in-buffer'. - By default, `helm-candidates-in-buffer' uses - `buffer-substring-no-properties'.") - -(helm-document-attribute 'display-to-real "optional" - " Function called with one parameter; the selected candidate. - - The function transforms the selected candidate, and the result - is passed to the action function. The display-to-real - attribute provides another way to pass other string than one - shown in Helm buffer. - - Traditionally, it is possible to make candidates, - candidate-transformer or filtered-candidate-transformer - function return a list with (DISPLAY . REAL) pairs. But if REAL - can be generated from DISPLAY, display-to-real is more - convenient and faster.") - -(helm-document-attribute 'real-to-display "optional" - " Function called with one parameter; the selected candidate. - - The inverse of display-to-real attribute. - - The function transforms the selected candidate, which is passed - to the action function, for display. The real-to-display - attribute provides the other way to pass other string than one - shown in Helm buffer. - - Traditionally, it is possible to make candidates, - candidate-transformer or filtered-candidate-transformer - function return a list with (DISPLAY . REAL) pairs. But if - DISPLAY can be generated from REAL, real-to-display is more - convenient. - - Note that DISPLAY parts returned from candidates / - candidate-transformer are IGNORED as the name `display-to-real' - says.") - -(helm-document-attribute 'cleanup "optional" - " Function called with no parameters when *helm* buffer is - closed. It is useful for killing unneeded candidates buffer. - - Note that the function is executed BEFORE performing action.") - -(helm-document-attribute 'candidate-number-limit "optional" - " Override `helm-candidate-number-limit' only for this source.") - -(helm-document-attribute 'accept-empty "optional" - " Pass empty string \"\" to action function.") - -(helm-document-attribute 'dummy "optional" - " Set `helm-pattern' to candidate. If this attribute is - specified, The candidates attribute is ignored. - - This attribute is implemented by plug-in.") - -(helm-document-attribute 'multiline "optional" - " Enable to selection multiline candidates.") - -(helm-document-attribute 'update "optional" - (substitute-command-keys - " Function called with no parameters at end of reinitialization when \ -\\\\[helm-force-update] is pressed.")) - -(helm-document-attribute 'mode-line "optional" - " Source local `helm-mode-line-string' (included in - `mode-line-format'). It accepts also variable/function name.") - -(helm-document-attribute 'header-line "optional" - " Source local `header-line-format'. - It accepts also variable/function name. ") - -(helm-document-attribute - 'resume "optional" - " Function called with no parameters at end of initialization - when `helm-resume' is started. - If this function try to do something against `helm-buffer', \(e.g updating, - searching etc...\) probably you should run it in a timer to ensure - `helm-buffer' is ready.") - -(helm-document-attribute 'keymap "optional" - " Specific keymap for this source. - It is useful to have a keymap per source when using more than - one source. Otherwise, a keymap can be set per command with - `helm' argument KEYMAP. NOTE: when a source have `helm-map' as - keymap attr, the global value of `helm-map' will override the - actual local one.") - -(helm-document-attribute 'help-message "optional" - " Help message for this source. - If not present, `helm-help-message' value will be used.") - -(helm-document-attribute 'match-part "optional" - " Allow matching candidate in the line with `candidates-in-buffer'. - In candidates-in-buffer sources, match is done with - `re-search-forward' which allow matching only a regexp on the - `helm-buffer'; when this search is done, match-part allow - matching only a specific part of the current line e.g with a - line like this: - - filename:candidate-containing-the-word-filename - - What you want is to ignore \"filename\" part and match only - \"candidate-containing-the-word-filename\" - - So give a function matching only the part of candidate after \":\" - - If source contain match-part attribute, match is computed only - on part of candidate returned by the call of function provided - by this attribute. The function should have one arg, candidate, - and return only a specific part of candidate. - - NOTE: This have effect only on sources using - `candidates-in-buffer'.") - -(helm-document-attribute 'match-strict "optional" - " When specifying a match function within a source and - helm-match-plugin is enabled, the result of all matching - functions will be concatened, which in some cases is not what - is wanted. When using `match-strict' only this or these - functions will be used. You can specify those functions as a - list of functions or a single symbol function. For anonymous - function don't add the dot, e.g: - - \(match-strict (lambda () (foo))).") - -(helm-document-attribute 'nohighlight "optional" - " Disable highlight match in this source.") - -(helm-document-attribute 'no-matchplugin "optional" - " Disable matchplugin for this source.") - -(helm-document-attribute 'history "optional" - " Allow passing history variable to helm from source. - It should be a quoted symbol evaluated from source, i.e: - (history . ,'history-var)") - -(helm-document-attribute 'follow "optional" - " Enable `helm-follow-mode' for this source only. - You must give it a value of 1 or -1, though giving a -1 value - is surely not what you want, e.g: (follow . 1) - - See `helm-follow-mode' for more infos") - -(helm-document-attribute 'follow-delay "optional" - " `helm-follow-mode' will execute persistent-action after this delay. -Otherwise value of `helm-follow-input-idle-delay' is used if non--nil, -If none of these are found fallback to `helm-input-idle-delay'.") - -(helm-document-attribute 'allow-dups "optional" - " Allow helm collecting duplicates candidates.") - -(helm-document-attribute 'filter-one-by-one "optional" - " A transformer function that treat candidates one by one. - It is called with one arg the candidate. - It is faster than `filtered-candidate-transformer' or `candidates-transformer', - but should be used only in sources that recompute constantly their candidates, - e.g `helm-source-find-files'. - Filtering happen early and candidates are treated - one by one instead of re-looping on the whole list. - If used with `filtered-candidate-transformer' or `candidates-transformer' - these functions should treat the candidates transformed by the `filter-one-by-one' - function in consequence.") - -(helm-document-attribute 'nomark "optional" - " Don't allow marking candidates when this attribute is present.") - -(provide 'helm-help) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-help.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-imenu.el b/emacs.d/elpa/helm-20141016.2217/helm-imenu.el deleted file mode 100644 index 1f4eb57..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-imenu.el +++ /dev/null @@ -1,170 +0,0 @@ -;;; helm-imenu.el --- Helm interface for Imenu -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'imenu) -(require 'helm-utils) - - -(defgroup helm-imenu nil - "Imenu related libraries and applications for helm." - :group 'helm) - -(defcustom helm-imenu-delimiter " / " - "Delimit types of candidates and his value in `helm-buffer'." - :group 'helm-imenu - :type 'string) - -(defcustom helm-imenu-execute-action-at-once-if-one t - "Goto the candidate when only one is remaining." - :group 'helm-imenu - :type 'boolean) - -(defcustom helm-imenu-lynx-style-map t - "Use Arrow keys to jump to occurences." - :group 'helm-imenu - :type 'boolean) - - -;;; keymap -(defvar helm-imenu-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-imenu-help) - (when helm-imenu-lynx-style-map - (define-key map (kbd "") 'helm-maybe-exit-minibuffer) - (define-key map (kbd "") 'helm-execute-persistent-action)) - (delq nil map))) - - -;;; Internals -(defvar helm-cached-imenu-alist nil) -(make-variable-buffer-local 'helm-cached-imenu-alist) - -(defvar helm-cached-imenu-candidates nil) -(make-variable-buffer-local 'helm-cached-imenu-candidates) - -(defvar helm-cached-imenu-tick nil) -(make-variable-buffer-local 'helm-cached-imenu-tick) - - -(defvar helm-source-imenu - `((name . "Imenu") - (candidates . helm-imenu-candidates) - (allow-dups) - (candidate-transformer . helm-imenu-transformer) - (persistent-action . helm-imenu-persistent-action) - (persistent-help . "Show this entry") - (keymap . ,helm-imenu-map) - (mode-line . helm-imenu-mode-line) - (action . helm-imenu-action) - "See (info \"(emacs)Imenu\")")) - - -(defun helm-imenu-action (candidate) - "Default action for `helm-source-imenu'." - (imenu candidate) - ;; If semantic is supported in this buffer - ;; imenu used `semantic-imenu-goto-function' - ;; and position have been highlighted, - ;; no need to highlight again. - (unless (eq imenu-default-goto-function - 'semantic-imenu-goto-function) - (helm-highlight-current-line nil nil nil nil 'pulse))) - -(defun helm-imenu-persistent-action (candidate) - "Default persistent action for `helm-source-imenu'." - (imenu candidate) - (helm-highlight-current-line)) - -(defun helm-imenu-candidates () - (with-helm-current-buffer - (let ((tick (buffer-modified-tick))) - (if (eq helm-cached-imenu-tick tick) - helm-cached-imenu-candidates - (setq imenu--index-alist nil) - (setq helm-cached-imenu-tick tick - helm-cached-imenu-candidates - (let ((index (imenu--make-index-alist))) - (helm-imenu--candidates-1 - (delete (assoc "*Rescan*" index) index)))))))) - -(defun helm-imenu--candidates-1 (alist) - (cl-loop for elm in alist - append (if (imenu--subalist-p elm) - (helm-imenu--candidates-1 - (cl-loop for (e . v) in (cdr elm) collect - (cons (propertize - e 'helm-imenu-type (car elm)) - v))) - (and (cdr elm) ; bug in imenu, should not be needed. - (list elm))))) - -(defun helm-imenu--get-prop (item) - ;; property value of ITEM can have itself - ;; a property value which have itself a property value - ;; ...and so on; Return a list of all these - ;; properties values starting at ITEM. - (let* ((prop (get-text-property 0 'helm-imenu-type item)) - (lst (list prop item))) - (when prop - (while prop - (setq prop (get-text-property 0 'helm-imenu-type prop)) - (and prop (push prop lst))) - lst))) - -(defun helm-imenu-transformer (candidates) - (cl-loop for (k . v) in candidates - for types = (or (helm-imenu--get-prop k) - (list "Function" k)) - collect - (cons (mapconcat (lambda (x) - (propertize - x 'face (cond ((string= x "Variables") - 'font-lock-variable-name-face) - ((string= x "Function") - 'font-lock-function-name-face) - ((string= x "Types") - 'font-lock-type-face)))) - types helm-imenu-delimiter) - (cons k v)))) - -;;;###autoload -(defun helm-imenu () - "Preconfigured `helm' for `imenu'." - (interactive) - (let ((imenu-auto-rescan t) - (str (thing-at-point 'symbol)) - (helm-execute-action-at-once-if-one - helm-imenu-execute-action-at-once-if-one)) - (helm :sources 'helm-source-imenu - :default (list (concat "\\_<" str "\\_>") str) - :candidate-number-limit 9999 - :buffer "*helm imenu*"))) - -(provide 'helm-imenu) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-imenu.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-info.el b/emacs.d/elpa/helm-20141016.2217/helm-info.el deleted file mode 100644 index 9dbf5c4..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-info.el +++ /dev/null @@ -1,144 +0,0 @@ -;;; helm-info.el --- Browse info index with helm -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-plugin) -(require 'helm-net) - -(declare-function Info-index-nodes "info" (&optional file)) -(declare-function Info-goto-node "info" (&optional fork)) -(declare-function Info-find-node "info.el" (filename nodename &optional no-going-back)) - - -(defgroup helm-info nil - "Info related Applications and libraries for Helm." - :group 'helm) - -;;; Build info-index sources with info-index plug-in. -;; -;; -(defun helm-build-info-index-command (name doc source buffer) - "Define an helm command NAME with documentation DOC. -Arg SOURCE will be an existing helm source named -`helm-source-info-' and BUFFER a string buffer name." - (eval (list 'defun name nil doc - (list 'interactive) - (list 'helm - :sources source - :buffer buffer - :candidate-number-limit 1000)))) - -(defun helm-define-info-index-sources (var-value &optional commands) - "Define helm sources named helm-source-info-. -Sources are generated for all entries of `helm-default-info-index-list'. -If COMMANDS arg is non--nil build also commands named `helm-info'. -Where NAME is one of `helm-default-info-index-list'." - (cl-loop with symbols = (cl-loop for str in var-value - collect - (intern (concat "helm-source-info-" str))) - for sym in symbols - for str in var-value - do (set sym (list (cons 'name (format "Info index: %s" str)) - (cons 'info-index str))) - when commands - do (let ((com (intern (concat "helm-info-" str)))) - (helm-build-info-index-command - com (format "Predefined helm for %s info." str) - sym (format "*helm info %s*" str))))) - -(defun helm-info-index-set (var value) - (set var value) - (helm-define-info-index-sources value t)) - -(defcustom helm-default-info-index-list - '("elisp" "cl" "org" "gnus" "tramp" "ratpoison" - "zsh" "bash" "coreutils" "fileutils" - "find" "sh-utils" "textutils" "libc" - "make" "automake" "autoconf" "eintr" - "emacs" "elib" "eieio" "gauche-refe" "guile" - "guile-tut" "goops" "screen" "latex" "gawk" - "sed" "m4" "wget" "binutils" "as" "bfd" "gprof" - "ld" "diff" "flex" "grep" "gzip" "libtool" - "texinfo" "info" "gdb" "stabs" "cvsbook" "cvs" - "bison" "id-utils" "global") - "Info Manual entries to use for building helm info index commands." - :group 'helm-info - :type '(repeat (choice string)) - :set 'helm-info-index-set) - -(defcustom helm-info-default-sources - '(helm-source-info-elisp - helm-source-info-cl - helm-source-info-eieio - helm-source-info-pages) - "The default sources to use in `helm-info-at-point'." - :group 'helm-info - :type '(repeat (choice symbol))) - - -;;; Info pages -(defvar helm-info-pages nil - "All info pages on system. -Will be calculated the first time you invoke helm with this -source.") - -(defun helm-info-pages-init () - "Collect candidates for initial Info node Top." - (if helm-info-pages - helm-info-pages - (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.") - topics) - (require 'info) - (with-temp-buffer - (Info-find-node "dir" "top") - (goto-char (point-min)) - (while (re-search-forward info-topic-regexp nil t) - (push (match-string-no-properties 1) topics)) - (kill-buffer)) - (setq helm-info-pages topics)))) - -(defvar helm-source-info-pages - `((name . "Info Pages") - (init . helm-info-pages-init) - (candidates . helm-info-pages) - (action . (("Show with Info" .(lambda (node-str) - (info (replace-regexp-in-string - "^[^:]+: " "" node-str)))))) - (requires-pattern . 2))) - -;;;###autoload -(defun helm-info-at-point () - "Preconfigured `helm' for searching info at point. -With a prefix-arg insert symbol at point." - (interactive) - (let ((helm-google-suggest-default-function - 'helm-google-suggest-emacs-lisp)) - (helm :sources helm-info-default-sources - :buffer "*helm info*"))) - -(provide 'helm-info) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-info.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-locate.el b/emacs.d/elpa/helm-20141016.2217/helm-locate.el deleted file mode 100644 index ec7c661..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-locate.el +++ /dev/null @@ -1,325 +0,0 @@ -;;; helm-locate.el --- helm interface for locate. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;; NOTE for WINDOZE users: -;; You have to install Everything with his command line interface here: -;; http://www.voidtools.com/download.php - -;;; Code: - -(require 'cl-lib) -(require 'helm) - - -(defgroup helm-locate nil - "Locate related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-locate-db-file-regexp "m?locate\.db$" - "Default regexp to match locate database. -If nil Search in all files." - :type 'string - :group 'helm-locate) - -(defcustom helm-ff-locate-db-filename "locate.db" - "The basename of the locatedb file you use locally in your directories. -When this is set and `helm' find such a file in the directory from -where you launch locate, it will use this file and will not prompt you -for a db file. -Note that this happen only when locate is launched with a prefix arg." - :group 'helm-locate - :type 'string) - -(defcustom helm-locate-command nil - "A list of arguments for locate program. -Normally you should not have to modify this yourself. - -If nil it will be calculated when `helm-locate' startup -with these default values for different systems: - -Gnu/linux: \"locate %s -e -A %s\" -berkeley-unix: \"locate %s %s\" -windows-nt: \"es %s %s\" -Others: \"locate %s %s\" - -This string will be passed to format so it should end with `%s'. -The first format spec is used for the \"-i\" value of locate/es, -So don't set it directly but use `helm-locate-case-fold-search' -for this. -The \"-r\" option must be the last option, however if not specified you will -be able to specify it during helm invocation by prefixing the pattern -you enter with \"-r\"." - :type 'string - :group 'helm-locate) - -(defcustom helm-locate-create-db-command - "updatedb -l 0 -o %s -U %s" - "Command used to create a locale locate db file." - :type 'string - :group 'helm-locate) - -(defcustom helm-locate-case-fold-search helm-case-fold-search - "It have the same meaning as `helm-case-fold-search'. -The -i option of locate will be used depending of value of -`helm-pattern' when this is set to 'smart. -When nil \"-i\" will not be used at all. -and when non--nil it will always be used. -NOTE: the -i option of the \"es\" command used on windows does -the opposite of \"locate\" command." - :group 'helm-locate - :type 'symbol) - - -(defvar helm-generic-files-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) - (define-key map (kbd "C-s") 'helm-ff-run-grep) - (define-key map (kbd "M-g s") 'helm-ff-run-grep) - (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) - (define-key map (kbd "M-g p") 'helm-ff-run-pdfgrep) - (define-key map (kbd "M-D") 'helm-ff-run-delete-file) - (define-key map (kbd "C-=") 'helm-ff-run-ediff-file) - (define-key map (kbd "C-c =") 'helm-ff-run-ediff-merge-file) - (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) - (define-key map (kbd "M-i") 'helm-ff-properties-persistent) - (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) - (define-key map (kbd "C-c X") 'helm-ff-run-open-file-with-default-tool) - (define-key map (kbd "M-.") 'helm-ff-run-etags) - (define-key map (kbd "C-w") 'helm-yank-text-at-point) - (define-key map (kbd "C-c @") 'helm-ff-run-insert-org-link) - (define-key map (kbd "C-c ?") 'helm-generic-file-help) - map) - "Generic Keymap for files.") - - -(defface helm-locate-finish - '((t (:foreground "Green"))) - "Face used in mode line when locate process is finish." - :group 'helm-locate) - - -(defun helm-ff-find-locatedb (&optional from-ff) - "Try to find if a local locatedb file is available. -The search is done in `helm-ff-default-directory' or -fall back to `default-directory' if FROM-FF is nil." - (when helm-ff-locate-db-filename - (cond ((and helm-ff-default-directory - from-ff - (file-exists-p (expand-file-name - helm-ff-locate-db-filename - helm-ff-default-directory)) - (expand-file-name - helm-ff-locate-db-filename - helm-ff-default-directory))) - ((and (not from-ff) - (file-exists-p (expand-file-name - helm-ff-locate-db-filename - default-directory)) - (expand-file-name - helm-ff-locate-db-filename - default-directory)))))) - -(defun helm-locate-1 (&optional localdb init from-ff default) - "Generic function to run Locate. -Prefix arg LOCALDB when (4) search and use a local locate db file when it -exists or create it, when (16) force update of existing db file -even if exists. -It have no effect when locate command is 'es'. -INIT is a string to use as initial input in prompt. -See `helm-locate-with-db' and `helm-locate'." - (require 'helm-mode) - (let ((pfn #'(lambda (candidate) - (if (file-directory-p candidate) - (message "Error: The locate Db should be a file") - (if (= (shell-command - (format helm-locate-create-db-command - candidate - helm-ff-default-directory)) - 0) - (message "New locatedb file `%s' created" candidate) - (error "Failed to create locatedb file `%s'" candidate))))) - (locdb (and localdb - (not (string-match "^es" helm-locate-command)) - (or (and (equal '(4) localdb) - (helm-ff-find-locatedb from-ff)) - (helm-read-file-name - "Create Locate Db file: " - :initial-input (expand-file-name "locate.db" - (or helm-ff-default-directory - default-directory)) - :preselect helm-locate-db-file-regexp - :test #'(lambda (x) - (if helm-locate-db-file-regexp - ;; Select only locate db files and directories - ;; to allow navigation. - (or (string-match - helm-locate-db-file-regexp x) - (file-directory-p x)) - x))))))) - (when (and locdb (or (equal localdb '(16)) - (not (file-exists-p locdb)))) - (funcall pfn locdb)) - (helm-locate-with-db (and localdb locdb) init default))) - -(defun helm-locate-set-command () - "Setup `helm-locate-command' if not already defined." - (unless helm-locate-command - (setq helm-locate-command - (cl-case system-type - (gnu/linux "locate %s -e -r %s") - (berkeley-unix "locate %s %s") - (windows-nt "es %s %s") - (t "locate %s %s"))))) - -(defvar helm-file-name-history nil) -(defun helm-locate-with-db (&optional db initial-input default) - "Run locate -d DB. -If DB is not given or nil use locate without -d option. -Argument DB can be given as a string or list of db files. -Argument INITIAL-INPUT is a string to use as initial-input. -See also `helm-locate'." - (when (and db (stringp db)) (setq db (list db))) - (helm-locate-set-command) - (let ((helm-ff-transformer-show-only-basename nil) - (helm-locate-command - (if db - (replace-regexp-in-string - "locate" - (format "locate -d %s" - (mapconcat 'identity - ;; Remove eventually - ;; marked directories by error. - (cl-loop for i in db - unless (file-directory-p i) - collect i) ":")) - helm-locate-command) - helm-locate-command))) - (setq helm-file-name-history (mapcar 'helm-basename file-name-history)) - (helm :sources 'helm-source-locate - :buffer "*helm locate*" - :input initial-input - :default default - :history 'helm-file-name-history))) - -(defun helm-locate-init () - "Initialize async locate process for `helm-source-locate'." - (let* ((locate-is-es (string-match "\\`es" helm-locate-command)) - (real-locate (string-match "\\`locate" helm-locate-command)) - (case-sensitive-flag (if locate-is-es "-i" "")) - (ignore-case-flag (if (or locate-is-es - (not real-locate)) "" "-i")) - process-connection-type - (args (split-string helm-pattern " "))) - (prog1 - (start-process-shell-command - "locate-process" helm-buffer - (format helm-locate-command - (cl-case helm-locate-case-fold-search - (smart (let ((case-fold-search nil)) - (if (string-match "[[:upper:]]" helm-pattern) - case-sensitive-flag - ignore-case-flag))) - (t (if helm-locate-case-fold-search - ignore-case-flag - case-sensitive-flag))) - (concat - ;; The pattern itself. - (shell-quote-argument (car args)) " " - ;; Possible locate args added - ;; after pattern, don't quote them. - (mapconcat 'identity (cdr args) " ")))) - (set-process-sentinel - (get-buffer-process helm-buffer) - #'(lambda (_process event) - (if (string= event "finished\n") - (with-helm-window - (setq mode-line-format - '(" " mode-line-buffer-identification " " - (:eval (format "L%s" (helm-candidate-number-at-point))) " " - (:eval (propertize - (format "[Locate Process Finish- (%s results)]" - (max (1- (count-lines - (point-min) (point-max))) - 0)) - 'face 'helm-locate-finish)))) - (force-mode-line-update)) - (helm-log "Error: Locate %s" - (replace-regexp-in-string "\n" "" event)))))))) - -(defvar helm-source-locate - `((name . "Locate") - (init . helm-locate-set-command) - (candidates-process . helm-locate-init) - (type . file) - (requires-pattern . 3) - (history . ,'helm-file-name-history) - (keymap . ,helm-generic-files-map) - (help-message . helm-generic-file-help-message) - (candidate-number-limit . 9999) - (no-matchplugin) - (mode-line . helm-generic-file-mode-line-string)) - "Find files matching the current input pattern with locate.") - -;;;###autoload -(defun helm-locate-read-file-name (prompt) - (let* (helm-ff-transformer-show-only-basename - (src `((name . "Locate read fname") - (init . helm-locate-set-command) - (candidates-process . helm-locate-init) - (action . identity) - (requires-pattern . 3) - (history . ,'helm-file-name-history) - (candidate-transformer . (helm-skip-boring-files - helm-highlight-files)) - (candidate-number-limit . 9999) - (no-matchplugin)))) - (or (helm :sources src - :prompt prompt - :buffer "*helm locate read fname*" - :resume 'noresume) - (keyboard-quit)))) - -;;;###autoload -(defun helm-locate (arg) - "Preconfigured `helm' for Locate. -Note: you can add locate options after entering pattern. -See 'man locate' for valid options and also `helm-locate-command'. - -You can specify a local database with prefix argument ARG. -With two prefix arg, refresh the current local db or create it -if it doesn't exists. -Many databases can be used: navigate and mark them. -See also `helm-locate-with-db'. - -To create a user specific db, use -\"updatedb -l 0 -o db_path -U directory\". -Where db_path is a filename matched by -`helm-locate-db-file-regexp'." - (interactive "P") - (setq helm-ff-default-directory default-directory) - (helm-locate-1 arg)) - -(provide 'helm-locate) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-locate.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-man.el b/emacs.d/elpa/helm-20141016.2217/helm-man.el deleted file mode 100644 index e0692e3..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-man.el +++ /dev/null @@ -1,102 +0,0 @@ -;;; helm-man.el --- Man and woman UI -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) - -(declare-function woman-file-name-all-completions "woman.el" (topic)) -(declare-function Man-getpage-in-background "man.el" (topic)) -(declare-function helm-generic-sort-fn "helm-utils.el" (S1 S2)) - -(defgroup helm-man nil - "Man and Woman applications for helm." - :group 'helm) - -(defcustom helm-man-or-woman-function 'Man-getpage-in-background - "Default command to display a man page." - :group 'helm-man - :type '(radio :tag "Preferred command to display a man page" - (const :tag "Man" Man-getpage-in-background) - (const :tag "Woman" woman))) - -;; Internal -(defvar helm-man-pages nil - "All man pages on system. -Will be calculated the first time you invoke helm with this -source.") - -(defun helm-man-default-action (candidate) - "Default action for jumping to a woman or man page from helm." - (let ((wfiles (mapcar - 'car (woman-file-name-all-completions candidate)))) - (condition-case nil - (if (> (length wfiles) 1) - (let ((file (helm-comp-read - "ManFile: " wfiles :must-match t))) - (if (eq helm-man-or-woman-function 'Man-getpage-in-background) - (manual-entry (format "-l %s" file)) - (woman-find-file file))) - (funcall helm-man-or-woman-function candidate)) - ;; If woman is unable to format correctly - ;; use man instead. - (error (kill-buffer) ; Kill woman buffer. - (Man-getpage-in-background candidate))))) - -(defvar helm-source-man-pages - '((name . "Manual Pages") - (init . (lambda () - (require 'woman) - (require 'helm-utils) - (unless helm-man-pages - (setq helm-man-pages - (ignore-errors - (woman-file-name "" t) - (sort (mapcar 'car woman-topic-all-completions) - 'string-lessp)))) - (helm-init-candidates-in-buffer 'global helm-man-pages))) - (candidates-in-buffer) - (persistent-action . ignore) - (filtered-candidate-transformer - . (lambda (candidates _source) - (sort candidates #'helm-generic-sort-fn))) - (action . (("Display Man page" . helm-man-default-action))) - ;; Woman does not work OS X - ;; http://xahlee.org/emacs/modernization_man_page.html - (action-transformer . (lambda (actions candidate) - (if (eq system-type 'darwin) - '(("Display Man page" . man)) - actions))))) - -;;;###autoload -(defun helm-man-woman (arg) - "Preconfigured `helm' for Man and Woman pages. -With a prefix arg reinitialize the cache." - (interactive "P") - (when arg (setq helm-man-pages nil)) - (helm-other-buffer 'helm-source-man-pages "*Helm man woman*")) - -(provide 'helm-man) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-man.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-match-plugin.el b/emacs.d/elpa/helm-20141016.2217/helm-match-plugin.el deleted file mode 100644 index ff3ce96..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-match-plugin.el +++ /dev/null @@ -1,436 +0,0 @@ -;;; helm-match-plugin.el --- Multiple regexp matching methods for helm -*- lexical-binding: t -*- - -;; Original Author: rubikitch - -;; Copyright (C) 2008 ~ 2011 rubikitch -;; Copyright (C) 2011 ~ 2014 Thierry Volpiatto - -;; Author: Thierry Volpiatto -;; URL: http://github.com/emacs-helm/helm - -;; 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 . - -;;; Code: - -(require 'helm) -(require 'cl-lib) - -;;;; Match-plugin - -;; Internal -(defvar helm-mp-default-match-functions nil) -(defvar helm-mp-default-search-functions nil) -(defvar helm-mp-default-search-backward-functions nil) - -(defun helm-mp-set-matching-method (var key) - "Default function to set matching methods in helm match plugin." - (set-default var key) - (cl-case (symbol-value var) - (multi1 (setq helm-mp-default-match-functions - '(helm-mp-exact-match helm-mp-1-match) - helm-mp-default-search-functions - '(helm-mp-exact-search helm-mp-1-search) - helm-mp-default-search-backward-functions - '(helm-mp-exact-search-backward - helm-mp-1-search-backward))) - (multi2 (setq helm-mp-default-match-functions - '(helm-mp-exact-match helm-mp-2-match) - helm-mp-default-search-functions - '(helm-mp-exact-search helm-mp-2-search) - helm-mp-default-search-backward-functions - '(helm-mp-exact-search-backward - helm-mp-2-search-backward))) - (multi3 (setq helm-mp-default-match-functions - '(helm-mp-exact-match helm-mp-3-match) - helm-mp-default-search-functions - '(helm-mp-exact-search helm-mp-3-search) - helm-mp-default-search-backward-functions - '(helm-mp-exact-search-backward - helm-mp-3-search-backward))) - (multi3p (setq helm-mp-default-match-functions - '(helm-mp-exact-match helm-mp-3p-match) - helm-mp-default-search-functions - '(helm-mp-exact-search helm-mp-3p-search) - helm-mp-default-search-backward-functions - '(helm-mp-exact-search-backward - helm-mp-3p-search-backward))) - (t (error "Unknown value: %s" helm-mp-matching-method)))) - -(defgroup helm-match-plugin nil - "Helm match plugin." - :group 'helm) - -(defcustom helm-mp-matching-method 'multi3 - "Matching method for helm match plugin. -You can set here different methods to match candidates in helm. -Here are the possible value of this symbol and their meaning: -- multi1: Respect order, prefix of pattern must match. -- multi2: Same but with partial match. -- multi3: The best, multiple regexp match, allow negation. -- multi3p: Same but prefix must match. -Default is multi3." - :type '(radio :tag "Matching methods for helm" - (const :tag "Multiple regexp 1 ordered with prefix match" multi1) - (const :tag "Multiple regexp 2 ordered with partial match" multi2) - (const :tag "Multiple regexp 3 matching no order, partial, best." multi3) - (const :tag "Multiple regexp 3p matching with prefix match" multi3p)) - :set 'helm-mp-set-matching-method - :group 'helm-match-plugin) - -(defface helm-match - '((((background light)) :foreground "#b00000") - (((background dark)) :foreground "gold1")) - "Face used to highlight matches." - :group 'helm-match-plugin) - -(defcustom helm-mp-highlight-delay 0.7 - "Highlight matches with `helm-match' face after this many seconds. - If nil, no highlight. " - :type 'integer - :group 'helm-match-plugin) - -(defcustom helm-mp-highlight-threshold 2 - "Minimum length of pattern to highlight. -The smaller this value is, the slower highlight is." - :type 'integer - :group 'helm-match-plugin) - -;;;###autoload -(define-minor-mode helm-match-plugin-mode - "Add more flexible regexp matching for helm. -See `helm-mp-matching-method' for the behavior of each method." - :group 'helm-match-plugin - :require 'helm-match-plugin - :global t - (if helm-match-plugin-mode - (progn - (add-to-list 'helm-compile-source-functions 'helm-compile-source--match-plugin) - (add-hook 'helm-update-hook 'helm-mp-highlight-match)) - (setq helm-compile-source-functions - (delq 'helm-compile-source--match-plugin - helm-compile-source-functions)) - (remove-hook 'helm-update-hook 'helm-mp-highlight-match))) - - -;;; Build regexps -;; -;; -(defvar helm-mp-space-regexp "[\\ ] " - "Regexp to represent space itself in multiple regexp match.") - -(defun helm-mp-split-pattern (pattern) - "Split PATTERN if it contain spaces and return resulting list. -If spaces in PATTERN are escaped, don't split at this place. -i.e \"foo bar\"=> (\"foo\" \"bar\") -but \"foo\ bar\"=> (\"foobar\")." - (if (string= pattern "") - '("") - (cl-loop for s in (split-string - (replace-regexp-in-string helm-mp-space-regexp - "\000\000" pattern) - " " t) - collect (replace-regexp-in-string "\000\000" " " s)))) - -(defun helm-mp-1-make-regexp (pattern) - "Replace spaces in PATTERN with \"\.*\"." - (mapconcat 'identity (helm-mp-split-pattern pattern) ".*")) - - -;;; Exact match. -;; -;; -;; Internal. -(defvar helm-mp-exact-pattern-str nil) -(defvar helm-mp-exact-pattern-real nil) - -(defun helm-mp-exact-get-pattern (pattern) - (unless (equal pattern helm-mp-exact-pattern-str) - (setq helm-mp-exact-pattern-str pattern - helm-mp-exact-pattern-real (concat "\n" pattern "\n"))) - helm-mp-exact-pattern-real) - - -(defun helm-mp-exact-match (str &optional pattern) - (string= str (or pattern helm-pattern))) - -(defun helm-mp-exact-search (pattern &rest _ignore) - (and (search-forward (helm-mp-exact-get-pattern pattern) nil t) - (forward-line -1))) - -(defun helm-mp-exact-search-backward (pattern &rest _ignore) - (and (search-backward (helm-mp-exact-get-pattern pattern) nil t) - (forward-line 1))) - - -;;; Prefix match -;; -;; -;; Internal -(defvar helm-mp-prefix-pattern-str nil) -(defvar helm-mp-prefix-pattern-real nil) - -(defun helm-mp-prefix-get-pattern (pattern) - (unless (equal pattern helm-mp-prefix-pattern-str) - (setq helm-mp-prefix-pattern-str pattern - helm-mp-prefix-pattern-real (concat "\n" pattern))) - helm-mp-prefix-pattern-real) - -(defun helm-mp-prefix-match (str &optional pattern) - (setq pattern (or pattern helm-pattern)) - (let ((len (length pattern))) - (and (<= len (length str)) - (string= (substring str 0 len) pattern )))) - -(defun helm-mp-prefix-search (pattern &rest _ignore) - (search-forward (helm-mp-prefix-get-pattern pattern) nil t)) - -(defun helm-mp-prefix-search-backward (pattern &rest _ignore) - (and (search-backward (helm-mp-prefix-get-pattern pattern) nil t) - (forward-line 1))) - - -;;; Multiple regexp patterns 1 (order is preserved / prefix). -;; -;; -;; Internal -(defvar helm-mp-1-pattern-str nil) -(defvar helm-mp-1-pattern-real nil) - -(defun helm-mp-1-get-pattern (pattern) - (unless (equal pattern helm-mp-1-pattern-str) - (setq helm-mp-1-pattern-str pattern - helm-mp-1-pattern-real - (concat "^" (helm-mp-1-make-regexp pattern)))) - helm-mp-1-pattern-real) - -(cl-defun helm-mp-1-match (str &optional (pattern helm-pattern)) - (string-match (helm-mp-1-get-pattern pattern) str)) - -(defun helm-mp-1-search (pattern &rest _ignore) - (re-search-forward (helm-mp-1-get-pattern pattern) nil t)) - -(defun helm-mp-1-search-backward (pattern &rest _ignore) - (re-search-backward (helm-mp-1-get-pattern pattern) nil t)) - - -;;; Multiple regexp patterns 2 (order is preserved / partial). -;; -;; -;; Internal -(defvar helm-mp-2-pattern-str nil) -(defvar helm-mp-2-pattern-real nil) - -(defun helm-mp-2-get-pattern (pattern) - (unless (equal pattern helm-mp-2-pattern-str) - (setq helm-mp-2-pattern-str pattern - helm-mp-2-pattern-real - (concat "^.*" (helm-mp-1-make-regexp pattern)))) - helm-mp-2-pattern-real) - -(cl-defun helm-mp-2-match (str &optional (pattern helm-pattern)) - (string-match (helm-mp-2-get-pattern pattern) str)) - -(defun helm-mp-2-search (pattern &rest _ignore) - (re-search-forward (helm-mp-2-get-pattern pattern) nil t)) - -(defun helm-mp-2-search-backward (pattern &rest _ignore) - (re-search-backward (helm-mp-2-get-pattern pattern) nil t)) - - -;;; Multiple regexp patterns 3 (permutation). -;; -;; -;; Internal -(defvar helm-mp-3-pattern-str nil) -(defvar helm-mp-3-pattern-list nil) - -(defun helm-mp-3-get-patterns (pattern) - "Return `helm-mp-3-pattern-list', a list of predicate/regexp cons cells. -e.g ((identity . \"foo\") (identity . \"bar\")). -This is done only if `helm-mp-3-pattern-str' is same as PATTERN." - (unless (equal pattern helm-mp-3-pattern-str) - (setq helm-mp-3-pattern-str pattern - helm-mp-3-pattern-list - (helm-mp-3-get-patterns-internal pattern))) - helm-mp-3-pattern-list) - -(defun helm-mp-3-get-patterns-internal (pattern) - "Return a list of predicate/regexp cons cells. -e.g ((identity . \"foo\") (identity . \"bar\"))." - (unless (string= pattern "") - (cl-loop for pat in (helm-mp-split-pattern pattern) - collect (if (string= "!" (substring pat 0 1)) - (cons 'not (substring pat 1)) - (cons 'identity pat))))) - -(defun helm-mp-3-match (str &optional pattern) - "Check if PATTERN match STR. -When PATTERN contain a space, it is splitted and matching is done -with the several resulting regexps against STR. -e.g \"bar foo\" will match \"foobar\" and \"barfoo\". -Argument PATTERN, a string, is transformed in a list of -cons cell with `helm-mp-3-get-patterns' if it contain a space. -e.g \"foo bar\"=>((identity . \"foo\") (identity . \"bar\")). -Then each predicate of cons cell(s) is called with regexp of same -cons cell against STR (a candidate). -i.e (identity (string-match \"foo\" \"foo bar\")) => t." - (let ((pat (helm-mp-3-get-patterns (or pattern helm-pattern)))) - (cl-loop for (predicate . regexp) in pat - always (funcall predicate (string-match regexp str))))) - -(defun helm-mp-3-search-base (pattern searchfn1 searchfn2) - "Try to find PATTERN in `helm-buffer' with SEARCHFN1 and SEARCHFN2. -This is the search function for `candidates-in-buffer' enabled sources. -Use the same method as `helm-mp-3-match' except it search in buffer -instead of matching on a string. -i.e (identity (re-search-forward \"foo\" (point-at-eol) t)) => t." - (cl-loop with pat = (if (stringp pattern) - (helm-mp-3-get-patterns pattern) - pattern) - while (funcall searchfn1 (or (cdar pat) "") nil t) - for bol = (point-at-bol) - for eol = (point-at-eol) - if (cl-loop for (pred . str) in (cdr pat) always - (progn (goto-char bol) - (funcall pred (funcall searchfn2 str eol t)))) - do (goto-char eol) and return t - else do (goto-char eol) - finally return nil)) - -(defun helm-mp-3-search (pattern &rest _ignore) - (when (stringp pattern) - (setq pattern (helm-mp-3-get-patterns pattern))) - (helm-mp-3-search-base - pattern 're-search-forward 're-search-forward)) - -(defun helm-mp-3-search-backward (pattern &rest _ignore) - (when (stringp pattern) - (setq pattern (helm-mp-3-get-patterns pattern))) - (helm-mp-3-search-base - pattern 're-search-backward 're-search-backward)) - - -;;; mp-3p- (multiple regexp pattern 3 with prefix search) -;; -;; -(defun helm-mp-3p-match (str &optional pattern) - "Check if PATTERN match STR. -Same as `helm-mp-3-match' but more strict, matching against prefix also. -e.g \"bar foo\" will match \"barfoo\" but not \"foobar\" contrarily to -`helm-mp-3-match'." - (let* ((pat (helm-mp-3-get-patterns (or pattern helm-pattern))) - (first (car pat))) - (and (funcall (car first) (helm-mp-prefix-match str (cdr first))) - (cl-loop for (predicate . regexp) in (cdr pat) - always (funcall predicate (string-match regexp str)))))) - -(defun helm-mp-3p-search (pattern &rest _ignore) - (when (stringp pattern) - (setq pattern (helm-mp-3-get-patterns pattern))) - (helm-mp-3-search-base - pattern 'helm-mp-prefix-search 're-search-forward)) - -(defun helm-mp-3p-search-backward (pattern &rest _ignore) - (when (stringp pattern) - (setq pattern (helm-mp-3-get-patterns pattern))) - (helm-mp-3-search-base - pattern 'helm-mp-prefix-search-backward 're-search-backward)) - - -;;; source compiler -;; -;; -(defun helm-compile-source--match-plugin (source) - (if (assoc 'no-matchplugin source) - source - (let* ((searchers (if (assoc 'search-from-end source) - helm-mp-default-search-backward-functions - helm-mp-default-search-functions)) - (defmatch (helm-aif (assoc-default 'match source) - (helm-mklist it))) - (defmatch-strict (helm-aif (assoc-default 'match-strict source) - (helm-mklist it))) - (defsearch (helm-aif (assoc-default 'search source) - (helm-mklist it))) - (defsearch-strict (helm-aif (assoc-default 'search-strict source) - (helm-mklist it))) - (matchfns (cond (defmatch-strict) - (defmatch - (append helm-mp-default-match-functions defmatch)) - (t helm-mp-default-match-functions))) - (searchfns (cond (defsearch-strict) - (defsearch - (append searchers defsearch)) - (t searchers)))) - `(,(if (assoc 'candidates-in-buffer source) - `(search ,@searchfns) `(match ,@matchfns)) - ,@source)))) - - -;;; Highlight matches. -;; -;; -(defun helm-mp-highlight-match () - "Highlight matches after `helm-mp-highlight-delay' seconds." - (unless (or (assoc 'nohighlight (helm-get-current-source)) - (not helm-mp-highlight-delay) - (helm-empty-buffer-p) - (string= helm-pattern "")) - (helm-mp-highlight-match-internal (window-end (helm-window))) - (run-with-idle-timer helm-mp-highlight-delay nil - 'helm-mp-highlight-match-internal - (with-current-buffer helm-buffer (point-max))))) - -(defun helm-mp-highlight-region (start end regexp face) - (save-excursion - (goto-char start) - (let ((case-fold-search (helm-set-case-fold-search regexp)) me) - (condition-case _err - (while (and (setq me (re-search-forward regexp nil t)) - (< (point) end) - (< 0 (- (match-end 0) (match-beginning 0)))) - (unless (helm-pos-header-line-p) - (put-text-property (match-beginning 0) me 'face face))) - (invalid-regexp nil))))) - -(defun helm-mp-highlight-match-internal (end) - (when helm-alive-p - (set-buffer helm-buffer) - (let ((requote (cl-loop for (pred . re) in - (helm-mp-3-get-patterns helm-pattern) - when (and (eq pred 'identity) - (>= (length re) - helm-mp-highlight-threshold)) - collect re into re-list - finally return - (if (and re-list (>= (length re-list) 1)) - (mapconcat 'identity re-list "\\|") - (regexp-quote helm-pattern))))) - (when (>= (length requote) helm-mp-highlight-threshold) - (helm-mp-highlight-region - (point-min) end requote 'helm-match))))) - -;; Enable match-plugin by default. -(helm-match-plugin-mode 1) - -(provide 'helm-match-plugin) - - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-match-plugin.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-misc.el b/emacs.d/elpa/helm-20141016.2217/helm-misc.el deleted file mode 100644 index 043a046..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-misc.el +++ /dev/null @@ -1,402 +0,0 @@ -;;; helm-misc.el --- Various functions for helm -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) - - -(defgroup helm-misc nil - "Various Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-time-zone-home-location "Paris" - "The time zone of your home" - :group 'helm-misc - :type 'string) - -(defcustom helm-mini-default-sources '(helm-source-buffers-list - helm-source-recentf - helm-source-buffer-not-found) - "Default sources list used in `helm-mini'." - :group 'helm-misc - :type '(repeat (choice symbol))) - -(defface helm-time-zone-current - '((t (:foreground "green"))) - "Face used to colorize current time in `helm-world-time'." - :group 'helm-misc) - -(defface helm-time-zone-home - '((t (:foreground "red"))) - "Face used to colorize home time in `helm-world-time'." - :group 'helm-misc) - - -;;; Latex completion -(defvar LaTeX-math-menu) -(defun helm-latex-math-candidates () - "Collect candidates for latex math completion." - (cl-loop for i in (cddr LaTeX-math-menu) - for elm = (cl-loop for s in i when (vectorp s) - collect (cons (aref s 0) (aref s 1))) - append elm)) - -(defvar helm-source-latex-math - '((name . "Latex Math Menu") - (init . (lambda () - (with-helm-current-buffer - (LaTeX-math-mode 1)))) - (candidate-number-limit . 9999) - (candidates . helm-latex-math-candidates) - (action . (lambda (candidate) - (call-interactively candidate))))) - - -;;;; -(defvar helm-source-fixme - '((name . "TODO/FIXME/DRY comments") - (headline . "^.*\\<\\(TODO\\|FIXME\\|DRY\\)\\>.*$") - (adjust) - (recenter)) - "Show TODO/FIXME/DRY comments in current file.") - -(defvar helm-source-rd-headline - '((name . "RD HeadLine") - (headline "^= \\(.+\\)$" "^== \\(.+\\)$" "^=== \\(.+\\)$" "^==== \\(.+\\)$") - (condition . (memq major-mode '(rdgrep-mode rd-mode))) - (migemo) - (subexp . 1)) - "Show RD headlines. - -RD is Ruby's POD. -http://en.wikipedia.org/wiki/Ruby_Document_format") - -(defvar helm-source-oddmuse-headline - '((name . "Oddmuse HeadLine") - (headline "^= \\(.+\\) =$" "^== \\(.+\\) ==$" - "^=== \\(.+\\) ===$" "^==== \\(.+\\) ====$") - (condition . (memq major-mode '(oddmuse-mode yaoddmuse-mode))) - (migemo) - (subexp . 1)) - "Show Oddmuse headlines, such as EmacsWiki.") - -(defvar helm-source-emacs-source-defun - '((name . "Emacs Source DEFUN") - (headline . "DEFUN\\|DEFVAR") - (condition . (string-match "/emacs2[0-9].+/src/.+c$" - (or buffer-file-name "")))) - "Show DEFUN/DEFVAR in Emacs C source file.") - -(defvar helm-source-emacs-lisp-expectations - '((name . "Emacs Lisp Expectations") - (headline . "(desc[ ]\\|(expectations") - (condition . (eq major-mode 'emacs-lisp-mode))) - "Show descriptions (desc) in Emacs Lisp Expectations. - -http://www.emacswiki.org/cgi-bin/wiki/download/el-expectations.el") - -(defvar helm-source-emacs-lisp-toplevels - '((name . "Emacs Lisp Toplevel / Level 4 Comment / Linkd Star") - (headline . "^(\\|(@\\*\\|^;;;;") - (get-line . buffer-substring) - (condition . (eq major-mode 'emacs-lisp-mode)) - (adjust)) - "Show top-level forms, level 4 comments and linkd stars (optional) in Emacs Lisp. -linkd.el is optional because linkd stars are extracted by regexp. -http://www.emacswiki.org/cgi-bin/wiki/download/linkd.el") - - -;;; Eev anchors -(defvar helm-source-eev-anchor - '((name . "Anchors") - (candidates - . (lambda () - (ignore-errors - (with-helm-current-buffer - (cl-loop initially (goto-char (point-min)) - while (re-search-forward - (format ee-anchor-format "\\([^\.].+\\)") nil t) - for anchor = (match-string-no-properties 1) - collect (cons (format "%5d:%s" - (line-number-at-pos (match-beginning 0)) - (format ee-anchor-format anchor)) - anchor)))))) - (persistent-action . (lambda (item) - (ee-to item) - (helm-highlight-current-line))) - (persistent-help . "Show this entry") - (action . (("Goto link" . ee-to))))) - -;;; Jabber Contacts (jabber.el) -(defun helm-jabber-online-contacts () - "List online Jabber contacts." - (with-no-warnings - (cl-loop for item in (jabber-concat-rosters) - when (get item 'connected) - collect - (if (get item 'name) - (cons (get item 'name) item) - (cons (symbol-name item) item))))) - -(defvar helm-source-jabber-contacts - '((name . "Jabber Contacts") - (init . (lambda () (require 'jabber))) - (candidates . (lambda () (mapcar 'car (helm-jabber-online-contacts)))) - (action . (lambda (x) - (jabber-chat-with - (jabber-read-account) - (symbol-name - (cdr (assoc x (helm-jabber-online-contacts))))))))) - -;;; World time -;; -(defun helm-time-zone-transformer (candidates _source) - (cl-loop for i in candidates - collect - (cond ((string-match (format-time-string "%H:%M" (current-time)) i) - (propertize i 'face 'helm-time-zone-current)) - ((string-match helm-time-zone-home-location i) - (propertize i 'face 'helm-time-zone-home)) - (t i)))) - -(defvar helm-source-time-world - '((name . "Time World List") - (init . (lambda () - (require 'time) - (let ((helm-buffer (helm-candidate-buffer 'global))) - (with-current-buffer helm-buffer - (display-time-world-display display-time-world-list))))) - (candidates-in-buffer) - (filtered-candidate-transformer . helm-time-zone-transformer))) - -;;; LaCarte -;; -;; -(defun helm-create-lacarte-source (name &optional maps) - "Create lacarte source named NAME for MAPS. -MAPS is like in `lacarte-get-overall-menu-item-alist'. -See - http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el" - `((name . ,name) - (init . (lambda () (require 'lacarte))) - (candidates . (lambda () - (with-helm-current-buffer - (delete '(nil) (lacarte-get-overall-menu-item-alist ,@maps))))) - (candidate-transformer . helm-lacarte-candidate-transformer) - (candidate-number-limit . 9999) - (type . command))) - -(defun helm-lacarte-candidate-transformer (cands) - (mapcar (lambda (cand) - (let* ((item (car cand)) - (match (string-match "[^>] \\((.*)\\)$" item))) - (when match - (put-text-property (match-beginning 1) (match-end 1) - 'face 'helm-M-x-key item)) - cand)) - cands)) - -(defvar helm-source-lacarte (helm-create-lacarte-source "Lacarte") - "Helm interface for lacarte.el. -See - http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el") - -;;;###autoload -(defun helm-browse-menubar () - "Helm interface to the menubar using lacarte.el." - (interactive) - (require 'lacarte) - (helm :sources 'helm-source-lacarte :buffer "*helm lacarte*")) - -(defun helm-call-interactively (cmd-or-name) - "Execute CMD-OR-NAME as Emacs command. -It is added to `extended-command-history'. -`helm-current-prefix-arg' is used as the command's prefix argument." - (setq extended-command-history - (cons (helm-stringify cmd-or-name) - (delete (helm-stringify cmd-or-name) extended-command-history))) - (let ((current-prefix-arg helm-current-prefix-arg) - (cmd (helm-symbolify cmd-or-name))) - (if (stringp (symbol-function cmd)) - (execute-kbd-macro (symbol-function cmd)) - (setq this-command cmd) - (call-interactively cmd)))) - -;;; Minibuffer History -;; -;; -(defvar helm-source-minibuffer-history - '((name . "Minibuffer History") - (header-name . (lambda (name) - (format "%s (%s)" name minibuffer-history-variable))) - (candidates - . (lambda () - (let ((history (cl-loop for i in - (symbol-value minibuffer-history-variable) - unless (string= "" i) collect i))) - (if (consp (car history)) - (mapcar 'prin1-to-string history) - history)))) - (migemo) - (multiline) - (action . (lambda (candidate) - (delete-minibuffer-contents) - (insert candidate))))) - -;;; Shell history -;; -;; -(defun helm-comint-input-ring-action (candidate) - "Default action for comint history." - (with-helm-current-buffer - (delete-region (comint-line-beginning-position) (point-max)) - (insert candidate))) - -(defvar helm-source-comint-input-ring - '((name . "Comint history") - (candidates . (lambda () - (with-helm-current-buffer - (ring-elements comint-input-ring)))) - (action . helm-comint-input-ring-action)) - "Source that provide helm completion against `comint-input-ring'.") - - -;;; Helm ratpoison UI -;; -;; -(defvar helm-source-ratpoison-commands - '((name . "Ratpoison Commands") - (init . helm-ratpoison-commands-init) - (candidates-in-buffer) - (action ("Execute the command" . helm-ratpoison-commands-execute)) - (display-to-real . helm-ratpoison-commands-display-to-real) - (candidate-number-limit))) - -(defun helm-ratpoison-commands-init () - (unless (helm-candidate-buffer) - (with-current-buffer (helm-candidate-buffer 'global) - ;; with ratpoison prefix key - (save-excursion - (call-process "ratpoison" nil (current-buffer) nil "-c" "help")) - (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t) - (replace-match " \\1: \\2")) - (goto-char (point-max)) - ;; direct binding - (save-excursion - (call-process "ratpoison" nil (current-buffer) nil "-c" "help top")) - (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t) - (replace-match "\\1: \\2"))))) - -(defun helm-ratpoison-commands-display-to-real (display) - (and (string-match ": " display) - (substring display (match-end 0)))) - -(defun helm-ratpoison-commands-execute (candidate) - (call-process "ratpoison" nil nil nil "-ic" candidate)) - -;;; Helm stumpwm UI -;; -;; -(defvar helm-source-stumpwm-commands - '((name . "Stumpwm Commands") - (init . helm-stumpwm-commands-init) - (candidates-in-buffer) - (action ("Execute the command" . helm-stumpwm-commands-execute)) - (candidate-number-limit))) - -(defun helm-stumpwm-commands-init () - (with-current-buffer (helm-candidate-buffer 'global) - (save-excursion - (call-process "stumpish" nil (current-buffer) nil "commands")) - (while (re-search-forward "[ ]*\\([^ ]+\\)[ ]*\n?" nil t) - (replace-match "\n\\1\n")) - (delete-blank-lines) - (sort-lines nil (point-min) (point-max)) - (goto-char (point-max)))) - -(defun helm-stumpwm-commands-execute (candidate) - (call-process "stumpish" nil nil nil candidate)) - -;;;###autoload -(defun helm-world-time () - "Preconfigured `helm' to show world time." - (interactive) - (helm-other-buffer 'helm-source-time-world "*helm world time*")) - -;;;###autoload -(defun helm-insert-latex-math () - "Preconfigured helm for latex math symbols completion." - (interactive) - (helm-other-buffer 'helm-source-latex-math "*helm latex*")) - -;;;###autoload -(defun helm-eev-anchors () - "Preconfigured `helm' for eev anchors." - (interactive) - (helm-other-buffer 'helm-source-eev-anchor "*Helm eev anchors*")) - -;;;###autoload -(defun helm-ratpoison-commands () - "Preconfigured `helm' to execute ratpoison commands." - (interactive) - (helm-other-buffer 'helm-source-ratpoison-commands - "*helm ratpoison commands*")) - -;;;###autoload -(defun helm-stumpwm-commands() - (interactive) - (helm-other-buffer 'helm-source-stumpwm-commands - "*helm stumpwm commands*")) - - -;;;###autoload -(defun helm-mini () - "Preconfigured `helm' lightweight version \(buffer -> recentf\)." - (interactive) - (require 'helm-files) - (let ((helm-ff-transformer-show-only-basename nil)) - (helm-other-buffer helm-mini-default-sources "*helm mini*"))) - -;;;###autoload -(defun helm-minibuffer-history () - "Preconfigured `helm' for `minibuffer-history'." - (interactive) - (let ((enable-recursive-minibuffers t)) - (helm-other-buffer 'helm-source-minibuffer-history - "*helm minibuffer-history*"))) - -;;;###autoload -(defun helm-comint-input-ring () - "Predefined `helm' that provide completion of `comint' history." - (interactive) - (when (derived-mode-p 'comint-mode) - (helm :sources 'helm-source-comint-input-ring - :input (buffer-substring-no-properties (comint-line-beginning-position) - (point-at-eol)) - :buffer "*helm comint history*"))) - - -(provide 'helm-misc) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-misc.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-mode.el b/emacs.d/elpa/helm-20141016.2217/helm-mode.el deleted file mode 100644 index f40fffc..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-mode.el +++ /dev/null @@ -1,1053 +0,0 @@ -;;; helm-mode.el --- Enable helm completion everywhere. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-files) - - -(defgroup helm-mode nil - "Enable helm completion." - :group 'helm) - -(defcustom helm-completing-read-handlers-alist - '((describe-function . helm-completing-read-symbols) - (describe-variable . helm-completing-read-symbols) - (debug-on-entry . helm-completing-read-symbols) - (find-function . helm-completing-read-symbols) - (find-tag . helm-completing-read-with-cands-in-buffer) - (ffap-alternate-file . nil) - (tmm-menubar . nil)) - "Alist of handlers to replace `completing-read', `read-file-name' in `helm-mode'. -Each entry is a cons cell like \(emacs_command . completing-read_handler\) -where key and value are symbols. - -Each key is an Emacs command that use originaly `completing-read'. - -Each value maybe an helm function that take same arguments as -`completing-read' plus NAME and BUFFER, where NAME is the name of the new -helm source and BUFFER the name of the buffer we will use. -This function prefix name must start by \"helm\". - -See `helm-completing-read-symbols' for example. - -Note that this function will be reused for ALL the `completing-read' -of this command, so it should handle all cases, e.g -If first `completing-read' complete against symbols and -second `completing-read' should handle only buffer, -your specialized function should handle the both. - -If the value of an entry is nil completion will fall back to -emacs vanilla behavior. -e.g If you want to disable helm completion for `describe-function': -\(describe-function . nil\). - -Ido is also supported, you can use `ido-completing-read' and -`ido-read-file-name' as value of an entry or just 'ido. -e.g ido completion for `find-file': -\(find-file . ido\) -same as -\(find-file . ido-read-file-name\) -Note that you don't need to enable `ido-mode' for this to work." - :group 'helm-mode - :type '(alist :key-type symbol :value-type symbol)) - -(defcustom helm-comp-read-case-fold-search helm-case-fold-search - "Default Local setting of `helm-case-fold-search' for `helm-comp-read'. -See `helm-case-fold-search' for more info." - :group 'helm-mode - :type 'symbol) - -(defcustom helm-mode-handle-completion-in-region t - "Whether to replace or not `completion-in-region-function'. -This enable support for `completing-read-multiple' and `completion-at-point' -when non--nil." - :group 'helm-mode - :type 'boolean) - -(defcustom helm-mode-reverse-history t - "Display history source after current source in `helm-mode' handled commands." - :group 'helm-mode - :type 'boolean) - - -(defvar helm-comp-read-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "") 'helm-cr-empty-string) - map) - "Keymap for `helm-comp-read'.") - - -;;; Internal -;; -;; -;; Flag to know if `helm-pattern' have been added -;; to candidate list in `helm-comp-read'. -(defvar helm-cr-unknown-pattern-flag nil) - - -;;; Helm `completing-read' replacement -;; -;; -(defun helm-cr-empty-string () - "Return empty string." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action - #'(lambda (_candidate) - (identity ""))))) - -(defun helm-comp-read-get-candidates (collection &optional test sort-fn alistp) - "Convert COLLECTION to list removing elements that don't match TEST. -See `helm-comp-read' about supported COLLECTION arguments. - -SORT-FN is a predicate to sort COLLECTION. - -ALISTP when non--nil will not use `all-completions' to collect -candidates because it doesn't handle alists correctly for helm. -i.e In `all-completions' the car of each pair is used as value. -In helm we want to use the cdr instead like \(display . real\), -so we return the alist as it is with no transformation by all-completions. - -e.g - -\(setq A '((a . 1) (b . 2) (c . 3))) -==>((a . 1) (b . 2) (c . 3)) -\(helm-comp-read \"test: \" A :alistp nil - :exec-when-only-one t - :initial-input \"a\") -==>\"a\" Which is not what we expect. - -\(helm-comp-read \"test: \" A :alistp t - :exec-when-only-one t - :initial-input \"1\") -==>\"1\" - -See docstring of `all-completions' for more info. - -If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." - - (let ((cands - (cond ((vectorp collection) - (all-completions "" collection test)) - ((and (symbolp collection) (boundp collection) - ;; Issue #324 history is let-bounded and given - ;; quoted as hist argument of completing-read. - ;; See example in `rcirc-browse-url'. - (symbolp (symbol-value collection))) - nil) - ;; When collection is a symbol, most of the time - ;; it should be a symbol used as a minibuffer-history. - ;; The value of this symbol in this case return a list - ;; of string which maybe are converted later as symbol - ;; in special cases. - ;; we treat here commandp as a special case as it return t - ;; also with a string unless its last arg is provided. - ;; Also, the history collections generally collect their - ;; elements as string, so intern them to call predicate. - ((and (symbolp collection) (boundp collection) test) - (let ((predicate `(lambda (elm) - (condition-case err - (if (eq (quote ,test) 'commandp) - (funcall (quote ,test) (intern elm)) - (funcall (quote ,test) elm)) - (wrong-type-argument - (funcall (quote ,test) (intern elm))))))) - (all-completions "" (symbol-value collection) predicate))) - ((and (symbolp collection) (boundp collection)) - (all-completions "" (symbol-value collection))) - ((and alistp test) - (cl-loop for i in collection when (funcall test i) collect i)) - (alistp collection) - (t (all-completions "" collection test))))) - (if sort-fn (sort cands sort-fn) cands))) - -(defun helm-cr-default-transformer (candidates _source) - "Default filter candidate function for `helm-comp-read'." - (cl-loop for c in candidates - for cand = (if (stringp c) (replace-regexp-in-string "\\s\\" "" c) c) - for pat = (replace-regexp-in-string "\\s\\" "" helm-pattern) - if (and (equal cand pat) helm-cr-unknown-pattern-flag) - collect - (cons (concat (propertize - " " 'display - (propertize "[?]" 'face 'helm-ff-prefix)) - c) - c) - into lst - else collect c into lst - finally return (helm-fast-remove-dups lst :test 'equal))) - -;;;###autoload -(cl-defun helm-comp-read (prompt collection - &key - test - initial-input - default - preselect - (buffer "*Helm Completions*") - must-match - reverse-history - (requires-pattern 0) - history - input-history - (case-fold helm-comp-read-case-fold-search) - (del-input t) - (persistent-action nil) - (persistent-help "DoNothing") - (mode-line helm-comp-read-mode-line) - (keymap helm-comp-read-map) - (name "Helm Completions") - candidates-in-buffer - exec-when-only-one - quit-when-no-cand - (volatile t) - sort - (fc-transformer 'helm-cr-default-transformer) - marked-candidates - nomark - (alistp t)) - "Read a string in the minibuffer, with helm completion. - -It is helm `completing-read' equivalent. - -- PROMPT is the prompt name to use. - -- COLLECTION can be a list, vector, obarray or hash-table. - It can be also a function that receives three arguments: - the values string, predicate and t. See `all-completions' for more details. - -Keys description: - -- TEST: A predicate called with one arg i.e candidate. - -- INITIAL-INPUT: Same as input arg in `helm'. - -- PRESELECT: See preselect arg of `helm'. - -- DEFAULT: This option is used only for compatibility with regular - Emacs `completing-read' (Same as DEFAULT arg of `completing-read'). - -- BUFFER: Name of helm-buffer. - -- MUST-MATCH: Candidate selected must be one of COLLECTION. - -- REVERSE-HISTORY: When non--nil display history source after current - source completion. - -- REQUIRES-PATTERN: Same as helm attribute, default is 0. - -- HISTORY: A list containing specific history, default is nil. - When it is non--nil, all elements of HISTORY are displayed in - a special source before COLLECTION. - -- INPUT-HISTORY: A symbol. the minibuffer input history will be - stored there, if nil or not provided, `minibuffer-history' - will be used instead. - -- CASE-FOLD: Same as `helm-case-fold-search'. - -- DEL-INPUT: Boolean, when non--nil (default) remove the partial - minibuffer input from HISTORY is present. - -- PERSISTENT-ACTION: A function called with one arg i.e candidate. - -- PERSISTENT-HELP: A string to document PERSISTENT-ACTION. - -- MODE-LINE: A string or list to display in mode line. - Default is `helm-comp-read-mode-line'. - -- KEYMAP: A keymap to use in this `helm-comp-read'. - (the keymap will be shared with history source) - -- NAME: The name related to this local source. - -- EXEC-WHEN-ONLY-ONE: Bound `helm-execute-action-at-once-if-one' - to non--nil. (possibles values are t or nil). - -- VOLATILE: Use volatile attribute \(enabled by default\). - -- SORT: A predicate to give to `sort' e.g `string-lessp'. - -- FC-TRANSFORMER: A `filtered-candidate-transformer' function. - -- MARKED-CANDIDATES: If non--nil return candidate or marked candidates as a list. - -- NOMARK: When non--nil don't allow marking candidates. - -- ALISTP: \(default is non--nil\) See `helm-comp-read-get-candidates'. - -- CANDIDATES-IN-BUFFER: when non--nil use a source build with - `helm-candidates-in-buffer' which is much faster. - Argument VOLATILE have no effect when CANDIDATES-IN-BUFFER is non--nil. - -Any prefix args passed during `helm-comp-read' invocation will be recorded -in `helm-current-prefix-arg', otherwise if prefix args were given before -`helm-comp-read' invocation, the value of `current-prefix-arg' will be used. -That's mean you can pass prefix args before or after calling a command -that use `helm-comp-read' See `helm-M-x' for example." - - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - (let ((action-fn `(("Sole action (Identity)" - . (lambda (candidate) - (if ,marked-candidates - (helm-marked-candidates) - (identity candidate))))))) - ;; Assume completion have been already required, - ;; so always use 'confirm. - (when (eq must-match 'confirm-after-completion) - (setq must-match 'confirm)) - (let* ((minibuffer-completion-confirm must-match) - (must-match-map (when must-match - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") - 'helm-confirm-and-exit-minibuffer) - map))) - (loc-map (if must-match-map - (make-composed-keymap - must-match-map (or keymap helm-map)) - (or keymap helm-map))) - (helm-read-file-name-mode-line-string - (replace-regexp-in-string "helm-maybe-exit-minibuffer" - "helm-confirm-and-exit-minibuffer" - helm-read-file-name-mode-line-string)) - (get-candidates (lambda () - (let ((cands (helm-comp-read-get-candidates - collection test sort alistp))) - (setq helm-cr-unknown-pattern-flag nil) - (unless (or (eq must-match t) - (string= helm-pattern "") - (assoc helm-pattern cands) - (assoc (intern helm-pattern) cands) - (member helm-pattern cands)) - (setq cands (append (list - ;; Unquote helm-pattern - ;; when it is added - ;; as candidate. - (replace-regexp-in-string - "\\s\\" "" helm-pattern)) - cands)) - (setq helm-cr-unknown-pattern-flag t)) - (if (and default (not (string= default ""))) - (delq nil (cons default (delete default cands))) - cands)))) - (history-get-candidates (lambda () - (let ((all (helm-comp-read-get-candidates - history test nil alistp))) - (when all - (delete - "" - (helm-fast-remove-dups - (if (and default (not (string= default ""))) - (delq nil (cons default - (delete default all))) - all) - :test 'equal)))))) - (src-hist `((name . ,(format "%s History" name)) - (candidates . ,history-get-candidates) - (filtered-candidate-transformer - . (lambda (candidates sources) - (cl-loop for i in candidates - ;; Input is added to history in completing-read's - ;; and may be regexp-quoted, so unquote it. - for cand = (replace-regexp-in-string "\\s\\" "" i) - do (set-text-properties 0 (length cand) nil cand) - collect cand))) - (persistent-action . ,persistent-action) - (persistent-help . ,persistent-help) - (keymap . ,loc-map) - (mode-line . ,mode-line) - (action . ,action-fn))) - (src `((name . ,name) - (candidates . ,get-candidates) - (filtered-candidate-transformer . ,fc-transformer) - (requires-pattern . ,requires-pattern) - (persistent-action . ,persistent-action) - (persistent-help . ,persistent-help) - (keymap . ,loc-map) - (mode-line . ,mode-line) - (action . ,action-fn))) - (src-1 `((name . ,name) - (init . (lambda () - (helm-init-candidates-in-buffer - 'global (funcall ',get-candidates)))) - (candidates-in-buffer) - (filtered-candidate-transformer . ,fc-transformer) - (requires-pattern . ,requires-pattern) - (persistent-action . ,persistent-action) - (persistent-help . ,persistent-help) - (keymap . ,loc-map) - (mode-line . ,mode-line) - (action . ,action-fn))) - (src-list (list src-hist - (if candidates-in-buffer - src-1 - (if volatile - (append src '((volatile))) - src)))) - (helm-execute-action-at-once-if-one exec-when-only-one) - (helm-quit-if-no-candidate quit-when-no-cand) - result) - (when nomark - (setq src-list (cl-loop for src in src-list - collect (cons '(nomark) src)))) - (when reverse-history (setq src-list (nreverse src-list))) - (setq result (helm - :sources src-list - :input initial-input - :default default - :preselect preselect - :prompt prompt - :resume 'noresume - :case-fold-search case-fold - :keymap loc-map - :history (and (symbolp input-history) input-history) - :buffer buffer)) - ;; Avoid adding an incomplete input to history. - (when (and result history del-input) - (cond ((and (symbolp history) ; History is a symbol. - (not (symbolp (symbol-value history)))) ; Fix Issue #324. - ;; Be sure history is not a symbol with a nil value. - (helm-aif (symbol-value history) (setcar it result))) - ((consp history) ; A list with a non--nil value. - (setcar history result)) - (t ; Possibly a symbol with a nil value. - (set history (list result))))) - (or - result - (when (and (eq helm-exit-status 0) - (eq must-match 'confirm)) - ;; Return empty string only if it is the DEFAULT - ;; value and helm-pattern is empty. - ;; otherwise return helm-pattern - (if (and (string= helm-pattern "") default) - default (identity helm-pattern))) - (unless (or (eq helm-exit-status 1) - must-match) ; FIXME this should not be needed now. - default) - (keyboard-quit))))) - -;; Generic completing-read -;; -;; Support also function as collection. -;; e.g M-x man is supported. -;; Support hash-table and vectors as collection. -;; NOTE: -;; Some crap emacs functions may not be supported -;; like ffap-alternate-file (bad use of completing-read) -;; and maybe others. -;; Provide a mode `helm-mode' which turn on -;; helm in all `completing-read' and `read-file-name' in Emacs. -;; -(defvar helm-completion-mode-string " Helm") - -(defvar helm-completion-mode-quit-message - "Helm completion disabled") - -(defvar helm-completion-mode-start-message - "Helm completion enabled") - -;;; Specialized handlers -;; -;; -(defun helm-completing-read-symbols - (prompt _collection test _require-match init - hist default _inherit-input-method name buffer) - "Specialized function for fast symbols completion in `helm-mode'." - (or - (helm - :sources `((name . ,name) - (init . (lambda () - (with-current-buffer (helm-candidate-buffer 'global) - (goto-char (point-min)) - (when (and ,default (stringp ,default) - ;; Some defaults args result as - ;; (symbol-name nil) == "nil". - ;; e.g debug-on-entry. - (not (string= ,default "nil")) - (not (string= ,default ""))) - (insert (concat ,default "\n"))) - (cl-loop for sym in (all-completions "" obarray ',test) - for s = (intern sym) - unless (or (and ,default (string= sym ,default)) - (keywordp s)) - do (insert (concat sym "\n")))))) - ;; FIXME for some reason I have to reload keymap - ;; here because it is overhidden by minibuf loc map. - ;; This shouldn't be needed. - (keymap . ,helm-map) - (persistent-action . helm-lisp-completion-persistent-action) - (persistent-help . "Show brief doc in mode-line") - (candidates-in-buffer) - (action . identity)) - :prompt prompt - :buffer buffer - :input init - :history hist - :resume 'noresume - :default (or default "")) - (keyboard-quit))) - - -;;; Generic completing read -;; -;; -(defun helm-completing-read-default-1 - (prompt collection test require-match - init hist default _inherit-input-method - name buffer &optional cands-in-buffer exec-when-only-one) - "Call `helm-comp-read' with same args as `completing-read'. -Extra optional arg CANDS-IN-BUFFER mean use `candidates-in-buffer' -method which is faster. -It should be used when candidate list don't need to rebuild dynamically." - (let ((history (or (car-safe hist) hist))) - (when (and default (listp default)) - ;; When DEFAULT is a list move the list on head of COLLECTION - ;; and set it to its car. #bugfix `grep-read-files'. - (setq collection (if (listp collection) - (append default collection) - ;; Else COLLECTION is maybe a function or a table. - (append default (all-completions "" collection)))) - (setq default (car default))) - (helm-comp-read - prompt collection - :test test - :history history - :reverse-history helm-mode-reverse-history - :input-history history - :must-match require-match - :alistp nil ; Be sure `all-completions' is used. - :name name - :requires-pattern (if (and (string= default "") - (or (eq require-match 'confirm) - (eq require-match - 'confirm-after-completion))) - 1 0) - :candidates-in-buffer cands-in-buffer - :exec-when-only-one exec-when-only-one - :buffer buffer - ;; If DEF is not provided, fallback to empty string - ;; to avoid `thing-at-point' to be appended on top of list - :default (or default "") - ;; Fail with special characters (e.g in gnus "nnimap+gmail:") - ;; if regexp-quote is not used. - ;; when init is added to history, it will be unquoted by - ; helm-comp-read. - :initial-input (and (stringp init) (regexp-quote init))))) - -(defun helm-completing-read-with-cands-in-buffer - (prompt collection test require-match - init hist default inherit-input-method - name buffer) - "Same as `helm-completing-read-default-1' but use candidates-in-buffer." - ;; Some commands like find-tag may use `read-file-name' from inside - ;; the calculation of collection. in this case it clash with - ;; candidates-in-buffer that reuse precedent data (files) which is wrong. - ;; So (re)calculate collection outside of main helm-session. - (let ((cands (all-completions "" collection))) - (helm-completing-read-default-1 prompt cands test require-match - init hist default inherit-input-method - name buffer t))) - -(cl-defun helm--completing-read-default - (prompt collection &optional - predicate require-match - initial-input hist def - inherit-input-method) - "An helm replacement of `completing-read'. -This function should be used only as a `completing-read-function'. - -Don't use it directly, use instead `helm-comp-read' in your programs. - -See documentation of `completing-read' and `all-completions' for details." - (let* ((current-command (or (helm-this-command) this-command)) - (str-command (if (consp current-command) ; Maybe a lambda. - "Anonymous" - (symbol-name current-command))) - (buf-name (format "*helm-mode-%s*" str-command)) - (entry (assq current-command - helm-completing-read-handlers-alist)) - (def-com (cdr-safe entry)) - (str-defcom (and def-com (symbol-name def-com))) - (def-args (list prompt collection predicate require-match - initial-input hist def inherit-input-method)) - ;; Append the two extra args needed to set the buffer and source name - ;; in helm specialized functions. - (any-args (append def-args (list str-command buf-name))) - helm-completion-mode-start-message ; Be quiet - helm-completion-mode-quit-message - ;; Be sure this pesty *completion* buffer doesn't popup. - ;; Note: `minibuffer-with-setup-hook' may setup a lambda - ;; calling `minibuffer-completion-help' or other minibuffer - ;; functions we DONT WANT here, in these cases removing the hook - ;; (a symbol) have no effect. Issue #448. - ;; But because `minibuffer-completion-table' and - ;; `minibuffer-completion-predicate' are not bound - ;; anymore here, these functions should have no effect now. - (minibuffer-setup-hook (remove 'minibuffer-completion-help - minibuffer-setup-hook)) - ;; Disable hack that could be used before `completing-read'. - ;; i.e (push ?\t unread-command-events). - unread-command-events) - (when (eq def-com 'ido) (setq def-com 'ido-completing-read)) - (unless (or (not entry) def-com) - ;; An entry in *read-handlers-alist exists but have - ;; a nil value, so we exit from here, disable `helm-mode' - ;; and run the command again with it original behavior. - ;; `helm-mode' will be restored on exit. - (cl-return-from helm--completing-read-default - (unwind-protect - (progn - (helm-mode -1) - (apply completing-read-function def-args)) - (helm-mode 1)))) - ;; If we use now `completing-read' we MUST turn off `helm-mode' - ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. - (when (or (eq def-com 'completing-read) - ;; All specialized functions are prefixed by "helm" - (and (stringp str-defcom) - (not (string-match "^helm" str-defcom)))) - (helm-mode -1)) - (unwind-protect - (cond (;; An helm specialized function exists, run it. - (and def-com helm-mode) - (apply def-com any-args)) - (;; Try to handle `ido-completing-read' everywhere. - (and def-com (eq def-com 'ido-completing-read)) - (setcar (memq collection def-args) - (all-completions "" collection predicate)) - (apply def-com def-args)) - (;; User set explicitely `completing-read' or something similar - ;; in *read-handlers-alist, use this with exactly the same - ;; args as in `completing-read'. - ;; If we are here `helm-mode' is now disabled. - def-com - (apply def-com def-args)) - (t ; Fall back to classic `helm-comp-read'. - (helm-completing-read-default-1 - prompt collection predicate require-match - initial-input hist def inherit-input-method - str-command buf-name))) - (helm-mode 1) - ;; When exiting minibuffer, `this-command' is set to - ;; `helm-exit-minibuffer', which is unwanted when starting - ;; on another `completing-read', so restore `this-command' to - ;; initial value when exiting. - (setq this-command current-command)))) - -;;; Generic read-file-name -;; -;; -(cl-defun helm-read-file-name - (prompt - &key - (name "Read File Name") - (initial-input (expand-file-name default-directory)) - (buffer "*Helm file completions*") - test - (case-fold helm-file-name-case-fold-search) - preselect - history - must-match - default - marked-candidates - nomark - (alistp t) - (persistent-action 'helm-find-files-persistent-action) - (persistent-help "Hit1 Expand Candidate, Hit2 or (C-u) Find file") - (mode-line helm-read-file-name-mode-line-string)) - "Read a file name with helm completion. -It is helm `read-file-name' emulation. - -Argument PROMPT is the default prompt to use. - -Keys description: - -- NAME: Source name, default to \"Read File Name\". - -- INITIAL-INPUT: Where to start read file name, default to `default-directory'. - -- BUFFER: `helm-buffer' name default to \"*Helm Completions*\". - -- TEST: A predicate called with one arg 'candidate'. - -- CASE-FOLD: Same as `helm-case-fold-search'. - -- PRESELECT: helm preselection. - -- HISTORY: Display HISTORY in a special source. - -- MUST-MATCH: Can be 'confirm, nil, or t. - -- MARKED-CANDIDATES: When non--nil return a list of marked candidates. - -- NOMARK: When non--nil don't allow marking candidates. - -- ALISTP: Don't use `all-completions' in history (take effect only on history). - -- PERSISTENT-ACTION: a persistent action function. - -- PERSISTENT-HELP: persistent help message. - -- MODE-LINE: A mode line message, default is `helm-read-file-name-mode-line-string'." - - (when (get-buffer helm-action-buffer) - (kill-buffer helm-action-buffer)) - ;; Assume completion have been already required, - ;; so always use 'confirm. - (when (eq must-match 'confirm-after-completion) - (setq must-match 'confirm)) - (let* ((action-fn `(("Sole action (Identity)" - . (lambda (candidate) - (if ,marked-candidates - (helm-marked-candidates :with-wildcard t) - (identity candidate)))))) - (helm-mp-highlight-delay nil) - ;; Be sure we don't erase the underlying minibuffer if some. - (helm-ff-auto-update-initial-value - (and helm-ff-auto-update-initial-value - (not (minibuffer-window-active-p (minibuffer-window))))) - helm-full-frame - (hist (and history (helm-comp-read-get-candidates - history nil nil alistp))) - (minibuffer-completion-confirm must-match) - (must-match-map (when must-match - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") - 'helm-confirm-and-exit-minibuffer) - map))) - (cmap (if must-match-map - (make-composed-keymap - must-match-map helm-read-file-map) - helm-read-file-map)) - (helm-read-file-name-mode-line-string - (replace-regexp-in-string "helm-maybe-exit-minibuffer" - "helm-confirm-and-exit-minibuffer" - helm-read-file-name-mode-line-string)) - (src-list `(((name . ,(format "%s History" name)) - (header-name . (lambda (hname) - (concat hname - helm-find-files-doc-header))) - (mode-line . ,mode-line) - (candidates . ,hist) - (keymap . ,cmap) - (persistent-action . ,persistent-action) - (persistent-help . ,persistent-help) - (action . ,action-fn)) - ((name . ,name) - (header-name . (lambda (hname) - (concat hname - helm-find-files-doc-header))) - (init . (lambda () - (setq helm-ff-auto-update-flag - helm-ff-auto-update-initial-value) - (setq helm-ff-auto-update--state - helm-ff-auto-update-flag) - (helm-set-local-variable 'helm-in-file-completion-p t))) - (mode-line . ,mode-line) - (candidates - . (lambda () - (append (and (not (file-exists-p helm-pattern)) - (list helm-pattern)) - (if ',test - (cl-loop with hn = (helm-ff-tramp-hostnames) - for i in (helm-find-files-get-candidates - ',must-match) - when (or (member i hn) ; A tramp host - (funcall ',test i)) ; Test ok - collect i) - (helm-find-files-get-candidates ',must-match))))) - (filtered-candidate-transformer . helm-ff-sort-candidates) - (filter-one-by-one . helm-ff-filter-candidate-one-by-one) - (keymap . ,cmap) - (persistent-action . ,persistent-action) - (candidate-number-limit . 9999) - (persistent-help . ,persistent-help) - (volatile) - (action . ,action-fn)))) - (result (helm - :sources (if nomark - (cl-loop for src in src-list - collect (cons '(nomark) src)) - src-list) - :input initial-input - :prompt prompt - :resume 'noresume - :case-fold-search case-fold - :default default - :buffer buffer - :preselect preselect))) - (or - (cond ((and result (stringp result) - (string= result "") "")) - ((and result - (stringp result) - (file-equal-p result initial-input) - default) - default) - ((and result (stringp result)) - (expand-file-name result)) - ((and result (listp result)) - (mapcar #'expand-file-name result)) - (t result)) - (when (and (not (string= helm-pattern "")) - (eq helm-exit-status 0) - (eq must-match 'confirm)) - (identity helm-pattern)) - (keyboard-quit)))) - -(cl-defun helm--generic-read-file-name - (prompt &optional dir default-filename mustmatch initial predicate) - "Generic helm replacement of `read-file-name'. -Don't use it directly, use instead `helm-read-file-name' in your programs." - (let* ((init (or initial dir default-directory)) - (current-command (or (helm-this-command) this-command)) - (str-command (symbol-name current-command)) - (helm-file-completion-sources - (cons str-command - (remove str-command helm-file-completion-sources))) - (buf-name (format "*helm-mode-%s*" str-command)) - (entry (assq current-command - helm-completing-read-handlers-alist)) - (def-com (cdr-safe entry)) - (str-defcom (and def-com (symbol-name def-com))) - (def-args (list prompt dir default-filename mustmatch initial predicate)) - ;; Append the two extra args needed to set the buffer and source name - ;; in helm specialized functions. - (any-args (append def-args (list str-command buf-name))) - (ido-state ido-mode) - helm-completion-mode-start-message ; Be quiet - helm-completion-mode-quit-message ; Same here - fname) - ;; Some functions that normally call `completing-read' can switch - ;; brutally to `read-file-name' (e.g find-tag), in this case - ;; the helm specialized function will fail because it is build - ;; for `completing-read', so set it to 'incompatible to be sure - ;; we switch to `helm-read-file-name' and don't try to call it - ;; with wrong number of args. - (when (eq def-com 'ido) - (setq def-com 'ido-read-file-name) (ido-mode 1)) - (when (and def-com (> (length (help-function-arglist def-com)) 8)) - (setq def-com 'incompatible)) - (unless (or (not entry) def-com) - (cl-return-from helm--generic-read-file-name - (unwind-protect - (progn - (helm-mode -1) - (apply read-file-name-function def-args)) - (helm-mode 1)))) - ;; If we use now `read-file-name' we MUST turn off `helm-mode' - ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. - (when (or (eq def-com 'read-file-name) - (eq def-com 'ido-read-file-name) - (and (stringp str-defcom) - (not (string-match "^helm" str-defcom)))) - (helm-mode -1)) - (unwind-protect - (setq fname - (cond (;; A specialized function exists, run it - ;; with the two extra args specific to helm.. - (and def-com helm-mode - (not (eq def-com 'ido-read-file-name)) - (not (eq def-com 'incompatible))) - (apply def-com any-args)) - (;; Def-com value is `ido-read-file-name' - ;; run it with default args. - (and def-com (eq def-com 'ido-read-file-name)) - (ido-mode 1) - (apply def-com def-args)) - (;; Def-com value is `read-file-name' - ;; run it with default args. - (eq def-com 'read-file-name) - (apply def-com def-args)) - (t ; Fall back to classic `helm-read-file-name'. - (helm-read-file-name - prompt - :name str-command - :buffer buf-name - :default default-filename - :initial-input (expand-file-name init dir) - :alistp nil - :must-match mustmatch - :test predicate)))) - (helm-mode 1) - (ido-mode (if ido-state 1 -1)) - ;; Same comment as in `helm--completing-read-default'. - (setq this-command current-command)) - fname)) - -(defun helm-mode--advice-lisp--local-variables (old--fn &rest args) - (ignore-errors - (apply old--fn args))) - -(defun helm--completion-in-region (start end collection &optional predicate) - "[EXPERIMENTAL] Helm replacement of `completion--in-region'. -Can be used as value for `completion-in-region-function'." - (cl-declare (special require-match prompt)) - (advice-add - 'lisp--local-variables - :around #'helm-mode--advice-lisp--local-variables) - (unwind-protect - (let* ((enable-recursive-minibuffers t) - (input (buffer-substring-no-properties start end)) - (current-command (or (helm-this-command) this-command)) - (str-command (symbol-name current-command)) - (buf-name (format "*helm-mode-%s*" str-command)) - (require-match (or (and (boundp 'require-match) require-match) - minibuffer-completion-confirm - ;; If prompt have not been propagated here, that's - ;; probably mean we have no prompt and we are in - ;; completion-at-point or friend, so use a non--nil - ;; value for require-match. - (not (boundp 'prompt)))) - ;; `completion-extra-properties' is let-bounded in `completion-at-point'. - ;; `afun' is a closure to call against each string in `data'. - ;; it provide the annotation info for each string. - ;; e.g "foo" => "foo " where foo is a function. - ;; See Issue #407. - (afun (plist-get completion-extra-properties :annotation-function)) - (data (all-completions input collection predicate)) - (file-comp-p (helm-mode--in-file-completion-p input (car data))) - ;; Completion-at-point and friends have no prompt. - (result (helm-comp-read - (or (and (boundp 'prompt) prompt) "Pattern: ") - (if file-comp-p - (cl-loop for f in data unless - (string-match "\\`\\.\\{1,2\\}/\\'" f) - collect f) - (if afun - (mapcar (lambda (s) - (let ((ann (funcall afun s))) - (if ann - (cons - (concat - s - (propertize - " " 'display - (propertize - ann - 'face 'completions-annotations))) - s) - s))) - data) - data)) - :name str-command - :nomark t - :initial-input - (cond ((and file-comp-p - (not (string-match "/\\'" input))) - (concat (helm-basename input) - (unless (string= input "") " "))) - ((string-match "/\\'" input) nil) - ((or (null require-match) - (stringp require-match)) - input) - (t (concat input " "))) - :buffer buf-name - :fc-transformer (append (list 'helm-cr-default-transformer) - (list (lambda (candidates _source) - (sort candidates 'helm-generic-sort-fn)))) - :exec-when-only-one t - :quit-when-no-cand - #'(lambda () - ;; Delay message to overwrite "Quit". - (run-with-timer - 0.01 nil - #'(lambda () - (message "[No matches]"))) - t) ; exit minibuffer immediately. - :must-match require-match))) - (when result - (delete-region (if (and file-comp-p - (save-excursion - (re-search-backward "~?/" start t))) - (match-end 0) start) - end) - (insert (if file-comp-p - (shell-quote-argument result) - result)))) - (advice-remove 'lisp--local-variables - #'helm-mode--advice-lisp--local-variables))) - -(defun helm-mode--in-file-completion-p (target candidate) - (when (and candidate target) - (or (string-match "/\\'" candidate) - (string-match "/\\'" target) - (if (string-match "~?/" target) - (file-exists-p (expand-file-name candidate (helm-basedir target))) - (file-exists-p (expand-file-name - candidate (with-helm-current-buffer - default-directory))))))) - -(when (boundp 'completion-in-region-function) - (defconst helm--old-completion-in-region-function completion-in-region-function)) - -;;;###autoload -(define-minor-mode helm-mode - "Toggle generic helm completion. - -All functions in Emacs that use `completing-read' -or `read-file-name' and friends will use helm interface -when this mode is turned on. -However you can modify this behavior for functions of your choice -with `helm-completing-read-handlers-alist'. - -Called with a positive arg, turn on unconditionally, with a -negative arg turn off. -You can turn it on with `helm-mode'. - -Some crap emacs functions may not be supported, -e.g `ffap-alternate-file' and maybe others -You can add such functions to `helm-completing-read-handlers-alist' -with a nil value. - -Note: This mode is incompatible with Emacs23." - :group 'helm-mode - :global t - :lighter helm-completion-mode-string - (cl-assert (boundp 'completing-read-function) nil - "`helm-mode' not available, upgrade to Emacs-24") - (if helm-mode - (progn - (setq completing-read-function 'helm--completing-read-default - read-file-name-function 'helm--generic-read-file-name) - (when (and (boundp 'completion-in-region-function) - helm-mode-handle-completion-in-region) - (setq completion-in-region-function #'helm--completion-in-region)) - (message helm-completion-mode-start-message)) - (setq completing-read-function (and (fboundp 'completing-read-default) - 'completing-read-default) - read-file-name-function (and (fboundp 'read-file-name-default) - 'read-file-name-default)) - (when (and (boundp 'completion-in-region-function) - (boundp 'helm--old-completion-in-region-function)) - (setq completion-in-region-function helm--old-completion-in-region-function)) - (message helm-completion-mode-quit-message))) - -(provide 'helm-mode) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-mode.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-net.el b/emacs.d/elpa/helm-20141016.2217/helm-net.el deleted file mode 100644 index 4e9d3dc..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-net.el +++ /dev/null @@ -1,607 +0,0 @@ -;;; helm-net.el --- helm browse url and search web. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'url) -(require 'xml) -(require 'browse-url) - - -(defgroup helm-net nil - "Net related applications and libraries for Helm." - :group 'helm) - -(defcustom helm-google-suggest-default-browser-function nil - "The browse url function you prefer to use with google suggest. -When nil, use the first browser function available -See `helm-browse-url-default-browser-alist'." - :group 'helm-net - :type 'symbol) - -(defcustom helm-home-url "http://www.google.fr" - "Default url to use as home url." - :group 'helm-net - :type 'string) - -(defcustom helm-surfraw-default-browser-function nil - "The browse url function you prefer to use with surfraw. -When nil, fallback to `browse-url-browser-function'." - :group 'helm-net - :type 'symbol) - -(defcustom helm-google-suggest-url - "http://google.com/complete/search?output=toolbar&q=" - "URL used for looking up Google suggestions." - :type 'string - :group 'helm-net) - -(defcustom helm-google-suggest-search-url - "http://www.google.com/search?ie=utf-8&oe=utf-8&q=" - "URL used for Google searching." - :type 'string - :group 'helm-net) - -(defcustom helm-google-suggest-use-curl-p nil - "When non--nil use CURL to get info from `helm-google-suggest-url'. -Otherwise `url-retrieve-synchronously' is used." - :type 'boolean - :group 'helm-net) - -(defcustom helm-yahoo-suggest-url - "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=Generic&query=" - "Url used for looking up Yahoo suggestions." - :type 'string - :group 'helm-net) - -(defcustom helm-yahoo-suggest-search-url - "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p=" - "Url used for Yahoo searching." - :type 'string - :group 'helm-net) - -(defcustom helm-surfraw-duckduckgo-url - "https://duckduckgo.com/lite/?q=%s&kp=1" - "The duckduckgo url. -This is a format string, don't forget the `%s'. -If you have personal settings saved on duckduckgo you should have -a personal url, see your settings on duckduckgo." - :type 'string - :group 'helm-net) - -(defcustom helm-wikipedia-suggest-url - "http://en.wikipedia.org/w/api.php?action=opensearch&search=" - "Url used for looking up Wikipedia suggestions." - :type 'string - :group 'helm-net) - -(defcustom helm-search-suggest-action-wikipedia-url - "https://en.wikipedia.org/wiki/Special:Search?search=%s" - "The Wikipedia search url. -This is a format string, don't forget the `%s'." - :type 'string - :group 'helm-net) - -(defcustom helm-wikipedia-summary-url - "http://en.wikipedia.org/w/api.php?action=parse&format=json&prop=text§ion=0&page=" - "URL for getting the summary of a Wikipedia topic." - :type 'string - :group 'helm-net) - -(defcustom helm-wikipedia-follow-delay 2 - "Delay before wikipedia summary popup." - :type 'number - :group 'helm-net) - -(defcustom helm-search-suggest-action-youtube-url - "http://www.youtube.com/results?aq=f&search_query=%s" - "The Youtube search url. -This is a format string, don't forget the `%s'." - :type 'string - :group 'helm-net) - -(defcustom helm-search-suggest-action-imdb-url - "http://www.imdb.com/find?s=all&q=%s" - "The IMDb search url. -This is a format string, don't forget the `%s'." - :type 'string - :group 'helm-net) - -(defcustom helm-search-suggest-action-google-maps-url - "http://maps.google.com/maps?f=q&source=s_q&q=%s" - "The Google Maps search url. -This is a format string, don't forget the `%s'." - :type 'string - :group 'helm-net) - -(defcustom helm-search-suggest-action-google-news-url - "http://www.google.com/search?safe=off&prmd=nvlifd&source=lnms&tbs=nws:1&q=%s" - "The Google News search url. -This is a format string, don't forget the `%s'." - :type 'string - :group 'helm-net) - - -;;; Additional actions for search suggestions -;; -;; -;; Internal - -(defun helm-search-suggest-perform-additional-action (url query) - "Perform the search via URL using QUERY as input." - (browse-url (format url (url-hexify-string query)))) - -(defvar helm-search-suggest-additional-actions - '(("Wikipedia" . (lambda (candidate) - (helm-search-suggest-perform-additional-action - helm-search-suggest-action-wikipedia-url - candidate))) - ("Youtube" . (lambda (candidate) - (helm-search-suggest-perform-additional-action - helm-search-suggest-action-youtube-url - candidate))) - ("IMDb" . (lambda (candidate) - (helm-search-suggest-perform-additional-action - helm-search-suggest-action-imdb-url - candidate))) - ("Google Maps" . (lambda (candidate) - (helm-search-suggest-perform-additional-action - helm-search-suggest-action-google-maps-url - candidate))) - ("Google News" . (lambda (candidate) - (helm-search-suggest-perform-additional-action - helm-search-suggest-action-google-news-url - candidate)))) - "List of additional actions for suggest sources.") - - -;;; Google Suggestions -;; -;; -;; Internal -(defvar helm-ggs-max-length-real-flag 0) -(defvar helm-ggs-max-length-num-flag 0) - -(defun helm-google-suggest-fetch (input) - "Fetch suggestions for INPUT from XML buffer. -Return an alist with elements like (data . number_results)." - (setq helm-ggs-max-length-real-flag 0 - helm-ggs-max-length-num-flag 0) - (let ((request (concat helm-google-suggest-url - (url-hexify-string input))) - (fetch #'(lambda () - (cl-loop - with result-alist = (xml-get-children - (car (xml-parse-region - (point-min) (point-max))) - 'CompleteSuggestion) - for i in result-alist - for data = (cdr (cl-caadr (assoc 'suggestion i))) - for nqueries = (cdr (cl-caadr (assoc 'num_queries i))) - for lqueries = (length (helm-ggs-set-number-result - nqueries)) - for ldata = (length data) - do - (progn - (when (> ldata helm-ggs-max-length-real-flag) - (setq helm-ggs-max-length-real-flag ldata)) - (when (> lqueries helm-ggs-max-length-num-flag) - (setq helm-ggs-max-length-num-flag lqueries))) - collect (cons data nqueries) into cont - finally return cont)))) - (if helm-google-suggest-use-curl-p - (with-temp-buffer - (call-process "curl" nil t nil request) - (funcall fetch)) - (with-current-buffer - (url-retrieve-synchronously request) - (funcall fetch))))) - -(defun helm-google-suggest-set-candidates (&optional request-prefix) - "Set candidates with result and number of google results found." - (let ((suggestions - (cl-loop with suggested-results = (helm-google-suggest-fetch - (or (and request-prefix - (concat request-prefix - " " helm-pattern)) - helm-pattern)) - for (real . numresult) in suggested-results - ;; Prepare number of results with "," - for fnumresult = (helm-ggs-set-number-result numresult) - ;; Calculate number of spaces to add before fnumresult - ;; if it is smaller than longest result - ;; `helm-ggs-max-length-num-flag'. - ;; e.g 1,234,567 - ;; 345,678 - ;; To be sure it is aligned properly. - for nspaces = (if (< (length fnumresult) - helm-ggs-max-length-num-flag) - (- helm-ggs-max-length-num-flag - (length fnumresult)) - 0) - ;; Add now the spaces before fnumresult. - for align-fnumresult = (concat (make-string nspaces ? ) - fnumresult) - for interval = (- helm-ggs-max-length-real-flag - (length real)) - for spaces = (make-string (+ 2 interval) ? ) - for display = (format "%s%s(%s results)" - real spaces align-fnumresult) - collect (cons display real)))) - (if (cl-loop for (_disp . dat) in suggestions - thereis (equal dat helm-pattern)) - suggestions - ;; if there is no suggestion exactly matching the input then - ;; prepend a Search on Google item to the list - (append - suggestions - (list (cons (concat "Search for " "'" helm-input "'" " on Google") - helm-input)))))) - -(defun helm-ggs-set-number-result (num) - (if num - (progn - (and (numberp num) (setq num (number-to-string num))) - (cl-loop for i in (reverse (split-string num "" t)) - for count from 1 - append (list i) into C - when (= count 3) - append (list ",") into C - and do (setq count 0) - finally return - (replace-regexp-in-string - "^," "" (mapconcat 'identity (reverse C) "")))) - "?")) - -(defun helm-google-suggest-action (candidate) - "Default action to jump to a google suggested candidate." - (let ((arg (concat helm-google-suggest-search-url - (url-hexify-string candidate)))) - (helm-aif helm-google-suggest-default-browser-function - (funcall it arg) - (helm-browse-url arg)))) - -(defvar helm-google-suggest-default-function - 'helm-google-suggest-set-candidates - "Default function to use in helm google suggest.") - -(defvar helm-source-google-suggest - `((name . "Google Suggest") - (candidates . (lambda () - (funcall helm-google-suggest-default-function))) - (action . ,(cons '("Google Search" . helm-google-suggest-action) - helm-search-suggest-additional-actions)) - (volatile) - (keymap . ,helm-map) - (requires-pattern . 3))) - -(defun helm-google-suggest-emacs-lisp () - "Try to emacs lisp complete with google suggestions." - (helm-google-suggest-set-candidates "emacs lisp")) - - -;;; Yahoo suggestions -;; -;; -(defun helm-yahoo-suggest-fetch (input) - "Fetch Yahoo suggestions for INPUT from XML buffer. -Return an alist with elements like (data . number_results)." - (let ((request (concat helm-yahoo-suggest-url - (url-hexify-string input)))) - (with-current-buffer - (url-retrieve-synchronously request) - (cl-loop with result-alist = - (xml-get-children - (car (xml-parse-region - (point-min) (point-max))) - 'Result) - for i in result-alist - collect (cl-caddr i))))) - -(defun helm-yahoo-suggest-set-candidates () - "Set candidates with Yahoo results found." - (let ((suggestions (helm-yahoo-suggest-fetch helm-input))) - (or suggestions - (append - suggestions - (list (cons (concat "Search for " "'" helm-input "'" " on Yahoo") - helm-input)))))) - -(defun helm-yahoo-suggest-action (candidate) - "Default action to jump to a Yahoo suggested candidate." - (helm-browse-url (concat helm-yahoo-suggest-search-url - (url-hexify-string candidate)))) - -(defvar helm-source-yahoo-suggest - `((name . "Yahoo Suggest") - (candidates . helm-yahoo-suggest-set-candidates) - (action . (("Yahoo Search" . helm-yahoo-suggest-action))) - (volatile) - (keymap . ,helm-map) - (requires-pattern . 3))) - -;;; Wikipedia suggestions -;; -;; -(declare-function json-read-from-string "json" (string)) -(defun helm-wikipedia-suggest-fetch () - "Fetch Wikipedia suggestions and return them as a list." - (require 'json) - (let ((request (concat helm-wikipedia-suggest-url - (url-hexify-string helm-pattern)))) - (if helm-google-suggest-use-curl-p - (with-temp-buffer - (call-process "curl" nil t nil request) - (helm-wikipedia--parse-buffer)) - (with-current-buffer - (url-retrieve-synchronously request) - (helm-wikipedia--parse-buffer))))) - -(defun helm-wikipedia--parse-buffer () - (goto-char (point-min)) - (when (re-search-forward "^\\[.+\\[\\(.*\\)\\]\\]" nil t) - (cl-loop for i across (aref (json-read-from-string (match-string 0)) 1) - collect i into result - finally return (or result - (append - result - (list (cons (format "Search for '%s' on wikipedia" - helm-pattern) - helm-pattern))))))) - -(defvar helm-wikipedia--summary-cache (make-hash-table :test 'equal)) -(defun helm-wikipedia-persistent-action (candidate) - (unless (string= (format "Search for '%s' on wikipedia" - helm-pattern) - (helm-get-selection nil t)) - (message "Fetching summary from Wikipedia...") - (let ((buf (get-buffer-create "*helm wikipedia summary*")) - result mess) - (while (progn - (setq result (or (gethash candidate helm-wikipedia--summary-cache) - (puthash candidate - (prog1 - (helm-wikipedia-fetch-summary candidate) - (setq mess "Done")) - helm-wikipedia--summary-cache))) - (when (and result - (listp result)) - (setq candidate (cdr result)) - (message "Redirected to %s" candidate) - t))) - (if (not result) - (message "Error when getting summary.") - (with-current-buffer buf - (erase-buffer) - (setq cursor-type nil) - (insert result) - (fill-region (point-min) (point-max)) - (goto-char (point-min))) - (display-buffer buf) - (message mess))))) - - -(defun helm-wikipedia-fetch-summary (input) - (let* ((request (concat helm-wikipedia-summary-url (url-hexify-string input)))) - (if helm-google-suggest-use-curl-p - (with-temp-buffer - (call-process "curl" nil t nil request) - (helm-wikipedia--parse-summary)) - (with-current-buffer - (url-retrieve-synchronously request) - (helm-wikipedia--parse-summary))))) - - -(defun helm-wikipedia--parse-summary () - (goto-char (point-min)) - (when (search-forward "{" nil t) - (let ((result (cdr (assoc '* - (assoc 'text - (assoc 'parse - (json-read-from-string - (buffer-substring-no-properties - (1- (point)) (point-max))))))))) - (when result - (if (string-match "]+>\\([^<]+\\)" result) - (cons 'redirect (match-string 1 result)) - - ;; find the beginning of the summary text in the result - - ;; check if there is a table before the summary and skip that - (when (or (string-match "\\(\n\\)?\n

" result) - ;; otherwise just find the first paragraph - (string-match "

" result)) - ;; remove cruft and do a simple formatting - (replace-regexp-in-string - "Cite error: .*" "" - (replace-regexp-in-string - " " "" - (replace-regexp-in-string - "\\[[^\]]+\\]" "" - (replace-regexp-in-string - "<[^>]*>" "" - (replace-regexp-in-string - "

\n

" "\n\n" - (substring result (match-end 0))))))))))))) - - -(defvar helm-source-wikipedia-suggest - `((name . "Wikipedia Suggest") - (candidates . helm-wikipedia-suggest-fetch) - (action . (("Wikipedia" . (lambda (candidate) - (helm-search-suggest-perform-additional-action - helm-search-suggest-action-wikipedia-url - candidate))))) - (persistent-action . helm-wikipedia-persistent-action) - (volatile) - (keymap . ,helm-map) - (follow . 1) - (follow-delay . ,helm-wikipedia-follow-delay) - (requires-pattern . 3))) - - -;;; Web browser functions. -;; -;; -;; If default setting of `w3m-command' is not -;; what you want and you modify it, you will have to reeval -;; also `helm-browse-url-default-browser-alist'. - -(defvar helm-browse-url-chromium-program "chromium-browser") -(defvar helm-browse-url-uzbl-program "uzbl-browser") -(defvar helm-browse-url-conkeror-program "conkeror") -(defvar helm-browse-url-default-browser-alist - `((,(or (and (boundp 'w3m-command) w3m-command) - "/usr/bin/w3m") . w3m-browse-url) - (,browse-url-firefox-program . browse-url-firefox) - (,helm-browse-url-chromium-program . helm-browse-url-chromium) - (,helm-browse-url-conkeror-program . helm-browse-url-conkeror) - (,helm-browse-url-uzbl-program . helm-browse-url-uzbl) - (,browse-url-kde-program . browse-url-kde) - (,browse-url-gnome-moz-program . browse-url-gnome-moz) - (,browse-url-mozilla-program . browse-url-mozilla) - (,browse-url-galeon-program . browse-url-galeon) - (,browse-url-netscape-program . browse-url-netscape) - (,browse-url-mosaic-program . browse-url-mosaic) - (,browse-url-xterm-program . browse-url-text-xterm) - ("emacs" . eww-browse-url)) - "*Alist of \(executable . function\) to try to find a suitable url browser.") - -(cl-defun helm-generic-browser (url cmd-name &rest args) - "Browse URL with NAME browser." - (let ((proc (concat cmd-name " " url))) - (message "Starting %s..." cmd-name) - (apply 'start-process proc nil cmd-name - (append args (list url))) - (set-process-sentinel - (get-process proc) - #'(lambda (process event) - (when (string= event "finished\n") - (message "%s process %s" process event)))))) - -(defun helm-browse-url-chromium (url &optional _ignore) - "Browse URL with google chrome browser." - (interactive "sURL: ") - (helm-generic-browser - url helm-browse-url-chromium-program)) - -(defun helm-browse-url-uzbl (url &optional _ignore) - "Browse URL with uzbl browser." - (interactive "sURL: ") - (helm-generic-browser url helm-browse-url-uzbl-program "-u")) - -(defun helm-browse-url-conkeror (url &optional _ignore) - "Browse URL with conkeror browser." - (interactive "sURL: ") - (helm-generic-browser url helm-browse-url-conkeror-program)) - -(defun helm-browse-url-default-browser (url &rest args) - "Find the first available browser and ask it to load URL." - (let ((default-browser-fn - (cl-loop for (exe . fn) in helm-browse-url-default-browser-alist - thereis (and exe (executable-find exe) (fboundp fn) fn)))) - (if default-browser-fn - (apply default-browser-fn url args) - (error "No usable browser found")))) - -(defun helm-browse-url (url &rest args) - "Default command to browse URL." - (if browse-url-browser-function - (browse-url url args) - (helm-browse-url-default-browser url args))) - - -;;; Surfraw -;; -;; Need external program surfraw. -;; - -;; Internal -(defvar helm-surfraw-engines-history nil) -(defvar helm-surfraw-input-history nil) -(defvar helm-surfraw--elvi-cache nil) - -(defun helm-build-elvi-list () - "Return list of all engines and descriptions handled by surfraw." - (or helm-surfraw--elvi-cache - (setq helm-surfraw--elvi-cache - (cdr (with-temp-buffer - (call-process "surfraw" nil t nil "-elvi") - (split-string (buffer-string) "\n")))))) - -;;;###autoload -(defun helm-surfraw (pattern engine) - "Preconfigured `helm' to search PATTERN with search ENGINE." - (interactive (list (read-string "SearchFor: " - nil 'helm-surfraw-input-history - (thing-at-point 'symbol)) - (helm-comp-read - "Engine: " - (helm-build-elvi-list) - :must-match t - :name "Surfraw Search Engines" - :del-input nil - :history helm-surfraw-engines-history))) - (let* ((engine-nodesc (car (split-string engine))) - (url (if (string= engine-nodesc "duckduckgo") - ;; "sr duckduckgo -p foo" is broken, workaround. - (format helm-surfraw-duckduckgo-url - (url-hexify-string pattern)) - (with-temp-buffer - (apply 'call-process "surfraw" nil t nil - (append (list engine-nodesc "-p") (split-string pattern))) - (replace-regexp-in-string - "\n" "" (buffer-string))))) - (browse-url-browser-function (or helm-surfraw-default-browser-function - browse-url-browser-function))) - (if (string= engine-nodesc "W") - (helm-browse-url helm-home-url) - (helm-browse-url url) - (setq helm-surfraw-engines-history - (cons engine (delete engine helm-surfraw-engines-history)))))) - -;;;###autoload -(defun helm-google-suggest () - "Preconfigured `helm' for google search with google suggest." - (interactive) - (helm-other-buffer 'helm-source-google-suggest "*helm google*")) - -;;;###autoload -(defun helm-yahoo-suggest () - "Preconfigured `helm' for Yahoo searching with Yahoo suggest." - (interactive) - (helm-other-buffer 'helm-source-yahoo-suggest "*helm yahoo*")) - -;;;###autoload -(defun helm-wikipedia-suggest () - "Preconfigured `helm' for Wikipedia lookup with Wikipedia suggest." - (interactive) - (helm :sources 'helm-source-wikipedia-suggest - :buffer "*helm wikipedia*")) - - -(provide 'helm-net) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-net.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-org.el b/emacs.d/elpa/helm-20141016.2217/helm-org.el deleted file mode 100644 index a0f7724..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-org.el +++ /dev/null @@ -1,185 +0,0 @@ -;;; helm-org.el --- Helm for org headlines and keywords completion -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: -(require 'cl-lib) -(require 'helm) -(require 'helm-plugin) -(require 'org) - -(declare-function org-get-current-options "ext:org-exp.el") - -;;; Org headlines -;; -;; -(defvar helm-source-org-headline - `((name . "Org Headline") - (headline - ,@(mapcar - (lambda (num) - (format "^\\*\\{%d\\} \\(.+?\\)\\([ \t]*:[[:lower:][:upper:]0-9_@:]+:\\)?[ \t]*$" - num)) - (number-sequence 1 8))) - (condition . (eq major-mode 'org-mode)) - (migemo) - (subexp . 1) - (persistent-action . (lambda (elm) - (helm-action-line-goto elm) - (org-cycle))) - (action-transformer - . (lambda (actions candidate) - '(("Go to line" . helm-action-line-goto) - ("Refile to this headline" . helm-org-headline-refile) - ("Insert link to this headline" - . helm-org-headline-insert-link-to-headline))))) - "Show Org headlines. -org-mode is very very much extended text-mode/outline-mode. - -See (find-library \"org.el\") -See http://orgmode.org for the latest version.") - -(defun helm-org-headline-insert-link-to-headline (lineno-and-content) - (insert - (save-excursion - (helm-goto-line (car lineno-and-content)) - (and (looking-at org-complex-heading-regexp) - (org-make-link-string (concat "*" (match-string 4))))))) - -(defun helm-org-headline-refile (lineno-and-content) - "Refile current org entry to LINENO-AND-CONTENT." - (with-helm-current-buffer - (org-cut-subtree) - (helm-goto-line (car lineno-and-content)) - (org-end-of-subtree t t) - (let ((org-yank-adjusted-subtrees t)) - (org-yank)))) - - -;;; Org keywords -;; -;; Stop supporting this in emacs-24.3.50.1. -(when (boundp 'org-additional-option-like-keywords) - (defvar helm-source-org-keywords - '((name . "Org Keywords") - (init . helm-org-keywords-init) - (candidates . helm-org-keywords-candidates) - (action . helm-org-keywords-insert) - (persistent-action . helm-org-keywords-show-help) - (persistent-help . "Show an example and info page to describe this keyword.") - (keywords-examples) - (keywords))) - - (defvar helm-org-keywords-info-location - '(("#+TITLE:" . "(org)Export options") - ("#+AUTHOR:" . "(org)Export options") - ("#+DATE:" . "(org)Export options") - ("#+EMAIL:" . "(org)Export options") - ("#+DESCRIPTION:" . "(org)Export options") - ("#+KEYWORDS:" . "(org)Export options") - ("#+LANGUAGE:" . "(org)Export options") - ("#+TEXT:" . "(org)Export options") - ("#+TEXT:" . "(org)Export options") - ("#+OPTIONS:" . "(org)Export options") - ("#+BIND:" . "(org)Export options") - ("#+LINK_UP:" . "(org)Export options") - ("#+LINK_HOME:" . "(org)Export options") - ("#+LATEX_HEADER:" . "(org)Export options") - ("#+EXPORT_SELECT_TAGS:" . "(org)Export options") - ("#+EXPORT_EXCLUDE_TAGS:" . "(org)Export options") - ("#+INFOJS_OPT" . "(org)Javascript support") - ("#+BEGIN_HTML" . "(org)Quoting HTML tags") - ("#+BEGIN_LaTeX" . "(org)Quoting LaTeX code") - ("#+ORGTBL" . "(org)Radio tables") - ("#+HTML:" . "(org)Quoting HTML tags") - ("#+LaTeX:" . "(org)Quoting LaTeX code") - ("#+BEGIN:" . "(org)Dynamic blocks") ;clocktable columnview - ("#+BEGIN_EXAMPLE" . "(org)Literal examples") - ("#+BEGIN_QUOTE" . "(org)Paragraphs") - ("#+BEGIN_VERSE" . "(org)Paragraphs") - ("#+BEGIN_SRC" . "(org)Literal examples") - ("#+CAPTION" . "(org)Tables in HTML export") - ("#+LABEL" . "(org)Tables in LaTeX export") - ("#+ATTR_HTML" . "(org)Links") - ("#+ATTR_LaTeX" . "(org)Images in LaTeX export"))) - - (defun helm-org-keywords-init () - (unless (helm-attr 'keywords-examples) - (require 'org) - (helm-attrset 'keywords-examples - (append - (mapcar - (lambda (x) - (string-match "^#\\+\\(\\([[:upper:]_]+:?\\).*\\)" x) - (cons (match-string 2 x) (match-string 1 x))) - (org-split-string (org-get-current-options) "\n")) - (mapcar 'list org-additional-option-like-keywords))) - (helm-attrset 'keywords (mapcar 'car (helm-attr 'keywords-examples))))) - - (defun helm-org-keywords-candidates () - (and (or (eq (buffer-local-value 'major-mode helm-current-buffer) 'org-mode) - (eq (buffer-local-value 'major-mode helm-current-buffer) 'message-mode)) - (helm-attr 'keywords))) - - (defun helm-org-keywords-insert (keyword) - (cond ((and (string-match "BEGIN" keyword) - (helm-region-active-p)) - (let ((beg (region-beginning)) - (end (region-end))) - (goto-char end) - (insert "\n#+" (replace-regexp-in-string - "BEGIN" "END" keyword) "\n") - (goto-char beg) - (insert "#+" keyword " ") - (save-excursion (insert "\n")))) - ((string-match "BEGIN" keyword) - (insert "#+" keyword " ") - (save-excursion - (insert "\n#+" (replace-regexp-in-string - "BEGIN" "END" keyword) "\n"))) - (t (insert "#+" keyword " ")))) - - (defun helm-org-keywords-show-help (keyword) - (info (or (assoc-default (concat "#+" keyword) helm-org-keywords-info-location) - "(org)In-buffer settings")) - (search-forward (concat "#+" keyword) nil t) - (helm-highlight-current-line) - (message "%s" (or (cdr (assoc keyword (helm-attr 'keywords-examples))) "")))) - -;;;###autoload -(defun helm-org-keywords () - "Preconfigured `helm' for org keywords." - (interactive) - (cl-assert (boundp 'org-additional-option-like-keywords) nil - "Helm-org-keyword not supported in %s" emacs-version) - (helm-other-buffer 'helm-source-org-keywords "*org keywords*")) - -;;;###autoload -(defun helm-org-headlines () - "Preconfigured helm to show org headlines." - (interactive) - (helm-other-buffer 'helm-source-org-headline "*org headlines*")) - - -(provide 'helm-org) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-org.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-pkg.el b/emacs.d/elpa/helm-20141016.2217/helm-pkg.el deleted file mode 100644 index c5b881f..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-pkg.el +++ /dev/null @@ -1,7 +0,0 @@ -(define-package "helm" "20141016.2217" "Helm is an Emacs incremental and narrowing framework" - '((emacs "24") - (cl-lib "0.5") - (async "1.2"))) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/helm-20141016.2217/helm-plugin.el b/emacs.d/elpa/helm-20141016.2217/helm-plugin.el deleted file mode 100644 index c3ac31e..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-plugin.el +++ /dev/null @@ -1,344 +0,0 @@ -;;; helm-plugin.el --- Helm plugins -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) - -(declare-function Info-index-nodes "info" (&optional file)) -(declare-function Info-goto-node "info" (&optional fork)) -(declare-function Info-find-node "info.el" (filename nodename &optional no-going-back)) - - -;;; Plug-in: `info-index' -;; -;; -(defvar Info-history) -(cl-defun helm-info-init (&optional (file (helm-attr 'info-file))) - ;; Allow reinit candidate buffer when using edebug. - (helm-aif (and debug-on-error - (helm-candidate-buffer)) - (kill-buffer it)) - (unless (helm-candidate-buffer) - (save-window-excursion - (info file) - (let (Info-history - (tobuf (helm-candidate-buffer 'global)) - (infobuf (current-buffer)) - s e - (nodes (or (helm-attr 'index-nodes) (Info-index-nodes)))) - (cl-dolist (node nodes) - (Info-goto-node node) - (goto-char (point-min)) - (while (search-forward "\n* " nil t) - (unless (search-forward "Menu:\n" (1+ (point-at-eol)) t) - (save-current-buffer (buffer-substring-no-properties - (point-at-bol) (point-at-eol))) - (setq s (point-at-bol) - e (point-at-eol)) - (with-current-buffer tobuf - (insert-buffer-substring infobuf s e) - (insert "\n"))))))))) - -(defun helm-info-goto (node-line) - (Info-goto-node (car node-line)) - (helm-goto-line (cdr node-line))) - -(defun helm-info-display-to-real (line) - (and (string-match - ;; This regexp is stolen from Info-apropos-matches - "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line) - (cons (format "(%s)%s" (helm-attr 'info-file) (match-string 2 line)) - (string-to-number (or (match-string 3 line) "1"))))) - -(defun helm-make-info-source (source file) - `(,@source - (name . ,(concat "Info Index: " file)) - (info-file . ,file) - (init . helm-info-init) - (display-to-real . helm-info-display-to-real) - (get-line . buffer-substring) - (candidates-in-buffer) - (action ("Goto node" . helm-info-goto)))) - -(defun helm-compile-source--info-index (source) - (helm-aif (helm-interpret-value (assoc-default 'info-index source)) - (helm-make-info-source source it) - source)) - -(add-to-list 'helm-compile-source-functions 'helm-compile-source--info-index) - -(helm-document-attribute 'info-index "info-index plugin" - " Create a source of info index very easily. - - Example: - - (defvar helm-source-info-wget '((info-index . \"wget\"))") - -(helm-document-attribute 'index-nodes "info-index plugin (optional)" - " Index nodes of info file. - - If it is omitted, `Info-index-nodes' is used to collect index - nodes. Some info files are missing index specification. - - See `helm-source-info-screen'.") - - -;;; Plug-in: `candidates-file' -;; -;; List all lines in a file. -(defun helm-compile-source--candidates-file (source) - (if (assoc-default 'candidates-file source) - `((init helm-p-candidates-file-init - ,@(let ((orig-init (assoc-default 'init source))) - (cond ((null orig-init) nil) - ((functionp orig-init) (list orig-init)) - (t orig-init)))) - (candidates-in-buffer) - ,@source) - source)) -(add-to-list 'helm-compile-source-functions 'helm-compile-source--candidates-file) - -(defun helm-p-candidates-file-init () - (cl-destructuring-bind (file &optional updating) - (helm-mklist (helm-attr 'candidates-file)) - (setq file (helm-interpret-value file)) - (with-current-buffer (helm-candidate-buffer 'global) - (insert-file-contents file) - (when updating - (buffer-disable-undo) - (font-lock-mode -1) - (auto-revert-mode 1))))) - -(helm-document-attribute 'candidates-file "candidates-file plugin" - " Use a file as the candidates buffer. - - 1st argument is a filename, string or function name or variable - name. If optional 2nd argument is non-nil, the file is opened with - `auto-revert-mode' enabled. - - Example: - - \(defvar helm-source-test-file - '((name . \"test1\") - (candidates-file \"~/.emacs.el\" t))) - - Will list all lines in .emacs.el.") - - -;;; Plug-in: `headline' -;; -;; -(defun helm-compile-source--helm-headline (source) - (if (assoc-default 'headline source) - (append '((init . helm-headline-init) - (get-line . buffer-substring) - (type . line)) - source - '((candidates-in-buffer) - (persistent-help . "Show this line"))) - source)) -(add-to-list 'helm-compile-source-functions 'helm-compile-source--helm-headline) - -(defun helm-headline-init () - (when (and (helm-current-buffer-is-modified) - (with-helm-current-buffer - (eval (or (helm-attr 'condition) t)))) - (helm-headline-make-candidate-buffer - (helm-interpret-value (helm-attr 'headline)) - (helm-interpret-value (helm-attr 'subexp))))) - -(helm-document-attribute 'headline "Headline plug-in" - " Regexp string for helm-headline to scan.") -(helm-document-attribute 'condition "Headline plug-in" - " A sexp representing the condition to use helm-headline.") -(helm-document-attribute 'subexp "Headline plug-in" - " Display (match-string-no-properties subexp).") - -(defun helm-headline-get-candidates (regexp subexp) - (with-helm-current-buffer - (save-excursion - (goto-char (point-min)) - (if (functionp regexp) (setq regexp (funcall regexp))) - (let ((matched - #'(lambda () - (if (numberp subexp) - (cons (match-string-no-properties subexp) - (match-beginning subexp)) - (cons (buffer-substring (point-at-bol) (point-at-eol)) - (point-at-bol))))) - (arrange - #'(lambda (headlines) - (unless (null headlines) ; FIX headlines empty bug! - (cl-loop with curhead = (make-vector - (1+ (cl-loop for (_ . hierarchy) in headlines - maximize hierarchy)) - "") - for ((str . pt) . hierarchy) in headlines - do (aset curhead hierarchy str) - collecting - (cons - (format "H%d:%s" (1+ hierarchy) - (mapconcat 'identity - (cl-loop for i from 0 to hierarchy - collecting (aref curhead i)) - " / ")) - pt)))))) - (if (listp regexp) - (funcall arrange - (sort - (cl-loop for re in regexp - for hierarchy from 0 - do (goto-char (point-min)) - appending - (cl-loop - while (re-search-forward re nil t) - collect (cons (funcall matched) hierarchy))) - (lambda (a b) (> (cdar b) (cdar a))))) - (cl-loop while (re-search-forward regexp nil t) - collect (funcall matched))))))) - -(defun helm-headline-make-candidate-buffer (regexp subexp) - (with-current-buffer (helm-candidate-buffer 'local) - (cl-loop for (content . pos) in (helm-headline-get-candidates regexp subexp) - do (insert - (format "%5d:%s\n" - (with-helm-current-buffer - (line-number-at-pos pos)) - content))))) - -(defun helm-headline-goto-position (pos recenter) - (goto-char pos) - (unless recenter - (set-window-start (get-buffer-window helm-current-buffer) (point)))) - - -;;; Plug-in: `persistent-help' -;; -;; Add help about persistent action in `helm-buffer' header. -(defun helm-compile-source--persistent-help (source) - (if (assoc 'header-line source) - source - (append source '((header-line . helm-persistent-help-string))))) -(add-to-list 'helm-compile-source-functions 'helm-compile-source--persistent-help) - -(defun helm-persistent-help-string () - (substitute-command-keys - (concat "\\\\[helm-execute-persistent-action]: " - (or (helm-interpret-value (helm-attr 'persistent-help)) - (helm-aif (or (assoc-default - 'persistent-action - (helm-get-current-source)) - (assoc-default - 'action (helm-get-current-source))) - (cond ((symbolp it) - (symbol-name it)) - ((listp it) - (or (ignore-errors (caar it)) "")))) - "") - " (keeping session)"))) - -(defun helm-display-to-real-numbered-line (candidate) - "This is used to display a line in occur style in helm sources. -e.g \" 12:some_text\". -It is used with type attribute 'line'." - (if (string-match "^ *\\([0-9]+\\):\\(.*\\)$" candidate) - (list (string-to-number (match-string 1 candidate)) - (match-string 2 candidate)) - (error "Line number not found"))) - - -;;; Type attributes -;; -;; -(define-helm-type-attribute 'line - '((display-to-real . helm-display-to-real-numbered-line) - (action ("Go to Line" . helm-action-line-goto))) - "LINENO:CONTENT string, eg. \" 16:foo\". - -Optional `target-file' attribute is a name of target file. - -Optional `before-jump-hook' attribute is a function with no -arguments which is called before jumping to position. - -Optional `after-jump-hook' attribute is a function with no -arguments which is called after jumping to position. - -If `adjust' attribute is specified, searches the line whose -content is CONTENT near the LINENO. - -If `recenter' attribute is specified, the line is displayed at -the center of window, otherwise at the top of window.") - -(define-helm-type-attribute 'file-line - `((filtered-candidate-transformer helm-filtered-candidate-transformer-file-line) - (multiline) - (action ("Go to" . helm-action-file-line-goto))) - "FILENAME:LINENO:CONTENT string, eg. \"~/.emacs:16:;; comment\". - -Optional `default-directory' attribute is a default-directory -FILENAME is interpreted. - -Optional `before-jump-hook' attribute is a function with no -arguments which is called before jumping to position. - -Optional `after-jump-hook' attribute is a function with no -arguments which is called after jumping to position. - -If `adjust' attribute is specified, searches the line whose -content is CONTENT near the LINENO. - -If `recenter' attribute is specified, the line is displayed at -the center of window, otherwise at the top of window.") - - -;;; Document new attributes -;; -;; -(helm-document-attribute 'persistent-help "persistent-help plug-in" - " A string to explain persistent-action of this source. It also - accepts a function or a variable name.") - -(helm-document-attribute 'default-directory "type . file-line" - " `default-directory' to interpret file.") - -(helm-document-attribute 'before-jump-hook "type . file-line / line" - " Function to call before jumping to the target location.") - -(helm-document-attribute 'after-jump-hook "type . file-line / line" - " Function to call after jumping to the target location.") - -(helm-document-attribute 'adjust "type . file-line" - " Search around line matching line contents.") - -(helm-document-attribute 'recenter "type . file-line / line" - " `recenter' after jumping.") - -(helm-document-attribute 'target-file "type . line" - " Goto line of target-file.") - -(provide 'helm-plugin) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-plugin ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-regexp.el b/emacs.d/elpa/helm-20141016.2217/helm-regexp.el deleted file mode 100644 index 2f382e8..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-regexp.el +++ /dev/null @@ -1,623 +0,0 @@ -;;; helm-regexp.el --- In buffer regexp searching and replacement for helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-plugin) - - -(defgroup helm-regexp nil - "Regexp related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-moccur-always-search-in-current nil - "Helm multi occur always search in current buffer when non--nil." - :group 'helm-regexp - :type 'boolean) - -(defcustom helm-moccur-use-ioccur-style-keys t - "Similar to `helm-grep-use-ioccur-style-keys' but for multi occur." - :group 'helm-regexp - :type 'boolean) - -(defcustom helm-moccur-auto-update-on-resume nil - "Allow auto updating helm-(m)occur buffer when outdated. -noask => Always update without asking -nil => Don't update but signal buffer needs update -never => Never update and do not signal buffer needs update -Any other non--nil value update after confirmation." - :group 'helm-regexp - :type '(radio :tag "Allow auto updating helm-(m)occur buffer when outdated." - (const :tag "Always update without asking" noask) - (const :tag "Never update and do not signal buffer needs update" never) - (const :tag "Don't update but signal buffer needs update" nil) - (const :tag "Update after confirmation" t))) - - -(defface helm-moccur-buffer - '((t (:foreground "DarkTurquoise" :underline t))) - "Face used to highlight moccur buffer names." - :group 'helm-regexp) - -(defface helm-resume-need-update - '((t (:background "red"))) - "Face used to flash moccur buffer when it needs update." - :group 'helm-regexp) - - -(defvar helm-moccur-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-") 'helm-goto-next-file) - (define-key map (kbd "M-") 'helm-goto-precedent-file) - (define-key map (kbd "C-w") 'helm-yank-text-at-point) - (define-key map (kbd "C-c ?") 'helm-moccur-help) - (define-key map (kbd "C-c o") 'helm-moccur-run-goto-line-ow) - (define-key map (kbd "C-c C-o") 'helm-moccur-run-goto-line-of) - (define-key map (kbd "C-x C-s") 'helm-moccur-run-save-buffer) - (when helm-moccur-use-ioccur-style-keys - (define-key map (kbd "") 'helm-execute-persistent-action) - (define-key map (kbd "") 'helm-moccur-run-default-action)) - (delq nil map)) - "Keymap used in Moccur source.") - - -(defvar helm-build-regexp-history nil) -(defun helm-query-replace-regexp (_candidate) - "Query replace regexp from `helm-regexp'. -With a prefix arg replace only matches surrounded by word boundaries, -i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." - (let ((regexp (funcall (helm-attr 'regexp)))) - (apply 'query-replace-regexp - (helm-query-replace-args regexp)))) - -(defun helm-kill-regexp-as-sexp (_candidate) - "Kill regexp in a format usable in lisp code." - (helm-regexp-kill-new - (prin1-to-string (funcall (helm-attr 'regexp))))) - -(defun helm-kill-regexp (_candidate) - "Kill regexp as it is in `helm-pattern'." - (helm-regexp-kill-new (funcall (helm-attr 'regexp)))) - -(defun helm-query-replace-args (regexp) - "create arguments of `query-replace-regexp' action in `helm-regexp'." - (let ((region-only (helm-region-active-p))) - (list - regexp - (query-replace-read-to regexp - (format "Query replace %sregexp %s" - (if helm-current-prefix-arg "word " "") - (if region-only "in region " "")) - t) - helm-current-prefix-arg - (when region-only (region-beginning)) - (when region-only (region-end))))) - -(defvar helm-source-regexp - '((name . "Regexp Builder") - (init . (lambda () - (helm-init-candidates-in-buffer - 'global (with-temp-buffer - (insert-buffer-substring helm-current-buffer) - (buffer-string))))) - (candidates-in-buffer) - (get-line . helm-regexp-get-line) - (persistent-action . helm-regexp-persistent-action) - (persistent-help . "Show this line") - (multiline) - (no-matchplugin) - (requires-pattern . 2) - (mode-line . "Press TAB to select action.") - (regexp . (lambda () helm-input)) - (action . (("Kill Regexp as sexp" . helm-kill-regexp-as-sexp) - ("Query Replace Regexp (C-u Not inside word.)" - . helm-query-replace-regexp) - ("Kill Regexp" . helm-kill-regexp))))) - -(defun helm-regexp-get-line (s e) - (let ((matches (match-data)) - (line (buffer-substring s e))) - (propertize - (cl-loop with ln = (format "%5d: %s" (line-number-at-pos (1- s)) line) - for i from 0 to (1- (/ (length matches) 2)) - concat (format "\n %s'%s'" (format "Group %d: " i) - (match-string i)) - into ln1 - finally return (concat ln ln1)) - ;; match beginning - ;; KLUDGE: point of helm-candidate-buffer is +1 than that of helm-current-buffer. - ;; It is implementation problem of candidates-in-buffer. - 'helm-realvalue (1- s)))) - -(defun helm-regexp-persistent-action (pt) - (helm-goto-char pt) - (helm-highlight-current-line)) - -(defun helm-regexp-kill-new (input) - (kill-new input) - (message "Killed: %s" input)) - -(defun helm-quote-whitespace (candidate) - "Quote whitespace, if some, in string CANDIDATE." - (replace-regexp-in-string " " "\\\\ " candidate)) - - -;;; Occur -;; -;; -(defvar helm-source-occur nil) -(defun helm-occur-init-source () - (unless helm-source-occur - (setq helm-source-occur - (helm-make-source "Occur" 'helm-source-multi-occur)))) - - -;;; Multi occur -;; -;; - -;; Internal -(defvar helm-multi-occur-buffer-list nil) -(defvar helm-multi-occur-buffer-tick nil) -(defun helm-moccur-init () - "Create the initial helm multi occur buffer." - (helm-init-candidates-in-buffer - 'global - (cl-loop with buffers = (helm-attr 'moccur-buffers) - for buf in buffers - for bufstr = (with-current-buffer buf (buffer-string)) - do (add-text-properties - 0 (length bufstr) - `(buffer-name ,(buffer-name (get-buffer buf))) - bufstr) - concat bufstr))) - -(defun helm-moccur-get-line (beg end) - "Format line for `helm-source-moccur'." - (format "%s:%d:%s" - (get-text-property beg 'buffer-name) - (save-restriction - (narrow-to-region (previous-single-property-change - (point) 'buffer-name) - (next-single-property-change - (point) 'buffer-name)) - (line-number-at-pos beg)) - (buffer-substring beg end))) - -(cl-defun helm-moccur-action (candidate - &optional (method (quote buffer)) mark) - "Jump to CANDIDATE with METHOD. -arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame." - (require 'helm-grep) - (let* ((split (helm-grep-split-line candidate)) - (buf (car split)) - (lineno (string-to-number (nth 1 split))) - (split-pat (if helm-occur-match-plugin-mode - (helm-mp-split-pattern helm-pattern) - (list helm-pattern)))) - (cl-case method - (buffer (switch-to-buffer buf)) - (buffer-other-window (switch-to-buffer-other-window buf)) - (buffer-other-frame (switch-to-buffer-other-frame buf))) - (helm-goto-line lineno) - ;; Move point to the nearest matching regexp from bol. - (cl-loop for reg in split-pat - when (save-excursion - (re-search-forward reg (point-at-eol) t)) - collect (match-beginning 0) into pos-ls - finally (when pos-ls (goto-char (apply #'min pos-ls)))) - (when mark - (set-marker (mark-marker) (point)) - (push-mark (point) 'nomsg)))) - -(defun helm-moccur-persistent-action (candidate) - (helm-moccur-goto-line candidate) - (helm-highlight-current-line)) - -(defun helm-moccur-goto-line (candidate) - "From multi occur, switch to buffer and go to nth 1 CANDIDATE line." - (helm-moccur-action - candidate 'buffer (or current-prefix-arg ; persistent. - helm-current-prefix-arg))) ; exit. - -(defun helm-moccur-goto-line-ow (candidate) - "Go to CANDIDATE line in other window. -Same as `helm-moccur-goto-line' but go in other window." - (helm-moccur-action - candidate 'buffer-other-window - (or current-prefix-arg ; persistent. - helm-current-prefix-arg))) ; exit. - -(defun helm-moccur-goto-line-of (candidate) - "Go to CANDIDATE line in new frame. -Same as `helm-moccur-goto-line' but go in new frame." - (helm-moccur-action - candidate 'buffer-other-frame - (or current-prefix-arg ; persistent. - helm-current-prefix-arg))) ; exit. - -(defun helm-moccur-run-goto-line-ow () - "Run goto line other window action from `helm-source-moccur'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-moccur-goto-line-ow))) - -(defun helm-moccur-run-goto-line-of () - "Run goto line new frame action from `helm-source-moccur'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-moccur-goto-line-of))) - -(defun helm-moccur-run-default-action () - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-moccur-goto-line))) - -;;;###autoload -(define-minor-mode helm-occur-match-plugin-mode - "Turn On/Off `helm-match-plugin-mode' only for `helm-m/occur'." - :global t - :init-value t - (if helm-occur-match-plugin-mode - (setq helm-source-moccur - (remove (assoc 'no-matchplugin helm-source-moccur) - helm-source-moccur) - helm-source-occur helm-source-moccur) - (helm-attrset 'no-matchplugin nil helm-source-moccur) - (setq helm-source-occur helm-source-moccur))) - -(defvar helm-source-moccur nil) -(defclass helm-source-multi-occur (helm-source-in-buffer) - ((init :initform (lambda () - (require 'helm-grep) - (helm-moccur-init))) - (filter-one-by-one :initform 'helm-moccur-filter-one-by-one) - (get-line :initform helm-moccur-get-line) - (nohighlight :initform t) - (migemo :initform t) - (action :initform '(("Go to Line" . helm-moccur-goto-line) - ("Goto line other window" . helm-moccur-goto-line-ow) - ("Goto line new frame" . helm-moccur-goto-line-of))) - (persistent-action :initform 'helm-moccur-persistent-action) - (persistent-help :initform "Go to line") - (recenter :initform t) - (resume :initform 'helm-moccur-resume-fn) - (candidate-number-limit :initform 9999) - (mode-line :initform helm-moccur-mode-line) - (keymap :initform helm-moccur-map) - (history :initform 'helm-grep-history) - (requires-pattern :initform 2))) - -(defun helm-moccur-resume-fn () - (with-helm-buffer - (let (new-tick-ls buffer-is-modified) - (set (make-local-variable 'helm-multi-occur-buffer-list) - (cl-loop for b in helm-multi-occur-buffer-list - when (buffer-live-p (get-buffer b)) - collect b)) - (setq buffer-is-modified (/= (length helm-multi-occur-buffer-list) - (length (helm-attr 'moccur-buffers)))) - (helm-attrset 'moccur-buffers helm-multi-occur-buffer-list) - (setq new-tick-ls (cl-loop for b in helm-multi-occur-buffer-list - collect (buffer-chars-modified-tick (get-buffer b)))) - (when buffer-is-modified - (setq helm-multi-occur-buffer-tick new-tick-ls)) - (cl-assert (> (length helm-multi-occur-buffer-list) 0) nil - "helm-resume error: helm-(m)occur buffer list is empty") - (unless (eq helm-moccur-auto-update-on-resume 'never) - (when (or buffer-is-modified - (cl-loop for b in helm-multi-occur-buffer-list - for new-tick = (buffer-chars-modified-tick (get-buffer b)) - for tick in helm-multi-occur-buffer-tick - thereis (/= tick new-tick))) - (helm-aif helm-moccur-auto-update-on-resume - (when (or (eq it 'noask) - (y-or-n-p "Helm (m)occur Buffer outdated, update? ")) - (run-with-idle-timer 0.1 nil (lambda () - (with-helm-buffer - (helm-force-update) - (message "Helm (m)occur Buffer have been udated") - (sit-for 1) (message nil)))) - (unless buffer-is-modified (setq helm-multi-occur-buffer-tick new-tick-ls))) - (run-with-idle-timer 0.1 nil (lambda () - (with-helm-buffer - (let ((ov (make-overlay (save-excursion - (goto-char (point-min)) - (forward-line 1) - (point)) - (point-max)))) - (overlay-put ov 'face 'helm-resume-need-update) - (sit-for 0.3) (delete-overlay ov) - (message "[Helm occur Buffer outdated (C-c C-u to update)]"))))) - (unless buffer-is-modified - (with-helm-after-update-hook - (setq helm-multi-occur-buffer-tick new-tick-ls) - (message "Helm (m)occur Buffer have been udated"))))))))) - -(defun helm-moccur-filter-one-by-one (candidate) - "`filter-one-by-one' function for `helm-source-moccur'." - (require 'helm-grep) - (let* ((split (helm-grep-split-line candidate)) - (buf (car split)) - (lineno (nth 1 split)) - (str (nth 2 split))) - (cons (concat (propertize - buf - 'face 'helm-moccur-buffer - 'help-echo (buffer-file-name - (get-buffer buf)) - 'buffer-name buf) - ":" - (propertize lineno 'face 'helm-grep-lineno) - ":" - (helm-grep-highlight-match - str helm-occur-match-plugin-mode)) - candidate))) - -(defun helm-multi-occur-1 (buffers &optional input) - "Main function to call `helm-source-moccur' with BUFFERS list." - (let ((bufs (if helm-moccur-always-search-in-current - (cons - ;; will become helm-current-buffer later. - (buffer-name (current-buffer)) - (remove helm-current-buffer helm-multi-occur-buffer-list)) - buffers))) - (unless helm-source-moccur - (setq helm-source-moccur - (helm-make-source "Moccur" 'helm-source-multi-occur))) - (helm-attrset 'moccur-buffers bufs helm-source-moccur) - (helm-set-local-variable 'helm-multi-occur-buffer-list bufs) - (helm-set-local-variable - 'helm-multi-occur-buffer-tick - (cl-loop for b in bufs - collect (buffer-chars-modified-tick (get-buffer b))))) - (helm :sources 'helm-source-moccur - :buffer "*helm multi occur*" - :history 'helm-grep-history - :input input - :truncate-lines t)) - -;;;###autoload -(defun helm-moccur-run-save-buffer () - "Run grep save results action from `helm-do-grep-1'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action 'helm-moccur-save-results))) - - -;;; helm-moccur-mode -;; -;; -(defvar helm-moccur-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "RET") 'helm-moccur-mode-goto-line) - (define-key map (kbd "C-o") 'helm-moccur-mode-goto-line-ow) - (define-key map (kbd "") 'undefined) - (define-key map (kbd "") 'undefined) - (define-key map (kbd "") 'helm-gm-next-file) - (define-key map (kbd "") 'helm-gm-precedent-file) - map)) - -(defun helm-moccur-mode-goto-line () - (interactive) - (helm-moccur-goto-line - (buffer-substring (point-at-bol) (point-at-eol)))) - -(defun helm-moccur-mode-goto-line-ow () - (interactive) - (helm-moccur-goto-line-ow - (buffer-substring (point-at-bol) (point-at-eol)))) - -(defun helm-moccur-save-results (_candidate) - "Save helm moccur results in a `helm-moccur-mode' buffer." - (let ((buf "*hmoccur*") - new-buf) - (when (get-buffer buf) - (setq new-buf (helm-read-string "OccurBufferName: " buf)) - (cl-loop for b in (helm-buffer-list) - when (and (string= new-buf b) - (not (y-or-n-p - (format "Buffer `%s' already exists overwrite? " - new-buf)))) - do (setq new-buf (helm-read-string "OccurBufferName: " "*hmoccur "))) - (setq buf new-buf)) - (with-current-buffer (get-buffer-create buf) - (setq buffer-read-only t) - (let ((inhibit-read-only t)) - (erase-buffer) - (insert "-*- mode: helm-moccur -*-\n\n" - (format "Moccur Results for `%s':\n\n" helm-pattern)) - (save-excursion - (insert (with-current-buffer helm-buffer - (goto-char (point-min)) (forward-line 1) - (buffer-substring (point) (point-max)))))) - (helm-moccur-mode) (pop-to-buffer buf)) - (message "Helm Moccur Results saved in `%s' buffer" buf))) - -;;;###autoload -(define-derived-mode helm-moccur-mode - special-mode "helm-moccur" - "Major mode to provide actions in helm moccur saved buffer. - -Special commands: -\\{helm-moccur-mode-map}" - (set (make-local-variable 'helm-multi-occur-buffer-list) - (with-helm-buffer helm-multi-occur-buffer-list)) - (set (make-local-variable 'revert-buffer-function) - #'helm-moccur-mode--revert-buffer-function)) - -(defun helm-moccur-mode--revert-buffer-function (&optional _ignore-auto _noconfirm) - (goto-char (point-min)) - (let (pattern) - (when (re-search-forward "^Moccur Results for `\\(.*\\)'" nil t) - (setq pattern (match-string 1)) - (forward-line 0) - (when (re-search-forward "^$" nil t) - (forward-line 1)) - (let ((inhibit-read-only t) - (buffer (current-buffer)) - (buflst helm-multi-occur-buffer-list)) - (delete-region (point) (point-max)) - (message "Reverting buffer...") - (save-excursion - (with-temp-buffer - (insert - "\n" - (cl-loop for buf in buflst - for bufstr = (or (and (buffer-live-p (get-buffer buf)) - (with-current-buffer buf - (buffer-string))) - "") - unless (string= bufstr "") - do (add-text-properties - 0 (length bufstr) - `(buffer-name ,(buffer-name (get-buffer buf))) - bufstr) - concat bufstr) - "\n") - (goto-char (point-min)) - (cl-loop while (re-search-forward pattern nil t) - for line = (helm-moccur-get-line (point-at-bol) (point-at-eol)) - when line - do (with-current-buffer buffer - (insert - (propertize - (car (helm-moccur-filter-one-by-one line)) - 'helm-real-value line) - "\n"))))) - (message "Reverting buffer done"))))) - - -;;; Predefined commands -;; -;; - -;;;###autoload -(defun helm-regexp () - "Preconfigured helm to build regexps. -`query-replace-regexp' can be run from there against found regexp." - (interactive) - (save-restriction - (when (and (helm-region-active-p) - ;; Don't narrow to region if buffer is already narrowed. - (not (helm-current-buffer-narrowed-p (current-buffer)))) - (narrow-to-region (region-beginning) (region-end))) - (helm :sources helm-source-regexp - :buffer "*helm regexp*" - :prompt "Regexp: " - :history 'helm-build-regexp-history))) - -;;;###autoload -(defun helm-occur () - "Preconfigured helm for Occur." - (interactive) - (helm-occur-init-source) - (let ((bufs (list (buffer-name (current-buffer))))) - (helm-attrset 'moccur-buffers bufs helm-source-occur) - (helm-set-local-variable 'helm-multi-occur-buffer-list bufs) - (helm-set-local-variable - 'helm-multi-occur-buffer-tick - (cl-loop for b in bufs - collect (buffer-chars-modified-tick (get-buffer b))))) - (helm :sources 'helm-source-occur - :buffer "*helm occur*" - :history 'helm-grep-history - :preselect (and (memq 'helm-source-occur helm-sources-using-default-as-input) - (format "%s:%d:" (buffer-name) (line-number-at-pos (point)))) - :truncate-lines t)) - -;;;###autoload -(defun helm-occur-from-isearch () - "Invoke `helm-occur' from isearch." - (interactive) - (let ((input (if isearch-regexp - isearch-string - (regexp-quote isearch-string))) - (bufs (list (buffer-name (current-buffer))))) - (isearch-exit) - (helm-occur-init-source) - (helm-attrset 'moccur-buffers bufs helm-source-occur) - (helm-set-local-variable 'helm-multi-occur-buffer-list bufs) - (helm-set-local-variable - 'helm-multi-occur-buffer-tick - (cl-loop for b in bufs - collect (buffer-chars-modified-tick (get-buffer b)))) - (helm :sources 'helm-source-occur - :buffer "*helm occur*" - :history 'helm-grep-history - :input input - :truncate-lines t))) - -;;;###autoload -(defun helm-multi-occur (buffers) - "Preconfigured helm for multi occur. - - BUFFERS is a list of buffers to search through. -With a prefix arg, reverse the behavior of -`helm-moccur-always-search-in-current'. -The prefix arg can be set before calling `helm-multi-occur' -or during the buffer selection." - (interactive (list (helm-comp-read - "Buffers: " (helm-buffer-list) - :marked-candidates t))) - (let ((helm-moccur-always-search-in-current - (if (or current-prefix-arg - helm-current-prefix-arg) - (not helm-moccur-always-search-in-current) - helm-moccur-always-search-in-current))) - (helm-multi-occur-1 buffers))) - -;;;###autoload -(defun helm-multi-occur-from-isearch (&optional _arg) - "Invoke `helm-multi-occur' from isearch. - -With a prefix arg, reverse the behavior of -`helm-moccur-always-search-in-current'. -The prefix arg can be set before calling -`helm-multi-occur-from-isearch' or during the buffer selection." - (interactive "p") - (let (buf-list - helm-moccur-always-search-in-current - (input (if isearch-regexp - isearch-string - (regexp-quote isearch-string)))) - (isearch-exit) - (setq buf-list (helm-comp-read "Buffers: " - (helm-buffer-list) - :name "Occur in buffer(s)" - :marked-candidates t)) - (setq helm-moccur-always-search-in-current - (if (or current-prefix-arg - helm-current-prefix-arg) - (not helm-moccur-always-search-in-current) - helm-moccur-always-search-in-current)) - (helm-multi-occur-1 buf-list input))) - - -(provide 'helm-regexp) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-regexp.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-ring.el b/emacs.d/elpa/helm-20141016.2217/helm-ring.el deleted file mode 100644 index 1493ff4..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-ring.el +++ /dev/null @@ -1,378 +0,0 @@ -;;; helm-ring.el --- kill-ring, mark-ring, and register browsers for helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) -(require 'helm-elisp) - -(declare-function undo-tree-restore-state-from-register "ext:undo-tree.el" (register)) - - -(defgroup helm-ring nil - "Ring related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-kill-ring-threshold 3 - "Minimum length of a candidate to be listed by `helm-source-kill-ring'." - :type 'integer - :group 'helm-ring) - -(defcustom helm-kill-ring-max-lines-number 5 - "Max number of lines displayed per candidate in kill-ring browser. -If nil or zero (disabled), don't truncate candidate, show all." - :type '(choice (const :tag "Disabled" nil) - (integer :tag "Max number of lines")) - :group 'helm-ring) - -(defcustom helm-kill-ring-show-completion t - "Show yank contents with an overlay in current buffer." - :group 'helm-ring - :type 'boolean) - -(defcustom helm-register-max-offset 160 - "Max size of string register entries before truncating." - :group 'helm-ring - :type 'integer) - - -;;; Kill ring -;; -;; -(defvar helm-kill-ring-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-y") 'helm-next-line) - (define-key map (kbd "M-u") 'helm-previous-line) - map) - "Keymap for `helm-show-kill-ring'.") - -(defvar helm-source-kill-ring - `((name . "Kill Ring") - (init . (lambda () (helm-attrset 'last-command last-command))) - (candidates . helm-kill-ring-candidates) - (filtered-candidate-transformer helm-kill-ring-transformer) - (action . (("Yank" . helm-kill-ring-action) - ("Delete" . (lambda (candidate) - (cl-loop for cand in (helm-marked-candidates) - do (setq kill-ring - (delete cand kill-ring))))))) - (persistent-action . (lambda (_candidate) (ignore))) - (persistent-help . "DoNothing") - (keymap . ,helm-kill-ring-map) - (last-command) - (migemo) - (multiline)) - "Source for browse and insert contents of kill-ring.") - -(defun helm-kill-ring-candidates () - (cl-loop for kill in (helm-fast-remove-dups kill-ring :test 'equal) - unless (or (< (length kill) helm-kill-ring-threshold) - (string-match "\\`[\n[:blank:]]+\\'" kill)) - collect kill)) - -(defun helm-kill-ring-transformer (candidates _source) - "Display only the `helm-kill-ring-max-lines-number' lines of candidate." - (cl-loop for i in candidates - for nlines = (with-temp-buffer (insert i) (count-lines (point-min) (point-max))) - if (and helm-kill-ring-max-lines-number - (> nlines helm-kill-ring-max-lines-number)) - collect (cons - (with-temp-buffer - (insert i) - (goto-char (point-min)) - (concat - (buffer-substring - (point-min) - (save-excursion - (forward-line helm-kill-ring-max-lines-number) - (point))) - "[...]")) i) - else collect i)) - -(defun helm-kill-ring-action (str) - "Insert STR in `kill-ring' and set STR to the head. -If this action is executed just after `yank', -replace with STR as yanked string." - (with-helm-current-buffer - (setq kill-ring (delete str kill-ring)) - (if (not (eq (helm-attr 'last-command helm-source-kill-ring) 'yank)) - (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) - ;; from `yank-pop' - (let ((inhibit-read-only t) - (before (< (point) (mark t)))) - (if before - (funcall (or yank-undo-function 'delete-region) (point) (mark t)) - (funcall (or yank-undo-function 'delete-region) (mark t) (point))) - (setq yank-undo-function nil) - (set-marker (mark-marker) (point) helm-current-buffer) - (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) - ;; Set the window start back where it was in the yank command, - ;; if possible. - (set-window-start (selected-window) yank-window-start t) - (when before - ;; This is like exchange-point-and-mark, but doesn't activate the mark. - ;; It is cleaner to avoid activation, even though the command - ;; loop would deactivate the mark because we inserted text. - (goto-char (prog1 (mark t) - (set-marker (mark-marker) (point) helm-current-buffer)))))) - (kill-new str))) - - - - -;;;; -;; DO NOT use these sources with other sources use -;; the commands `helm-mark-ring', `helm-global-mark-ring' or -;; `helm-all-mark-rings' instead. - -(defun helm-mark-ring-get-marks (pos) - (save-excursion - (goto-char pos) - (forward-line 0) - (let ((line (car (split-string (thing-at-point 'line) "[\n\r]")))) - (when (string= "" line) - (setq line "")) - (format "%7d: %s" (line-number-at-pos) line)))) - -(defun helm-mark-ring-get-candidates () - (with-helm-current-buffer - (cl-loop with marks = (if (mark t) (cons (mark-marker) mark-ring) mark-ring) - for i in marks - for m = (helm-mark-ring-get-marks i) - unless (and recip (member m recip)) - collect m into recip - finally return recip))) - -(defvar helm-source-mark-ring - '((name . "mark-ring") - (candidates . helm-mark-ring-get-candidates) - (action . (("Goto line" - . (lambda (candidate) - (helm-goto-line (string-to-number candidate)))))) - (persistent-action . (lambda (candidate) - (helm-goto-line (string-to-number candidate)) - (helm-highlight-current-line))) - (persistent-help . "Show this line"))) - - -;;; Global-mark-ring -(defvar helm-source-global-mark-ring - '((name . "global-mark-ring") - (candidates . helm-global-mark-ring-get-candidates) - (action . (("Goto line" - . (lambda (candidate) - (let ((items (split-string candidate ":"))) - (helm-switch-to-buffer (cl-second items)) - (helm-goto-line (string-to-number (car items)))))))) - (persistent-action . (lambda (candidate) - (let ((items (split-string candidate ":"))) - (helm-switch-to-buffer (cl-second items)) - (helm-goto-line (string-to-number (car items))) - (helm-highlight-current-line)))) - (persistent-help . "Show this line"))) - -(defun helm-global-mark-ring-format-buffer (marker) - (with-current-buffer (marker-buffer marker) - (goto-char marker) - (forward-line 0) - (let (line) - (if (string= "" line) - (setq line "") - (setq line (car (split-string (thing-at-point 'line) - "[\n\r]")))) - (format "%7d:%s: %s" - (line-number-at-pos) (marker-buffer marker) line)))) - -(defun helm-global-mark-ring-get-candidates () - (let ((marks global-mark-ring)) - (when marks - (cl-loop for i in marks - for gm = (unless (or (string-match - "^ " (format "%s" (marker-buffer i))) - (null (marker-buffer i))) - (helm-global-mark-ring-format-buffer i)) - when (and gm (not (member gm recip))) - collect gm into recip - finally return recip)))) - - -;;;; -;;; Insert from register -(defvar helm-source-register - '((name . "Registers") - (candidates . helm-register-candidates) - (action-transformer . helm-register-action-transformer) - (multiline) - (action)) - "See (info \"(emacs)Registers\")") - -(defun helm-register-candidates () - "Collecting register contents and appropriate commands." - (cl-loop for (char . val) in register-alist - for key = (single-key-description char) - for string-actions = - (cond - ((numberp val) - (list (int-to-string val) - 'insert-register - 'increment-register)) - ((markerp val) - (let ((buf (marker-buffer val))) - (if (null buf) - (list "a marker in no buffer") - (list (concat - "a buffer position:" - (buffer-name buf) - ", position " - (int-to-string (marker-position val))) - 'jump-to-register - 'insert-register)))) - ((and (consp val) (window-configuration-p (car val))) - (list "window configuration." - 'jump-to-register)) - ((and (vectorp val) - (fboundp 'undo-tree-register-data-p) - (undo-tree-register-data-p (elt val 1))) - (list - "Undo-tree entry." - 'undo-tree-restore-state-from-register)) - ((or (and (vectorp val) (eq 'registerv (aref val 0))) - (and (consp val) (frame-configuration-p (car val)))) - (list "frame configuration." - 'jump-to-register)) - ((and (consp val) (eq (car val) 'file)) - (list (concat "file:" - (prin1-to-string (cdr val)) - ".") - 'jump-to-register)) - ((and (consp val) (eq (car val) 'file-query)) - (list (concat "file:a file-query reference: file " - (car (cdr val)) - ", position " - (int-to-string (car (cdr (cdr val)))) - ".") - 'jump-to-register)) - ((consp val) - (let ((lines (format "%4d" (length val)))) - (list (format "%s: %s\n" lines - (truncate-string-to-width - (mapconcat 'identity (list (car val)) - "^J") (- (window-width) 15))) - 'insert-register))) - ((stringp val) - (list - ;; without properties - (concat (substring-no-properties - val 0 (min (length val) helm-register-max-offset)) - (if (> (length val) helm-register-max-offset) - "[...]" "")) - 'insert-register - 'append-to-register - 'prepend-to-register)) - (t - "GARBAGE!")) - collect (cons (format "Register %3s:\n %s" key (car string-actions)) - (cons char (cdr string-actions))))) - -(defun helm-register-action-transformer (_actions register-and-functions) - "Decide actions by the contents of register." - (cl-loop with func-actions = - '((insert-register - "Insert Register" . - (lambda (c) (insert-register (car c)))) - (jump-to-register - "Jump to Register" . - (lambda (c) (jump-to-register (car c)))) - (append-to-register - "Append Region to Register" . - (lambda (c) (append-to-register - (car c) (region-beginning) (region-end)))) - (prepend-to-register - "Prepend Region to Register" . - (lambda (c) (prepend-to-register - (car c) (region-beginning) (region-end)))) - (increment-register - "Increment Prefix Arg to Register" . - (lambda (c) (increment-register - helm-current-prefix-arg (car c)))) - (undo-tree-restore-state-from-register - "Restore Undo-tree register" - (lambda (c) (and (fboundp 'undo-tree-restore-state-from-register) - (undo-tree-restore-state-from-register (car c)))))) - for func in (cdr register-and-functions) - for cell = (assq func func-actions) - when cell - collect (cdr cell))) - -;;;###autoload -(defun helm-mark-ring () - "Preconfigured `helm' for `helm-source-mark-ring'." - (interactive) - (helm :sources 'helm-source-mark-ring - :resume 'noresume - :buffer "*helm mark*")) - -;;;###autoload -(defun helm-global-mark-ring () - "Preconfigured `helm' for `helm-source-global-mark-ring'." - (interactive) - (helm :sources 'helm-source-global-mark-ring - :resume 'noresume - :buffer "*helm global mark*")) - -;;;###autoload -(defun helm-all-mark-rings () - "Preconfigured `helm' for `helm-source-global-mark-ring' and \ -`helm-source-mark-ring'." - (interactive) - (helm :sources '(helm-source-mark-ring - helm-source-global-mark-ring) - :resume 'noresume - :buffer "*helm mark ring*")) - -;;;###autoload -(defun helm-register () - "Preconfigured `helm' for Emacs registers." - (interactive) - (helm :sources 'helm-source-register - :resume 'noresume - :buffer "*helm register*")) - -;;;###autoload -(defun helm-show-kill-ring () - "Preconfigured `helm' for `kill-ring'. -It is drop-in replacement of `yank-pop'. - -First call open the kill-ring browser, next calls move to next line." - (interactive) - (helm :sources helm-source-kill-ring - :buffer "*helm kill ring*" - :resume 'noresume - :allow-nest t)) - -(provide 'helm-ring) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-ring.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-semantic.el b/emacs.d/elpa/helm-20141016.2217/helm-semantic.el deleted file mode 100644 index da3dddb..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-semantic.el +++ /dev/null @@ -1,161 +0,0 @@ -;;; helm-semantic.el --- Helm interface for Semantic -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Daniel Hackney -;; Author: Daniel Hackney - -;; 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: - -;; Uses `candidates-in-buffer' for speed. - -;;; Code: - -(require 'cl-lib) -(require 'semantic) -(require 'helm-imenu) - -(declare-function pulse-momentary-highlight-one-line "pulse.el" (point &optional face)) - -(defcustom helm-semantic-lynx-style-map t - "Use Arrow keys to jump to occurences." - :group 'helm-imenu - :type 'boolean) - -;;; keymap -(defvar helm-semantic-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-semantic-help) - (when helm-imenu-lynx-style-map - (define-key map (kbd "") 'helm-maybe-exit-minibuffer) - (define-key map (kbd "") 'helm-execute-persistent-action)) - (delq nil map))) - -(defun helm-semantic-init-candidates (tags depth &optional class) - "Write the contents of TAGS to the current buffer." - (let ((class class) cur-type) - (cl-dolist (tag tags) - (when (listp tag) - (cl-case (setq cur-type (semantic-tag-class tag)) - ((function variable type) - (let ((spaces (make-string (* depth 2) ?\s)) - (type-p (eq cur-type 'type))) - (unless (and (> depth 0) (not type-p)) - (setq class nil)) - (insert - (if (and class (not type-p)) - (format "%s%sClass(%s) " - spaces (if (< depth 2) "" "├►") class) - spaces) - ;; Save the tag for later - (propertize (semantic-format-tag-summarize tag nil t) - 'semantic-tag tag) - "\n") - (and type-p (setq class (car tag))) - ;; Recurse to children - (helm-semantic-init-candidates - (semantic-tag-components tag) (1+ depth) class))) - - ;; Don't do anything with packages or includes for now - ((package include) - (insert - (propertize (semantic-format-tag-summarize tag nil t) - 'semantic-tag tag) - "\n") - ) - ;; Catch-all - (t)))))) - -(defun helm-semantic-default-action (_candidate &optional persistent) - ;; By default, helm doesn't pass on the text properties of the selection. - ;; Fix this. - (helm-log-run-hook 'helm-goto-line-before-hook) - (with-current-buffer helm-buffer - (when (looking-at " ") - (goto-char (next-single-property-change - (point-at-bol) 'semantic-tag nil (point-at-eol)))) - (let ((tag (get-text-property (point) 'semantic-tag))) - (semantic-go-to-tag tag) - (unless persistent - (pulse-momentary-highlight-one-line (point)))))) - -(defun helm-semantic--maybe-set-needs-update () - (with-helm-current-buffer - (let ((tick (buffer-modified-tick))) - (unless (eq helm-cached-imenu-tick tick) - (setq helm-cached-imenu-tick tick) - (semantic-parse-tree-set-needs-update))))) - -(defvar helm-source-semantic - `((name . "Semantic Tags") - (init . (lambda () - (helm-semantic--maybe-set-needs-update) - (let ((tags (semantic-fetch-tags))) - (with-current-buffer (helm-candidate-buffer 'global) - (helm-semantic-init-candidates tags 0))))) - (candidates-in-buffer) - (allow-dups) - (get-line . buffer-substring) - (persistent-action . (lambda (elm) - (helm-semantic-default-action elm t) - (helm-highlight-current-line))) - (persistent-help . "Show this entry") - (keymap . ,helm-semantic-map) - (mode-line . helm-semantic-mode-line) - (action . helm-semantic-default-action) - "Source to search tags using Semantic from CEDET.")) - -;;;###autoload -(defun helm-semantic () - "Preconfigured `helm' for `semantic'." - (interactive) - (let ((str (thing-at-point 'symbol))) - (helm :sources 'helm-source-semantic - :default (list (concat "\\_<" str "\\_>") str) - :candidate-number-limit 9999 - :buffer "*helm semantic*"))) - -;;;###autoload -(defun helm-semantic-or-imenu () - "Run `helm' with `semantic' or `imenu'. - -If `semantic-mode' is active in the current buffer, then use -semantic for generating tags, otherwise fall back to `imenu'. -Fill in the symbol at point by default." - (interactive) - (let* ((source (if (semantic-active-p) - 'helm-source-semantic - 'helm-source-imenu)) - (imenu-p (eq source 'helm-source-imenu)) - (str (thing-at-point 'symbol)) - (imenu-auto-rescan imenu-p) - (helm-execute-action-at-once-if-one - (and imenu-p - helm-imenu-execute-action-at-once-if-one))) - (helm :sources source - :default (list (concat "\\_<" str "\\_>") str) - :buffer "*helm semantic/imenu*" - :candidate-number-limit 9999 - :preselect (unless imenu-p (thing-at-point 'symbol))))) - -(provide 'helm-semantic) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-semantic.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-source.el b/emacs.d/elpa/helm-20141016.2217/helm-source.el deleted file mode 100644 index 5c1db26..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-source.el +++ /dev/null @@ -1,929 +0,0 @@ -;;; helm-source.el --- Helm source creation. -*- lexical-binding: t -*- - -;; Copyright (C) 2014 Thierry Volpiatto - -;; Author: Thierry Volpiatto -;; URL: http://github.com/emacs-helm/helm - -;; 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: - -;; Interface to create helm sources easily. -;; Actually the eieo objects are transformed in alist for compatibility. -;; In the future this package should allow creating source as eieo objects -;; without conversion to alist, teaching helm to read such a structure. -;; The compatibility with alists would be kept. - -;;; Code: - -(require 'cl-lib) -(require 'eieio) - -(defgeneric helm--setup-source (source) - "Prepare slots and handle slot errors before creating a helm source.") - -(defgeneric helm-setup-user-source (source) - "Allow users modifying slots in SOURCE just before creation.") - - -;;; Classes for sources -;; -;; -(defclass helm-source () - ((name - :initarg :name - :initform nil - :custom string - :documentation - " The name of the source. - A string which is also the heading which appears - above the list of matches from the source. Must be unique.") - - (header-name - :initarg :header-name - :initform nil - :custom function - :documentation - " A function returning the display string of the header. - Its argument is the name of the source. This attribute is useful to - add an additional information with the source name. - It doesn't modify the name of the source.") - - (init - :initarg :init - :initform nil - :custom function - :documentation - " Function called with no parameters when helm is started. - It is useful for collecting current state information which can be - used to create the list of candidates later. - Initialization of `candidates-in-buffer' is done here - with `helm-init-candidates-in-buffer'.") - - (candidates - :initarg :candidates - :initform nil - :custom (choice function list) - :documentation - " Specifies how to retrieve candidates from the source. - It can either be a variable name, a function called with no parameters - or the actual list of candidates. - - The list must be a list whose members are strings, symbols - or (DISPLAY . REAL) pairs. - - In case of (DISPLAY . REAL) pairs, the DISPLAY string is shown - in the Helm buffer, but the REAL one is used as action - argument when the candidate is selected. This allows a more - readable presentation for candidates which would otherwise be, - for example, too long or have a common part shared with other - candidates which can be safely replaced with an abbreviated - string for display purposes. - - Note that if the (DISPLAY . REAL) form is used then pattern - matching is done on the displayed string, not on the real - value.") - - (update - :initarg :update - :initform nil - :custom function - :documentation - " Function called with no parameters at end of reinitialization - when `helm-force-update' is called.") - - (cleanup - :initarg :cleanup - :initform nil - :custom function - :documentation - " Function called with no parameters when *helm* buffer is - closed. It is useful for killing unneeded candidates buffer. - - Note that the function is executed BEFORE performing action.") - - (delayed - :initarg :delayed - :initform nil - :custom (choice null integer) - :documentation - " Candidates from the source are shown only if the user stops - typing and is idle for `helm-idle-delay' seconds. - If a value is given to delayed attr, this value is used instead only - if it is > to `helm-idle-delay'.") - - (keymap - :initarg :keymap - :initform nil - :custom sexp - :documentation - " Specific keymap for this source. - It is useful to have a keymap per source when using more than - one source. Otherwise, a keymap can be set per command with - `helm' argument KEYMAP. NOTE: when a source have `helm-map' as - keymap attr, the global value of `helm-map' will override the - actual local one.") - - (action - :initarg :action - :initform 'identity - :custom (alist :key-type string - :value-type function) - :documentation - " It is a list of (DISPLAY . FUNCTION) pairs or FUNCTION. - FUNCTION is called with one parameter: the selected candidate. - - An action other than the default can be chosen from this list - of actions for the currently selected candidate (by default - with TAB). The DISPLAY string is shown in the completions - buffer and the FUNCTION is invoked when an action is - selected. The first action of the list is the default. - - You should use `helm-make-actions' to build this alist easily.") - - (persistent-action - :initarg :persistent-action - :initform nil - :custom function - :documentation - " Can be a either a Function called with one parameter (the - selected candidate) or a cons cell where first element is this - same function and second element a symbol (e.g never-split) - that inform `helm-execute-persistent-action'to not split his - window to execute this persistent action.") - - (persistent-help - :initarg :persistent-help - :initform nil - :custom string - :documentation - " A string to explain persistent-action of this source. It also - accepts a function or a variable name. - It will be displayed in source header.") - - (help-message - :initarg :help-message - :initform nil - :custom (choice string function) - :documentation - " Help message for this source. - If not present, `helm-help-message' value will be used.") - - (multiline - :initarg :multiline - :initform nil - :custom boolean - :documentation - " Enable to selection multiline candidates.") - - (requires-pattern - :initarg :requires-pattern - :initform nil - :custom integer - :documentation - " If present matches from the source are shown only if the - pattern is not empty. Optionally, it can have an integer - parameter specifying the required length of input which is - useful in case of sources with lots of candidates.") - - (candidate-transformer - :initarg :candidate-transformer - :initform nil - :custom (choice function list) - :documentation - " It's a function or a list of functions called with one argument - when the completion list from the source is built. The argument - is the list of candidates retrieved from the source. The - function should return a transformed list of candidates which - will be used for the actual completion. If it is a list of - functions, it calls each function sequentially. - - This can be used to transform or remove items from the list of - candidates. - - Note that `candidates' is run already, so the given transformer - function should also be able to handle candidates with (DISPLAY - . REAL) format.") - - (filtered-candidate-transformer - :initarg :filtered-candidate-transformer - :initform nil - :custom (choice function list) - :documentation - " It has the same format as `candidate-transformer', except the - function is called with two parameters: the candidate list and - the source. - - This transformer is run on the candidate list which is already - filtered by the current pattern. While `candidate-transformer' - is run only once, it is run every time the input pattern is - changed. - - It can be used to transform the candidate list dynamically, for - example, based on the current pattern. - - In some cases it may also be more efficent to perform candidate - transformation here, instead of with `candidate-transformer' - even if this transformation is done every time the pattern is - changed. For example, if a candidate set is very large then - `candidate-transformer' transforms every candidate while only - some of them will actually be displayed due to the limit - imposed by `helm-candidate-number-limit'. - - Note that `candidates' and `candidate-transformer' is run - already, so the given transformer function should also be able - to handle candidates with (DISPLAY . REAL) format.") - - (filter-one-by-one - :initarg :filter-one-by-one - :initform nil - :custom (choice function list) - :documentation - " A transformer function that treat candidates one by one. - It is called with one arg the candidate. - It is faster than `filtered-candidate-transformer' or - `candidates-transformer', but should be used only in sources - that recompute constantly their candidates, e.g `helm-source-find-files'. - Filtering happen early and candidates are treated - one by one instead of re-looping on the whole list. - If used with `filtered-candidate-transformer' or `candidates-transformer' - these functions should treat the candidates transformed by the - `filter-one-by-one' function in consequence.") - - (display-to-real - :initarg :display-to-real - :initform nil - :custom function - :documentation - " Function called with one parameter; the selected candidate. - - The function transforms the selected candidate, and the result - is passed to the action function. The display-to-real - attribute provides another way to pass to action other string than - the one shown in Helm buffer. - - Traditionally, it is possible to make candidates, - candidate-transformer or filtered-candidate-transformer - function return a list with (DISPLAY . REAL) pairs. But if REAL - can be generated from DISPLAY, display-to-real is more - convenient and faster. - - NOTE: This is deprecated and you have better time using `filter-one-by-one'.") - - (real-to-display - :initarg :real-to-display - :initform nil - :custom function - :documentation - " Function called with one parameter; the selected candidate. - The real value of candidates will be shown in display. - See `display-to-real'.") - - (action-transformer - :initarg :action-transformer - :initform nil - :custom (choice function list) - :documentation - " It's a function or a list of functions called with two - arguments when the action list from the source is - assembled. The first argument is the list of actions, the - second is the current selection. If it is a list of functions, - it calls each function sequentially. - - The function should return a transformed action list. - - This can be used to customize the list of actions based on the - currently selected candidate.") - - (pattern-transformer - :initarg :pattern-transformer - :initform nil - :custom (choice function list) - :documentation - " It's a function or a list of functions called with one argument - before computing matches. Its argument is `helm-pattern'. - Functions should return transformed `helm-pattern'. - - It is useful to change interpretation of `helm-pattern'.") - - (candidate-number-limit - :initarg :candidate-number-limit - :initform nil - :custom integer - :documentation - " Override `helm-candidate-number-limit' only for this source.") - - (volatile - :initarg :volatile - :initform nil - :custom boolean - :documentation - " Indicates the source assembles the candidate list dynamically, - so it shouldn't be cached within a single Helm - invocation. It is only applicable to synchronous sources, - because asynchronous sources are not cached.") - - (match - :initarg :match - :initform nil - :custom (choice function list) - :documentation - " List of functions called with one parameter: a candidate. The - function should return non-nil if the candidate matches the - current pattern (see variable `helm-pattern'). - - When using `candidates-in-buffer' its default value is `identity' and - don't have to be changed, use the `search' slot instead. - - This attribute allows the source to override the default - pattern matching based on `string-match'. It can be used, for - example, to implement a source for file names and do the - pattern matching on the basename of files, since it's more - likely one is typing part of the basename when searching for a - file, instead of some string anywhere else in its path. - - If the list contains more than one function then the list of - matching candidates from the source is constructed by appending - the results after invoking the first function on all the - potential candidates, then the next function, and so on. The - matching candidates supplied by the first function appear first - in the list of results and then results from the other - functions, respectively. - - This attribute has no effect for asynchronous sources (see - attribute `candidates'), since they perform pattern matching - themselves.") - - (nomark - :initarg :nomark - :initform nil - :custom boolean - :documentation - " Don't allow marking candidates when this attribute is present.") - - (nohighlight - :initarg :nohighlight - :initform nil - :custom boolean - :documentation - " Disable highlight match in this source.") - - (allow-dups - :initarg :allow-dups - :initform nil - :custom boolean - :documentation - " Allow helm collecting duplicates candidates.") - - (recenter - :initarg :recenter - :initform nil - :custom boolean - :documentation - " `recenter' after jumping to candidate.") - - (history - :initarg :history - :initform nil - :custom symbol - :documentation - " Allow passing history variable to helm from source. - It should be a quoted symbol.") - - (coerce - :initarg :coerce - :initform nil - :custom function - :documentation - " It's a function called with one argument: the selected candidate. - This function is intended for type convertion. In normal case, - the selected candidate (string) is passed to action - function. If coerce function is specified, it is called just - before action function. - - Example: converting string to symbol - (coerce . intern)") - - (mode-line - :initarg :mode-line - :initform nil - :custom (choice string sexp) - :documentation - " Source local `helm-mode-line-string' (included in - `mode-line-format'). It accepts also variable/function name.") - - (header-line - :initarg :header-line - :initform 'helm-persistent-help-string - :custom (choice string function) - :documentation - " Source local `header-line-format'. - It accepts also variable/function name.") - - (resume - :initarg :resume - :initform nil - :custom function - :documentation - " Function called with no parameters at end of initialization - when `helm-resume' is started. - If this function try to do something against `helm-buffer', \(e.g updating, - searching etc...\) probably you should run it in a timer to ensure - `helm-buffer' is ready.") - - (follow - :initarg :follow - :initform nil - :custom integer - :documentation - " Enable `helm-follow-mode' for this source only. - You must give it a value of 1 or -1, though giving a -1 value - is surely not what you want, e.g: (follow . 1) - - See `helm-follow-mode' for more infos.") - - (follow-delay - :initarg :follow-delay - :initform nil - :custom integer - :documentation - " `helm-follow-mode' will execute persistent-action after this delay. - Otherwise value of `helm-follow-input-idle-delay' is used if non--nil, - If none of these are found fallback to `helm-input-idle-delay'.") - - (dont-plug - :initarg :dont-plug - :initform nil - :custom list - :documentation - " A list of compile functions plugin to ignore.") - - (migemo - :initarg :migemo - :initform nil - :custom boolean - :documentation - " Needed for Japanese input with helm-migemo.el. - If you are not Japanese, ignore this.") - - (matchplugin - :initarg :matchplugin - :initform t - :custom boolean) - - (before-init-hook - :initarg :before-init-hook - :initform nil - :custom symbol - :documentation - " A local hook that run at beginning of initilization of this source. - i.e Before the creation of `helm-buffer'.") - - (after-init-hook - :initarg :after-init-hook - :initform nil - :custom symbol - :documentation - " A local hook that run at end of initilization of this source. - i.e After the creation of `helm-buffer'.")) - - "Main interface to define helm sources." - :abstract t) - -(defclass helm-source-sync (helm-source) - ((candidates - :initform '("ERROR: You must specify the `candidates' slot, either with a list or a function")) - - (dont-plug - :initform '(helm-compile-source--match-plugin)) - - (match-strict - :initarg :match-strict - :initform nil - :custom function - :documentation - " When specifying a match function within a source and - helm-match-plugin is enabled, the result of all matching - functions will be concatened, which in some cases is not what - is wanted. When using `match-strict' only this or these - functions will be used. You can specify those functions as a - list of functions or a single symbol function."))) - -(defclass helm-source-async (helm-source) - ((candidates-process - :initarg :candidates-process - :initform nil - :custom function - :documentation - " You should use this attribute when using a function involving - an async process instead of `candidates'. - The function must return a process.") - - (matchplugin :initform nil))) - -(defclass helm-source-in-buffer (helm-source) - ((init - :initform 'helm-default-init-source-in-buffer-function) - - (data - :initarg :data - :initform nil - :custom (choice list string) - :documentation - " A string or a list that will be used to feed the `helm-candidates-buffer'. - This data will be passed in a function added to the init slot and - the buffer will be build with `helm-init-candidates-in-buffer'. - This is an easy and fast method to build a `candidates-in-buffer' source.") - - (dont-plug - :initform '(helm-compile-source--candidates-in-buffer - helm-compile-source--match-plugin)) - - (candidates - :initform 'helm-candidates-in-buffer) - - (volatile - :initform t) - - (match - :initform '(identity)) - - (get-line - :initarg :get-line - :initform 'buffer-substring-no-properties - :custom function - :documentation - " A function like `buffer-substring-no-properties' or `buffer-substring'. - This function converts point of line-beginning and point of line-end, - which represents a candidate computed by `helm-candidates-in-buffer'. - By default, `helm-candidates-in-buffer' uses - `buffer-substring-no-properties'.") - - (search - :initarg :search - :initform '(helm-candidates-in-buffer-search-from-start) - :custom (choice function list) - :documentation - " List of functions like `re-search-forward' or `search-forward'. - Buffer search function used by `helm-candidates-in-buffer'. - By default, `helm-candidates-in-buffer' uses `re-search-forward'.") - - (search-from-end - :initarg :search-from-end - :initform nil - :custom boolean - :documentation - " Make `helm-candidates-in-buffer' search from the end of buffer. - If this attribute is specified, `helm-candidates-in-buffer' - uses `re-search-backward' instead. - - NOTE: This is here for compatibilty, but it is not used anymore.") - - (search-strict - :initarg :search-strict - :initform nil - :custom function - :documentation - " When specifying a search function within a source and - helm-match-plugin is enabled, the result of all searching - functions will be concatened, which in some cases is not what - is wanted. When using `search-strict' only this or these - functions will be used. You can specify those functions as a - list of functions or a single symbol function.") - - (match-part - :initarg :match-part - :initform nil - :custom function - :documentation - " Allow matching candidate in the line with `candidates-in-buffer'. - In candidates-in-buffer sources, match is done with - `re-search-forward' which allow matching only a regexp on the - `helm-buffer'; when this search is done, match-part allow - matching only a specific part of the current line e.g with a - line like this: - - filename:candidate-containing-the-word-filename - - What you want is to ignore \"filename\" part and match only - \"candidate-containing-the-word-filename\" - - So give a function matching only the part of candidate after \":\" - - If source contain match-part attribute, match is computed only - on part of candidate returned by the call of function provided - by this attribute. The function should have one arg, candidate, - and return only a specific part of candidate."))) - -(defclass helm-source-dummy (helm-source) - ((candidates - :initform '("dummy")) - - (filtered-candidate-transformer - :initform 'helm-dummy-candidate) - - (matchplugin - :initform nil) - - (accept-empty - :initarg :accept-empty - :initform t - :custom boolean - :documentation - " Allow exiting with an empty string. - You should keep the default value.") - - (match - :initform 'identity) - - (volatile - :initform t))) - - -;;; Classes for types. -;; -;; Files -(defclass helm-type-file (helm-source) () - "A class to define helm type file.") - -(defmethod helm--setup-source :before ((source helm-type-file)) - (oset source :action - (helm-make-actions - "Find file" 'helm-find-many-files - "Find file as root" 'helm-find-file-as-root - "Find file other window" 'find-file-other-window - "Find file other frame" 'find-file-other-frame - "Open dired in file's directory" 'helm-open-dired - "Grep File(s) `C-u recurse'" 'helm-find-files-grep - "Zgrep File(s) `C-u Recurse'" 'helm-ff-zgrep - "Pdfgrep File(s)" 'helm-ff-pdfgrep - "Insert as org link" 'helm-files-insert-as-org-link - "Checksum File" 'helm-ff-checksum - "Ediff File" 'helm-find-files-ediff-files - "Ediff Merge File" 'helm-find-files-ediff-merge-files - "Etags `M-., C-u tap, C-u C-u reload tag file'" - 'helm-ff-etags-select - "View file" 'view-file - "Insert file" 'insert-file - "Add marked files to file-cache" 'helm-ff-cache-add-file - "Delete file(s)" 'helm-delete-marked-files - "Open file externally (C-u to choose)" 'helm-open-file-externally - "Open file with default tool" 'helm-open-file-with-default-tool - "Find file in hex dump" 'hexl-find-file)) - (oset source :persistent-help "Show this file") - (oset source :action-transformer '(helm-transform-file-load-el - helm-transform-file-browse-url - helm-transform-file-cache)) - (oset source :candidate-transformer '(helm-skip-boring-files - helm-highlight-files - helm-w32-pathname-transformer))) - -;; Bookmarks -(defclass helm-type-bookmark (helm-source) () - "A class to define type bookmarks.") - -(defmethod helm--setup-source :before ((source helm-type-bookmark)) - (oset source :action (helm-make-actions - "Jump to bookmark" 'helm-bookmark-jump - "Jump to BM other window" 'helm-bookmark-jump-other-window - "Bookmark edit annotation" 'bookmark-edit-annotation - "Bookmark show annotation" 'bookmark-show-annotation - "Delete bookmark(s)" 'helm-delete-marked-bookmarks - "Edit Bookmark" 'helm-bookmark-edit-bookmark - "Rename bookmark" 'helm-bookmark-rename - "Relocate bookmark" 'bookmark-relocate)) - (oset source :keymap helm-bookmark-map) - (oset source :mode-line helm-bookmark-mode-line-string)) - -;; Buffers -(defclass helm-type-buffer (helm-source) () - "A class to define type buffer.") - -(defmethod helm--setup-source :before ((source helm-type-buffer)) - (oset source :action (helm-make-actions - "Switch to buffer" 'helm-switch-to-buffer - (lambda () (and (locate-library "popwin") "Switch to buffer in popup window")) - 'popwin:popup-buffer - "Switch to buffer other window" 'switch-to-buffer-other-window - "Switch to buffer other frame" 'switch-to-buffer-other-frame - (lambda () (and (locate-library "elscreen") "Display buffer in Elscreen")) - 'helm-find-buffer-on-elscreen - "Query replace regexp" 'helm-buffer-query-replace-regexp - "Query replace" 'helm-buffer-query-replace - "View buffer" 'view-buffer - "Display buffer" 'display-buffer - "Grep buffers (C-u grep all buffers)" 'helm-zgrep-buffers - "Multi occur buffer(s)" 'helm-multi-occur-as-action - "Revert buffer(s)" 'helm-revert-marked-buffers - "Insert buffer" 'insert-buffer - "Kill buffer(s)" 'helm-kill-marked-buffers - "Diff with file" 'diff-buffer-with-file - "Ediff Marked buffers" 'helm-ediff-marked-buffers - "Ediff Merge marked buffers" (lambda (candidate) - (helm-ediff-marked-buffers candidate t)))) - (oset source :persistent-help "Show this buffer") - (oset source :filtered-candidate-transformer '(helm-skip-boring-buffers - helm-buffers-sort-transformer - helm-highlight-buffers))) - - -;;; Error functions -;; -;; -(defun helm-default-init-source-in-buffer-function () - (helm-init-candidates-in-buffer 'global - '("ERROR: No buffer handling your data, use either the `init' slot or the `data' slot."))) - - -;;; Internal Builder functions. -;; -;; -(defun helm--create-source (object class) - "[INTERNAL] Build a helm source from a CLASS OBJECT." - (cl-loop for s in (object-slots object) - for slot = (class-slot-initarg class s) - for slot-val = (slot-value object slot) - when slot-val - collect (cons s (unless (eq t slot-val) slot-val)))) - -(defun helm-make-source (name class &rest args) - "Build a `helm' source named NAME with ARGS for CLASS. -Argument NAME is a string which define the source name, so no need to use -the keyword :name in your source, NAME will be used instead. -Argument CLASS is an eieio class object. -Arguments ARGS are keyword value pairs as defined in CLASS." - (let ((source (apply #'make-instance class name args))) - (oset source :name name) - (helm--setup-source source) - (helm-setup-user-source source) - (helm--create-source source (object-class source)))) - -(defun helm-make-type (class &rest args) - (let ((source (apply #'make-instance class args))) - (oset source :name nil) - (helm--setup-source source) - (helm--create-source source (object-class source)))) - -(defun helm-source-mp-get-search-or-match-fns (source method) - (require 'helm-match-plugin) - (let ((searchers (and (eq method 'search) - (if (eq t (oref source :search-from-end)) - helm-mp-default-search-backward-functions - helm-mp-default-search-functions))) - (defmatch (helm-aif (slot-value source :match) - (helm-mklist it))) - (defmatch-strict (helm-aif (and (eq method 'match) - (slot-value source :match-strict)) - (helm-mklist it))) - (defsearch (helm-aif (and (eq method 'search) - (slot-value source :search)) - (helm-mklist it))) - (defsearch-strict (helm-aif (and (eq method 'search-strict) - (slot-value source :search-strict)) - (helm-mklist it)))) - (cl-case method - (match (cond (defmatch-strict) - (defmatch - (append helm-mp-default-match-functions defmatch)) - (t helm-mp-default-match-functions))) - (search (cond (defsearch-strict) - (defsearch - (append searchers defsearch)) - (t searchers)))))) - - -;;; Modifiers -;; -(cl-defun helm-source-add-action-to-source-if (name fn source predicate - &optional (index 4)) - "Same as `helm-add-action-to-source-if' but for SOURCE defined as eieio object. -You can use this inside a `helm--setup-source' method for a SOURCE defined as -an eieio class." - (let* ((actions (oref source :action)) - (action-transformers (oref source :action-transformer)) - (new-action (list (cons name fn))) - (transformer `(lambda (actions candidate) - (cond ((funcall (quote ,predicate) candidate) - (helm-append-at-nth - actions (quote ,new-action) ,index)) - (t actions))))) - (when (symbolp actions) - (oset source :action (list (cons "Default action" actions)))) - (when (symbolp action-transformers) - (setq action-transformers (list action-transformers))) - (oset source - :action-transformer - (delq nil (append (list transformer) action-transformers))))) - -;;; Methods to access types slots. -(defmethod helm-source-get-action-from-type ((object helm-type-file)) - (oref object :action)) - - -;;; Methods to build sources. -;; -;; -(defmethod helm--setup-source :before ((source helm-source)) - (helm-aif (slot-value source :keymap) - (and (symbolp it) (set-slot-value source :keymap (symbol-value it))))) - -(defmethod helm-setup-user-source ((_source helm-source))) - -(defmethod helm--setup-source ((source helm-source-sync)) - (when (slot-value source :matchplugin) - (oset source :match - (helm-source-mp-get-search-or-match-fns source 'match)))) - -(defmethod helm--setup-source ((source helm-source-in-buffer)) - (let ((cur-init (slot-value source :init))) - (helm-aif (slot-value source :data) - (oset source - :init (delq - nil - `(,(and (null (eq 'helm-default-init-source-in-buffer-function - cur-init)) - cur-init) - (lambda () - (helm-init-candidates-in-buffer - 'global - (if (functionp ,it) (funcall ,it) - (if (stringp ,it) ,it ',it))))))))) - (when (slot-value source :matchplugin) - (oset source :search (helm-source-mp-get-search-or-match-fns source 'search))) - (let ((mtc (slot-value source :match))) - (cl-assert (or (equal '(identity) mtc) - (eq 'identity mtc)) - nil "Invalid slot value for `match'") - (cl-assert (eq (slot-value source :volatile) t) - nil "Invalid slot value for `volatile'"))) - -(defmethod helm--setup-source ((source helm-source-async)) - (cl-assert (null (slot-value source :candidates)) - nil "Incorrect use of `candidates' use `candidates-process' instead")) - -(defmethod helm--setup-source ((source helm-source-dummy)) - (let ((mtc (slot-value source :match))) - (cl-assert (or (equal '(identity) mtc) - (eq 'identity mtc)) - nil "Invalid slot value for `match'") - (cl-assert (eq (slot-value source :volatile) t) - nil "Invalid slot value for `volatile'") - (cl-assert (equal (slot-value source :candidates) '("dummy")) - nil "Invalid slot value for `candidates'") - (cl-assert (eq (slot-value source :accept-empty) t) - nil "Invalid slot value for `accept-empty'"))) - - -;;; User functions -;; -;; Sources -(defmacro helm-build-sync-source (name &rest args) - "Build a synchronous helm source with name NAME. -Args ARGS are keywords provided by `helm-source-sync'." - `(helm-make-source ,name 'helm-source-sync ,@args)) - -(defmacro helm-build-async-source (name &rest args) - "Build a asynchronous helm source with name NAME. -Args ARGS are keywords provided by `helm-source-async'." - `(helm-make-source ,name 'helm-source-async ,@args)) - -(defmacro helm-build-in-buffer-source (name &rest args) - "Build a helm source with name NAME using `candidates-in-buffer' method. -Args ARGS are keywords provided by `helm-source-in-buffer'." - `(helm-make-source ,name 'helm-source-in-buffer ,@args)) - -(defmacro helm-build-dummy-source (name &rest args) - "Build a helm source with name NAME using `dummy' method. -Args ARGS are keywords provided by `helm-source-dummy'." - `(helm-make-source ,name 'helm-source-dummy ,@args)) - -;; Types -(defun helm-actions-from-type-file () - (let ((source (make-instance 'helm-type-file))) - (helm--setup-source source) - (helm-source-get-action-from-type source))) - -(defun helm-build-type-file () - (helm-make-type 'helm-type-file)) - -(provide 'helm-source) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-source ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-sys.el b/emacs.d/elpa/helm-20141016.2217/helm-sys.el deleted file mode 100644 index fe0a25d..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-sys.el +++ /dev/null @@ -1,301 +0,0 @@ -;;; helm-sys.el --- System related functions for helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) - - -(defgroup helm-sys nil - "System related helm library." - :group 'helm) - -(defface helm-top-columns - '((t :inherit helm-header)) - "Face for helm help string in minibuffer." - :group 'helm-sys) - - -(defun helm-top-command-set-fn (var _value) - (set var - (cl-case system-type - (darwin "env COLUMNS=%s ps -axo pid,user,pri,nice,ucomm,tty,start,vsz,%%cpu,%%mem,etime,command") - (t "env COLUMNS=%s top -b -n 1")))) - -(defcustom helm-top-command "env COLUMNS=%s top -b -n 1" - "Top command used to display output of top. -To use top command, a version supporting batch mode (-b option) is needed. -On Mac OSX top command doesn't support this, so ps command -is used by default instead. -If you modify this the number and order of elements displayed -should be the same as top command to have the sort commands -working properly, that is 12 elements with the 2 first being -PID and USER and the last 4 being %CPU, %MEM, TIME and COMMAND. -A format string where %s will be replaced with `frame-width'." - :group 'helm-sys - :type 'string - :set 'helm-top-command-set-fn) - - -;;; Top (process) -;; -;; -(defvar helm-top-sort-fn nil) -(defvar helm-top-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "C-c ?") 'helm-top-help) - (define-key map (kbd "M-P") 'helm-top-run-sort-by-cpu) - (define-key map (kbd "M-C") 'helm-top-run-sort-by-com) - (define-key map (kbd "M-M") 'helm-top-run-sort-by-mem) - (define-key map (kbd "M-U") 'helm-top-run-sort-by-user) - map)) - -(defvar helm-source-top - `((name . "Top") - (header-name . (lambda (name) (concat name " (Press C-c C-u to refresh)"))) - (init . helm-top-init) - (candidates-in-buffer) - (nomark) - (display-to-real . helm-top-display-to-real) - (persistent-action . helm-top-sh-persistent-action) - (persistent-help . "SIGTERM") - (mode-line . helm-top-mode-line) - (follow . never) - (keymap . ,helm-top-map) - (filtered-candidate-transformer . helm-top-sort-transformer) - (action-transformer . helm-top-action-transformer))) - -(defun helm-top-transformer (candidates _source) - "Transformer for `helm-top'. -Return empty string for non--valid candidates." - (cl-loop for disp in candidates collect - (cond ((string-match "^ *[0-9]+" disp) disp) - ((string-match "^ *PID" disp) - (cons (propertize disp 'face 'helm-top-columns) "")) - (t (cons disp ""))))) - -(defun helm-top-action-transformer (actions _candidate) - "Action transformer for `top'. -Show actions only on line starting by a PID." - (let ((disp (helm-get-selection nil t))) - (cond ((string-match "^ *[0-9]+" disp) - (list '("kill (SIGTERM)" . (lambda (pid) (helm-top-sh "TERM" pid))) - '("kill (SIGKILL)" . (lambda (pid) (helm-top-sh "KILL" pid))) - '("kill (SIGINT)" . (lambda (pid) (helm-top-sh "INT" pid))) - '("kill (Choose signal)" - . (lambda (pid) - (helm-top-sh - (helm-comp-read (format "Kill [%s] with signal: " pid) - '("ALRM" "HUP" "INT" "KILL" "PIPE" "POLL" - "PROF" "TERM" "USR1" "USR2" "VTALRM" - "STKFLT" "PWR" "WINCH" "CHLD" "URG" - "TSTP" "TTIN" "TTOU" "STOP" "CONT" - "ABRT" "FPE" "ILL" "QUIT" "SEGV" - "TRAP" "SYS" "EMT" "BUS" "XCPU" "XFSZ") - :must-match t) - pid))))) - (t actions)))) - -(defun helm-top-sh (sig pid) - "Run kill shell command with signal SIG on PID for `helm-top'." - (let ((cmd (format "kill -%s %s" sig pid))) - (message "Executed %s\n%s" cmd (shell-command-to-string cmd)))) - -(defun helm-top-sh-persistent-action (pid) - (delete-other-windows) - (helm-top-sh "TERM" pid) - (helm-force-update)) - -(defun helm-top-init () - "Insert output of top command in candidate buffer." - (unless helm-top-sort-fn (helm-top-set-mode-line "CPU")) - (with-current-buffer (helm-candidate-buffer 'global) - (call-process-shell-command - (format helm-top-command (frame-width)) - nil (current-buffer)))) - -(defun helm-top-display-to-real (line) - "Return pid only from LINE." - (car (split-string line))) - -;; Sort top command - -(defun helm-top-set-mode-line (str) - (if (string-match "Sort:\\[\\(.*\\)\\] " helm-top-mode-line) - (setq helm-top-mode-line (replace-match str nil nil helm-top-mode-line 1)) - (setq helm-top-mode-line (concat (format "Sort:[%s] " str) helm-top-mode-line)))) - -(defun helm-top-sort-transformer (candidates source) - (helm-top-transformer - (if helm-top-sort-fn - (cl-loop for c in candidates - if (string-match "^ *[0-9]+" c) - collect c into pid-cands - else collect c into header-cands - finally return (append - header-cands - (sort pid-cands helm-top-sort-fn))) - candidates) - source)) - -(defun helm-top-sort-by-com (s1 s2) - (let* ((split-1 (split-string s1)) - (split-2 (split-string s2)) - (com-1 (nth 11 split-1)) - (com-2 (nth 11 split-2))) - (string< com-1 com-2))) - -(defun helm-top-sort-by-mem (s1 s2) - (let* ((split-1 (split-string s1)) - (split-2 (split-string s2)) - (mem-1 (string-to-number (nth 9 split-1))) - (mem-2 (string-to-number (nth 9 split-2)))) - (> mem-1 mem-2))) - -(defun helm-top-sort-by-user (s1 s2) - (let* ((split-1 (split-string s1)) - (split-2 (split-string s2)) - (user-1 (nth 1 split-1)) - (user-2 (nth 1 split-2))) - (string< user-1 user-2))) - -(defun helm-top-run-sort-by-com () - (interactive) - (helm-top-set-mode-line "COM") - (setq helm-top-sort-fn 'helm-top-sort-by-com) - (helm-force-update)) - -(defun helm-top-run-sort-by-cpu () - (interactive) - (helm-top-set-mode-line "CPU") - (setq helm-top-sort-fn nil) - (helm-force-update)) - -(defun helm-top-run-sort-by-mem () - (interactive) - (helm-top-set-mode-line "MEM") - (setq helm-top-sort-fn 'helm-top-sort-by-mem) - (helm-force-update)) - -(defun helm-top-run-sort-by-user () - (interactive) - (helm-top-set-mode-line "USER") - (setq helm-top-sort-fn 'helm-top-sort-by-user) - (helm-force-update)) - - -;;; X RandR resolution change -;; -;; -;;; FIXME I do not care multi-display. - -(defun helm-xrandr-info () - "Return a pair with current X screen number and current X display name." - (with-temp-buffer - (call-process "xrandr" nil (current-buffer) nil - "--current") - (let (screen output) - (goto-char (point-min)) - (save-excursion - (when (re-search-forward "\\(^Screen \\)\\([0-9]\\):" nil t) - (setq screen (match-string 2)))) - (when (re-search-forward "^\\(.*\\) connected" nil t) - (setq output (match-string 1))) - (list screen output)))) - -(defun helm-xrandr-screen () - "Return current X screen number." - (car (helm-xrandr-info))) - -(defun helm-xrandr-output () - "Return current X display name." - (cadr (helm-xrandr-info))) - -(defvar helm-source-xrandr-change-resolution - '((name . "Change Resolution") - (candidates - . (lambda () - (with-temp-buffer - (call-process "xrandr" nil (current-buffer) nil - "--screen" (helm-xrandr-screen) "-q") - (goto-char 1) - (cl-loop with modes = nil - while (re-search-forward " \\([0-9]+x[0-9]+\\)" nil t) - for mode = (match-string 1) - unless (member mode modes) - collect mode into modes - finally return modes)))) - (action - ("Change Resolution" - . (lambda (mode) - (call-process "xrandr" nil nil nil - "--screen" (helm-xrandr-screen) - "--output" (helm-xrandr-output) - "--mode" mode)))))) - - -;;; Emacs process -;; -;; -(defvar helm-source-emacs-process - '((name . "Emacs Process") - (init . (lambda () (list-processes--refresh))) - (candidates . (lambda () (mapcar #'process-name (process-list)))) - (persistent-action . (lambda (elm) - (delete-process (get-process elm)) - (helm-delete-current-selection))) - (update . list-processes--refresh) - (persistent-help . "Kill Process") - (action ("Kill Process" . (lambda (elm) - (delete-process (get-process elm))))))) - - -;;;###autoload -(defun helm-top () - "Preconfigured `helm' for top command." - (interactive) - (save-window-excursion - (unless helm-alive-p (delete-other-windows)) - (helm :sources 'helm-source-top - :buffer "*helm top*" :full-frame t - :candidate-number-limit 9999 - :preselect "^\\s-*[0-9]+"))) - -;;;###autoload -(defun helm-list-emacs-process () - "Preconfigured `helm' for emacs process." - (interactive) - (helm-other-buffer 'helm-source-emacs-process "*helm process*")) - -;;;###autoload -(defun helm-xrandr-set () - (interactive) - (helm :sources 'helm-source-xrandr-change-resolution - :buffer "*helm xrandr*")) - -(provide 'helm-sys) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-sys.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-tags.el b/emacs.d/elpa/helm-20141016.2217/helm-tags.el deleted file mode 100644 index 06d51da..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-tags.el +++ /dev/null @@ -1,339 +0,0 @@ -;;; helm-tags.el --- Helm for Etags and Ctags. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'helm-utils) - - -(defgroup helm-tags nil - "Tags related Applications and libraries for Helm." - :group 'helm) - -(defcustom helm-etags-tag-file-name "TAGS" - "Etags tag file name." - :type 'string - :group 'helm-tags) - -(defcustom helm-etags-tag-file-search-limit 10 - "The limit level of directory to search tag file. -Don't search tag file deeply if outside this value." - :type 'number - :group 'helm-tags) - -(defcustom helm-etags-match-part-only t - "Whether to match only the tag part of CANDIDATE in -helm-source-ctags-select." - :type 'boolean - :group 'helm-tags) - -(defcustom helm-etags-execute-action-at-once-if-one t - "Whether to jump straight to the selected tag if there's only -one match." - :type 'boolean - :group 'helm-tags) - -(defun helm-etags-run-switch-other-window () - "Run switch to other window action from `helm-source-etags-select'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action - (lambda (c) - (helm-etags-action-goto 'find-file-other-window c))))) - -(defun helm-etags-run-switch-other-frame () - "Run switch to other frame action from `helm-source-etags-select'." - (interactive) - (with-helm-alive-p - (helm-quit-and-execute-action - (lambda (c) - (helm-etags-action-goto 'find-file-other-frame c))))) - -(defvar helm-etags-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (define-key map (kbd "M-") 'helm-goto-next-file) - (define-key map (kbd "M-") 'helm-goto-precedent-file) - (define-key map (kbd "C-w") 'helm-yank-text-at-point) - (define-key map (kbd "C-c ?") 'helm-etags-help) - (define-key map (kbd "C-c o") 'helm-etags-run-switch-other-window) - (define-key map (kbd "C-c C-o") 'helm-etags-run-switch-other-frame) - map) - "Keymap used in Etags.") - - -;;; Ctags -;; -;; -(defvar helm-ctags-modes - '( c-mode c++-mode awk-mode csharp-mode java-mode javascript-mode lua-mode - makefile-mode pascal-mode perl-mode cperl-mode php-mode python-mode - scheme-mode sh-mode slang-mode sql-mode tcl-mode )) - -(defun helm-ctags-init () - (when (and buffer-file-name - (memq major-mode helm-ctags-modes) - (helm-current-buffer-is-modified)) - (with-current-buffer (helm-candidate-buffer 'local) - (call-process-shell-command - (if (string-match "\\.el\\.gz$" helm-buffer-file-name) - (format "ctags -e -u -f- --language-force=lisp --fields=n =(zcat %s) " - helm-buffer-file-name) - (format "ctags -e -u -f- --fields=n %s " helm-buffer-file-name)) - nil (current-buffer)) - (goto-char (point-min)) - (forward-line 2) - (delete-region (point-min) (point)) - (cl-loop while (and (not (eobp)) (search-forward "\001" (point-at-eol) t)) - for lineno-start = (point) - for lineno = (buffer-substring - lineno-start - (1- (search-forward "," (point-at-eol) t))) - do - (forward-line 0) - (insert (format "%5s:" lineno)) - (search-forward "\177" (point-at-eol) t) - (delete-region (1- (point)) (point-at-eol)) - (forward-line 1))))) - -(defvar helm-source-ctags - '((name . "Exuberant ctags") - (init . helm-ctags-init) - (candidates-in-buffer) - (adjust) - (type . line)) - "Needs Exuberant Ctags. - -http://ctags.sourceforge.net/") - - -;;; Etags -;; -;; -(defvar helm-etags-mtime-alist nil - "Store the last modification time of etags files here.") -(defvar helm-etags-cache (make-hash-table :test 'equal) - "Cache content of etags files used here for faster access.") - -(defun helm-etags-get-tag-file (&optional directory) - "Return the path of etags file if found. -Lookes recursively in parents directorys for a -`helm-etags-tag-file-name' file." - ;; Get tag file from `default-directory' or upper directory. - (let ((current-dir (helm-etags-find-tag-file-directory - (or directory default-directory)))) - ;; Return nil if not find tag file. - (when current-dir - (expand-file-name helm-etags-tag-file-name current-dir)))) - -(defun helm-etags-all-tag-files () - "Return files from the following sources; - 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. - 2) `tags-file-name', which is commonly set by `find-tag' command. - 3) `tags-table-list' which is commonly set by `visit-tags-table' command." - (helm-fast-remove-dups - (delq nil - (append (list (helm-etags-get-tag-file) - tags-file-name) - tags-table-list)) - :test 'equal)) - -(defun helm-etags-find-tag-file-directory (current-dir) - "Try to find the directory containing tag file. -If not found in CURRENT-DIR search in upper directory." - (let ((file-exists? #'(lambda (dir) - (let ((tag-path (expand-file-name - helm-etags-tag-file-name dir))) - (and (stringp tag-path) - (file-regular-p tag-path) - (file-readable-p tag-path)))))) - (cl-loop with count = 0 - until (funcall file-exists? current-dir) - ;; Return nil if outside the value of - ;; `helm-etags-tag-file-search-limit'. - if (= count helm-etags-tag-file-search-limit) - do (cl-return nil) - ;; Or search upper directories. - else - do (cl-incf count) - (setq current-dir (expand-file-name (concat current-dir "../"))) - finally return current-dir))) - -(defun helm-etags-get-header-name (_x) - "Create header name for this helm etags session." - (concat "Etags in " - (with-helm-current-buffer - (helm-etags-get-tag-file)))) - -(defun helm-etags-create-buffer (file) - "Create the `helm-buffer' based on contents of etags tag FILE." - (let* ((tag-fname file) - max - (split (with-current-buffer (find-file-noselect tag-fname) - (prog1 - (split-string (buffer-string) "\n" 'omit-nulls) - (setq max (line-number-at-pos (point-max))) - (kill-buffer)))) - (progress-reporter (make-progress-reporter "Loading tag file..." 0 max))) - (cl-loop - with fname - with cand - for i in split for count from 0 - for elm = (unless (string-match "^\x0c" i) - (helm-aif (string-match "\177" i) - (substring i 0 it) - i)) - do (cond ((and elm (string-match "^\\([^,]+\\),[0-9]+$" elm)) - (setq fname (match-string 1 elm))) - (elm (setq cand (concat fname ": " elm))) - (t (setq cand nil))) - when cand do (progn - (insert (concat cand "\n")) - (progress-reporter-update progress-reporter count))))) - -(defun helm-etags-init () - "Feed `helm-buffer' using `helm-etags-cache' or tag file. -If no entry in cache, create one." - (let ((tagfiles (helm-etags-all-tag-files))) - (when tagfiles - (with-current-buffer (helm-candidate-buffer 'global) - (dolist (f tagfiles) - (helm-aif (gethash f helm-etags-cache) - ;; An entry is present in cache, insert it. - (insert it) - ;; No entry, create a new buffer using content of tag file (slower). - (helm-etags-create-buffer f) - ;; Store content of buffer in cache. - (puthash f (buffer-string) helm-etags-cache) - ;; Store or set the last modification of tag file. - (helm-aif (assoc f helm-etags-mtime-alist) - ;; If an entry exists modify it. - (setcdr it (helm-etags-mtime f)) - ;; No entry create a new one. - (add-to-list 'helm-etags-mtime-alist - (cons f (helm-etags-mtime f)))))))))) - -(defun helm-etags-split-line (line) - (let ((regexp "\\`\\([[:lower:][:upper:]]?:?.*?\\): \\(.*\\)")) - (when (string-match regexp line) - (cl-loop for n from 1 to 2 collect (match-string n line))))) - -(defvar helm-source-etags-select - `((name . "Etags") - (header-name . helm-etags-get-header-name) - (init . helm-etags-init) - (candidates-in-buffer) - (match-part . (lambda (candidate) - ;; Match only the tag part of CANDIDATE - ;; and not the filename. - (if helm-etags-match-part-only - (cadr (helm-etags-split-line candidate)) - candidate))) - (mode-line . helm-etags-mode-line-string) - (keymap . ,helm-etags-map) - (action . (("Go to tag" . (lambda (c) - (helm-etags-action-goto 'find-file c))) - ("Go to tag in other window" . (lambda (c) - (helm-etags-action-goto - 'find-file-other-window - c))) - ("Go to tag in other frame" . (lambda (c) - (helm-etags-action-goto - 'find-file-other-frame - c))))) - (persistent-help . "Go to line") - (persistent-action . (lambda (candidate) - (helm-etags-action-goto 'find-file candidate) - (helm-highlight-current-line)))) - "Helm source for Etags.") - -(defvar find-tag-marker-ring) - -(defun helm-etags-action-goto (switcher candidate) - "Helm default action to jump to an etags entry in other window." - (require 'etags) - (helm-log-run-hook 'helm-goto-line-before-hook) - (let* ((split (helm-etags-split-line candidate)) - (fname (cl-loop for tagf being the hash-keys of helm-etags-cache - for f = (expand-file-name - (car split) (file-name-directory tagf)) - when (file-exists-p f) - return f)) - (elm (cadr split))) - (if (null fname) - (error "file %s not found" fname) - (ring-insert find-tag-marker-ring (point-marker)) - (funcall switcher fname) - (goto-char (point-min)) - (search-forward elm nil t) - (goto-char (match-beginning 0))))) - -(defun helm-etags-mtime (file) - "Last modification time of etags tag FILE." - (cadr (nth 5 (file-attributes file)))) - -(defun helm-etags-file-modified-p (file) - "Check if tag FILE have been modified in this session. -If FILE is nil return nil." - (let ((last-modif (and file - (assoc-default file helm-etags-mtime-alist)))) - (and last-modif - (/= last-modif (helm-etags-mtime file))))) - - -;;;###autoload -(defun helm-etags-select (arg) - "Preconfigured helm for etags. -If called with a prefix argument or if any of the tag files have -been modified, reinitialize cache. - -This function aggregates three sources of tag files: - - 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. - 2) `tags-file-name', which is commonly set by `find-tag' command. - 3) `tags-table-list' which is commonly set by `visit-tags-table' command." - (interactive "P") - (let ((tag-files (helm-etags-all-tag-files)) - (helm-execute-action-at-once-if-one helm-etags-execute-action-at-once-if-one) - (str (thing-at-point 'symbol))) - (if (cl-notany 'file-exists-p tag-files) - (message "Error: No tag file found. Create with etags shell command, or visit with `find-tag' or `visit-tags-table'.") - (cl-loop for k being the hash-keys of helm-etags-cache - unless (member k tag-files) - do (remhash k helm-etags-cache)) - (mapc (lambda (f) - (when (or (equal arg '(4)) - (and helm-etags-mtime-alist - (helm-etags-file-modified-p f))) - (remhash f helm-etags-cache))) - tag-files) - (helm :sources 'helm-source-etags-select - :keymap helm-etags-map - :default (list (concat "\\_<" str "\\_>") str) - :buffer "*helm etags*")))) - -(provide 'helm-tags) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-tags.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-utils.el b/emacs.d/elpa/helm-20141016.2217/helm-utils.el deleted file mode 100644 index 42058e5..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-utils.el +++ /dev/null @@ -1,960 +0,0 @@ -;;; helm-utils.el --- Utilities Functions for helm. -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) -(require 'compile) ; Fixme: Is this needed? -(require 'dired) - -(declare-function helm-find-files-1 "helm-files.el" (fname &optional preselect)) - - -(defgroup helm-utils nil - "Utilities routines for Helm." - :group 'helm) - -(defcustom helm-su-or-sudo "sudo" - "What command to use for root access." - :type 'string - :group 'helm-utils) - -(defcustom helm-yank-symbol-first nil - "`helm-yank-text-at-point' yanks symbol at point on first -invocation if this is non-nil." - :type 'boolean - :group 'helm-utils) - -(defcustom helm-default-kbsize 1024.0 - "Default Kbsize to use for showing files size. -It is a float, usually 1024.0 but could be 1000.0 on some systems." - :group 'helm-utils - :type 'float) - -(defvar helm-goto-line-before-hook '(helm-save-current-pos-to-mark-ring) - "Run before jumping to line. -This hook run when jumping from `helm-goto-line', `helm-etags-default-action', -and `helm-imenu-default-action'.") - -(defvar helm-save-pos-before-jump-register ?_ - "The register where `helm-save-pos-to-register-before-jump' save position.") - -(defface helm-selection-line - '((t (:background "IndianRed4" :underline t))) - "Face used in the `helm-current-buffer' when jumping to candidate." - :group 'helm-utils) - - -;;; compatibility -;; -;; -(unless (fboundp 'window-system) - (defun window-system (&optional _arg) - window-system)) - -(unless (fboundp 'make-composed-keymap) - (defun make-composed-keymap (maps &optional parent) - "Construct a new keymap composed of MAPS and inheriting from PARENT. -When looking up a key in the returned map, the key is looked in each -keymap of MAPS in turn until a binding is found. -If no binding is found in MAPS, the lookup continues in PARENT, if non-nil. -As always with keymap inheritance, a nil binding in MAPS overrides -any corresponding binding in PARENT, but it does not override corresponding -bindings in other keymaps of MAPS. -MAPS can be a list of keymaps or a single keymap. -PARENT if non-nil should be a keymap." - `(keymap - ,@(if (keymapp maps) (list maps) maps) - ,@parent))) - -(unless (fboundp 'assoc-default) - (defun assoc-default (key alist &optional test default) - "Find object KEY in a pseudo-alist ALIST. -ALIST is a list of conses or objects. Each element (or the element's car, -if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY). -If that is non-nil, the element matches; -then `assoc-default' returns the element's cdr, if it is a cons, -or DEFAULT if the element is not a cons. - -If no element matches, the value is nil. -If TEST is omitted or nil, `equal' is used." - (let (found (tail alist) value) - (while (and tail (not found)) - (let ((elt (car tail))) - (when (funcall (or test 'equal) (if (consp elt) (car elt) elt) key) - (setq found t value (if (consp elt) (cdr elt) default)))) - (setq tail (cdr tail))) - value))) - -;; Function not available in XEmacs, -(unless (fboundp 'minibuffer-contents) - (defun minibuffer-contents () - "Return the user input in a minbuffer as a string. -The current buffer must be a minibuffer." - (field-string (point-max))) - - (defun delete-minibuffer-contents () - "Delete all user input in a minibuffer. -The current buffer must be a minibuffer." - (delete-field (point-max)))) - -;; Function not available in older Emacs (<= 22.1). -(unless (fboundp 'buffer-chars-modified-tick) - (defun buffer-chars-modified-tick (&optional buffer) - "Return BUFFER's character-change tick counter. -Each buffer has a character-change tick counter, which is set to the -value of the buffer's tick counter (see `buffer-modified-tick'), each -time text in that buffer is inserted or deleted. By comparing the -values returned by two individual calls of `buffer-chars-modified-tick', -you can tell whether a character change occurred in that buffer in -between these calls. No argument or nil as argument means use current -buffer as BUFFER." - (with-current-buffer (or buffer (current-buffer)) - (if (listp buffer-undo-list) - (length buffer-undo-list) - (buffer-modified-tick))))) - -;; Functions not available in versions < emacs-24. -;; Allow using helm-async.el in Emacs-23 among other things. -(unless (and (fboundp 'file-equal-p) - (fboundp 'file-in-directory-p)) - (defun file-equal-p (file1 file2) - "Return non-nil if files FILE1 and FILE2 name the same file. -If FILE1 or FILE2 does not exist, the return value is unspecified." - (let ((handler (or (find-file-name-handler file1 'file-equal-p) - (find-file-name-handler file2 'file-equal-p)))) - (if handler - (funcall handler 'file-equal-p file1 file2) - (let (f1-attr f2-attr) - (and (setq f1-attr (file-attributes (file-truename file1))) - (setq f2-attr (file-attributes (file-truename file2))) - (equal f1-attr f2-attr)))))) - - ;; This is the original loop version, more readable, not the one of 24.1+. - (defun file-in-directory-p (file dir) - "Return non-nil if FILE is in DIR or a subdirectory of DIR. -A directory is considered to be \"in\" itself. -Return nil if DIR is not an existing directory." - (let ((handler (or (find-file-name-handler file 'file-in-directory-p) - (find-file-name-handler dir 'file-in-directory-p)))) - (if handler - (funcall handler 'file-in-directory-p file dir) - (when (file-directory-p dir) - (cl-loop with f1 = (file-truename file) - with f2 = (file-truename dir) - with ls1 = (or (split-string f1 "/" t) (list "/")) - with ls2 = (or (split-string f2 "/" t) (list "/")) - for p = (string-match "^/" f1) - for i in ls1 for j in ls2 - when (string= i j) - concat (if p (concat "/" i) (concat i "/")) into root - finally return (file-equal-p (file-truename root) f2))))))) - - -;; CUA workaround -(defadvice cua-delete-region (around helm-avoid-cua activate) - (ignore-errors ad-do-it)) - -(defadvice copy-region-as-kill (around helm-avoid-cua activate) - (if cua-mode - (ignore-errors ad-do-it) - ad-do-it)) - - -;;; Utils functions -;; -;; -(defun helm-ff-find-printers () - "Return a list of available printers on Unix systems." - (when (executable-find "lpstat") - (let ((printer-list (with-temp-buffer - (call-process "lpstat" nil t nil "-a") - (split-string (buffer-string) "\n")))) - (cl-loop for p in printer-list - for printer = (car (split-string p)) - when printer - collect printer)))) - -;; Shut up byte compiler in emacs24*. -(defun helm-switch-to-buffer (buffer-or-name) - "Same as `switch-to-buffer' whithout warnings at compile time." - (with-no-warnings - (switch-to-buffer buffer-or-name))) - -(cl-defmacro helm-position (item seq &key (test 'eq) all) - "A simple and faster replacement of CL `position'. -Return position of first occurence of ITEM found in SEQ. -Argument SEQ can be a string, in this case ITEM have to be a char. -Argument ALL, if non--nil specify to return a list of positions of -all ITEM found in SEQ." - (let ((key (if (stringp seq) 'across 'in))) - `(cl-loop for c ,key ,seq - for index from 0 - when (funcall ,test c ,item) - if ,all collect index into ls - else return index - finally return ls))) - -(defun helm-substring (str width) - "Return the substring of string STR from 0 to WIDTH. -Handle multibyte characters by moving by columns." - (with-temp-buffer - (save-excursion - (insert str)) - (move-to-column width) - (buffer-substring (point-at-bol) (point)))) - -(cl-defun helm-substring-by-width (str width &optional (endstr "...")) - "Truncate string STR to end at column WIDTH. -Similar to `truncate-string-to-width'. -Add ENDSTR (default \"...\") at end of truncated STR. -Add spaces at end if needed to reach WIDTH when STR is shorter than WIDTH." - (cl-loop for ini-str = str - then (substring ini-str 0 (1- (length ini-str))) - for sw = (string-width ini-str) - when (<= sw width) return - (concat ini-str endstr (make-string (- width sw) ? )))) - -(defun helm-string-multibyte-p (str) - "Check if string STR contains multibyte characters." - (cl-loop for c across str - thereis (> (char-width c) 1))) - -(defun helm-get-pid-from-process-name (process-name) - "Get pid from running process PROCESS-NAME." - (cl-loop with process-list = (list-system-processes) - for pid in process-list - for process = (assoc-default 'comm (process-attributes pid)) - when (and process (string-match process-name process)) - return pid)) - -(cl-defun helm-current-buffer-narrowed-p (&optional - (buffer helm-current-buffer)) - "Check if BUFFER is narrowed. -Default is `helm-current-buffer'." - (with-current-buffer buffer - (let ((beg (point-min)) - (end (point-max)) - (total (buffer-size))) - (or (/= beg 1) (/= end (1+ total)))))) - -(defun helm-region-active-p () - (and transient-mark-mode mark-active (/= (mark) (point)))) - -(defun helm-goto-char (loc) - "Go to char, revealing if necessary." - (goto-char loc) - (when (or (eq major-mode 'org-mode) - (and (boundp 'outline-minor-mode) - outline-minor-mode)) - (require 'org) ; On some old Emacs versions org may not be loaded. - (org-reveal))) - -(defun helm-goto-line (lineno &optional noanim) - "Goto LINENO opening only outline headline if needed. -Animation is used unless NOANIM is non--nil." - (helm-log-run-hook 'helm-goto-line-before-hook) - (goto-char (point-min)) - (helm-goto-char (point-at-bol lineno)) - (unless noanim - (helm-highlight-current-line nil nil nil nil 'pulse))) - -(defun helm-save-pos-to-register-before-jump () - "Save current buffer position to `helm-save-pos-before-jump-register'. -To use this add it to `helm-goto-line-before-hook'." - (with-helm-current-buffer - (unless helm-in-persistent-action - (point-to-register helm-save-pos-before-jump-register)))) - -(defun helm-save-current-pos-to-mark-ring () - "Save current buffer position to mark ring. -To use this add it to `helm-goto-line-before-hook'." - (with-helm-current-buffer - (unless helm-in-persistent-action - (set-marker (mark-marker) (point)) - (push-mark (point) 'nomsg)))) - -;;;###autoload -(defun helm-show-all-in-this-source-only (arg) - "Show only current source of this helm session with all its candidates. -With a numeric prefix arg show only the ARG number of candidates." - (interactive "p") - (with-helm-window - (with-helm-default-directory helm-default-directory - (let ((helm-candidate-number-limit (and (> arg 1) arg))) - (helm-set-source-filter - (list (assoc-default 'name (helm-get-current-source)))))))) - -;;;###autoload -(defun helm-display-all-sources () - "Display all sources previously hidden by `helm-set-source-filter'." - (interactive) - (helm-set-source-filter nil)) - -(defun helm-displaying-source-names () - "Return the list of sources name for this helm session." - (with-current-buffer helm-buffer - (goto-char (point-min)) - (cl-loop with pos - while (setq pos (next-single-property-change (point) 'helm-header)) - do (goto-char pos) - collect (buffer-substring-no-properties (point-at-bol)(point-at-eol)) - do (forward-line 1)))) - -(defun helm-files-match-only-basename (candidate) - "Allow matching only basename of file when \" -b\" is added at end of pattern. -If pattern contain one or more spaces, fallback to match-plugin -even is \" -b\" is specified." - (let ((source (helm-get-current-source))) - (if (string-match "\\([^ ]*\\) -b\\'" helm-pattern) - (progn - (helm-attrset 'no-matchplugin nil source) - (string-match (match-string 1 helm-pattern) - (helm-basename candidate))) - ;; Disable no-matchplugin by side effect. - (helm-aif (assq 'no-matchplugin source) - (setq source (delete it source))) - (string-match - (replace-regexp-in-string " -b\\'" "" helm-pattern) - candidate)))) - -(defun helm--mapconcat-candidate (candidate) - "Transform string CANDIDATE in regexp. -e.g helm.el$ - => \"[^h]*h[^e]*e[^l]*l[^m]*m[^.]*[.][^e]*e[^l]*l$\" - ^helm.el$ - => \"helm[.]el$\"." - (let ((ls (split-string candidate "" t))) - (if (string= "^" (car ls)) - (mapconcat (lambda (c) - (if (string= c ".") - (concat "[" c "]") c)) - (cdr ls) "") - (mapconcat (lambda (c) - (cond ((string= c ".") - (concat "[^" c "]*" (concat "[" c "]"))) - ((string= c "$") c) - (t (concat "[^" c "]*" (regexp-quote c))))) - ls "")))) - -(defun helm-skip-entries (seq regexp-list) - "Remove entries which matches one of REGEXP-LIST from SEQ." - (cl-loop for i in seq - unless (cl-loop for regexp in regexp-list - thereis (and (stringp i) - (string-match regexp i))) - collect i)) - -(defun helm-shadow-entries (seq regexp-list) - "Put shadow property on entries in SEQ matching a regexp in REGEXP-LIST." - (let ((face 'italic)) - (cl-loop for i in seq - if (cl-loop for regexp in regexp-list - thereis (and (stringp i) - (string-match regexp i))) - collect (propertize i 'face face) - else collect i))) - -(defun helm-stringify (str-or-sym) - "Get string of STR-OR-SYM." - (if (stringp str-or-sym) - str-or-sym - (symbol-name str-or-sym))) - -(defun helm-symbolify (str-or-sym) - "Get symbol of STR-OR-SYM." - (if (symbolp str-or-sym) - str-or-sym - (intern str-or-sym))) - -(defun helm-describe-function (func) - "FUNC is symbol or string." - (describe-function (helm-symbolify func)) - (message nil)) - -(defun helm-describe-variable (var) - "VAR is symbol or string." - (describe-variable (helm-symbolify var)) - (message nil)) - -(defun helm-find-function (func) - "FUNC is symbol or string." - (find-function (helm-symbolify func))) - -(defun helm-find-variable (var) - "VAR is symbol or string." - (find-variable (helm-symbolify var))) - -(defun helm-kill-new (candidate &optional replace) - "CANDIDATE is symbol or string. -See `kill-new' for argument REPLACE." - (kill-new (helm-stringify candidate) replace)) - -(cl-defun helm-fast-remove-dups (seq &key (test 'eq)) - "Remove duplicates elements in list SEQ. -This is same as `remove-duplicates' but with memoisation. -It is much faster, especially in large lists. -A test function can be provided with TEST argument key. -Default is `eq'." - (cl-loop with cont = (make-hash-table :test test) - for elm in seq - unless (gethash elm cont) - do (puthash elm elm cont) - finally return - (cl-loop for i being the hash-values in cont collect i))) - -;;;###autoload -(defun helm-quit-and-find-file () - "Drop into `helm-find-files' from `helm'. -If current selection is a buffer or a file, `helm-find-files' -from its directory." - (interactive) - (require 'helm-grep) - (helm-run-after-quit - (lambda (f) - (if (file-exists-p f) - (helm-find-files-1 (file-name-directory f) - (regexp-quote - (if helm-ff-transformer-show-only-basename - (helm-basename f) f))) - (helm-find-files-1 f))) - (let* ((sel (helm-get-selection)) - (grep-line (and (stringp sel) - (helm-grep-split-line sel))) - (bmk-name (replace-regexp-in-string "\\`\\*" "" sel)) - (bmk (assoc bmk-name bookmark-alist))) - (if (stringp sel) - (helm-aif (get-buffer (or (get-text-property - (1- (length sel)) 'buffer-name sel) - sel)) - (or (buffer-file-name it) - (car (rassoc it dired-buffers)) - (and (with-current-buffer it - (eq major-mode 'org-agenda-mode)) - org-directory - (expand-file-name org-directory)) - (with-current-buffer it default-directory)) - (cond (bmk (helm-aif (bookmark-get-filename bmk) - (if (and ffap-url-regexp - (string-match ffap-url-regexp it)) - it (expand-file-name it)) - default-directory)) - ((or (file-remote-p sel) - (file-exists-p sel)) - (expand-file-name sel)) - ((and grep-line (file-exists-p (car grep-line))) - (expand-file-name (car grep-line))) - ((and ffap-url-regexp (string-match ffap-url-regexp sel)) sel) - (t default-directory))) - default-directory)))) - -;; Same as `vc-directory-exclusion-list'. -(defvar helm-walk-ignore-directories - '("SCCS" "RCS" "CVS" "MCVS" ".svn" ".git" ".hg" ".bzr" - "_MTN" "_darcs" "{arch}")) - -(cl-defun helm-walk-directory (directory &key path (directories t) match skip-subdirs) - "Walk through DIRECTORY tree. -Argument PATH can be one of basename, relative, or full, default to basename. -Argument DIRECTORIES when non--nil (default) return also directories names, -otherwise skip directories names. -Argument MATCH can be a predicate or a regexp. -Argument SKIP-SUBDIRS when non--nil will skip `helm-walk-ignore-directories' -unless it is given as a list of directories, in this case this list will be used -instead of `helm-walk-ignore-directories'." - (let* (result - (fn (cl-case path - (basename 'file-name-nondirectory) - (relative 'file-relative-name) - (full 'identity) - (t 'file-name-nondirectory))) - ls-R) - (setq ls-R (lambda (dir) - (unless (and skip-subdirs - (member (helm-basename dir) - (if (listp skip-subdirs) - skip-subdirs - helm-walk-ignore-directories))) - (cl-loop with ls = (directory-files - dir t directory-files-no-dot-files-regexp) - for f in ls - if (file-directory-p f) - do (progn (when directories - (push (funcall fn f) result)) - ;; Don't recurse in directory symlink. - (unless (file-symlink-p f) - (funcall ls-R f))) - else do - (if match - (and (if (functionp match) - (funcall match f) - (and (stringp match) - (string-match - match (file-name-nondirectory f)))) - (push (funcall fn f) result)) - (push (funcall fn f) result)))))) - (funcall ls-R directory) - (nreverse result))) - -(defun helm-generic-sort-fn (s1 s2) - "Sort predicate function for helm candidates. -Args S1 and S2 can be single or \(display . real\) candidates, -that is sorting is done against real value of candidate." - (let* ((reg1 (concat "\\_<" helm-pattern "\\_>")) - (reg2 (concat "\\_<" helm-pattern)) - (split (split-string helm-pattern)) - (str1 (if (consp s1) (cdr s1) s1)) - (str2 (if (consp s2) (cdr s2) s2)) - (score #'(lambda (str r1 r2 lst) - (cond ((string-match r1 str) 4) - ((and (string-match " " helm-pattern) - (string-match (concat "\\_<" (car lst)) str) - (cl-loop for r in (cdr lst) - always (string-match r str))) 3) - ((and (string-match " " helm-pattern) - (cl-loop for r in lst always (string-match r str))) 2) - ((string-match r2 str) 1) - (t 0)))) - (sc1 (funcall score str1 reg1 reg2 split)) - (sc2 (funcall score str2 reg1 reg2 split))) - (cond ((or (zerop (string-width helm-pattern)) - (and (zerop sc1) (zerop sc2))) - (string-lessp str1 str2)) - ((= sc1 sc2) - (< (length str1) (length str2))) - (t (> sc1 sc2))))) - -(defun helm-basename (fname &optional ext) - "Print FNAME with any leading directory components removed. -If specified, also remove filename extension EXT." - (let ((non-essential t)) - (if (and ext (or (string= (file-name-extension fname) ext) - (string= (file-name-extension fname t) ext)) - (not (file-directory-p fname))) - (file-name-sans-extension (file-name-nondirectory fname)) - (file-name-nondirectory (directory-file-name fname))))) - -(defun helm-basedir (fname) - "Return the base directory of filename." - (helm-aif (and fname (file-name-directory fname)) - (file-name-as-directory it))) - -(defun helm-ff-get-host-from-tramp-invalid-fname (fname) - "Extract hostname from an incomplete tramp file name. -Return nil on valid file name remote or not." - (let* ((str (helm-basename fname)) - (split (split-string str ":")) - (meth (car (member (car split) (mapcar 'car tramp-methods))))) - (when (and meth (<= (length split) 2)) - (cadr split)))) - -(cl-defun helm-file-human-size (size &optional (kbsize helm-default-kbsize)) - "Return a string showing SIZE of a file in human readable form. -SIZE can be an integer or a float depending it's value. -`file-attributes' will take care of that to avoid overflow error. -KBSIZE if a floating point number, defaulting to `helm-default-kbsize'." - (let ((M (cons "M" (/ size (expt kbsize 2)))) - (G (cons "G" (/ size (expt kbsize 3)))) - (K (cons "K" (/ size kbsize))) - (B (cons "B" size))) - (cl-loop with result = B - for (a . b) in - (cl-loop for (x . y) in (list M G K B) - unless (< y 1) collect (cons x y)) - when (< b (cdr result)) do (setq result (cons a b)) - finally return (if (string= (car result) "B") - (format "%s" size) - (format "%.1f%s" (cdr result) (car result)))))) - -(cl-defun helm-file-attributes - (file &key type links uid gid access-time modif-time - status size mode gid-change inode device-num dired human-size - mode-type mode-owner mode-group mode-other (string t)) - "Return `file-attributes' elements of FILE separately according to key value. -Availables keys are: -- TYPE: Same as nth 0 `files-attributes' if STRING is nil - otherwise return either symlink, directory or file (default). -- LINKS: See nth 1 `files-attributes'. -- UID: See nth 2 `files-attributes'. -- GID: See nth 3 `files-attributes'. -- ACCESS-TIME: See nth 4 `files-attributes', however format time - when STRING is non--nil (the default). -- MODIF-TIME: See nth 5 `files-attributes', same as above. -- STATUS: See nth 6 `files-attributes', same as above. -- SIZE: See nth 7 `files-attributes'. -- MODE: See nth 8 `files-attributes'. -- GID-CHANGE: See nth 9 `files-attributes'. -- INODE: See nth 10 `files-attributes'. -- DEVICE-NUM: See nth 11 `files-attributes'. -- DIRED: A line similar to what 'ls -l' return. -- HUMAN-SIZE: The size in human form, see `helm-file-human-size'. -- MODE-TYPE, mode-owner,mode-group, mode-other: Split what - nth 7 `files-attributes' return in four categories. -- STRING: When non--nil (default) `helm-file-attributes' return - more friendly values. -If you want the same behavior as `files-attributes' , -\(but with return values in proplist\) use a nil value for STRING. -However when STRING is non--nil, time and type value are different from what -you have in `file-attributes'." - (let* ((all (cl-destructuring-bind - (type links uid gid access-time modif-time - status size mode gid-change inode device-num) - (file-attributes file string) - (list :type (if string - (cond ((stringp type) "symlink") ; fname - (type "directory") ; t - (t "file")) ; nil - type) - :links links - :uid uid - :gid gid - :access-time (if string - (format-time-string - "%Y-%m-%d %R" access-time) - access-time) - :modif-time (if string - (format-time-string - "%Y-%m-%d %R" modif-time) - modif-time) - :status (if string - (format-time-string - "%Y-%m-%d %R" status) - status) - :size size - :mode mode - :gid-change gid-change - :inode inode - :device-num device-num))) - (modes (helm-split-mode-file-attributes (cl-getf all :mode)))) - (cond (type (cl-getf all :type)) - (links (cl-getf all :links)) - (uid (cl-getf all :uid)) - (gid (cl-getf all :gid)) - (access-time (cl-getf all :access-time)) - (modif-time (cl-getf all :modif-time)) - (status (cl-getf all :status)) - (size (cl-getf all :size)) - (mode (cl-getf all :mode)) - (gid-change (cl-getf all :gid-change)) - (inode (cl-getf all :inode)) - (device-num (cl-getf all :device-num)) - (dired - (concat - (helm-split-mode-file-attributes (cl-getf all :mode) t) " " - (number-to-string (cl-getf all :links)) " " - (cl-getf all :uid) ":" - (cl-getf all :gid) " " - (if human-size - (helm-file-human-size (cl-getf all :size)) - (int-to-string (cl-getf all :size))) " " - (cl-getf all :modif-time))) - (human-size (helm-file-human-size (cl-getf all :size))) - (mode-type (cl-getf modes :mode-type)) - (mode-owner (cl-getf modes :user)) - (mode-group (cl-getf modes :group)) - (mode-other (cl-getf modes :other)) - (t (append all modes))))) - -(defun helm-split-mode-file-attributes (str &optional string) - "Split mode file attributes STR into a proplist. -If STRING is non--nil return instead a space separated string." - (cl-loop with type = (substring str 0 1) - with cdr = (substring str 1) - for i across cdr - for count from 1 - if (<= count 3) - concat (string i) into user - if (and (> count 3) (<= count 6)) - concat (string i) into group - if (and (> count 6) (<= count 9)) - concat (string i) into other - finally return - (if string - (mapconcat 'identity (list type user group other) " ") - (list :mode-type type :user user :group group :other other)))) - -(defun helm-current-directory () - "Return current-directory name at point. -Useful in dired buffers when there is inserted subdirs." - (if (eq major-mode 'dired-mode) - (dired-current-directory) - default-directory)) - -(defmacro with-helm-display-marked-candidates (buffer-or-name candidates &rest body) - (declare (indent 0) (debug t)) - (let ((buffer (make-symbol "buffer")) - (window (make-symbol "window"))) - `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name)) - ,window) - (unwind-protect - (with-current-buffer ,buffer - (dired-format-columns-of-files ,candidates) - (select-window - (setq ,window (temp-buffer-window-show - ,buffer - '(display-buffer-below-selected - (window-height . fit-window-to-buffer))))) - (progn ,@body)) - (quit-window 'kill ,window))))) - -;;; Persistent Action Helpers -;; -;; -;; Internal -(defvar helm-match-line-overlay nil) - -(defun helm-highlight-current-line (&optional start end buf face pulse) - "Highlight and underline current position" - (let* ((start (or start (line-beginning-position))) - (end (or end (1+ (line-end-position)))) - (args (list start end buf))) - (if (not helm-match-line-overlay) - (setq helm-match-line-overlay (apply 'make-overlay args)) - (apply 'move-overlay helm-match-line-overlay args)) - (overlay-put helm-match-line-overlay - 'face (or face 'helm-selection-line)) - (recenter) - (when pulse - (sit-for 0.3) - (helm-match-line-cleanup)))) - -(defun helm-match-line-cleanup () - (when helm-match-line-overlay - (delete-overlay helm-match-line-overlay) - (setq helm-match-line-overlay nil))) - -(defun helm-match-line-update () - (when helm-match-line-overlay - (delete-overlay helm-match-line-overlay) - (helm-highlight-current-line))) - -(add-hook 'helm-cleanup-hook 'helm-match-line-cleanup) -(add-hook 'helm-after-persistent-action-hook 'helm-match-line-update) - -(defun helm-w32-prepare-filename (file) - "Convert filename FILE to something usable by external w32 executables." - (replace-regexp-in-string ; For UNC paths - "/" "\\" - (replace-regexp-in-string ; Strip cygdrive paths - "/cygdrive/\\(.\\)" "\\1:" - file nil nil) nil t)) - -;;;###autoload -(defun helm-w32-shell-execute-open-file (file) - (interactive "fOpen file:") - (with-no-warnings - (w32-shell-execute "open" (helm-w32-prepare-filename file)))) - -(defun helm-open-file-with-default-tool (file) - "Open FILE with the default tool on this platform." - (let (process-connection-type) - (if (eq system-type 'windows-nt) - (helm-w32-shell-execute-open-file file) - (start-process "helm-open-file-with-default-tool" - nil - (cond ((eq system-type 'gnu/linux) - "xdg-open") - ((or (eq system-type 'darwin) ;; Mac OS X - (eq system-type 'macos)) ;; Mac OS 9 - "open")) - file)))) - -(defun helm-open-dired (file) - "Opens a dired buffer in FILE's directory. If FILE is a -directory, open this directory." - (if (file-directory-p file) - (dired file) - (dired (file-name-directory file)) - (dired-goto-file file))) - -(defun helm-action-line-goto (lineno-and-content) - (apply #'helm-goto-file-line - (append lineno-and-content - (list (helm-interpret-value (helm-attr 'target-file)) - (if (and (helm-attr-defined 'target-file) - (not helm-in-persistent-action)) - 'find-file-other-window - 'find-file))))) - -(cl-defun helm-action-file-line-goto (file-line-content) - (apply #'helm-goto-file-line - (if (stringp file-line-content) - ;; Case: filtered-candidate-transformer is skipped - (cdr (helm-filtered-candidate-transformer-file-line-1 - file-line-content)) - file-line-content))) - -(defun helm-require-or-error (feature function) - (or (require feature nil t) - (error "Need %s to use `%s'." feature function))) - -(defun helm-filtered-candidate-transformer-file-line (candidates _source) - (delq nil (mapcar 'helm-filtered-candidate-transformer-file-line-1 - candidates))) - -(defun helm-filtered-candidate-transformer-file-line-1 (candidate) - (when (string-match "^\\(.+?\\):\\([0-9]+\\):\\(.*\\)$" candidate) - (let ((filename (match-string 1 candidate)) - (lineno (match-string 2 candidate)) - (content (match-string 3 candidate))) - (cons (format "%s:%s\n %s" - (propertize filename 'face compilation-info-face) - (propertize lineno 'face compilation-line-face) - content) - (list (string-to-number lineno) content - (expand-file-name - filename - (or (helm-interpret-value (helm-attr 'default-directory)) - (and (helm-candidate-buffer) - (buffer-local-value - 'default-directory (helm-candidate-buffer)))))))))) - -(cl-defun helm-goto-file-line (lineno &optional content file (find-file-function #'find-file)) - (helm-aif (helm-attr 'before-jump-hook) - (funcall it)) - (when file (funcall find-file-function file)) - (if (helm-attr-defined 'adjust) - (helm-goto-line-with-adjustment lineno content) - (helm-goto-line lineno)) - (unless (helm-attr-defined 'recenter) - (set-window-start (get-buffer-window helm-current-buffer) (point))) - (helm-aif (helm-attr 'after-jump-hook) - (funcall it)) - (when helm-in-persistent-action - (helm-highlight-current-line))) - -(defun helm-find-file-as-root (candidate) - (let ((buf (helm-basename candidate)) - non-essential) - (if (buffer-live-p (get-buffer buf)) - (progn - (set-buffer buf) - (find-alternate-file (concat "/" helm-su-or-sudo - "::" (expand-file-name candidate)))) - (find-file (concat "/" helm-su-or-sudo "::" (expand-file-name candidate)))))) - -(defun helm-find-many-files (_ignore) - (let ((helm--reading-passwd-or-string t)) - (mapc 'find-file (helm-marked-candidates)))) - -(defun helm-goto-line-with-adjustment (line line-content) - (let ((startpos) - offset found pat) - ;; This constant is 1/2 the initial search window. - ;; There is no sense in making it too small, - ;; since just going around the loop once probably - ;; costs about as much as searching 2000 chars. - (setq offset 1000 - found nil - pat (concat (if (eq selective-display t) - "\\(^\\|\^m\\) *" "^ *") ;allow indent - (regexp-quote line-content))) - ;; If no char pos was given, try the given line number. - (setq startpos (progn (helm-goto-line line) (point))) - (or startpos (setq startpos (point-min))) - ;; First see if the tag is right at the specified location. - (goto-char startpos) - (setq found (looking-at pat)) - (while (and (not found) - (progn - (goto-char (- startpos offset)) - (not (bobp)))) - (setq found - (re-search-forward pat (+ startpos offset) t) - offset (* 3 offset))) ; expand search window - (or found - (re-search-forward pat nil t) - (error "not found"))) - ;; Position point at the right place - ;; if the search string matched an extra Ctrl-m at the beginning. - (and (eq selective-display t) - (looking-at "\^m") - (forward-char 1)) - (forward-line 0)) - -(defun helm-quit-and-execute-action (action) - "Quit current helm session and execute ACTION." - (setq helm-saved-action action) - (helm-exit-minibuffer)) - -;; Yank text at point. -;; -;; -;; Internal -(defvar helm-yank-point nil) - -;;;###autoload -(defun helm-yank-text-at-point () - "Yank text at point in `helm-current-buffer' into minibuffer. -If `helm-yank-symbol-first' is non--nil the first yank -grabs the entire symbol." - (interactive) - (with-helm-current-buffer - (let ((fwd-fn (if helm-yank-symbol-first - 'forward-symbol 'forward-word))) - ;; Start to initial point if C-w have never been hit. - (unless helm-yank-point (setq helm-yank-point (point))) - (save-excursion - (goto-char helm-yank-point) - (funcall fwd-fn 1) - (helm-set-pattern - (concat - helm-pattern (replace-regexp-in-string - "\\`\n" "" - (buffer-substring-no-properties - helm-yank-point (point))))) - (setq helm-yank-point (point)))))) - -(defun helm-reset-yank-point () - (setq helm-yank-point nil)) - -;; FIXME why do we run this after PA? -;; Seems it is not needed, thus it create a bug -;; when we want to hit repetitively C-w and follow-mode is enabled, -;; or if we run a PA between to hits on C-w. -;; Keep this commented for now. -;(add-hook 'helm-after-persistent-action-hook 'helm-reset-yank-point) -(add-hook 'helm-cleanup-hook 'helm-reset-yank-point) -(add-hook 'helm-after-initialize-hook 'helm-reset-yank-point) - -(defun helm-html-bookmarks-to-alist (file url-regexp bmk-regexp) - "Parse html bookmark FILE and return an alist with (title . url) as elements." - (let (bookmarks-alist url title) - (with-temp-buffer - (insert-file-contents file) - (goto-char (point-min)) - (while (re-search-forward "href=\\|^ *

\\([^><]+.[^]\\)") -(defvar helm-w3m-bookmark-url-regexp "\\(https\\|http\\|ftp\\|file\\)://[^>]*") -(defvar helm-w3m-bookmarks-alist nil) -(defvar helm-source-w3m-bookmarks - '((name . "W3m Bookmarks") - (init . (lambda () - (setq helm-w3m-bookmarks-alist - (helm-html-bookmarks-to-alist - w3m-bookmark-file - helm-w3m-bookmark-url-regexp - helm-w3m-bookmarks-regexp)))) - (candidates . (lambda () - (mapcar #'car helm-w3m-bookmarks-alist))) - (filtered-candidate-transformer - helm-adaptive-sort - helm-highlight-w3m-bookmarks) - (action . (("Browse Url" - . (lambda (candidate) - (helm-w3m-browse-bookmark candidate))) - ("Copy Url" - . (lambda (elm) - (kill-new (helm-w3m-bookmarks-get-value elm)))) - ("Browse Url Externally" - . (lambda (candidate) - (helm-w3m-browse-bookmark candidate t))) - ("Delete Bookmark" - . (lambda (candidate) - (helm-w3m-delete-bookmark candidate))) - ("Rename Bookmark" - . (lambda (candidate) - (helm-w3m-rename-bookmark candidate))))) - (persistent-action . (lambda (candidate) - (if current-prefix-arg - (helm-w3m-browse-bookmark candidate t) - (helm-w3m-browse-bookmark candidate nil t)))) - (persistent-help . "Open URL with emacs-w3m in new tab / \ -C-u \\[helm-execute-persistent-action]: Open URL with Firefox")) - "Needs w3m and emacs-w3m. - -http://w3m.sourceforge.net/ -http://emacs-w3m.namazu.org/") - - -(defun helm-w3m-bookmarks-get-value (elm) - (replace-regexp-in-string - "\"" "" (cdr (assoc elm helm-w3m-bookmarks-alist)))) - -(defun helm-w3m-browse-bookmark (elm &optional use-external new-tab) - (let* ((fn (if use-external 'helm-browse-url 'w3m-browse-url)) - (arg (and (eq fn 'w3m-browse-url) new-tab))) - (funcall fn (helm-w3m-bookmarks-get-value elm) arg))) - -(defun helm-highlight-w3m-bookmarks (bookmarks _source) - (cl-loop for i in bookmarks - collect (propertize - i 'face 'helm-w3m-bookmarks - 'help-echo (helm-w3m-bookmarks-get-value i)))) - - -(defun helm-w3m-delete-bookmark (elm) - "Delete w3m bookmark from `w3m-bookmark-file'." - (with-current-buffer - (find-file-literally w3m-bookmark-file) - (goto-char (point-min)) - (when (re-search-forward elm nil t) - (forward-line 0) - (delete-region (point) - (line-end-position)) - (delete-blank-lines)) - (save-buffer) - (kill-buffer))) - -(defun helm-w3m-rename-bookmark (elm) - "Rename w3m bookmark in `w3m-bookmark-file'." - (let* ((old-title (replace-regexp-in-string ">" "" elm)) - (new-title (helm-read-string "NewTitle: " old-title))) - (with-current-buffer - (find-file-literally w3m-bookmark-file) - (goto-char (point-min)) - (when (re-search-forward (concat elm "<") nil t) - (goto-char (1- (point))) - (delete-char (- (length old-title))) - (insert new-title)) - (save-buffer) - (kill-buffer)))) - -;;;###autoload -(defun helm-w3m-bookmarks () - "Preconfigured `helm' for w3m bookmark. - -Needs w3m and emacs-w3m. - -http://w3m.sourceforge.net/ -http://emacs-w3m.namazu.org/" - (interactive) - (helm-other-buffer 'helm-source-w3m-bookmarks - "*helm w3m bookmarks*")) - - -(provide 'helm-w3m) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-w3m.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm-yaoddmuse.el b/emacs.d/elpa/helm-20141016.2217/helm-yaoddmuse.el deleted file mode 100644 index 7df5332..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm-yaoddmuse.el +++ /dev/null @@ -1,171 +0,0 @@ -;;; helm-yaoddmuse.el --- Helm extension for yaoddmuse -*- lexical-binding: t -*- - -;; Copyright (C) 2012 ~ 2014 Thierry Volpiatto - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm) - -(declare-function yaoddmuse-update-pagename "ext:yaoddmuse.el" (&optional unforced)) -(declare-function yaoddmuse-get-library-list "ext:yaoddmuse.el" (&optional dirs string)) - -;; Be sure to have yaoddmuse.el installed -;; install-elisp may be required if you want to install elisp file from here. -(defvar helm-yaoddmuse-use-cache-file nil) -(defvar helm-yaoddmuse-cache-file "~/.emacs.d/yaoddmuse-cache.el") -(defvar helm-yaoddmuse-ew-cache nil) -(defvar yaoddmuse-pages-hash) - -(defun helm-yaoddmuse-get-candidates () - (if helm-yaoddmuse-use-cache-file - (ignore-errors - (unless helm-yaoddmuse-ew-cache - (load helm-yaoddmuse-cache-file) - (setq helm-yaoddmuse-ew-cache - (gethash "EmacsWiki" yaoddmuse-pages-hash))) - helm-yaoddmuse-ew-cache) - (yaoddmuse-update-pagename t) - (gethash "EmacsWiki" yaoddmuse-pages-hash))) - -(defvar helm-source-yaoddmuse-emacswiki-edit-or-view - '((name . "Yaoddmuse Edit or View (EmacsWiki)") - (candidates . helm-yaoddmuse-get-candidates) - (action . (("Edit page" . (lambda (candidate) - (yaoddmuse-edit "EmacsWiki" candidate))) - ("Browse page" - . (lambda (candidate) - (yaoddmuse-browse-page "EmacsWiki" candidate))) - ("Browse page other window" - . (lambda (candidate) - (if (one-window-p) - (split-window-vertically)) - (yaoddmuse-browse-page "EmacsWiki" candidate))) - ("Browse diff" - . (lambda (candidate) - (yaoddmuse-browse-page-diff "EmacsWiki" candidate))) - ("Copy URL" - . (lambda (candidate) - (kill-new (yaoddmuse-url "EmacsWiki" candidate)) - (message "Have copy page %s's URL to yank." candidate))) - ("Create page" - . (lambda (candidate) - (yaoddmuse-edit "EmacsWiki" helm-input))) - ("Update cache" - . (lambda (candidate) - (if helm-yaoddmuse-use-cache-file - (progn - (helm-yaoddmuse-cache-pages t) - (setq helm-yaoddmuse-ew-cache - (gethash "EmacsWiki" yaoddmuse-pages-hash))) - (yaoddmuse-update-pagename)))))) - (action-transformer helm-yaoddmuse-action-transformer)) - "Needs yaoddmuse.el. - -http://www.emacswiki.org/emacs/download/yaoddmuse.el") - - -(defvar helm-source-yaoddmuse-emacswiki-post-library - '((name . "Yaoddmuse Post library (EmacsWiki)") - (init . (helm-yaoddmuse-init)) - (candidates-in-buffer) - (action . (("Post library and Browse" - . (lambda (candidate) - (yaoddmuse-post-file - (find-library-name candidate) - "EmacsWiki" - (file-name-nondirectory (find-library-name candidate)) - nil t))) - ("Post library" - . (lambda (candidate) - (yaoddmuse-post-file - (find-library-name candidate) - "EmacsWiki" - (file-name-nondirectory - (find-library-name candidate)))))))) - "Needs yaoddmuse.el. - -http://www.emacswiki.org/emacs/download/yaoddmuse.el") - - -(defun helm-yaoddmuse-action-transformer (actions candidate) - "Allow the use of `install-elisp' only on elisp files." - (if (string-match "\.el$" candidate) - (append actions '(("Install Elisp" - . (lambda (elm) - (install-elisp-from-emacswiki elm))))) - actions)) - -;;;###autoload -(defun helm-yaoddmuse-cache-pages (&optional load) - "Fetch the list of files on emacswiki and create cache file. -If load is non--nil load the file and feed `yaoddmuse-pages-hash'." - (interactive) - (yaoddmuse-update-pagename) - (save-excursion - (find-file helm-yaoddmuse-cache-file) - (erase-buffer) - (insert "(puthash \"EmacsWiki\" '(") - (cl-loop for i in (gethash "EmacsWiki" yaoddmuse-pages-hash) - do - (insert (concat "(\"" (car i) "\") "))) - (insert ") yaoddmuse-pages-hash)\n") - (save-buffer) - (kill-buffer (current-buffer)) - (when (or current-prefix-arg - load) - (load helm-yaoddmuse-cache-file)))) - -(defun helm-yaoddmuse-init () - "Init helm buffer status." - (let ((helm-buffer (helm-candidate-buffer 'global)) - (library-list (yaoddmuse-get-library-list))) - (with-current-buffer helm-buffer - ;; Insert library name. - (cl-dolist (library library-list) - (insert (format "%s\n" library))) - ;; Sort lines. - (sort-lines nil (point-min) (point-max))))) - -;;;###autoload -(defun helm-yaoddmuse-emacswiki-edit-or-view () - "Preconfigured `helm' to edit or view EmacsWiki page. - -Needs yaoddmuse.el. - -http://www.emacswiki.org/emacs/download/yaoddmuse.el" - (interactive) - (helm :sources 'helm-source-yaoddmuse-emacswiki-edit-or-view)) - -;;;###autoload -(defun helm-yaoddmuse-emacswiki-post-library () - "Preconfigured `helm' to post library to EmacsWiki. - -Needs yaoddmuse.el. - -http://www.emacswiki.org/emacs/download/yaoddmuse.el" - (interactive) - (helm :sources 'helm-source-yaoddmuse-emacswiki-post-library)) - -(provide 'helm-yaoddmuse) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm-yaoddmuse.el ends here diff --git a/emacs.d/elpa/helm-20141016.2217/helm.el b/emacs.d/elpa/helm-20141016.2217/helm.el deleted file mode 100644 index 2536901..0000000 --- a/emacs.d/elpa/helm-20141016.2217/helm.el +++ /dev/null @@ -1,4673 +0,0 @@ -;;; helm.el --- Emacs incremental and narrowing framework -*- lexical-binding: t -*- - -;; Copyright (C) 2007 Tamas Patrovics -;; 2008 ~ 2011 rubikitch -;; 2011 ~ 2014 Thierry Volpiatto - -;; This is a fork of anything.el wrote by Tamas Patrovics. - -;; Authors of anything.el: Tamas Patrovics -;; rubikitch -;; Thierry Volpiatto - -;; Author: Thierry Volpiatto -;; URL: http://github.com/emacs-helm/helm - -;; 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 . - -;;; Code: - -(require 'cl-lib) -(require 'helm-source) - - -;;; Multi keys -;; -;; -;;;###autoload -(defun helm-define-multi-key (keymap key functions &optional delay) - "In KEYMAP, define key sequence KEY for function list FUNCTIONS. -Each function run sequentialy each time the key KEY is pressed. -If DELAY is specified switch back to initial function of FUNCTIONS list -after DELAY seconds. -The functions in FUNCTIONS list are functions with no args. -e.g - \(defun foo () - (message \"Run foo\")) - \(defun bar () - (message \"Run bar\")) - \(defun baz () - (message \"Run baz\")) - -\(helm-define-multi-key global-map \" q\" '(foo bar baz) 2) - -Each time \" q\" is pressed the next function is executed, if you wait -More than 2 seconds, next hit will run again the first function and so on." - (define-key keymap key (helm-make-multi-command functions delay))) - -;;;###autoload -(defmacro helm-multi-key-defun (name docstring funs &optional delay) - "Define NAME as a multi-key command running FUNS. -After DELAY seconds the FUNS list is reinitialised. -See `helm-define-multi-key'." - (declare (indent 2)) - (setq docstring (if docstring (concat docstring "\n\n") - "This is a helmish multi-key command.")) - `(defalias (quote ,name) (helm-make-multi-command ,funs ,delay) ,docstring)) - -(defun helm-make-multi-command (functions &optional delay) - "Return an anonymous multi-key command running FUNCTIONS. -Run each function of FUNCTIONS list in turn when called within DELAY seconds." - (declare (indent 1)) - (let ((funs functions) - (iter (cl-gensym "helm-iter-key")) - (timeout delay)) - (eval (list 'defvar iter nil)) - #'(lambda () (interactive) (helm-run-multi-key-command funs iter timeout)))) - -(defun helm-run-multi-key-command (functions iterator delay) - (let ((fn #'(lambda () - (cl-loop for count from 1 to (length functions) - collect count))) - next) - (unless (and (symbol-value iterator) - ;; Reset iterator when another key is pressed. - (eq this-command real-last-command)) - (set iterator (helm-iter-list (funcall fn)))) - (setq next (helm-iter-next (symbol-value iterator))) - (unless next - (set iterator (helm-iter-list (funcall fn))) - (setq next (helm-iter-next (symbol-value iterator)))) - (and next (symbol-value iterator) (call-interactively (nth (1- next) functions))) - (when delay (run-with-idle-timer delay nil `(lambda () - (setq ,iterator nil)))))) - -(defun helm-iter-list (seq) - "Return an iterator object from SEQ." - (let ((lis seq)) - (lambda () - (let ((elm (car lis))) - (setq lis (cdr lis)) - elm)))) - -(defun helm-iter-next (iterator) - "Return next elm of ITERATOR." - (funcall iterator)) - -(helm-multi-key-defun helm-toggle-resplit-and-swap-windows - "Multi key command to resplit and swap helm window. -First call run `helm-toggle-resplit-window', -second call within 0.5s run `helm-swap-windows'." - '(helm-toggle-resplit-window helm-swap-windows) 1) - -;;;###autoload -(defmacro helm-define-key-with-subkeys (map key subkey command - &optional other-subkeys menu exit-fn) - "Allow defining a KEY without having to type its prefix again on next calls. -Arg MAP is the keymap to use, SUBKEY is the initial long keybinding to -call COMMAND. -Arg OTHER-SUBKEYS is an unquoted alist specifying other short keybindings -to use once started. -e.g: - -\(helm-define-key-with-subkeys global-map - \(kbd \"C-x v n\") ?n 'git-gutter:next-hunk ((?p . 'git-gutter:previous-hunk))\) - - -In this example, `C-x v n' will run `git-gutter:next-hunk' subsequent hit on \"n\" -will run this command again and subsequent hit on \"p\" will run `git-gutter:previous-hunk'. - -Arg MENU is a string to display in minibuffer to describe SUBKEY and OTHER-SUBKEYS. -Arg EXIT-FN specify a function to run on exit. - -Any other keys pressed run their assigned command defined in MAP and exit the loop." - - (let ((other-keys (and other-subkeys - (cl-loop for (x . y) in other-subkeys - collect (list x (list 'call-interactively y) t))))) - `(define-key ,map ,key - #'(lambda () - (interactive) - (unwind-protect - (progn - (call-interactively ,command) - (while (let ((input (read-key ,menu)) kb com) - (cl-case input - (,subkey (call-interactively ,command) t) - ,@other-keys - (t (setq kb (this-command-keys-vector)) - (setq com (lookup-key ,map kb)) - (if (commandp com) - (call-interactively com) - (setq unread-command-events - (nconc (mapcar 'identity - (this-single-command-raw-keys)) - unread-command-events))) - nil))))) - (and ,exit-fn (funcall ,exit-fn))))))) - - -;;; Keymap -;; -;; -(defvar helm-map - (let ((map (make-sparse-keymap))) - (set-keymap-parent map minibuffer-local-map) - (define-key map (kbd "") 'helm-next-line) - (define-key map (kbd "") 'helm-previous-line) - (define-key map (kbd "C-n") 'helm-next-line) - (define-key map (kbd "C-p") 'helm-previous-line) - (define-key map (kbd "") 'helm-follow-action-forward) - (define-key map (kbd "") 'helm-follow-action-backward) - (define-key map (kbd "") 'helm-previous-page) - (define-key map (kbd "") 'helm-next-page) - (define-key map (kbd "M-v") 'helm-previous-page) - (define-key map (kbd "C-v") 'helm-next-page) - (define-key map (kbd "M-<") 'helm-beginning-of-buffer) - (define-key map (kbd "M->") 'helm-end-of-buffer) - (define-key map (kbd "C-g") 'helm-keyboard-quit) - (define-key map (kbd "") 'helm-next-source) - (define-key map (kbd "") 'helm-previous-source) - (define-key map (kbd "") 'helm-maybe-exit-minibuffer) - (define-key map (kbd "C-i") 'helm-select-action) - (define-key map (kbd "C-z") 'helm-execute-persistent-action) - (define-key map (kbd "C-j") 'helm-execute-persistent-action) - (define-key map (kbd "C-o") 'helm-next-source) - (define-key map (kbd "C-l") 'helm-recenter-top-bottom-other-window) - (define-key map (kbd "M-C-l") 'helm-reposition-window-other-window) - (define-key map (kbd "C-M-v") 'helm-scroll-other-window) - (define-key map (kbd "M-") 'helm-scroll-other-window) - (define-key map (kbd "C-M-y") 'helm-scroll-other-window-down) - (define-key map (kbd "C-M-S-v") 'helm-scroll-other-window-down) - (define-key map (kbd "M-") 'helm-scroll-other-window-down) - (define-key map (kbd "") 'helm-scroll-other-window) - (define-key map (kbd "") 'helm-scroll-other-window-down) - (define-key map (kbd "C-@") 'helm-toggle-visible-mark) - (define-key map (kbd "C-SPC") 'helm-toggle-visible-mark) - (define-key map (kbd "M-SPC") 'helm-toggle-visible-mark) - (define-key map (kbd "M-[") nil) - (define-key map (kbd "M-(") 'helm-prev-visible-mark) - (define-key map (kbd "M-)") 'helm-next-visible-mark) - (define-key map (kbd "C-k") 'helm-delete-minibuffer-contents) - (define-key map (kbd "C-x C-f") 'helm-quit-and-find-file) - (define-key map (kbd "M-m") 'helm-toggle-all-marks) - (define-key map (kbd "M-a") 'helm-mark-all) - (define-key map (kbd "M-u") 'helm-unmark-all) - (define-key map (kbd "C-w") 'helm-yank-text-at-point) - (define-key map (kbd "C-M-a") 'helm-show-all-in-this-source-only) - (define-key map (kbd "C-M-e") 'helm-display-all-sources) - (define-key map (kbd "C-r") 'undefined) - (define-key map (kbd "C-s") 'undefined) - (define-key map (kbd "M-s") 'undefined) - (define-key map (kbd "C-}") 'helm-narrow-window) - (define-key map (kbd "C-{") 'helm-enlarge-window) - (define-key map (kbd "C-c -") 'helm-swap-windows) - (define-key map (kbd "C-c C-d") 'helm-delete-current-selection) - (define-key map (kbd "C-c C-y") 'helm-yank-selection) - (define-key map (kbd "C-c C-k") 'helm-kill-selection-and-quit) - (define-key map (kbd "C-c C-i") 'helm-copy-to-buffer) - (define-key map (kbd "C-c C-f") 'helm-follow-mode) - (define-key map (kbd "C-c C-u") 'helm-force-update) - (define-key map (kbd "M-p") 'previous-history-element) - (define-key map (kbd "M-n") 'next-history-element) - (define-key map (kbd "C-!") 'helm-toggle-suspend-update) - (define-key map (kbd "C-x b") 'helm-resume-previous-session-after-quit) - (define-key map (kbd "C-x C-b") 'helm-resume-list-buffers-after-quit) - ;; Disable usage of the mouse while in helm. - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - (define-key map (kbd "") 'ignore) - ;; Disable `file-cache-minibuffer-complete'. - (define-key map (kbd "") 'undefined) - ;; 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-debug-output) - ;; Use `describe-mode' key in `global-map'. - (define-key map [f1] nil) ; Allow to eval keymap without errors. - (define-key map (kbd "C-h C-h") 'undefined) - (define-key map (kbd "C-h h") 'undefined) - (cl-dolist (k (where-is-internal 'describe-mode global-map)) - (define-key map k 'helm-help)) - ;; Bind all actions from 1 to 12 to their corresponding nth index+1. - (cl-loop for n from 0 to 12 do - (define-key map (kbd (format "" (1+ n))) - `(lambda () - (interactive) - (helm-select-nth-action ,n)))) - map) - "Keymap for helm.") - - -(defgroup helm nil - "Open helm." - :prefix "helm-" :group 'convenience) - -(defcustom helm-completion-window-scroll-margin 5 - " `scroll-margin' to use for helm completion window. -Which see. Set to 0 to disable. -NOTE: This have no effect when `helm-display-source-at-screen-top' -id non--nil." - :group 'helm - :type 'integer) - -(defcustom helm-display-source-at-screen-top t - "Display candidates at the top of screen. -This happen when using `helm-next-source' and `helm-previous-source'. -NOTE: When non--nil (default) disable `helm-completion-window-scroll-margin'." - :group 'helm - :type 'boolean) - -(defcustom helm-candidate-number-limit 100 - "Limit candidate number globally. -Do not show more candidates than this limit from individual sources. -It is usually pointless to show hundreds of matches -when the pattern is empty, because it is much simpler to type a -few characters to narrow down the list of potential candidates. - -Set it to nil if you don't want this limit." - :group 'helm - :type '(choice (const :tag "Disabled" nil) integer)) - -(defcustom helm-idle-delay 0.01 - "Be idle for this many seconds, before updating in delayed sources. -This is useful for sources involving heavy operations -\(like launching external programs\), so that candidates -from the source are not retrieved unnecessarily if the user keeps typing. - -It also can be used to declutter the results helm displays, -so that results from certain sources are not shown with every -character typed, only if the user hesitates a bit. -Be sure to know what you are doing when modifying this." - :group 'helm - :type 'float) - -(defcustom helm-input-idle-delay 0.01 - "Be idle for this many seconds, before updating. - -Unlike `helm-idle-delay', it is also effective for non-delayed sources. -If nil, candidates are collected immediately. - -Note: If this value is too low compared to `helm-idle-delay', -you may have duplicated sources when using multiples sources. -Safe value is always >= `helm-idle-delay'. -Default settings are equal value for both. -Be sure to know what you are doing when modifying this." - :group 'helm - :type 'float) - -(defcustom helm-exit-idle-delay 0 - "Be idle for this many seconds before exiting minibuffer while helm is updating. -Note that this does nothing when helm-buffer is up to date -\(i.e exit without delay in this condition\)." - :group 'helm - :type 'float) - -(defcustom helm-full-frame nil - "Use current window to show the candidates. -If t then Helm doesn't pop up a new window." - :group 'helm - :type 'boolean) - -(defvaralias 'helm-samewindow 'helm-full-frame) -(make-obsolete-variable 'helm-samewindow 'helm-full-frame "1.4.8.1") - -(defcustom helm-quick-update nil - "If non-nil, suppress displaying sources which are out of screen at first. -They are treated as delayed sources at this input. -This flag makes `helm' a bit faster with many sources." - :group 'helm - :type 'boolean) - -(defcustom helm-candidate-separator - "--------------------" - "Candidates separator of `multiline' source." - :group 'helm - :type 'string) - -(defcustom helm-save-configuration-functions - '(set-window-configuration . current-window-configuration) - "The functions used to restore/save window or frame configurations. -It is a pair where the car is the function to restore window or frame config, -and the cdr is the function to save the window or frame config. - -If you want to save and restore frame configuration, set this variable to - '\(set-frame-configuration . current-frame-configuration\) -NOTE: This may not work properly with own-frame minibuffer settings. -Older version saves/restores frame configuration, but the default is changed now -because flickering can occur in some environment." - :group 'helm - :type 'sexp) - -(defcustom helm-persistent-action-use-special-display nil - "If non-nil, use `special-display-function' in persistent action." - :group 'helm - :type 'boolean) - -(defcustom helm-scroll-amount nil - "Scroll amount when scrolling other window in a helm session. -It is used by `helm-scroll-other-window' -and `helm-scroll-other-window-down'. - -If you prefer scrolling line by line, set this value to 1." - :group 'helm - :type 'integer) - -(defcustom helm-display-function 'helm-default-display-buffer - "Function to display *helm* buffer. -It is `helm-default-display-buffer' by default, -which affects `helm-full-frame'." - :group 'helm - :type 'symbol) - -(defcustom helm-case-fold-search 'smart - "Add 'smart' option to `case-fold-search'. -When smart is enabled, ignore case in the search strings -if pattern contains no uppercase characters. -Otherwise, with a nil or t value, the behavior is same as -`case-fold-search'. -Default value is smart, other possible values are nil and t. -NOTE: This have no effect in asynchronous sources, you will -have to implement a similar feature directly in the process. -See in helm-grep.el how it is implemented." - :group 'helm - :type '(choice (const :tag "Ignore case" t) - (const :tag "Respect case" nil) - (other :tag "Smart" 'smart))) - -(defcustom helm-file-name-case-fold-search - (if (memq system-type - '(cygwin windows-nt ms-dos darwin)) - t - helm-case-fold-search) - "Local setting of `helm-case-fold-search' for reading filenames. - -See `helm-case-fold-search' for more info." - :group 'helm - :type 'symbol) - -(defcustom helm-reuse-last-window-split-state nil - "Reuse the last state of window split, vertical or horizontal. -That is when you use `helm-toggle-resplit-window' the next helm session -will reuse the same window scheme than the one of last session unless -`helm-split-window-default-side' is 'same or 'other." - :group 'helm - :type 'boolean) - -(defcustom helm-split-window-preferred-function 'helm-split-window-default-fn - "Default function used for splitting window." - :group 'helm - :type 'function) - -(defcustom helm-split-window-default-side 'below - "The default side to display `helm-buffer'. -Must be one acceptable arg for `split-window' SIDE, -that is 'below, 'above, 'left or 'right. - -Other acceptable values are 'same which always display `helm-buffer' -in current window and 'other that display `helm-buffer' below if only one -window or in `other-window-for-scrolling' if available. - -A nil value as same effect as 'below. -If `helm-full-frame' is non--nil, it take precedence on this. - -See also `helm-split-window-in-side-p' and `helm-always-two-windows' that -take precedence on this. - -NOTE: this have no effect if `helm-split-window-preferred-function' is not -`helm-split-window-default-fn' unless this new function handle this." - :group 'helm - :type 'symbol) - -(defcustom helm-split-window-in-side-p nil - "Force splitting inside selected window when non--nil. -See also `helm-split-window-default-side'. - -NOTE: this have no effect if `helm-split-window-preferred-function' is not -`helm-split-window-default-fn' unless this new function handle this." - :group 'helm - :type 'boolean) - -(defcustom helm-always-two-windows nil - "When non--nil helm will use two windows in this frame. -That is one window to display `helm-buffer' and one to display -`helm-current-buffer'. -Note: this have no effect when `helm-split-window-in-side-p' is non--nil, -or when `helm-split-window-default-side' is set to 'same." - :group 'helm - :type 'boolean) - -(defcustom helm-sources-using-default-as-input '(helm-source-imenu - helm-source-semantic - helm-source-info-elisp - helm-source-etags-select) - "List of helm sources that need to use `helm-maybe-use-default-as-input'. -When a source is member of this list, default `thing-at-point' -will be used as input." - :group 'helm - :type '(repeat (choice symbol))) - -(defcustom helm-delete-minibuffer-contents-from-point nil - "When non--nil, `helm-delete-minibuffer-contents' delete region from `point'. -Otherwise (default) delete `minibuffer-contents'." - :group 'helm - :type 'boolean) - -(defcustom helm-follow-mode-persistent nil - "Retrieve last state of `helm-follow-mode' in next helm session when non--nil. -This will not make it persistent through emacs sessions though, -you will have to set explicitely the `follow' attribute in the source where -you want this mode enabled definitely." - :group 'helm - :type 'boolean) - -(defcustom helm-prevent-escaping-from-minibuffer t - "Prevent escaping from minibuffer during helm session." - :group 'helm - :type 'boolean) - -(defcustom helm-truncate-lines nil - "Truncate long lines when non--nil. -See `truncate-lines'." - :group 'helm - :type 'boolean) - -(defcustom helm-move-to-line-cycle-in-source nil - "Move to end or beginning of source when reaching top or bottom of source. -This happen when using `helm-next/previous-line'." - :group 'helm - :type 'boolean) - - -;;; Faces -;; -;; -(defface helm-source-header - '((((background dark)) - :background "#22083397778B" - :foreground "white" - :weight bold :height 1.3 :family "Sans Serif") - (((background light)) - :background "#abd7f0" - :foreground "black" - :weight bold :height 1.3 :family "Sans Serif")) - "Face for source header in the helm buffer." - :group 'helm) - -(defface helm-visible-mark - '((((min-colors 88) (background dark)) - (:background "green1" :foreground "black")) - (((background dark)) - (:background "green" :foreground "black")) - (((background light)) :background "#d1f5ea") - (((min-colors 88)) - (:background "green1")) - (t (:background "green"))) - "Face for visible mark." - :group 'helm) - -(defface helm-header - '((t (:inherit header-line))) - "Face for header lines in the helm buffer." - :group 'helm) - -(defface helm-candidate-number - '((((background dark)) :background "Yellow" :foreground "black") - (((background light)) :background "#faffb5" :foreground "black")) - "Face for candidate number in mode-line." :group 'helm) - -(defface helm-selection - '((((background dark)) :background "ForestGreen" :underline t) - (((background light)) :background "#b5ffd1" :underline t)) - "Face for currently selected item in the helm buffer." - :group 'helm) - -(defface helm-separator - '((((background dark)) :foreground "red") - (((background light)) :foreground "#ffbfb5")) - "Face for multiline source separator." - :group 'helm) - -(defface helm-action - '((t (:underline t))) - "Face for action lines in the helm action buffer." - :group 'helm) - -(defface helm-prefarg - '((((background dark)) :foreground "green") - (((background light)) :foreground "red")) - "Face for showing prefix arg in mode-line." - :group 'helm) - - -;;; Variables. -;; -;; -(defvar helm-type-attributes nil - "It's a list of \(TYPE ATTRIBUTES ...\). -ATTRIBUTES are the same as attributes for `helm-sources'. -TYPE connects the value to the appropriate sources. -Don't set this directly, use instead `define-helm-type-attribute'. - -This allows specifying common attributes for several sources. -For example, sources which provide files can specify -common attributes with a `file' type.") - -(defvar helm-source-filter nil - "A list of source names to be displayed. -Other sources won't appear in the search results. -If nil then there is no filtering. -See also `helm-set-source-filter'.") - -(defvar helm-action-buffer "*helm action*" - "Buffer showing actions.") - -(defvar helm-selection-overlay nil - "Overlay used to highlight the currently selected item.") - -(defvar helm-async-processes nil - "List of information about asynchronous processes managed by helm.") - -(defvar helm-before-initialize-hook nil - "Run before helm initialization. -This hook is run before init functions in `helm-sources'.") - -(defvar helm-after-initialize-hook nil - "Run after helm initialization. -Global variables are initialized and the helm buffer is created. -But the helm buffer has no contents.") - -(defvar helm-update-hook nil - "Run after the helm buffer was updated according the new input pattern. -This hook is run at the beginning of buffer. -The first candidate is selected after running this hook. -See also `helm-after-update-hook'.") - -(defvar helm-after-update-hook nil - "Run after the helm buffer was updated according the new input pattern. -This is very similar to `helm-update-hook' but selection is not moved. -It is useful to select a particular object instead of the first one.") - -(defvar helm-cleanup-hook nil - "Run after helm minibuffer is closed. -IOW this hook is executed BEFORE performing action.") - -(defvar helm-select-action-hook nil - "Run when opening the action buffer.") - -(defvar helm-before-action-hook nil - "Run before executing action. -Contrarily to `helm-cleanup-hook', -this hook run before helm minibuffer is closed -and before performing action.") - -(defvar helm-after-action-hook nil - "Run after executing action.") - -(defvar helm-exit-minibuffer-hook nil - "Run just before exiting minibuffer.") - -(defvar helm-after-persistent-action-hook nil - "Run after executing persistent action.") - -(defvar helm-move-selection-before-hook nil - "Run before moving selection in `helm-buffer'.") - -(defvar helm-move-selection-after-hook nil - "Run after moving selection in `helm-buffer'.") - -(defvar helm-restored-variables - '(helm-candidate-number-limit - helm-source-filter - helm-source-in-each-line-flag - helm-map - helm-sources) - "Variables which are restored after `helm' invocation.") - -(defvar helm-execute-action-at-once-if-one nil - "Execute default action and exit when only one candidate is remaining.") - -(defvar helm-quit-if-no-candidate nil - "Quit when there is no candidates when non--nil. -This variable accepts a function, which is executed if no candidate.") - -(defvar helm-maybe-use-default-as-input nil - "Use :default arg of `helm' as input to update display. -Note that if also :input is specified as `helm' arg, it will take -precedence on :default.") - -(defvar helm-source-in-each-line-flag nil - "Non-nil means add helm-source text-property in each candidate. -experimental feature.") - -(defvar helm-debug-variables nil - "A list of helm variables to show in `helm-debug-output'. -Otherwise all variables started with `helm-' are shown.") - -(defvar helm-debug-buffer "*Debug Helm Log*") - -(defvar helm-debug nil - "If non-nil, write log message into `helm-debug-buffer' buffer. -It is disabled by default because `helm-debug-buffer' grows quickly.") - -(defvar helm-compile-source-functions - '(helm-compile-source--type - helm-compile-source--dummy - helm-compile-source--candidates-in-buffer) - "Functions to compile elements of `helm-sources' (plug-in).") - -(defvar helm-mode-line-string "\ -\\\ -\\[helm-help]:Help \ -\\[helm-select-action]:Act \ -\\[helm-maybe-exit-minibuffer]/\ -f1/f2/f-n:NthAct" - "Help string displayed in mode-line in `helm'. -It can be a string or a list of two args, in this case, -first arg is a string that will be used as name for candidates number, -second arg any string to display in mode line. -If nil, use default `mode-line-format'.") - - -;;; Internal Variables -;; -;; -(defvar helm-current-prefix-arg nil - "Record `current-prefix-arg' when exiting minibuffer.") -(defvar helm-saved-action nil - "Saved value of the currently selected action by key.") -(defvar helm-saved-current-source nil - "Value of the current source when the action list is shown.") -(defvar helm-compiled-sources nil - "Compiled version of `helm-sources'.") -(defvar helm-in-persistent-action nil - "Flag whether in persistent-action or not.") -(defvar helm-last-buffer nil - "`helm-buffer' of previously `helm' session.") -(defvar helm-saved-selection nil - "Value of the currently selected object when the action list is shown.") -(defvar helm-sources nil - "[INTERNAL] Value of current sources in use, a list.") -(defvar helm-buffer "*helm*" - "Buffer showing completions.") -(defvar helm-current-buffer nil - "Current buffer when `helm' is invoked.") -(defvar helm-buffer-file-name nil - "Variable `buffer-file-name' when `helm' is invoked.") -(defvar helm-default-directory nil - "The value of `default-directory' when `helm' is initialized.") -(defvar helm-candidate-cache (make-hash-table :test 'equal) - "Holds the available candidate within a single helm invocation.") -(defvar helm-pattern "" - "The input pattern used to update the helm buffer.") -(defvar helm-input "" - "The input typed in the candidates panel.") -(defvar helm-input-local nil - "Internal, store locally `helm-pattern' value for later use in `helm-resume'.") -(defvar helm-source-name nil) -(defvar helm-current-source nil) -(defvar helm-candidate-buffer-alist nil) -(defvar helm-match-hash (make-hash-table :test 'equal)) -(defvar helm-cib-hash (make-hash-table :test 'equal)) -(defvar helm-tick-hash (make-hash-table :test 'equal)) -(defvar helm-issued-errors nil) -(defvar helm-debug-root-directory nil - "When non--nil, save helm log to `helm-last-log-file'. -Be aware that if you set that, you will end up with a huge directory -of log files, so use that only for debugging purpose. -See `helm-log-save-maybe' for more info.") -(defvar helm-last-log-file nil - "The name of the last helm session log file.") -(defvar helm-follow-mode nil) -(defvar helm--local-variables nil) -(defvar helm-split-window-state nil) -(defvar helm--window-side-state nil) -(defvar helm-selection-point nil) -(defvar helm-alive-p nil) -(defvar helm-visible-mark-overlays nil) -(defvar helm-update-blacklist-regexps '("^" "^ *" "$" "!" " " "\\b" - "\\<" "\\>" "\\_<" "\\_>" ".*")) -(defvar helm-suspend-update-flag nil) -(defvar helm-force-updating-p nil) -(defvar helm-exit-status 0 - "Flag to inform whether helm have exited or quitted. -Exit with 0 mean helm have exited executing an action. -Exit with 1 mean helm have quitted with \\[keyboard-quit] -It is useful for example to restore a window config if helm abort -in special cases. -See `helm-exit-minibuffer' and `helm-keyboard-quit'.") -(defvar helm-minibuffer-confirm-state nil) -(defvar helm-quit nil) -(defvar helm-attributes nil "List of all `helm' attributes.") -(defvar helm-buffers nil - "All of `helm-buffer' in most recently used order.") -(defvar helm-current-position nil - "Cons of \(point . window-start\) when `helm' is invoked. -It is needed to restore position in `helm-current-buffer' -when `helm' is keyboard-quitted.") -(defvar helm-last-frame-or-window-configuration nil - "Used to store window or frame configuration when helm start.") -(defvar helm-onewindow-p nil) -(defvar helm-types nil) -(defvar helm--mode-line-string-real nil) ; The string to display in mode-line. -(defvar helm-persistent-action-display-window nil) -(defvar helm-marked-candidates nil - "Marked candadates. List of \(source . real\) pair.") -(defvar helm-in-file-completion-p nil) -(defvar helm--mode-line-display-prefarg nil) -(defvar helm--temp-follow-flag nil - "[INTERNAL] A simple flag to notify persistent action we are following.") -(defvar helm--reading-passwd-or-string nil) -(defvar helm--in-update nil) - - -;; Utility: logging -(defun helm-log (format-string &rest args) - "Log message `helm-debug' is non-nil. -Messages are written to the `helm-debug-buffer' buffer. - -Argument FORMAT-STRING is a string to use with `format'. -Use optional arguments ARGS like in `format'." - (when helm-debug - (with-current-buffer (get-buffer-create helm-debug-buffer) - (outline-mode) - (buffer-disable-undo) - (set (make-local-variable 'inhibit-read-only) t) - (goto-char (point-max)) - (insert (let ((tm (current-time))) - (format (concat (if (string-match "Start session" format-string) - "* " "** ") - "%s.%06d (%s)\n %s\n") - (format-time-string "%H:%M:%S" tm) - (nth 2 tm) - (helm-log-get-current-function) - (apply #'format (cons format-string args)))))))) - -(defun helm-log-run-hook (hook) - "Run HOOK like `run-hooks' but write these actions to helm log buffer." - (helm-log "Executing %s with value = %S" hook (symbol-value hook)) - (helm-log "Executing %s with global value = %S" hook (default-value hook)) - (run-hooks hook) - (helm-log "executed %s" hook)) - -(defun helm-log-get-current-function () - "Get function name calling `helm-log'. -The original idea is from `tramp-debug-message'." - (cl-loop with exclude-func-re = "^helm-\\(?:interpret\\|log\\|.*funcall\\)" - for btn from 1 to 40 - for btf = (cl-second (backtrace-frame btn)) - for fn = (if (symbolp btf) (symbol-name btf) "") - if (and (string-match "^helm" fn) - (not (string-match exclude-func-re fn))) - return fn)) - -(defun helm-log-error (&rest args) - "Accumulate error messages into `helm-issued-errors'. -ARGS are args given to `format'. -e.g (helm-log-error \"Error %s: %s\" (car err) (cdr err))." - (apply 'helm-log (concat "ERROR: " (car args)) (cdr args)) - (let ((msg (apply 'format args))) - (unless (member msg helm-issued-errors) - (add-to-list 'helm-issued-errors msg)))) - -(defun helm-log-save-maybe () - "May be save log buffer to `helm-last-log-file'. -If `helm-debug-root-directory' is non--nil and a valid directory, -a directory named 'helm-debug-' -will be created there and the log recorded in a file named -at the date and time of today in this directory." - (when (and (stringp helm-debug-root-directory) - (file-directory-p helm-debug-root-directory) - helm-debug) - (let ((logdir (expand-file-name (concat "helm-debug-" - (format-time-string "%Y%m%d")) - helm-debug-root-directory))) - (make-directory logdir t) - (with-current-buffer (get-buffer-create helm-debug-buffer) - (write-region (point-min) (point-max) - (setq helm-last-log-file - (expand-file-name - (format-time-string "%Y%m%d-%H%M%S") - logdir)) - nil 'silent) - (kill-buffer))))) - -;;;###autoload -(defun helm-debug-open-last-log () - "Open helm log file of last helm session. -If `helm-last-log-file' is nil, switch to `helm-debug-buffer' ." - (interactive) - (if helm-last-log-file - (view-file helm-last-log-file) - (switch-to-buffer helm-debug-buffer) - (view-mode 1) (visual-line-mode 1))) - -(defun helm-print-error-messages () - "Print error messages in `helm-issued-errors'." - (and helm-issued-errors - (message "Helm issued errors: %s" - (mapconcat 'identity (reverse helm-issued-errors) "\n")))) - - -;; Programming Tools -(defmacro helm-aif (test-form then-form &rest else-forms) - "Like `if' but set the result of TEST-FORM in a temprary variable called `it'. -THEN-FORM and ELSE-FORMS are then excuted just like in `if'." - (declare (indent 2) (debug t)) - `(let ((it ,test-form)) - (if it ,then-form ,@else-forms))) - -(defun helm-mklist (obj) - "If OBJ is a list \(but not lambda\), return itself. -Otherwise make a list with one element." - (if (and (listp obj) (not (functionp obj))) - obj - (list obj))) - -(defun helm-this-command () - "Return the actual command in action. -Like `this-command' but return the real command, -not `exit-minibuffer' or unwanted functions." - (cl-loop with bl = '(helm-maybe-exit-minibuffer - helm-confirm-and-exit-minibuffer - helm-exit-minibuffer - exit-minibuffer) - for count from 1 to 50 - for btf = (backtrace-frame count) - for fn = (cl-second btf) - if (and (commandp fn) (not (memq fn bl))) return fn - else - if (and (eq fn 'call-interactively) - (> (length btf) 2)) - return (cadr (cdr btf)))) - - -;; Helm API - -(defun helm-buffer-get () - "Return `helm-action-buffer' if shown otherwise `helm-buffer'." - (if (helm-action-window) - helm-action-buffer - helm-buffer)) - -(defun helm-window () - "Window of `helm-buffer'." - (get-buffer-window (helm-buffer-get) 'visible)) - -(defun helm-action-window () - "Window of `helm-action-buffer'." - (get-buffer-window helm-action-buffer 'visible)) - -(defmacro with-helm-window (&rest body) - "Be sure BODY is excuted in the helm window." - (declare (indent 0) (debug t)) - `(with-selected-window (helm-window) - ,@body)) - -(defmacro with-helm-current-buffer (&rest body) - "Eval BODY inside `helm-current-buffer'." - (declare (indent 0) (debug t)) - `(with-current-buffer (or (and (buffer-live-p helm-current-buffer) - helm-current-buffer) - (setq helm-current-buffer - (current-buffer))) - ,@body)) - -(defmacro with-helm-buffer (&rest body) - "Eval BODY inside `helm-buffer'." - (declare (indent 0) (debug t)) - `(with-current-buffer (helm-buffer-get) - ,@body)) - -(defmacro with-helm-restore-variables(&rest body) - "Restore `helm-restored-variables' after executing BODY." - (declare (indent 0) (debug t)) - `(let ((orig-vars (mapcar (lambda (v) - (cons v (symbol-value v))) - helm-restored-variables))) - (unwind-protect (progn ,@body) - (cl-loop for (var . value) in orig-vars - do (set var value)) - (helm-log "restore variables")))) - -(defmacro with-helm-default-directory (directory &rest body) - (declare (indent 2) (debug t)) - `(let ((default-directory (or (and ,directory - (file-name-as-directory ,directory)) - default-directory))) - ,@body)) - -(defun helm-default-directory () - "Return the value of `helm-default-directory'." - (buffer-local-value 'helm-default-directory (get-buffer helm-buffer))) - -(defmacro with-helm-temp-hook (hook &rest body) - "Execute temporarily BODY as a function for HOOK." - (declare (indent 1) (debug t)) - (let ((fun (cl-gensym "helm-hook"))) - `(progn - (defun ,fun () - (unwind-protect - (progn ,@body) - (remove-hook ,hook (quote ,fun)))) - (add-hook ,hook (quote ,fun))))) - -(defmacro with-helm-after-update-hook (&rest body) - "Execute BODY at end of `helm-update'." - (declare (indent 0) (debug t)) - `(with-helm-temp-hook 'helm-after-update-hook ,@body)) - -(defmacro with-helm-alive-p (&rest body) - "Return error when BODY run outside helm context." - (declare (indent 0) (debug t)) - `(progn - (if helm-alive-p - (progn ,@body) - (error "Running helm command outside of context")))) - -(cl-defun helm-attr (attribute-name - &optional (src (helm-get-current-source)) compute) - "Get the value of ATTRIBUTE-NAME of SRC. -If SRC is omitted, use current source. -If COMPUTE is non--nil compute value of ATTRIBUTE-NAME -with `helm-interpret-value'." - (helm-aif (or (assq attribute-name src) - (helm-get-attribute-from-source-type attribute-name src)) - (if compute (helm-interpret-value (cdr it)) (cdr it)))) - -(cl-defun helm-attr-defined (attribute-name - &optional (src (helm-get-current-source))) - "Return non-nil if ATTRIBUTE-NAME of SRC is defined. -if SRC is omitted, use current source." - (and (helm-attr attribute-name src) t)) - -(cl-defun helm-attrset (attribute-name value - &optional - (src (helm-get-current-source)) - alter-type) - "Set the value of ATTRIBUTE-NAME of source SRC to VALUE. -If ATTRIBUTE-NAME doesn't exists in source it is created with value VALUE. -If ALTER-TYPE is non--nil alter the value of ATTRIBUTE-NAME in `helm-attributes' -if it exists. -If SRC is omitted, use current source. -If operation succeed, return value, otherwise nil." - (let ((from-type (helm-get-attribute-from-source-type attribute-name src)) - done) - (helm-aif (or (assq attribute-name src) - (and alter-type from-type)) - (prog1 (setcdr it value) (setq done t)) - (unless from-type - (setcdr src (cons (cons attribute-name value) (cdr src))) - (setq done t))) - (and done value))) - -(defun helm-get-attribute-from-source-type (attribute source) - "Get ATTRIBUTE from type attribute of SOURCE." - (when (assq 'type source) - (assq attribute - (assq (cdr (assq 'type source)) - helm-type-attributes)))) - -(defun helm-get-attribute-from-type (attribute type) - "Get ATTRIBUTE from TYPE. -arg TYPE is an existing type defined in `helm-type-attributes'." - (assq attribute (assq type helm-type-attributes))) - -(defun helm-get-actions-from-type (source) - "Get actions list from type attribute of SOURCE." - (when (assq 'type source) - (helm-get-attribute-from-source-type 'action source))) - -(defun helm-inherit-attribute-from-source (attribute source) - "Get the ATTRIBUTE of SOURCE." - (helm-aif (assq attribute source) - it - (helm-get-attribute-from-source-type attribute source))) - -(defun helm-append-at-nth (seq elm index) - "Append ELM at INDEX in SEQ." - (let ((len (length seq))) - (when (> index len) (setq index len)) - (cl-loop for i in seq - for count from 1 collect i - when (= count index) - if (listp elm) append elm - else collect elm))) - -(defun helm-add-action-to-source (name fn source &optional index) - "Add new action NAME linked to function FN to SOURCE. -Function FN should be a valid function that take one arg i.e candidate, -argument NAME is a string that will appear in action menu -and SOURCE should be an existing helm source already loaded. -If INDEX is specified, action is added in action list at INDEX, -otherwise it is added at end. -This allow user to add a specific action to an existing source -without modifying source code." - (let ((actions (helm-attr 'action source)) - (new-action (list (cons name fn)))) - (when (symbolp actions) - (setq actions (list (cons "Default action" actions)))) - (helm-attrset 'action - (if index - (helm-append-at-nth actions new-action index) - (append actions new-action)) - source))) - -(defun helm-delete-action-from-source (action-or-name source) - "Delete ACTION-OR-NAME from SOURCE. -ACTION-OR-NAME can either be the name of action or the symbol function -associated to name." - (let* ((actions (helm-attr 'action source)) - (del-action (if (symbolp action-or-name) - (rassoc action-or-name actions) - (assoc action-or-name actions)))) - (helm-attrset 'action (delete del-action actions) source))) - -(cl-defun helm-add-action-to-source-if (name fn source predicate - &optional (index 4) test-only) - "Add new action NAME linked to function FN to SOURCE. -Action NAME will be available when the current candidate matches PREDICATE. -This function add an entry in the `action-transformer' attribute -of SOURCE (or create one if not found). -Function PREDICATE should take one arg candidate. -Function FN should be a valid function that take one arg i.e candidate, -argument NAME is a string that will appear in action menu -and SOURCE should be an existing helm source already loaded. -If INDEX is specified, action is added in action list at INDEX. -Value of INDEX should be always >=1, default to 4. -This allow user to add a specific `action-tranformer' -to an existing source without modifying source code. -E.g -Add the action \"Byte compile file async\" linked to -function 'async-byte-compile-file to source `helm-source-find-files' -only when predicate helm-ff-candidates-lisp-p return non--nil: - -\(helm-add-action-to-source-if \"Byte compile file async\" - 'async-byte-compile-file - helm-source-find-files - 'helm-ff-candidates-lisp-p\)." - (let* ((actions (helm-attr 'action source)) - (action-transformers (helm-attr 'action-transformer source)) - (new-action (list (cons name fn))) - (transformer `(lambda (actions candidate) - (cond ((funcall (quote ,predicate) candidate) - (helm-append-at-nth - actions (quote ,new-action) ,index)) - (t actions))))) - (when (symbolp actions) - (helm-attrset 'action (list (cons "Default action" actions)) source)) - (when (symbolp action-transformers) - (setq action-transformers (list action-transformers))) - (if test-only ; debug - (delq nil (append (list transformer) action-transformers)) - (helm-attrset 'action-transformer - (helm-fast-remove-dups - (delq nil (append (list transformer) action-transformers)) - :test 'equal) - source)))) - -(defun helm-set-source-filter (sources) - "Set the value of `helm-source-filter' to SOURCES and update. - -This function sets a filter for helm sources and it may be -called while helm is running. It can be used to toggle -displaying of sources dynamically. For example, additional keys -can be bound into `helm-map' to display only the file-related -results if there are too many matches from other sources and -you're after files only: - -Shift+F shows only file results from some sources: - -\(define-key helm-map \"F\" 'helm-my-show-files-only) - -\(defun helm-my-show-files-only () - (interactive) - (helm-set-source-filter '(\"File Name History\" - \"Files from Current Directory\"))) - -Shift+A shows all results: - -\(define-key helm-map \"A\" 'helm-my-show-all) - -\(defun helm-my-show-all () - (interactive) - (helm-set-source-filter nil)) - -The -my- part is added to avoid collisions with -existing Helm function names." - (unless (and (listp sources) - (cl-loop for name in sources always (stringp name))) - (error "Invalid data in `helm-set-source-filter': %S" sources)) - (let ((cur-disp-sel (with-current-buffer helm-buffer - (helm-get-selection nil t)))) - (setq helm-source-filter sources) - (helm-log "helm-source-filter = %S" helm-source-filter) - ;; Use force-update to run init/update functions. - (helm-force-update (regexp-quote cur-disp-sel)))) - -(defun helm-set-sources (sources &optional no-init no-update) - "Set SOURCES during `helm' invocation. -If NO-INIT is non-nil, skip executing init functions of SOURCES. -If NO-UPDATE is non-nil, skip executing `helm-update'." - (with-current-buffer helm-buffer - (setq helm-compiled-sources nil - helm-sources sources) - (helm-log "helm-compiled-sources = %S" helm-compiled-sources) - (helm-log "helm-sources = %S" helm-sources)) - (unless no-init (helm-funcall-foreach 'init)) - (unless no-update (helm-update))) - -(defun helm-get-sources () - "Return compiled `helm-sources', which is memoized. - -Attributes: - -- type - `helm-type-attributes' are merged in. -- candidates-buffer - candidates, volatile and match attribute are created." - (cond - ;; action - ((helm-action-window) - helm-sources) - ;; memoized - (helm-compiled-sources) - ;; first time - (t - (prog1 - (setq helm-compiled-sources - (helm-compile-sources - helm-sources helm-compile-source-functions)) - (helm-log "helm-compiled-sources = %S" helm-compiled-sources))))) - -(cl-defun helm-get-selection (&optional (buffer nil buffer-s) - force-display-part) - "Return the currently selected item or nil. -if BUFFER is nil or unspecified, use helm-buffer as default value. -If FORCE-DISPLAY-PART is non-nil, return the display string. -If FORCE-DISPLAY-PART value is 'withprop the display string is returned -with its properties." - (setq buffer (if (and buffer buffer-s) buffer helm-buffer)) - (unless (helm-empty-buffer-p buffer) - (with-current-buffer buffer - (let* ((disp-fn (if (eq force-display-part 'withprop) - 'buffer-substring - 'buffer-substring-no-properties)) - (selection - (or (and (not force-display-part) - (get-text-property (overlay-start - helm-selection-overlay) - 'helm-realvalue)) - ;; It is needed to return properties of DISP in some case, - ;; e.g for `helm-confirm-and-exit-minibuffer', - ;; so use `buffer-substring' here when 'withprop is specified. - (let ((disp (funcall - disp-fn - (overlay-start helm-selection-overlay) - (1- (overlay-end helm-selection-overlay)))) - (source (helm-get-current-source))) - (helm-aif (and (not force-display-part) - (assoc-default 'display-to-real source)) - (helm-funcall-with-source source it disp) - disp))))) - (unless (equal selection "") - (helm-log "selection = %S" selection) - selection))))) - -(defun helm-get-actions-from-current-source () - "Return the associated action for the selected candidate. -It is a function symbol \(sole action\) or list -of \(action-display . function\)." - (unless (helm-empty-buffer-p (helm-buffer-get)) - (helm-aif (helm-attr 'action-transformer) - (helm-composed-funcall-with-source - (helm-get-current-source) it - (helm-attr 'action) (helm-get-selection)) - (helm-attr 'action)))) - -(defun helm-get-current-source () - "Return the source for the current selection. -Allow also checking if helm-buffer contain candidates." - (or helm-current-source - (with-current-buffer (helm-buffer-get) - (or - ;; This happen only when `helm-source-in-each-line-flag' - ;; is non--nil and there is candidates in buffer. - (get-text-property (point) 'helm-source) - ;; Return nil when no--candidates. - (cl-block exit - ;; This goto-char shouldn't be necessary, but point is moved to - ;; point-min somewhere else which shouldn't happen. - (goto-char (overlay-start helm-selection-overlay)) - (let* ((header-pos (or (helm-get-previous-header-pos) - (helm-get-next-header-pos))) - (source-name - (save-excursion - (unless header-pos - (cl-return-from exit nil)) - (goto-char header-pos) - (helm-current-line-contents)))) - (cl-loop for source in (helm-get-sources) thereis - (and (equal (assoc-default 'name source) source-name) - source)))))))) - -(defun helm-buffer-is-modified (buffer) - "Return non-nil when BUFFER is modified since `helm' was invoked." - (let* ((b (get-buffer buffer)) - (key (concat (buffer-name b) "/" (helm-attr 'name))) - (source-tick (or (gethash key helm-tick-hash) 0)) - (buffer-tick (buffer-chars-modified-tick b)) - (modifiedp (/= source-tick buffer-tick))) - (puthash key buffer-tick helm-tick-hash) - (helm-log "buffer = %S" buffer) - (helm-log "modifiedp = %S" modifiedp) - modifiedp)) - -(defun helm-current-buffer-is-modified () - "Check if `helm-current-buffer' is modified since `helm' was invoked." - (helm-buffer-is-modified helm-current-buffer)) - -(defun helm-run-after-quit (function &rest args) - "Perform an action after quitting `helm'. -The action is to call FUNCTION with arguments ARGS." - (setq helm-quit t) - (helm-kill-async-processes) - (helm-log "function = %S" function) - (helm-log "args = %S" args) - (apply 'run-with-timer 0.1 nil function args) - (helm-exit-minibuffer)) - - -(defun define-helm-type-attribute (type definition &optional doc) - "Register type attribute of TYPE as DEFINITION with DOC. -DOC is displayed in `helm-type-attributes' docstring. - -Use this function is better than setting `helm-type-attributes' directly." - (cl-loop for i in definition do - ;; without `ignore-errors', error at emacs22 - (ignore-errors (setf i (delete nil i)))) - (helm-add-type-attribute type definition) - (and doc (helm-document-type-attribute type doc)) - nil) - -(defun helm-document-attribute (attribute short-doc &optional long-doc) - "Register ATTRIBUTE documentation introduced by plug-in. -SHORT-DOC is displayed beside attribute name. -LONG-DOC is displayed below attribute name and short documentation." - (if long-doc - (setq short-doc (concat "(" short-doc ")")) - (setq long-doc short-doc - short-doc "")) - (add-to-list 'helm-attributes attribute t) - (put attribute 'helm-attrdoc - (concat "- " (symbol-name attribute) - " " short-doc "\n\n" long-doc "\n"))) - -(put 'helm-document-attribute 'lisp-indent-function 2) - -(defun helm-interpret-value (value &optional source) - "Interpret VALUE as variable, function or literal and return it. -If VALUE is a function, call it with no arguments and return the value. -If SOURCE compute VALUE for this source. -If VALUE is a variable, return the value. -If VALUE is a symbol, but it is not a function or a variable, cause an error. -Otherwise, return VALUE itself." - (cond ((and source (functionp value)) - (helm-funcall-with-source source value)) - ((functionp value) - (funcall value)) - ((and (symbolp value) (boundp value)) - (symbol-value value)) - ((symbolp value) - (error - "helm-interpret-value: Symbol must be a function or a variable")) - (t - value))) - -(defun helm-set-local-variable (&rest args) - "Bind each pair in ARGS locally to `helm-buffer'. -Use this to set local vars before calling helm. -Usage: helm-set-local-variable ([VAR VALUE]...) -Just like `setq' except that the vars are not set sequentially. -IOW Don't use VALUE of previous VAR to eval the VALUE of next VAR. -When helm is alive use `make-local-variable' as usual on `helm-buffer'. - -\(fn VAR VALUE ...)" - (setq helm--local-variables - (append (cl-loop for i on args by #'cddr - collect (cons (car i) (cadr i))) - helm--local-variables))) - -(defun helm-make-actions (&rest args) - "Build an alist with (NAME . ACTION) elements with each pairs in ARGS. -Where NAME is a string or a function returning a string or nil and ACTION -a function. -If NAME returns nil the pair is skipped. - -\(fn NAME ACTION ...)" - (cl-loop for i on args by #'cddr - for name = (car i) - when (functionp name) - do (setq name (funcall name)) - when name - collect (cons name (cadr i)))) - -;; Core: API helper -(cl-defun helm-empty-buffer-p (&optional (buffer helm-buffer)) - "Check if BUFFER have candidates. -Default value for BUFFER is `helm-buffer'." - (zerop (buffer-size (and buffer (get-buffer buffer))))) - -(defun helm-empty-source-p () - "Check if current source contains candidates. -This happen only in certains cases when e.g the last element -of a source is deleted without updating the source." - (with-helm-window - (or (helm-empty-buffer-p) - (and (helm-end-of-source-p) - (eq (point-at-bol) (point-at-eol)) - (or - (save-excursion - (forward-line -1) - (helm-pos-header-line-p)) - (bobp)))))) - - -;; Core: tools -(defun helm-current-line-contents () - "Current line string without properties." - (buffer-substring-no-properties (point-at-bol) (point-at-eol))) - -(defun helm-funcall-with-source (source functions &rest args) - "Call from SOURCE FUNCTIONS list or single function FUNCTIONS with ARGS. -FUNCTIONS can be a symbol or a list of functions. -Return the result of last function call." - (let ((helm-source-name (assoc-default 'name source)) - (helm-current-source source) - (funs (if (functionp functions) (list functions) functions))) - (helm-log "helm-source-name = %S" helm-source-name) - (helm-log "functions = %S" functions) - (helm-log "args = %S" args) - (cl-loop with result for fn in funs - do (setq result (apply fn args)) finally return result))) - -(defun helm-funcall-foreach (sym &optional sources) - "Call the associated function to SYM for each source if any." - (let ((sources (or sources (helm-get-sources)))) - (cl-dolist (source sources) - (helm-aif (assoc-default sym source) - (helm-funcall-with-source source it))))) - -(defun helm-normalize-sources (sources) - "If SOURCES is only one source, make a list of one element." - (cond ((or (and sources - (symbolp sources)) - (and (listp sources) (assq 'name sources))) - (list sources)) - (sources) - (t helm-sources))) - -(defun helm-get-candidate-number (&optional in-current-source) - "Return candidates number in `helm-buffer'. -If IN-CURRENT-SOURCE is provided return number of candidates -in the source where point is." - (with-current-buffer (helm-buffer-get) - (if (or (helm-empty-buffer-p) - (helm-empty-source-p)) - 0 - (save-excursion - (if in-current-source - (goto-char (helm-get-previous-header-pos)) - (goto-char (point-min))) - (forward-line 1) - (if (helm-pos-multiline-p) - (save-excursion - (cl-loop with count-multi = 1 - while (and (not (if in-current-source - (save-excursion - (forward-line 2) - (or (helm-pos-header-line-p) (eobp))) - (eobp))) - (search-forward helm-candidate-separator nil t)) - do (cl-incf count-multi) - finally return count-multi)) - (save-excursion - (cl-loop with ln = 0 - while (not (if in-current-source - (or (helm-pos-header-line-p) (eobp)) - (eobp))) - unless (helm-pos-header-line-p) - do (cl-incf ln) - do (forward-line 1) finally return ln))))))) - -(defmacro with-helm-quittable (&rest body) - "If an error occur in execution of BODY, quit helm safely." - (declare (indent 0) (debug t)) - `(let (inhibit-quit) - (condition-case _v - (progn ,@body) - (quit (setq helm-quit t) - (exit-minibuffer) - (keyboard-quit))))) - -(defun helm-compose (arg-lst func-lst) - "Apply arguments specified in ARG-LST with each function of FUNC-LST. -The result of each function will be the new `car' of ARG-LST. -Each function in FUNC-LST must accept (length ARG-LST) arguments -\(See examples below) . -This function allows easy sequencing of transformer functions. -Where generally, ARG-LST is '(candidates-list source) and FUNC-LST a -list of transformer functions that take one or two arguments depending -we are using 'filtered-candidate-transformer' or 'candidate-transformer'. -e.g -filtered-candidate-transformer: -\(helm-compose '((1 2 3 4 5 6 7) - '((name . \"A helm source\") (candidates . (a b c)))) - '((lambda (candidates _source) - (cl-loop for i in candidates - when (cl-oddp i) collect i)) - (lambda (candidates _source) - (cl-loop for i in candidates collect (1+ i))))) -=>(2 4 6 8) - -candidate-transformer: -\(helm-compose '((1 2 3 4 5 6 7)) - '((lambda (candidates) - (cl-loop for i in candidates - when (cl-oddp i) collect i)) - (lambda (candidates) - (cl-loop for i in candidates collect (1+ i))))) -=> (2 4 6 8)." - (cl-dolist (func func-lst) - (setcar arg-lst (apply func arg-lst))) - (car arg-lst)) - -(defun helm-composed-funcall-with-source (source funcs &rest args) - "With SOURCE apply `helm-funcall-with-source' with each FUNCS and ARGS. -This is used in transformers to modify candidates list." - (if (functionp funcs) - (apply 'helm-funcall-with-source source funcs args) - (apply 'helm-funcall-with-source source - (lambda (&rest oargs) (helm-compose oargs funcs)) - args))) - - -;; Core: entry point -;; `:allow-nest' is not in this list because it is treated before. -(defconst helm-argument-keys - '(:sources :input :prompt :resume - :preselect :buffer :keymap :default :history)) - -;;;###autoload -(defun helm (&rest plist) - "Main function to execute helm sources. - -Keywords supported: -:sources :input :prompt :resume :preselect -:buffer :keymap :default :history :allow-nest - -Extra LOCAL-VARS keywords are supported, see below. - -PLIST is a list like \(:key1 val1 :key2 val2 ...\) or -\(&optional sources input prompt resume - preselect buffer keymap default history\). - -Basic keywords are the following: - -\:sources - -A list of sources used for this session. It also accepts a -symbol, interpreted as a variable of a helm source -i.e (a symbol can be passed instead of a list of sources). -It also accepts an alist representing a helm source, which is -detected by \(assq 'name ANY-SOURCES\). -NOTE: In this case the source is embedded in the helm command and -have no symbol name, so it is not reachable from outside. -It will be referenced in `helm-sources' as a whole alist. - -\:input - -Temporary value of `helm-pattern', ie. initial input of minibuffer. - -\:prompt - -Prompt other than \"pattern: \". - -\:resume - -If t, Resurrect previously instance of `helm'. Skip the initialization. -If 'noresume, this instance of `helm' cannot be resumed. - -\:preselect - -Initially selected candidate. Specified by exact candidate or a regexp. - -\:buffer - -`helm-buffer' instead of *helm*. - -\:keymap - -`helm-map' for current `helm' session. - -\:default - -A default argument that will be inserted in minibuffer \ -with \\\\[next-history-element]. -When nil or not present `thing-at-point' will be used instead. -If `helm-maybe-use-default-as-input' is non--nil display will be -updated using :default arg as input unless :input is specified, -which in this case will take precedence on :default -This is a string or a list, in this case the car of the list will -be used as initial default input, but you will be able to cycle in this -list with \\\\[next-history-element]. - -\:history - -By default all minibuffer input is pushed to `minibuffer-history', -if an argument HISTORY is provided, input will be pushed to HISTORY. -History element should be a symbol. - -\:allow-nest - -Allow running this helm command within a running helm session. - -Of course, conventional arguments are supported, the two are same. - -\(helm :sources sources :input input :prompt prompt :resume resume - :preselect preselect :buffer buffer :keymap keymap :default default - :history history\) - -and - -\(helm sources input prompt resume preselect buffer keymap default history\) - -are the same. - -However the use of non keyword args is deprecated and should not be used. - -Other keywords are interpreted as local variables of this helm session. -The `helm-' prefix can be omitted. For example, - -\(helm :sources 'helm-source-buffers-list - :buffer \"*buffers*\" :candidate-number-limit 10\) - -means starting helm session with `helm-source-buffers' -source in *buffers* buffer and set variable `helm-candidate-number-limit' -to 10 as session local variable. - -\(fn &key SOURCES INPUT PROMPT RESUME PRESELECT BUFFER KEYMAP DEFAULT HISTORY ALLOW-NEST OTHER-LOCAL-VARS)" - (let ((fn (cond ((or (and helm-alive-p (plist-get plist :allow-nest)) - (and helm-alive-p (memq 'allow-nest plist))) - #'helm-nest) - ((keywordp (car plist)) - #'helm) - (t #'helm-internal)))) - (if (and helm-alive-p (eq fn #'helm)) - (if (helm-alive-p) - ;; A helm session is normally running. - (error "Error: Trying to run helm within a running helm session") - ;; A helm session is already running and user jump somewhere else - ;; without desactivating it. - (with-helm-buffer - (prog1 - (message "Aborting an helm session running in background") - ;; `helm-alive-p' will be reset in unwind-protect forms. - (helm-keyboard-quit)))) - (if (keywordp (car plist)) - ;; Parse `plist' and move not regular `helm-argument-keys' - ;; to `helm--local-variables', then calling helm on itself - ;; with normal arguments (the non--arguments-keys removed) - ;; will end up in [1]. - (progn - (setq helm--local-variables - (append helm--local-variables - ;; Vars passed by keyword on helm call - ;; take precedence on same vars - ;; that may have been passed before helm call. - (helm-parse-keys plist))) - (apply fn (mapcar #'(lambda (key) (plist-get plist key)) - helm-argument-keys))) - (apply fn plist))))) ; [1] fn == helm-internal. - -(defun helm-alive-p () - "Check if `helm' is alive. -An `helm' session is considered alive if `helm-alive-p' is non--nil, -the `helm-buffer' is visible, and cursor is in minibuffer." - (and helm-alive-p - (get-buffer-window helm-buffer 'visible) - (minibuffer-window-active-p (minibuffer-window)) - (minibufferp (current-buffer)))) - -(defun helm-parse-keys (keys) - "Parse the KEYS arguments of `helm'. -Return only the keys that are not in `helm-argument-keys', -prefix them with \"helm\" and convert them to alist. -This allow to add arguments that are not part of `helm-argument-keys', -but are valid helm variables. -e.g :candidate-number-limit will be bound to `helm-candidate-number-limit' -in source. - - (helm-parse-keys '(:sources ((name . \"test\") - (candidates . (a b c))) - :buffer \"toto\" - :candidate-number-limit 4)) - ==> ((helm-candidate-number-limit . 4))." - - (cl-loop for (key value) on keys by #'cddr - for symname = (substring (symbol-name key) 1) - for sym = (intern (if (string-match "^helm-" symname) - symname - (concat "helm-" symname))) - unless (memq key helm-argument-keys) - collect (cons sym value))) - -;;; Core: entry point helper -(defun helm-internal (&optional - any-sources any-input - any-prompt any-resume - any-preselect any-buffer - any-keymap any-default any-history) - "The internal helm function called by `helm'. -For ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT ANY-BUFFER and -ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'." - ;; Activate the advice for `tramp-read-passwd'. - (if (fboundp 'advice-add) - (advice-add 'tramp-read-passwd :around #'helm--advice-tramp-read-passwd) - (ad-activate 'tramp-read-passwd)) - (catch 'exit ; `exit-minibuffer' use this tag on exit. - (helm-log (concat "[Start session] " (make-string 41 ?+))) - (helm-log "any-prompt = %S" any-prompt) - (helm-log "any-preselect = %S" any-preselect) - (helm-log "any-buffer = %S" any-buffer) - (helm-log "any-keymap = %S" any-keymap) - (helm-log "any-default = %S" any-default) - (helm-log "any-history = %S" any-history) - (let ((old-overriding-local-map overriding-terminal-local-map) - (non-essential t) - (old--cua cua-mode) - (helm-maybe-use-default-as-input - (or helm-maybe-use-default-as-input ; it is let-bounded so use it. - (cl-loop for s in (helm-normalize-sources any-sources) - thereis (memq s helm-sources-using-default-as-input))))) - ;; cua-mode overhide local helm bindings. - ;; disable this stupid thing if enabled. - (and cua-mode (cua-mode -1)) - (unwind-protect - (condition-case _v - (let (;; `helm-source-name' is non-nil - ;; when `helm' is invoked by action, reset it. - helm-source-name - helm-current-source - helm-in-persistent-action - helm-quit - (helm-buffer (or any-buffer helm-buffer))) - (with-helm-restore-variables - (helm-initialize - any-resume any-input any-default any-sources) - (helm-display-buffer helm-buffer) - (add-hook 'post-command-hook 'helm--maybe-update-keymap) - (helm-log "show prompt") - (unwind-protect - (helm-read-pattern-maybe - any-prompt any-input any-preselect - any-resume any-keymap any-default any-history) - (helm-cleanup))) - (prog1 - (unless helm-quit (helm-execute-selection-action)) - (helm-log (concat "[End session] " (make-string 41 ?-))))) - (quit - (helm-restore-position-on-quit) - (helm-log (concat "[End session (quit)] " (make-string 34 ?-))) - nil)) - (remove-hook 'post-command-hook 'helm--maybe-update-keymap) - (if (fboundp 'advice-add) - (advice-remove 'tramp-read-passwd #'helm--advice-tramp-read-passwd) - (ad-deactivate 'tramp-read-passwd)) - (helm-log "helm-alive-p = %S" (setq helm-alive-p nil)) - (setq overriding-terminal-local-map old-overriding-local-map) - (setq helm-alive-p nil) - (setq helm-in-file-completion-p nil) - (and old--cua (cua-mode 1)) - (helm-log-save-maybe))))) - - -;;; Helm resume -;; -;; -(defun helm-resume (arg) - "Resurrect previously invoked `helm'. -Called with a prefix arg, allow choosing among all existing -helm buffers. i.e choose among various helm sessions. -Called from lisp, you can specify a buffer-name as a string with ARG." - (interactive "P") - (let (any-buffer helm-full-frame cur-dir) - (if arg - (if (and (stringp arg) (bufferp (get-buffer arg))) - (setq any-buffer arg) - (setq any-buffer (helm-resume-select-buffer))) - (setq any-buffer helm-last-buffer)) - (cl-assert any-buffer nil - "helm-resume: No helm buffers found to resume") - ;; Reset `cursor-type' to nil as it have been set to t - ;; when quitting previous session. - (with-current-buffer any-buffer (setq cursor-type nil)) - (setq helm-full-frame (buffer-local-value - 'helm-full-frame (get-buffer any-buffer))) - (setq helm-compiled-sources nil) - (setq cur-dir (buffer-local-value - 'helm-default-directory (get-buffer any-buffer))) - (unless (buffer-live-p helm-current-buffer) - ;; `helm-current-buffer' may have been killed. - (setq helm-current-buffer (current-buffer))) - ;; Restart with same `default-directory' value this session - ;; was initially started with. - (with-helm-default-directory cur-dir - (helm - :sources (buffer-local-value - 'helm-sources (get-buffer any-buffer)) - :input (buffer-local-value 'helm-input-local (get-buffer any-buffer)) - :resume t - :buffer any-buffer)))) - -(defun helm-resume-previous-session-after-quit (arg) - "Resume previous helm session within running helm." - (interactive "p") - (if (and helm-alive-p (> (length helm-buffers) arg)) - (helm-run-after-quit `(lambda () (helm-resume (nth ,arg helm-buffers)))) - (message "No previous helm sessions to resume yet!"))) - -(defun helm-resume-list-buffers-after-quit () - "List resumable helm buffers within running helm." - (interactive) - (if (and helm-alive-p (> (length helm-buffers) 0)) - (helm-run-after-quit #'(lambda () (helm-resume t))) - (message "No previous helm sessions to resume yet!"))) - -(defun helm-resume-p (any-resume) - "Whether current helm session is resumed or not." - (eq any-resume t)) - -(defun helm-resume-select-buffer () - "Select an `helm-buffer' in `helm-buffers' list to resume a helm session. -Return nil if no `helm-buffer' found." - (when helm-buffers - (or (helm :sources '(((name . "Resume helm buffer") - (candidates . helm-buffers) - (action . identity))) - :resume 'noresume - :buffer "*helm resume*") - (keyboard-quit)))) - - -;;;###autoload -(defun helm-other-buffer (any-sources any-buffer) - "Simplified interface of `helm' with other `helm-buffer'. -Call `helm' with only ANY-SOURCES and ANY-BUFFER as args." - (helm :sources any-sources :buffer any-buffer)) - -(defun helm-nest (&rest same-as-helm) - "Allow calling `helm' whithin a running helm session. -Arguments SAME-AS-HELM are the same as `helm', which see." - (with-helm-window - (let ((orig-helm-current-buffer helm-current-buffer) - (orig-helm-buffer helm-buffer) - (orig-helm-last-frame-or-window-configuration - helm-last-frame-or-window-configuration) - (orig-one-window-p helm-onewindow-p)) - (unwind-protect - (let (helm-current-position - helm-current-buffer - helm-pattern - (helm-buffer (or (cl-getf same-as-helm :buffer) - (nth 5 same-as-helm) - "*Helm*")) - helm-sources - helm-compiled-sources - (helm-full-frame t) - (enable-recursive-minibuffers t)) - (apply #'helm same-as-helm)) - (with-current-buffer orig-helm-buffer - (setq helm-alive-p t) ; Nested session set this to nil on exit. - (setq helm-buffer orig-helm-buffer) - (helm-initialize-overlays helm-buffer) - (unless (helm-empty-buffer-p) (helm-mark-current-line t)) - (setq helm-last-frame-or-window-configuration - orig-helm-last-frame-or-window-configuration) - (setq cursor-type nil) - (setq helm-current-buffer orig-helm-current-buffer) - (setq helm-onewindow-p orig-one-window-p)))))) - - -;;; Core: Accessors -;; -(defun helm-current-position (save-or-restore) - "Restore or save current position in `helm-current-buffer'. -Argument SAVE-OR-RESTORE is one of save or restore." - (cl-case save-or-restore - (save - (helm-log "Save position at %S" (cons (point) (window-start))) - (setq helm-current-position (cons (point) (window-start)))) - (restore - (helm-log "Restore position at %S in buffer %s" - helm-current-position - (buffer-name (current-buffer))) - (goto-char (car helm-current-position)) - ;; Fix this position with the NOFORCE arg of `set-window-start' - ;; otherwise, if there is some other buffer than `helm-current-buffer' - ;; one, position will be lost. - (set-window-start (selected-window) (cdr helm-current-position) t)))) - - -(defun helm-frame-or-window-configuration (save-or-restore) - "Save or restore last frame or window configuration. -Possible value of SAVE-OR-RESTORE are 'save and 'restore. -window or frame configuration is saved/restored according to values of -`helm-save-configuration-functions'." - (helm-log "helm-save-configuration-functions = %S" - helm-save-configuration-functions) - (let ((window-persistent-parameters (append '((no-other-window . t)) - window-persistent-parameters))) - (cl-case save-or-restore - (save (setq helm-last-frame-or-window-configuration - (funcall (cdr helm-save-configuration-functions)))) - (restore (funcall (car helm-save-configuration-functions) - helm-last-frame-or-window-configuration) - ;; Restore frame focus. - ;; This is needed for minibuffer own-frame config - ;; when recursive minibuffers are in use. - ;; e.g M-: + helm-minibuffer-history. - (let ((frame (if (minibufferp helm-current-buffer) - (selected-frame) - (last-nonminibuffer-frame)))) - (select-frame-set-input-focus frame)))))) - -(defun helm-split-window-default-fn (window) - (let (split-width-threshold) - (if (and (fboundp 'window-in-direction) - ;; Don't try to split when starting in a minibuffer - ;; e.g M-: and try to use helm-show-kill-ring. - (not (minibufferp helm-current-buffer))) - (if (or (one-window-p t) - helm-split-window-in-side-p) - (split-window - (selected-window) nil (if (eq helm-split-window-default-side 'other) - 'below helm-split-window-default-side)) - ;; If more than one window reuse one of them. - (cl-case helm-split-window-default-side - (left (or (helm-window-in-direction 'left) - (helm-window-in-direction 'above) - (selected-window))) - (above (or (helm-window-in-direction 'above) - (helm-window-in-direction 'left) - (selected-window))) - (right (or (helm-window-in-direction 'right) - (helm-window-in-direction 'below) - (selected-window))) - (below (or (helm-window-in-direction 'below) - (helm-window-in-direction 'right) - (selected-window))) - (same (selected-window)) - (other (other-window-for-scrolling)) - (t (or (window-next-sibling) (selected-window))))) - (split-window-sensibly window)))) - -(defun helm-window-in-direction (direction) - "Same as `window-in-direction' but check if window is dedicated." - (helm-aif (window-in-direction direction) - (and (not (window-dedicated-p it)) it))) - - -;;; Display helm buffer -;; -;; -(defun helm-display-buffer (buffer) - "Display BUFFER. -The function used to display `helm-buffer'." - (let (pop-up-frames - (split-window-preferred-function - helm-split-window-preferred-function) - (helm-split-window-default-side - (if (and (not helm-full-frame) - helm-reuse-last-window-split-state) - (cond ((eq helm-split-window-default-side 'same) 'same) - ((eq helm-split-window-default-side 'other) 'other) - (helm--window-side-state) - (t helm-split-window-default-side)) - helm-split-window-default-side))) - (prog1 - (funcall (with-current-buffer buffer helm-display-function) buffer) - (setq helm-onewindow-p (one-window-p t)) - ;; Don't allow other-window and friends switching out of minibuffer. - (when helm-prevent-escaping-from-minibuffer - (helm-prevent-switching-other-window))))) - -(cl-defun helm-prevent-switching-other-window (&key (enabled t)) - "Allow setting `no-other-window' window parameter in all windows. -Arg ENABLE will be the value of the `no-other-window' window property." - (walk-windows - #'(lambda (w) - (unless (window-dedicated-p w) - (set-window-parameter w 'no-other-window enabled))) 0)) - -(defun helm-default-display-buffer (buffer) - "Default function to display `helm-buffer' BUFFER. -It uses `switch-to-buffer' or `pop-to-buffer' depending of value of -`helm-full-frame' and/or `helm-split-window-default-side'." - (if (or (buffer-local-value 'helm-full-frame (get-buffer buffer)) - (and (eq helm-split-window-default-side 'same) - (one-window-p t))) - (progn (delete-other-windows) (switch-to-buffer buffer)) - (when (and helm-always-two-windows - (not (eq helm-split-window-default-side 'same)) - (not (minibufferp helm-current-buffer)) - (not helm-split-window-in-side-p)) - (delete-other-windows)) - (pop-to-buffer buffer))) - - -;;; Core: initialize -;; -(defun helm-initialize (any-resume any-input any-default any-sources) - "Start initialization of `helm' session. -For ANY-RESUME ANY-INPUT ANY-DEFAULT and ANY-SOURCES See `helm'." - (helm-log "start initialization: any-resume=%S any-input=%S" - any-resume any-input) - (helm-frame-or-window-configuration 'save) - (setq helm-sources (helm-normalize-sources any-sources)) - (helm-log "sources = %S" helm-sources) - (helm-current-position 'save) - (if (helm-resume-p any-resume) - (helm-initialize-overlays (helm-buffer-get)) - (helm-initial-setup any-default)) - (setq helm-alive-p t) - (unless (eq any-resume 'noresume) - (helm-recent-push helm-buffer 'helm-buffers) - (setq helm-last-buffer helm-buffer)) - (when any-input (setq helm-input any-input - helm-pattern any-input)) - ;; If a `resume' attribute is present `helm-funcall-foreach' - ;; will run its function. - (when (helm-resume-p any-resume) - (helm-funcall-foreach 'resume)) - (helm-log "end initialization")) - -(defun helm-initialize-overlays (buffer) - "Initialize helm overlays in BUFFER." - (helm-log "overlay setup") - (if helm-selection-overlay - ;; make sure the overlay belongs to the helm buffer if - ;; it's newly created - (move-overlay helm-selection-overlay (point-min) (point-min) - (get-buffer buffer)) - - (setq helm-selection-overlay - (make-overlay (point-min) (point-min) (get-buffer buffer))) - (overlay-put helm-selection-overlay 'face 'helm-selection))) - -(defun helm-restore-position-on-quit () - "Restore position in `helm-current-buffer' when quitting." - (helm-current-position 'restore)) - -(defun helm-recent-push (elt list-var) - "Add ELT to the value of LIST-VAR as most recently used value." - (let ((m (member elt (symbol-value list-var)))) - (and m (set list-var (delq (car m) (symbol-value list-var)))) - (push elt (symbol-value list-var)))) - -(defun helm--current-buffer () - "[internal] Return `current-buffer' BEFORE `helm-buffer' is initialized. -Note that this will return the minibuffer in use after helm have started, -so to get the buffer where helm started while in a helm session, -use `helm-current-buffer'. -It is intended to use this only in `helm-initial-setup'." - (if (minibuffer-window-active-p (minibuffer-window)) - ;; If minibuffer is active be sure to use it's buffer - ;; as `helm-current-buffer', this allow to use helm - ;; from an already active minibuffer (M-: etc...) - (window-buffer (active-minibuffer-window)) - ;; Fix Issue #456 - ;; Use this instead of `current-buffer' to ensure - ;; helm session started in helm-mode from a completing-read - ;; Use really the buffer where we started and not the one - ;; where the completing-read is wrapped. i.e - ;; (with-current-buffer SOME-OTHER-BUFFER (completing-read [...]) - (window-buffer (with-selected-window (minibuffer-window) - (minibuffer-selected-window))))) - -(defun helm-initial-setup (any-default) - "Initialize helm settings and set up the helm buffer." - (helm-log-run-hook 'helm-before-initialize-hook) - (cl-loop for s in (helm-get-sources) - for hook = (assoc-default 'before-init-hook s) - when hook do (helm-log-run-hook hook)) - (setq helm-current-prefix-arg nil) - (setq helm-suspend-update-flag nil) - (setq helm-current-buffer (helm--current-buffer)) - (setq helm-buffer-file-name buffer-file-name) - (setq helm-issued-errors nil) - (setq helm-compiled-sources nil) - (setq helm-saved-current-source nil) - (unless (and (or helm-split-window-state - helm--window-side-state) - helm-reuse-last-window-split-state) - (setq helm-split-window-state - (if (or (null split-width-threshold) - (and (integerp split-width-threshold) - (>= split-width-threshold (+ (frame-width) 4)))) - 'vertical 'horizontal)) - (setq helm--window-side-state - (or helm-split-window-default-side 'below))) - ;; Call the init function for sources where appropriate - (helm-funcall-foreach - 'init (and helm-source-filter - (cl-remove-if-not #'(lambda (s) - (member (assoc-default 'name s) - helm-source-filter)) - (helm-get-sources)))) - (setq helm-pattern (or (and helm-maybe-use-default-as-input - (or (if (listp any-default) - (car any-default) any-default) - (with-helm-current-buffer - (thing-at-point 'symbol)))) - "")) - (setq helm-input "") - (clrhash helm-candidate-cache) - (helm-create-helm-buffer) - (helm-clear-visible-mark) - (helm-log-run-hook 'helm-after-initialize-hook) - (cl-loop for s in (helm-get-sources) - for hook = (assoc-default 'after-init-hook s) - when hook do (helm-log-run-hook hook))) - -(defun helm-create-helm-buffer () - "Create and setup `helm-buffer'." - (let ((root-dir default-directory)) - (with-current-buffer (get-buffer-create helm-buffer) - (helm-log "kill local variables: %S" (buffer-local-variables)) - (kill-all-local-variables) - (set (make-local-variable 'inhibit-read-only) t) - (buffer-disable-undo) - (erase-buffer) - (set (make-local-variable 'helm-map) helm-map) - (make-local-variable 'helm-sources) - (set (make-local-variable 'helm-follow-mode) nil) - (set (make-local-variable 'helm-display-function) helm-display-function) - (set (make-local-variable 'helm-selection-point) nil) - (set (make-local-variable 'scroll-margin) - (if helm-display-source-at-screen-top - 0 helm-completion-window-scroll-margin)) - (set (make-local-variable 'helm-default-directory) root-dir) - (set (make-local-variable 'default-directory) root-dir) - (set (make-local-variable 'helm-marked-candidates) nil) - (helm-initialize-persistent-action) - (helm-log "helm-display-function = %S" helm-display-function) - (helm-log "helm--local-variables = %S" helm--local-variables) - (cl-loop for (var . val) in helm--local-variables - do (set (make-local-variable var) val) - finally (setq helm--local-variables nil)) - (setq truncate-lines helm-truncate-lines) ; already local. - (setq cursor-type nil) - (setq mode-name "Helm")) - (helm-initialize-overlays helm-buffer) - (get-buffer helm-buffer))) - -(defun helm-read-pattern-maybe (any-prompt any-input - any-preselect any-resume any-keymap - any-default any-history) - "Read pattern with prompt ANY-PROMPT and initial input ANY-INPUT. -For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." - (if (and (helm-resume-p any-resume) - ;; When no source, helm-buffer is empty - ;; or contain non--candidate lines (e.g grep exit status) - (helm-get-current-source)) - (helm-mark-current-line t) - (helm-update any-preselect)) - (with-current-buffer (helm-buffer-get) - (let* ((src (helm-get-current-source)) - (src-keymap (assoc-default 'keymap src)) - (hist (or (and any-history (symbolp any-history) any-history) - ;; Needed for resuming. - (assoc-default 'history src))) - (timer nil) - blink-matching-paren - (first-src (car helm-sources)) - (source-delayed-p (or (assq 'delayed src) - (assq 'delayed (if (symbolp first-src) - (symbol-value first-src) - first-src))))) - ;; Startup with the first keymap found either in current source - ;; or helm arg, otherwise use global value of `helm-map'. - ;; This map will be used as a `minibuffer-local-map'. - ;; Maybe it will be overriden when changing source - ;; by `helm--maybe-update-keymap'. - ;; Note that helm-map have been made buffer-local - ;; in `helm-create-helm-buffer'. - (setq helm-map (or src-keymap any-keymap helm-map)) - (helm-log "helm-get-candidate-number => %S" - (helm-get-candidate-number)) - (helm-log "helm-execute-action-at-once-if-one = %S" - helm-execute-action-at-once-if-one) - (helm-log "helm-quit-if-no-candidate = %S" helm-quit-if-no-candidate) - ;; If source is delayed `helm-execute-action-at-once-if-one' - ;; and `helm-quit-if-no-candidate' are handled after update finish. - (when source-delayed-p - ;; Note that we quickly add the hook now when `helm-update' - ;; is already started, but because source is delayed the hook - ;; should have the time to be passed !!! - ;; the hook will remove itself once done. - (with-helm-after-update-hook (helm-exit-or-quit-maybe))) - ;; Reset `helm-pattern' for non--delayed sources and update - ;; display if no result found with precedent value of `helm-pattern' - ;; unless `helm-quit-if-no-candidate' is non--nil, in this case - ;; Don't force update with an empty pattern. - ;; Reset also `helm-maybe-use-default-as-input' as this checking - ;; happen only on startup. - (when (and helm-maybe-use-default-as-input (not source-delayed-p)) - (setq helm-pattern "") - (setq helm-maybe-use-default-as-input nil) - (and (helm-empty-buffer-p) - (null helm-quit-if-no-candidate) - (helm-force-update))) - ;; Handle `helm-execute-action-at-once-if-one' and - ;; `helm-quit-if-no-candidate' now only for not--delayed sources. - (cond ((and helm-execute-action-at-once-if-one - (not source-delayed-p) - (= (helm-get-candidate-number) 1)) - (ignore)) ; Don't enter the minibuffer loop. - ((and helm-quit-if-no-candidate - (not source-delayed-p) - (= (helm-get-candidate-number) 0)) - (setq helm-quit t) - (and (functionp helm-quit-if-no-candidate) - (funcall helm-quit-if-no-candidate))) - (t ; Enter now minibuffer and wait for input. - (let ((tap (or any-default - (with-helm-current-buffer - (thing-at-point 'symbol))))) - (unwind-protect - (minibuffer-with-setup-hook - #'(lambda () - (setq timer (run-with-idle-timer - (max helm-input-idle-delay 0.001) 'repeat - #'(lambda () - ;; Stop updating when in persistent action - ;; or when `helm-suspend-update-flag' is - ;; non--nil. - (unless (or helm-in-persistent-action - helm-suspend-update-flag) - (save-selected-window - (helm-check-minibuffer-input) - (helm-print-error-messages))))))) - (read-from-minibuffer (or any-prompt "pattern: ") - any-input helm-map - nil hist tap t)) - (when timer (cancel-timer timer) (setq timer nil))))))))) - -(defun helm-exit-or-quit-maybe () - "Exit and run default action if only one candidate, quit if no candidates. -This function is handling `helm-execute-action-at-once-if-one' and -`helm-quit-if-no-candidate' in delayed sources." - (with-helm-window - (cond ((and helm-execute-action-at-once-if-one - (= (helm-get-candidate-number) 1)) - (helm-exit-minibuffer)) - ((and helm-quit-if-no-candidate - (= (helm-get-candidate-number) 0)) - (setq helm-quit t) - (and (functionp helm-quit-if-no-candidate) - (funcall helm-quit-if-no-candidate)) - (keyboard-quit))))) - -(defun helm-toggle-suspend-update () - "Enable or disable update of display in helm. -This can be useful for e.g writing quietly a complex regexp." - (interactive) - (when (setq helm-suspend-update-flag (not helm-suspend-update-flag)) - (helm-kill-async-processes) - (setq helm-pattern "")) - (message (if helm-suspend-update-flag - "Helm update suspended!" - "Helm update reenabled!"))) - -(defadvice tramp-read-passwd (around disable-helm-update) - ;; Suspend update when prompting for a tramp password. - (setq helm-suspend-update-flag t) - (setq overriding-terminal-local-map nil) - (setq helm--reading-passwd-or-string t) - (let (stimers) - (unwind-protect - (progn - (setq stimers (with-timeout-suspend)) - ad-do-it) - (with-timeout-unsuspend stimers) - (setq helm--reading-passwd-or-string nil) - (setq helm-suspend-update-flag nil)))) - -(defun helm--advice-tramp-read-passwd (old--fn &rest args) - ;; Suspend update when prompting for a tramp password. - (setq helm-suspend-update-flag t) - (setq overriding-terminal-local-map nil) - (setq helm--reading-passwd-or-string t) - (unwind-protect - ;; No need to suspend timer in emacs-24.4 - (apply old--fn args) - (setq helm--reading-passwd-or-string nil) - (setq helm-suspend-update-flag nil))) - -(defun helm--maybe-update-keymap () - "Handle differents keymaps in multiples sources. - -It will override `helm-map' with the local map of current source. -If no map is found in current source do nothing (keep previous map)." - (with-helm-buffer - (helm-aif (assoc-default 'keymap (helm-get-current-source)) - ;; Fix #466; we use here set-transient-map - ;; to not overhide other minor-mode-map's. - (if (fboundp 'set-transient-map) - (set-transient-map it) - (set-temporary-overlay-map it))))) - - -;; Core: clean up - -(defun helm-cleanup () - "Clean up the mess when helm exit or quit." - (helm-log "start cleanup") - (with-current-buffer helm-buffer - ;; bury-buffer from this window. - (bury-buffer) ;[1] - ;; Be sure we call this from helm-buffer. - (helm-funcall-foreach 'cleanup)) - (helm-kill-async-processes) - ;; When running helm from a dedicated frame - ;; with no minibuffer, helm will run in the main frame - ;; which have a minibuffer, so be sure to disable - ;; the `no-other-window' prop there. - (helm-prevent-switching-other-window :enabled nil) - (helm-log-run-hook 'helm-cleanup-hook) - (helm-frame-or-window-configuration 'restore) - ;; [1] now bury-buffer from underlying windows otherwise, - ;; if this window is killed the underlying buffer will - ;; be a helm buffer. - (replace-buffer-in-windows helm-buffer) - (setq helm-alive-p nil) - (setq helm-in-file-completion-p nil) - ;; This is needed in some cases where last input - ;; is yielded infinitely in minibuffer after helm session. - (helm-clean-up-minibuffer)) - -(defun helm-clean-up-minibuffer () - "Remove contents of minibuffer." - (let ((miniwin (minibuffer-window))) - ;; Clean only current minibuffer used by helm. - ;; i.e The precedent one is active. - (unless (minibuffer-window-active-p miniwin) - (with-current-buffer (window-buffer miniwin) - (delete-minibuffer-contents))))) - - -;;; Core: input handling -;; -;; -(defun helm-check-minibuffer-input () - "Check minibuffer content." - (with-helm-quittable - (with-selected-window (or (active-minibuffer-window) - (minibuffer-window)) - (helm-check-new-input (minibuffer-contents))))) - -(defun helm-check-new-input (input) - "Check INPUT string and update the helm buffer if necessary." - ;; First time minibuffer is entered - ;; we check value of `helm-pattern' that have been set - ;; in `helm-initial-setup' when `helm-maybe-use-default-as-input' - ;; is non--nil. After this initial check, reset - ;; `helm-maybe-use-default-as-input' and ignore this. - ;; This happen only when source is `delayed'. - (when helm-maybe-use-default-as-input ; nil when non--delayed. - (setq input helm-pattern) - (with-helm-after-update-hook (setq helm-pattern "")) - (setq helm-maybe-use-default-as-input nil)) - ;; In delayed sources `helm-pattern' have not been resat yet. - (unless (equal input helm-pattern) - (setq helm-pattern input) - (unless (helm-action-window) - (setq helm-input helm-pattern)) - (helm-log "helm-pattern = %S" helm-pattern) - (helm-log "helm-input = %S" helm-input) - (setq helm--in-update t) - (helm-update))) - -(defun helm--reset-update-flag () - (run-with-idle-timer - helm-exit-idle-delay nil - (lambda () (setq helm--in-update nil)))) - -(add-hook 'helm-after-update-hook #'helm--reset-update-flag) - - -;;; Core: source compiler -;; -;; -(defun helm-compile-sources (sources funcs) - "Compile SOURCES with FUNCS. -See `helm-compile-source-functions'. -Helm plug-ins are realized by this function." - (mapcar - (lambda (source) - (cl-loop with src = (if (listp source) source (symbol-value source)) - for noplug = (assoc 'dont-plug src) - for f in funcs - unless (and noplug (memq f (cdr noplug))) - do (setq src (funcall f src)) - finally (cl-return src))) - sources)) - - -;; Core: all candidates - -(defun helm-get-candidates (source) - "Retrieve and return the list of candidates from SOURCE." - (let* (inhibit-quit - (candidate-fn (assoc-default 'candidates source)) - (candidate-proc (assoc-default 'candidates-process source)) - (type-error (lambda () - (error - "`%s' must either be a function, a variable or a list" - (or candidate-fn candidate-proc)))) - (candidates (condition-case err - ;; Process candidates-(process) function - ;; It may return a process or a list of candidates. - (if candidate-proc - (helm-interpret-value candidate-proc source) - (helm-interpret-value candidate-fn source)) - (error (helm-log "Error: %S" err) nil)))) - (when (and (processp candidates) (not candidate-proc)) - (warn "Candidates function `%s' should be called in a `candidates-process' attribute" - candidate-fn)) - (cond ((processp candidates) - ;; Candidates will be filtered later in process filter. - candidates) - ((null candidates) candidates) - ((listp candidates) - ;; Transform candidates with `candidate-transformer' functions if - ;; some, otherwise return candidates. - (helm-transform-candidates candidates source)) - (t (funcall type-error))))) - -(defmacro helm-while-no-input (&rest body) - "Same as `while-no-input' but without testing with `input-pending-p'." - (declare (debug t) (indent 0)) - (let ((catch-sym (make-symbol "input")) - inhibit-quit) - `(with-local-quit - (catch ',catch-sym - (let ((throw-on-input ',catch-sym)) - ,@body))))) - -(defun helm-get-cached-candidates (source) - "Return the cached value of candidates for SOURCE. -Cache the candidates if there is not yet a cached value." - (let* ((name (assoc-default 'name source)) - (candidate-cache (gethash name helm-candidate-cache))) - (helm-aif candidate-cache - (prog1 it (helm-log "Use cached candidates")) - (helm-log "No cached candidates, calculate candidates") - (let ((candidates (helm-get-candidates source))) - (cond ((processp candidates) - (push (cons candidates - (append source - (list (cons 'item-count 0) - (cons 'incomplete-line "")))) - helm-async-processes) - (set-process-filter candidates 'helm-output-filter) - (setq candidates nil)) - ((not (assoc 'volatile source)) - (puthash name candidates helm-candidate-cache))) - candidates)))) - - -;;; Core: candidate transformers -(defun helm-transform-mapcar (function args) - "`mapcar' for candidate-transformer. - -ARGS is (cand1 cand2 ...) or ((disp1 . real1) (disp2 . real2) ...) - -\(helm-transform-mapcar 'upcase '(\"foo\" \"bar\")) -=> (\"FOO\" \"BAR\") -\(helm-transform-mapcar 'upcase '((\"1st\" . \"foo\") (\"2nd\" . \"bar\"))) -=> ((\"1st\" . \"FOO\") (\"2nd\" . \"BAR\")) -" - (cl-loop for arg in args - if (consp arg) - collect (cons (car arg) (funcall function (cdr arg))) - else - collect (funcall function arg))) - -(defun helm-process-candidate-transformer (candidates source) - "Execute `candidate-transformer' function(s) on CANDIDATES in SOURCE." - (helm-aif (assoc-default 'candidate-transformer source) - (helm-composed-funcall-with-source source it candidates) - candidates)) - -(defun helm-process-filtered-candidate-transformer (candidates source) - "Execute `filtered-candidate-transformer' function(s) on CANDIDATES in SOURCE." - (helm-aif (assoc-default 'filtered-candidate-transformer source) - (helm-composed-funcall-with-source source it candidates source) - candidates)) - -(defmacro helm--maybe-process-filter-one-by-one-candidate (candidate source) - "Execute `filter-one-by-one' function(s) on CANDIDATE in SOURCE." - `(helm-aif (assoc-default 'filter-one-by-one ,source) - (if (and (listp it) - (not (functionp it))) ;; Don't treat lambda's as list. - (cl-loop for f in it - do (setq ,candidate (funcall f ,candidate))) - (setq ,candidate (funcall it ,candidate))))) - -(defun helm--initialize-one-by-one-candidates (candidates source) - "Process the CANDIDATES with the `filter-one-by-one' function in SOURCE. -Return CANDIDATES when pattern is empty." - (helm-aif (and (string= helm-pattern "") - (assoc-default 'filter-one-by-one source)) - (cl-loop for cand in candidates - do (helm--maybe-process-filter-one-by-one-candidate cand source) - collect cand) - candidates)) - -(defun helm-process-filtered-candidate-transformer-maybe - (candidates source process-p) - "Execute `filtered-candidate-transformer' function(s) on CANDIDATES in SOURCE. -When PROCESS-P is non-nil execute `filtered-candidate-transformer' -functions if some, otherwise return CANDIDATES." - (if process-p - ;; When no filter return CANDIDATES unmodified. - (helm-process-filtered-candidate-transformer candidates source) - candidates)) - -(defun helm-process-real-to-display (candidates source) - "Execute real-to-display function on all CANDIDATES of SOURCE." - (helm-aif (assoc-default 'real-to-display source) - (setq candidates (helm-funcall-with-source - source 'mapcar - (lambda (cand_) - (if (consp cand_) - ;; override DISPLAY from candidate-transformer - (cons (funcall it (cdr cand_)) (cdr cand_)) - (cons (funcall it cand_) cand_))) - candidates)) - candidates)) - -(defun helm-transform-candidates (candidates source &optional process-p) - "Transform CANDIDATES of SOURCE according to candidate transformers. -When PROCESS-P is non-nil execute the `filtered-candidate-transformer' functions -otherwise only the `candidate-transformer' functions are processed. -When attribute `real-to-display' is present, execute its function on all maybe -filtered CANDIDATES." - (helm-process-real-to-display - (helm-process-filtered-candidate-transformer-maybe - (helm-process-candidate-transformer - (helm--initialize-one-by-one-candidates candidates source) source) - source process-p) - source)) - - -;; Core: narrowing candidates -(defun helm-candidate-number-limit (source) - "Apply candidate-number-limit attribute value. -This overhide variable `helm-candidate-number-limit'. - -e.g: -If \(candidate-number-limit\) is in SOURCE, show all candidates in SOURCE. -If \(candidate-number-limit . 123\) is in SOURCE limit candidate to 123." - (helm-aif (assq 'candidate-number-limit source) - (or (cdr it) 99999999) - (or helm-candidate-number-limit 99999999))) - -(defun helm-candidate-get-display (candidate) - "Get searched display part from CANDIDATE. -CANDIDATE is a string, a symbol, or \(DISPLAY . REAL\) cons cell." - (format "%s" (or (car-safe candidate) candidate))) - -(defun helm-process-pattern-transformer (pattern source) - "Execute pattern-transformer attribute PATTERN function in SOURCE." - (helm-aif (assoc-default 'pattern-transformer source) - (helm-composed-funcall-with-source source it pattern) - pattern)) - -(defun helm-default-match-function (candidate) - "Check if `helm-pattern' match CANDIDATE. -Default function to match candidates according to `helm-pattern'." - (string-match helm-pattern candidate)) - -(defun helm-match-functions (source) - (let ((matchfns (or (assoc-default 'match source) - (assoc-default 'match-strict source) - #'helm-default-match-function))) - (if (and (listp matchfns) (not (functionp matchfns))) - matchfns (list matchfns)))) - -(defmacro helm--accumulate-candidates (candidate newmatches - hash item-count limit source) - "Add CAND into NEWMATCHES and use HASH to uniq NEWMATCHES. -Argument ITEM-COUNT count the matches. -if ITEM-COUNT reaches LIMIT, exit from inner loop." - `(unless (gethash ,candidate ,hash) - (unless (assq 'allow-dups ,source) - (puthash ,candidate t ,hash)) - (helm--maybe-process-filter-one-by-one-candidate ,candidate source) - (push ,candidate ,newmatches) - (cl-incf ,item-count) - (when (= ,item-count ,limit) (cl-return)))) - -(defun helm-take-first-elements (seq n) - "Return the N first element of SEQ if SEQ is longer than N. -It is used to narrow down list of candidates to `helm-candidate-number-limit'." - (if (> (length seq) n) (cl-subseq seq 0 n) seq)) - -(cl-defun helm-set-case-fold-search (&optional (pattern helm-pattern)) - "Used to set the value of `case-fold-search' in helm. -Return t or nil depending of value of `helm-case-fold-search' -and `helm-pattern'." - (let ((helm-case-fold-search - (helm-aif (assq 'case-fold-search (helm-get-current-source)) - (cdr it) - helm-case-fold-search)) - ;; Only parse basename for filenames - ;; to avoid setting case sensitivity - ;; when expanded directories contains upcase - ;; characters. - (bn-or-pattern (if (string-match "[~/]*" pattern) - ;; `helm-basename' is not available yet. - (file-name-nondirectory - (directory-file-name pattern)) - pattern))) - (helm-set-case-fold-search-1 bn-or-pattern))) - -(defun helm-set-case-fold-search-1 (pattern) - (cl-case helm-case-fold-search - (smart (let ((case-fold-search nil)) - (if (string-match "[[:upper:]]" pattern) nil t))) - (t helm-case-fold-search))) - -(defun helm-match-from-candidates (cands matchfns limit source) - (let (matches) - (condition-case err - (let ((item-count 0) - (case-fold-search (helm-set-case-fold-search))) - (clrhash helm-match-hash) - (cl-dolist (match matchfns) - (let (newmatches) - (cl-dolist (candidate cands) - (unless (gethash candidate helm-match-hash) - (when (funcall match - (helm-candidate-get-display candidate)) - (helm--accumulate-candidates - candidate newmatches - helm-match-hash item-count limit source)))) - ;; filter-one-by-one may return nil candidates, so delq them if some. - (setq matches (nconc matches (nreverse (delq nil newmatches))))))) - (error (unless (eq (car err) 'invalid-regexp) ; Always ignore regexps errors. - (helm-log-error "helm-match-from-candidates in source `%s': %s %s" - (assoc-default 'name source) (car err) (cdr err))) - (setq matches nil))) - matches)) - -(defun helm-compute-matches (source) - "Start computing candidates in SOURCE." - (save-current-buffer - (let ((matchfns (helm-match-functions source)) - (helm-source-name (assoc-default 'name source)) - (helm-current-source source) - (limit (helm-candidate-number-limit source)) - (helm-pattern (helm-process-pattern-transformer - helm-pattern source))) - ;; If source have a `filtered-candidate-transformer' attr - ;; Filter candidates with this func, otherwise just compute - ;; candidates. - (helm-process-filtered-candidate-transformer - (if (or (equal helm-pattern "") - (equal matchfns '(identity))) - ;; Compute all candidates up to LIMIT. - (helm-take-first-elements - (helm-get-cached-candidates source) limit) - ;; Compute candidates according to pattern with their match fns. - (helm-match-from-candidates - (helm-get-cached-candidates source) matchfns limit source)) - source)))) - -(defun helm-render-source (source matches) - "Display MATCHES from SOURCE according to its settings." - (helm-log "Source name = %S" (assoc-default 'name source)) - (when matches - (helm-insert-header-from-source source) - (if (not (assq 'multiline source)) - (cl-loop for m in matches - for count from 1 - do (helm-insert-match m 'insert source count)) - (let ((start (point)) - (count 0) - separate) - (cl-dolist (match matches) - (cl-incf count) - (if separate - (helm-insert-candidate-separator) - (setq separate t)) - (helm-insert-match match 'insert source count)) - (put-text-property start (point) 'helm-multiline t))))) - -(defmacro helm--maybe-use-while-no-input (&rest body) - "Wrap BODY in `helm-while-no-input' unless initializing a remote connection." - `(progn - (if (and (file-remote-p helm-pattern) - (not (file-remote-p helm-pattern nil t))) - ;; Tramp will ask for passwd, don't use `helm-while-no-input'. - ,@body - (helm-log "Using here `helm-while-no-input'") - (helm-while-no-input ,@body)))) - -(defun helm--compute-sources (src-list) - (cl-loop with matches = (helm--maybe-use-while-no-input - (cl-loop for src in src-list - collect (helm-compute-matches src))) - when (eq matches t) do (setq matches nil) - for src in src-list - for mtc in matches - do (helm-render-source src mtc))) - -(cl-defun helm-process-delayed-sources (delayed-sources &optional preselect source) - "Process helm DELAYED-SOURCES. -Move selection to string or regexp PRESELECT if non--nil. -This function is called in `helm-process-delayed-sources-timer' -when emacs is idle for `helm-idle-delay'." - (with-helm-quittable - (helm-log "Delayed sources = %S" - (mapcar (lambda (s) - (assoc-default 'name s)) - delayed-sources)) - (with-current-buffer (helm-buffer-get) - (save-excursion - (goto-char (point-max)) - (helm--compute-sources delayed-sources) - (when (and (not (helm-empty-buffer-p)) - ;; No selection yet. - (= (overlay-start helm-selection-overlay) - (overlay-end helm-selection-overlay))) - (helm-update-move-first-line 'without-hook))) - (save-excursion - (goto-char (point-min)) - (helm-log-run-hook 'helm-update-hook)) - (setq helm-force-updating-p nil) - (unless (assoc 'candidates-process source) - (helm-display-mode-line (helm-get-current-source)) - (helm-log-run-hook 'helm-after-update-hook)) - (when preselect (helm-preselect preselect source))))) - - -;;; Core: helm-update -;; -(defun helm-update (&optional preselect source) - "Update candidates list in `helm-buffer' according to `helm-pattern'. -Argument PRESELECT is a string or regexp used to move selection to a particular -place once updating is done. It should be used on single source because search -is done on whole `helm-buffer' and not on current source." - (helm-log "Start updating") - (helm-kill-async-processes) - ;; When persistent action have been called - ;; we have two windows even with `helm-full-frame'. - ;; So go back to one window when updating if `helm-full-frame' - ;; is non--nil. - (with-helm-window - (when helm-onewindow-p (delete-other-windows))) - (with-current-buffer (helm-buffer-get) - (set (make-local-variable 'helm-input-local) helm-pattern) - (let (normal-sources - delayed-sources) - (unwind-protect - (progn - ;; Iterate over all the sources - (cl-loop for source in (cl-remove-if-not - 'helm-update-source-p (helm-get-sources)) - if (helm-delayed-source-p source) - ;; Delayed sources just get collected for later - ;; processing - collect source into ds - else - ;; Collect the normal sources - collect source into ns - ;; Export the variables from cl-loop - finally (setq delayed-sources ds - normal-sources ns)) - (erase-buffer) - ;; Render all the sources into the helm buffer after - ;; calculating all candidates. - ;; Candidates must be computed AFTER erasing buffer - ;; even if it cause flickering; Doing so avoid - ;; unexpected results when executing actions. - (helm--compute-sources normal-sources)) - (helm-log "Delayed sources = %S" - (mapcar (lambda (s) (assoc-default 'name s)) - delayed-sources)) - (cond ((and preselect delayed-sources normal-sources) - ;; Preselection run here when there is - ;; normal AND delayed sources. - (helm-log "Update preselect candidate %s" preselect) - (helm-preselect preselect source)) - (delayed-sources ; Preselection and hooks will run later. - (helm-update-move-first-line 'without-hook)) - (t ; No delayed sources, run the hooks now. - (helm-update-move-first-line) - (unless (assoc 'candidates-process source) - (helm-display-mode-line (helm-get-current-source)) - (helm-log-run-hook 'helm-after-update-hook)) - (when preselect - (helm-log "Update preselect candidate %s" preselect) - (helm-preselect preselect source)) - (setq helm-force-updating-p nil))) - (when delayed-sources - ;; Allow giving a value to `delayed' attr from inside source. - ;; Retain the biggest value (the slower) found in DELAYED-SOURCES. - (let ((helm-idle-delay (cl-loop with delay = helm-idle-delay - for s in delayed-sources - for d = (assoc-default 'delayed s) - when d do (setq delay (max delay d)) - finally return delay))) - (run-with-idle-timer - ;; Be sure helm-idle-delay is > - ;; to helm-input-idle-delay - ;; otherwise use value of helm-input-idle-delay - ;; or 0.01 if == to 0. - (max helm-idle-delay helm-input-idle-delay 0.001) nil - 'helm-process-delayed-sources delayed-sources preselect source))) - (helm-log "end update"))))) - -;; Update keymap after updating. -;; Putting this in a hook allow users to disable it. -(add-hook 'helm-after-update-hook 'helm--maybe-update-keymap) - -(defun helm-update-source-p (source) - "Whether SOURCE need updating or not." - (let ((len (string-width - (if (or (not (assoc 'no-matchplugin source)) - helm-match-plugin-mode) - ;; Don't count spaces entered when using - ;; match-plugin. - (replace-regexp-in-string " " "" helm-pattern) - helm-pattern)))) - (and (or (not helm-source-filter) - (member (assoc-default 'name source) helm-source-filter)) - (>= len - (helm-aif (assoc 'requires-pattern source) (or (cdr it) 1) 0)) - ;; These incomplete regexps hang helm forever - ;; so defer update. Maybe replace spaces quoted when using - ;; match-plugin-mode. - (not (member (replace-regexp-in-string "\\s\\ " " " helm-pattern) - helm-update-blacklist-regexps))))) - -(defun helm-delayed-source-p (source) - "Wheter SOURCE is a delayed source or not." - (or (assoc 'delayed source) - (and helm-quick-update - (< (window-height (get-buffer-window (current-buffer))) - (line-number-at-pos (point-max)))))) - -(defun helm-update-move-first-line (&optional without-hook) - "Goto first line of `helm-buffer'." - (goto-char (point-min)) - (unless without-hook - (save-excursion (helm-log-run-hook 'helm-update-hook))) - (helm-next-line)) - -(defun helm-force-update (&optional preselect) - "Force recalculation and update of candidates. -The difference with `helm-update' is this function is reevaling -the `init' and `update' attributes functions when present -before updating candidates according to pattern i.e calling `helm-update'. -Selection is preserved to current candidate or moved to PRESELECT -if specified." - (interactive) - (let ((source (helm-get-current-source)) - (selection (helm-get-selection nil t)) - ;; `helm-goto-source' need to have all sources displayed - ;; So disable `helm-quick-update'. - helm-quick-update) - (setq helm-force-updating-p t) - (when source - (mapc 'helm-force-update--reinit - (helm-get-sources))) - (helm-update (or preselect selection) source) - (with-helm-window (recenter)))) - -(defun helm-force-update--reinit (source) - "Reinit SOURCE by calling his update and/or init functions." - (helm-aif (helm-funcall-with-source - source 'helm-candidate-buffer) - (kill-buffer it)) - (cl-dolist (attr '(update init)) - (helm-aif (assoc-default attr source) - (helm-funcall-with-source source it))) - (helm-remove-candidate-cache source)) - -(defun helm-remove-candidate-cache (source) - "Remove SOURCE from `helm-candidate-cache'." - (remhash (assoc-default 'name source) helm-candidate-cache)) - -(defun helm-insert-match (match insert-function source &optional num) - "Insert MATCH into `helm-buffer' with INSERT-FUNCTION for SOURCE. -If MATCH is a list then insert the string intended to appear on the display -and store the real value in a text property." - (let ((start (point-at-bol (point))) - (dispvalue (or (car-safe match) match)) - (realvalue (cdr-safe match))) - (setq dispvalue - (cond ((symbolp dispvalue) (symbol-name dispvalue)) - ((numberp dispvalue) (number-to-string dispvalue)) - ((string= "" dispvalue)) - (t dispvalue))) - (when (stringp dispvalue) - (funcall insert-function dispvalue) - ;; Some sources with candidates-in-buffer have already added - ;; 'helm-realvalue property when creating candidate buffer. - (unless (get-text-property start 'helm-realvalue) - (and realvalue - (put-text-property start (point-at-eol) - 'helm-realvalue realvalue))) - (when num - (put-text-property start (point-at-eol) 'helm-cand-num num)) - (when helm-source-in-each-line-flag - (put-text-property start (point-at-eol) 'helm-source source)) - (funcall insert-function "\n")))) - -(defun helm-insert-header-from-source (source) - "Insert SOURCE name in `helm-buffer' header. -Maybe insert by overlay additional info after source name if SOURCE have -header-name attribute." - (let ((name (assoc-default 'name source))) - (helm-insert-header - name - (helm-aif (assoc-default 'header-name source) - (helm-funcall-with-source source it name))))) - -(defun helm-insert-header (name &optional display-string) - "Insert header of source NAME into the helm buffer. -If DISPLAY-STRING is non--nil and a string, display this additional info -after the source name by overlay." - (unless (bobp) - (let ((start (point))) - (insert "\n") - (put-text-property start (point) 'helm-header-separator t))) - (let ((start (point))) - (insert name) - (put-text-property (point-at-bol) - (point-at-eol) 'helm-header t) - (when display-string - (overlay-put (make-overlay (point-at-bol) (point-at-eol)) - 'display display-string)) - (insert "\n") - (put-text-property start (point) 'face 'helm-source-header))) - -(defun helm-insert-candidate-separator () - "Insert separator of candidates into the helm buffer." - (insert (propertize helm-candidate-separator 'face 'helm-separator)) - (put-text-property (point-at-bol) - (point-at-eol) 'helm-candidate-separator t) - (insert "\n")) - - -;;; Core: async process -;; -(defun helm-output-filter (process output-string) - "The `process-filter' function for helm async sources." - (helm-output-filter-1 (assoc process helm-async-processes) output-string)) - -(defun helm-output-filter-1 (process-assoc output-string) - (helm-log "output-string = %S" output-string) - (with-current-buffer helm-buffer - (let ((source (cdr process-assoc))) - (save-excursion - (helm-aif (assoc-default 'insertion-marker source) - (goto-char it) - (goto-char (point-max)) - (helm-insert-header-from-source source) - (setcdr process-assoc - (append source `((insertion-marker . ,(point-marker)))))) - (helm-output-filter--process-source - (car process-assoc) output-string source - (helm-candidate-number-limit source)))) - (helm-output-filter--post-process))) - -(defun helm-output-filter--process-source (process output-string source limit) - (cl-dolist (candidate (helm-transform-candidates - (helm-output-filter--collect-candidates - (split-string output-string "\n") - (assoc 'incomplete-line source) - source) - source t)) - (when candidate ; filter-one-by-one may return nil candidates. - (if (assq 'multiline source) - (let ((start (point))) - (helm-insert-candidate-separator) - (helm-insert-match candidate 'insert-before-markers source - (1+ (cdr (assoc 'item-count source)))) - (put-text-property start (point) 'helm-multiline t)) - (helm-insert-match candidate 'insert-before-markers source - (1+ (cdr (assoc 'item-count source))))) - (cl-incf (cdr (assoc 'item-count source))) - (when (>= (assoc-default 'item-count source) limit) - (helm-kill-async-process process) - (cl-return))))) - -(defun helm-output-filter--collect-candidates (lines incomplete-line-info source) - "Collect LINES maybe completing the truncated first and last lines." - ;; The output of process may come in chunks of any size, - ;; so the last line of LINES come truncated, this truncated line is - ;; stored in INCOMPLETE-LINE-INFO and will be concated with the first - ;; incomplete line of next chunk arriving. - ;; INCOMPLETE-LINE-INFO is an attribute of source which is created - ;; with an empty string when the source is computed => (incomplete-line . "") - (helm-log "incomplete-line-info = %S" (cdr incomplete-line-info)) - (butlast - (cl-loop for line in lines - ;; On start `incomplete-line-info' value is empty string. - for newline = (helm-aif (cdr incomplete-line-info) - (prog1 - (concat it line) - (setcdr incomplete-line-info nil)) - line) - do (helm--maybe-process-filter-one-by-one-candidate newline source) - collect newline - ;; Store last incomplete line (last chunk truncated) - ;; until new output arrives. - finally do (setcdr incomplete-line-info line)))) - -(defun helm-output-filter--post-process () - (let ((src (helm-get-current-source))) - (helm-log-run-hook 'helm-update-hook) - (helm-aif (get-buffer-window helm-buffer 'visible) - (with-selected-window it - (helm-skip-noncandidate-line 'next) - (helm-mark-current-line) - (helm-display-mode-line src) - (helm-log-run-hook 'helm-after-update-hook))))) - -(defun helm-process-deferred-sentinel-hook (process event file) - "Defer remote processes in sentinels. -Meant to be called at beginning of a sentinel process function." - (when (and (string= event "finished\n") - (or (file-remote-p file) - ;; `helm-suspend-update-flag' - ;; is non--nil here only during a - ;; running process, this will never be called - ;; when user set it explicitely with `C-!'. - helm-suspend-update-flag)) - (setq helm-suspend-update-flag t) - ;; Kill the process but don't delete entry in - ;; `helm-async-processes'. - (helm-kill-async-process process) - ;; When tramp tries to open the same connection twice in a - ;; short time frame (less than 5s) it throw 'suppress which - ;; call the real-handler on the main "Emacs", so we wait - ;; 5s before updating to avoid this [1], but allowing user to - ;; enter input during this delay. - ;; [1] On last Emacs versions, this is fixed and tramp return - ;; nil in this situation. - ;; Note: It is difficult to have a value < to 5 for - ;; `tramp-connection-min-time-diff', because the process die - ;; when calling too quickly same process. - (run-at-time (or (and (boundp 'tramp-connection-min-time-diff) - tramp-connection-min-time-diff) - 5) - nil #'(lambda () - (when helm-alive-p ; Don't run timer fn after quit. - (setq helm-suspend-update-flag nil) - (helm-check-minibuffer-input)))))) - -(defun helm-kill-async-processes () - "Kill all asynchronous processes registered in `helm-async-processes'." - (while helm-async-processes - (helm-kill-async-process (caar helm-async-processes)) - (setq helm-async-processes (cdr helm-async-processes)))) - -(defun helm-kill-async-process (process) - "Stop output from `helm-output-filter' and kill associated PROCESS." - (set-process-filter process nil) - (delete-process process)) - - -;;; Core: action -;; -(defun helm-execute-selection-action () - "Execute current action and kill the action buffer if present." - (helm-log-run-hook 'helm-before-action-hook) - ;; Position can be different when `helm-current-buffer' - ;; is splitted, so jump to this position before executing action. - (helm-current-position 'restore) - (unwind-protect - (helm-execute-selection-action-1) - (helm-aif (get-buffer helm-action-buffer) - (kill-buffer it)) - (helm-log-run-hook 'helm-after-action-hook))) - -(defun helm-execute-selection-action-1 (&optional - selection action - preserve-saved-action) - "Execute ACTION on current SELECTION. -If PRESERVE-SAVED-ACTION is non--nil save action." - (helm-log "executing action") - (setq action (helm-get-default-action - (or action - helm-saved-action - (if (get-buffer helm-action-buffer) - (helm-get-selection helm-action-buffer) - (helm-get-actions-from-current-source))))) - (let ((source (or helm-saved-current-source - (helm-get-current-source))) - non-essential) - (setq selection (or selection - (helm-get-selection) - (and (assoc 'accept-empty source) ""))) - (unless preserve-saved-action (setq helm-saved-action nil)) - (when (and selection action) - (helm-funcall-with-source - source action - (helm-coerce-selection selection source))))) - -(defun helm-coerce-selection (selection source) - "Apply coerce attribute function to SELECTION in SOURCE. -Coerce source with coerce function." - (helm-aif (assoc-default 'coerce source) - (helm-funcall-with-source source it selection) - selection)) - -(defun helm-get-default-action (action) - "Get the first ACTION value of action list in source." - (if (and (listp action) (not (functionp action))) - (cdar action) - action)) - -(defun helm-select-action () - "Select an action for the currently selected candidate. -If action buffer is selected, back to the helm buffer." - (interactive) - (helm-log-run-hook 'helm-select-action-hook) - (setq helm-saved-selection (helm-get-selection)) - (with-selected-frame (with-helm-window (selected-frame)) - (cond ((get-buffer-window helm-action-buffer 'visible) - (set-window-buffer (get-buffer-window helm-action-buffer) - helm-buffer) - (kill-buffer helm-action-buffer) - (helm-display-mode-line (helm-get-current-source)) - (helm-set-pattern helm-input 'noupdate)) - (helm-saved-selection - (setq helm-saved-current-source (helm-get-current-source)) - (let ((actions (helm-get-actions-from-current-source))) - (if (functionp actions) - (message "Sole action: %s" actions) - (helm-show-action-buffer actions) - (helm-delete-minibuffer-contents) - ;; Make `helm-pattern' differs from the previous value. - (setq helm-pattern 'dummy) - (helm-check-minibuffer-input)))) - (t (message "No Actions available"))))) - -(defun helm-show-action-buffer (actions) - (with-current-buffer (get-buffer-create helm-action-buffer) - (erase-buffer) - (buffer-disable-undo) - (set-window-buffer (get-buffer-window helm-buffer) helm-action-buffer) - (set (make-local-variable 'helm-sources) - `(((name . "Actions") - (volatile) - (nomark) - (candidates . ,actions) - (mode-line . ("Action(s)" "TAB:BackToCands RET/f1/f2/fn:NthAct")) - (candidate-transformer - . (lambda (candidates) - (cl-loop for (i . j) in candidates - for count from 1 - collect - (cons (concat (cond ((> count 12) - " ") - ((< count 10) - (format "[f%s] " count)) - (t (format "[f%s] " count))) - (propertize i 'face 'helm-action)) j)))) - (candidate-number-limit)))) - (set (make-local-variable 'helm-source-filter) nil) - (set (make-local-variable 'helm-selection-overlay) nil) - (helm-initialize-overlays helm-action-buffer))) - - -;; Core: selection - -(defun helm-display-source-at-screen-top-maybe (unit) - "Display source at top of screen when UNIT value is 'source. -With any other value of UNIT return nil." - (when (and helm-display-source-at-screen-top (eq unit 'source)) - (set-window-start (selected-window) - (save-excursion (forward-line -1) (point))))) - -(defun helm-skip-noncandidate-line (direction) - "Skip source header or candidates separator when going in DIRECTION. -Possible value of DIRECTION are 'next or 'previous. -Same as `helm-skip-header-and-separator-line' but ensure -point is moved to the right place when at bop or eob." - (helm-skip-header-and-separator-line direction) - (and (bobp) (forward-line 1)) ; Skip first header. - (and (eobp) (forward-line -1))) ; Avoid last empty line. - -(defun helm-skip-header-and-separator-line (direction) - "Skip source header or candidate separator when going to next/previous line. -Possible value of DIRECTION are 'next or 'previous." - (let ((fn (cl-ecase direction - (next 'eobp) - (previous 'bobp)))) - (while (and (not (funcall fn)) - (or (helm-pos-header-line-p) - (helm-pos-candidate-separator-p))) - (forward-line (if (and (eq direction 'previous) - (not (eq (point-at-bol) (point-min)))) - -1 1))))) - -(defun helm-display-mode-line (source &optional force) - "Setup mode-line and header-line for `helm-buffer'." - (set (make-local-variable 'helm-mode-line-string) - (helm-interpret-value (or (and (listp source) ; Check if source is empty. - (assoc-default 'mode-line source)) - (default-value 'helm-mode-line-string)) - source)) - (let ((follow (and (eq (cdr (assq 'follow source)) 1) "(HF) "))) - ;; Setup mode-line. - (if helm-mode-line-string - (setq mode-line-format - `(" " mode-line-buffer-identification " " - (:eval (format "L%d" (helm-candidate-number-at-point))) - " " ,follow - (:eval (when ,helm--mode-line-display-prefarg - (let ((arg (prefix-numeric-value - (or prefix-arg current-prefix-arg)))) - (unless (= arg 1) - (propertize (format "[prefarg:%s] " arg) - 'face 'helm-prefarg))))) - (:eval (helm-show-candidate-number - (car-safe helm-mode-line-string))) - " " helm--mode-line-string-real " -%-") - helm--mode-line-string-real - (substitute-command-keys (if (listp helm-mode-line-string) - (cadr helm-mode-line-string) - helm-mode-line-string))) - (setq mode-line-format (default-value 'mode-line-format))) - ;; Setup header-line. - (let* ((hlstr (helm-interpret-value - (and (listp source) - (assoc-default 'header-line source)) - source)) - (hlend (make-string (max 0 (- (window-width) (length hlstr))) ? ))) - (setq header-line-format - (propertize (concat " " hlstr hlend) 'face 'helm-header)))) - (when force (force-mode-line-update))) - -(defun helm-show-candidate-number (&optional name) - "Used to display candidate number in mode-line. -You can specify NAME of candidates e.g \"Buffers\" otherwise -it is \"Candidate\(s\)\" by default." - (when helm-alive-p - (unless (helm-empty-source-p) - (propertize - (format "[%s %s]" - (helm-get-candidate-number 'in-current-source) - (or name "Candidate(s)")) - 'face 'helm-candidate-number)))) - -(cl-defun helm-move-selection-common (&key where direction) - "Move the selection marker to a new position. -Position is determined by WHERE and DIRECTION. -Key arg WHERE can be one of: - - line - - page - - edge - - source -Key arg DIRECTION can be one of: - - previous - - next - - A source or a source name when used with :WHERE 'source." - (let ((move-func (cl-case where - (line (cl-ecase direction - (previous 'helm-move--previous-line-fn) - (next 'helm-move--next-line-fn))) - (page (cl-ecase direction - (previous 'helm-move--previous-page-fn) - (next 'helm-move--next-page-fn))) - (edge (cl-ecase direction - (previous 'helm-move--beginning-of-buffer-fn) - (next 'helm-move--end-of-buffer-fn))) - (source (cl-case direction - (previous 'helm-move--previous-source-fn) - (next 'helm-move--next-source-fn) - (t (lambda () ; A source is passed as DIRECTION arg. - (helm-move--goto-source-fn direction)))))))) - (unless (or (helm-empty-buffer-p (helm-buffer-get)) - (not (helm-window))) - (with-helm-window - (helm-log-run-hook 'helm-move-selection-before-hook) - (funcall move-func) - (and (memq direction '(next previous)) - (helm-skip-noncandidate-line direction)) - (when (helm-pos-multiline-p) - (helm-move--beginning-of-multiline-candidate)) - (helm-display-source-at-screen-top-maybe where) - (when (helm-get-previous-header-pos) - (helm-mark-current-line)) - (helm-display-mode-line (helm-get-current-source)) - (helm-log-run-hook 'helm-move-selection-after-hook))))) - -(defun helm-move--beginning-of-multiline-candidate () - (let ((header-pos (helm-get-previous-header-pos)) - (separator-pos (helm-get-previous-candidate-separator-pos))) - (when header-pos - (goto-char (if (or (null separator-pos) - (< separator-pos header-pos)) - header-pos - separator-pos)) - (forward-line 1)))) - -(defun helm-move--previous-multi-line-fn () - (forward-line -1) - (unless (helm-pos-header-line-p) - (helm-skip-header-and-separator-line 'previous) - (helm-move--beginning-of-multiline-candidate))) - -(defun helm-move--previous-line-fn () - (if (not (helm-pos-multiline-p)) - (forward-line -1) - (helm-move--previous-multi-line-fn)) - (when (and helm-move-to-line-cycle-in-source - (helm-pos-header-line-p)) - (forward-line 1) - (helm-move--end-of-source) - ;; We are at end of helm-buffer - ;; check if last candidate is a multiline candidate - ;; and jump to it - (when (and (eobp) - (save-excursion (forward-line -1) (helm-pos-multiline-p))) - (helm-move--previous-multi-line-fn)))) - -(defun helm-move--next-multi-line-fn () - (let ((header-pos (helm-get-next-header-pos)) - (separator-pos (helm-get-next-candidate-separator-pos))) - (cond ((and separator-pos - (or (null header-pos) (< separator-pos header-pos))) - (goto-char separator-pos)) - (header-pos - (goto-char header-pos))))) - -(defun helm-move--next-line-fn () - (if (not (helm-pos-multiline-p)) - (forward-line 1) - (helm-move--next-multi-line-fn)) - (when (and helm-move-to-line-cycle-in-source - (or (save-excursion (and (helm-pos-multiline-p) - (goto-char (overlay-end - helm-selection-overlay)) - (helm-end-of-source-p t))) - (helm-end-of-source-p t))) - (helm-move--beginning-of-source))) - -(defun helm-move--previous-page-fn () - (condition-case nil - (scroll-down) - (beginning-of-buffer (goto-char (point-min))))) - -(defun helm-move--next-page-fn () - (condition-case nil - (scroll-up) - (end-of-buffer (goto-char (point-max))))) - -(defun helm-move--beginning-of-buffer-fn () - (goto-char (point-min))) - -(defun helm-move--end-of-buffer-fn () - (goto-char (point-max))) - -(defun helm-move--end-of-source () - (goto-char (or (helm-get-next-header-pos) (point-max))) - (when (helm-pos-header-line-p) (forward-line -2))) - -(defun helm-move--beginning-of-source () - (goto-char (helm-get-previous-header-pos)) - (forward-line 1)) - -(defun helm-move--previous-source-fn () - (forward-line -1) - (if (bobp) - (goto-char (point-max)) - (helm-skip-header-and-separator-line 'previous)) - (goto-char (helm-get-previous-header-pos)) - (forward-line 1)) - -(defun helm-move--next-source-fn () - (goto-char (or (helm-get-next-header-pos) (point-min)))) - -(defun helm-move--goto-source-fn (source-or-name) - (goto-char (point-min)) - (let ((name (if (stringp source-or-name) source-or-name - (assoc-default 'name source-or-name)))) - (condition-case err - (while (not (string= name (helm-current-line-contents))) - (goto-char (helm-get-next-header-pos))) - (error (helm-log "%S" err))))) - -(defun helm-candidate-number-at-point () - (with-helm-buffer - (or (get-text-property (point) 'helm-cand-num) 1))) - -(defun helm--next-or-previous-line (direction &optional arg) - ;; Be sure to not use this in non--interactives calls. - (let ((helm-move-to-line-cycle-in-source - (and helm-move-to-line-cycle-in-source arg))) - (if (and arg (> arg 1)) - (cl-loop with pos = (helm-candidate-number-at-point) - with cand-num = (helm-get-candidate-number t) - with iter = (min arg (- cand-num pos)) - for count from 1 - while (<= count iter) - do - (helm-move-selection-common :where 'line :direction direction)) - (helm-move-selection-common :where 'line :direction direction)))) - -(defun helm-previous-line (&optional arg) - "Move selection to the ARG previous line(s). -Same behavior than `helm-next-line' when called with a numeric prefix arg." - (interactive "p") - (helm--next-or-previous-line 'previous arg)) - -(defun helm-next-line (&optional arg) - "Move selection to the next ARG line(s). -When a numeric prefix arg is given and this numeric arg -is > to the number of candidates, move to last candidate of -current source (i.e don't move to next source if some)." - (interactive "p") - (helm--next-or-previous-line 'next arg)) - -(defun helm-previous-page () - "Move selection back with a pageful." - (interactive) - (helm-move-selection-common :where 'page :direction 'previous)) - -(defun helm-next-page () - "Move selection forward with a pageful." - (interactive) - (helm-move-selection-common :where 'page :direction 'next)) - -(defun helm-beginning-of-buffer () - "Move selection at the top." - (interactive) - (helm-move-selection-common :where 'edge :direction 'previous)) - -(defun helm-end-of-buffer () - "Move selection at the bottom." - (interactive) - (helm-move-selection-common :where 'edge :direction 'next)) - -(defun helm-previous-source () - "Move selection to the previous source." - (interactive) - (helm-move-selection-common :where 'source :direction 'previous)) - -(defun helm-next-source () - "Move selection to the next source." - (interactive) - (helm-move-selection-common :where 'source :direction 'next)) - -(defun helm-goto-source (source-or-name) - "Move the selection to the source SOURCE-OR-NAME." - (helm-move-selection-common :where 'source :direction source-or-name)) - -(defun helm--follow-action (arg) - (let ((helm--temp-follow-flag t)) - (when (or (eq last-command 'helm-follow-action-forward) - (eq last-command 'helm-follow-action-backward) - (eq last-command 'helm-execute-persistent-action)) - (if (> arg 0) - (helm-next-line) - (helm-previous-line))) - (helm-execute-persistent-action))) - -(defun helm-follow-action-forward () - "Go to next line and execute persistent action." - (interactive) - (helm--follow-action 1)) - -(defun helm-follow-action-backward () - "Go to previous line and execute persistent action." - (interactive) - (helm--follow-action -1)) - -(defun helm-mark-current-line (&optional resumep) - "Move `helm-selection-overlay' to current line. -Note that this is not related with visibles marks, which are used -to mark candidates." - (with-helm-window - (when resumep - (goto-char helm-selection-point)) - (move-overlay - helm-selection-overlay (point-at-bol) - (if (helm-pos-multiline-p) - (let ((header-pos (helm-get-next-header-pos)) - (separator-pos (helm-get-next-candidate-separator-pos))) - (or (and (null header-pos) separator-pos) - (and header-pos separator-pos - (< separator-pos header-pos) - separator-pos) - header-pos - (point-max))) - (1+ (point-at-eol)))) - (setq helm-selection-point (overlay-start helm-selection-overlay))) - (helm-follow-execute-persistent-action-maybe)) - -(defun helm-confirm-and-exit-minibuffer () - "Maybe ask for confirmation when exiting helm. -It is similar to `minibuffer-complete-and-exit' adapted to helm. -If `minibuffer-completion-confirm' value is 'confirm, -send in minibuffer confirm message and exit on next hit. -If `minibuffer-completion-confirm' value is t, -don't exit and send message 'no match'." - (interactive) - (if (and (helm--updating-p) - (null helm--reading-passwd-or-string)) - (progn (message "[Display not ready]") - (sit-for 0.5) (message nil)) - (let* ((empty-buffer-p (with-current-buffer helm-buffer - (eq (point-min) (point-max)))) - (unknown (and (not empty-buffer-p) - (string= (get-text-property - 0 'display (helm-get-selection nil 'withprop)) - "[?]")))) - (cond ((and (or empty-buffer-p unknown) - (eq minibuffer-completion-confirm 'confirm)) - (setq helm-minibuffer-confirm-state - 'confirm) - (setq minibuffer-completion-confirm nil) - (minibuffer-message " [confirm]")) - ((and (or empty-buffer-p unknown) - (eq minibuffer-completion-confirm t)) - (minibuffer-message " [No match]")) - (t - (setq helm-minibuffer-confirm-state nil) - (helm-exit-minibuffer)))))) -(add-hook 'helm-after-update-hook 'helm-confirm-and-exit-hook) - -(defun helm-confirm-and-exit-hook () - "Restore `minibuffer-completion-confirm' when helm update." - (unless (or (eq minibuffer-completion-confirm t) - (not helm-minibuffer-confirm-state)) - (setq minibuffer-completion-confirm - helm-minibuffer-confirm-state))) - -(defun helm-read-string (prompt &optional initial-input history - default-value inherit-input-method) - "Same as `read-string' but for reading string from a helm session." - (let ((helm--reading-passwd-or-string t)) - (read-string - prompt initial-input history default-value inherit-input-method))) - -(defun helm--updating-p () - ;; helm timer is between two cycles. - ;; IOW `helm-check-minibuffer-input' haven't yet compared input - ;; and `helm-pattern'. - (or (not (equal (minibuffer-contents) helm-pattern)) - ;; `helm-check-minibuffer-input' have launched `helm-update'. - helm--in-update)) - -(defun helm-maybe-exit-minibuffer () - (interactive) - (if (and (helm--updating-p) - (null helm--reading-passwd-or-string)) - (progn (message "[Display not ready]") - (sit-for 0.5) (message nil)) - (helm-exit-minibuffer))) - -(defun helm-exit-minibuffer () - "Select the current candidate by exiting the minibuffer." - (unless helm-current-prefix-arg - (setq helm-current-prefix-arg current-prefix-arg)) - (setq helm-exit-status 0) - (helm-log-run-hook 'helm-exit-minibuffer-hook) - (exit-minibuffer)) - -(defun helm-keyboard-quit () - "Quit minibuffer in helm. -If action buffer is displayed, kill it." - (interactive) - (when (get-buffer-window helm-action-buffer 'visible) - (kill-buffer helm-action-buffer)) - (setq helm-exit-status 1) - (abort-recursive-edit)) - -(defun helm-get-next-header-pos () - "Return the position of the next header from point." - (next-single-property-change (point) 'helm-header)) - -(defun helm-get-previous-header-pos () - "Return the position of the previous header from point." - (previous-single-property-change (point) 'helm-header)) - -(defun helm-pos-multiline-p () - "Return non-nil if the current position is in the multiline source region." - (get-text-property (point) 'helm-multiline)) - -(defun helm-get-next-candidate-separator-pos () - "Return the position of the next candidate separator from point." - (let ((hp (helm-get-next-header-pos))) - (helm-aif (next-single-property-change (point) 'helm-candidate-separator) - (or - ;; Be sure we don't catch - ;; the separator of next source. - (and hp (< it hp) it) - ;; The separator found is in next source - ;; we are at last cand, so use the header pos. - (and hp (< hp it) hp) - ;; A single source, just try next separator. - it)))) - -(defun helm-get-previous-candidate-separator-pos () - "Return the position of the previous candidate separator from point." - (previous-single-property-change (point) 'helm-candidate-separator)) - -(defun helm-pos-header-line-p () - "Return t if the current line is a header line." - (or (get-text-property (point-at-bol) 'helm-header) - (get-text-property (point-at-bol) 'helm-header-separator))) - -(defun helm-pos-candidate-separator-p () - "Return t if the current line is a candidate separator." - (get-text-property (point-at-bol) 'helm-candidate-separator)) - - -;;; Debugging -;; -;; -(defun helm-debug-output () - "Show all helm-related variables at this time." - (interactive) - (helm-help-internal " *Helm Debug*" 'helm-debug-output-function)) - -(defun helm-debug-output-function (&optional vars) - (message "Calculating all helm-related values...") - (insert "If you debug some variables or forms, set `helm-debug-variables' -to a list of forms.\n\n") - (cl-dolist (v (or vars - helm-debug-variables - (apropos-internal "^helm-" 'boundp))) - (insert "** " - (pp-to-string v) "\n" - (pp-to-string (with-current-buffer helm-buffer (eval v))) "\n")) - (message "Calculating all helm-related values...Done")) - - -;; Core: misc -(defun helm-kill-buffer-hook () - "Remove tick entry from `helm-tick-hash' when killing a buffer." - (cl-loop for key being the hash-keys in helm-tick-hash - if (string-match (format "^%s/" (regexp-quote (buffer-name))) key) - do (remhash key helm-tick-hash))) -(add-hook 'kill-buffer-hook 'helm-kill-buffer-hook) - -(defun helm-preselect (candidate-or-regexp &optional source) - "Move `helm-selection-overlay' to CANDIDATE-OR-REGEXP on startup." - (with-helm-window - (when candidate-or-regexp - (if helm-force-updating-p - (and source (helm-goto-source source)) - (goto-char (point-min)) - (forward-line 1)) - (let ((start (point))) - (or (re-search-forward candidate-or-regexp nil t) - (goto-char start)))) - (forward-line 0) ; Avoid scrolling right on long lines. - (when (helm-pos-multiline-p) - (helm-move--beginning-of-multiline-candidate)) - (helm-mark-current-line))) - -(defun helm-delete-current-selection () - "Delete the currently selected item." - (interactive) - (with-helm-window - (cond ((helm-pos-multiline-p) - (helm-aif (helm-get-next-candidate-separator-pos) - (delete-region (point-at-bol) - (1+ (progn (goto-char it) (point-at-eol)))) - ;; last candidate - (goto-char (helm-get-previous-candidate-separator-pos)) - (delete-region (point-at-bol) (point-max))) - (when (helm-end-of-source-p) - (goto-char (or (helm-get-previous-candidate-separator-pos) - (point-min))) - (forward-line 1))) - (t - (delete-region (point-at-bol) (1+ (point-at-eol))) - (when (helm-end-of-source-p t) - (let ((headp (save-excursion - (forward-line -1) - (not (helm-pos-header-line-p))))) - (and headp (forward-line -1)))))) - (unless (helm-end-of-source-p t) - (helm-mark-current-line)))) - -(defun helm-end-of-source-p (&optional at-point) - "Return non--nil if we are at eob or end of source." - (save-excursion - (if (and (helm-pos-multiline-p) (null at-point)) - (null (helm-get-next-candidate-separator-pos)) - (forward-line (if at-point 0 1)) - (or (eq (point-at-bol) (point-at-eol)) - (helm-pos-header-line-p) - (eobp))))) - -(defun helm-edit-current-selection-internal (func) - (with-helm-window - (forward-line 0) - (let ((realvalue (get-text-property (point) 'helm-realvalue)) - (multiline (get-text-property (point) 'helm-multiline))) - (funcall func) - (forward-line 0) - (and realvalue - (put-text-property (point) (point-at-eol) - 'helm-realvalue realvalue)) - (and multiline - (put-text-property (point) (point-at-eol) - 'helm-multiline multiline)) - (helm-mark-current-line)))) - -(defmacro helm-edit-current-selection (&rest forms) - "Evaluate FORMS at current selection in the helm buffer. -Used generally to modify current selection." - (declare (indent 0) (debug t)) - `(helm-edit-current-selection-internal - (lambda () ,@forms))) - -(defun helm-set-pattern (pattern &optional noupdate) - "Set minibuffer contents to PATTERN. -if optional NOUPDATE is non-nil, helm buffer is not changed." - (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) - (delete-minibuffer-contents) - (insert pattern)) - (when noupdate - (setq helm-pattern pattern))) - -(defun helm-minibuffer-completion-contents () - "Return the user input in a minibuffer before point as a string. -That is what completion commands operate on." - (buffer-substring (field-beginning) (point))) - -(defun helm-delete-minibuffer-contents (&optional arg) - "Delete minibuffer contents. -When called with a prefix arg or when -`helm-delete-minibuffer-contents-from-point' is non--nil, -delete minibuffer contents from point instead of deleting all." - (interactive "P") - (require 'helm-utils) - (let* ((input (minibuffer-contents)) - (str (if (or arg helm-delete-minibuffer-contents-from-point) - (helm-minibuffer-completion-contents) ""))) - (helm-reset-yank-point) - (if (> (length input) 0) - ;; minibuffer is not empty, delete contents and update. - (helm-set-pattern str) - ;; minibuffer is already empty, force update. - (helm-force-update)))) - - -;;; Plugins -;; -;; Built-in plug-in: type -(defun helm-compile-source--type (source) - (helm-aif (assoc-default 'type source) - (append source (assoc-default it helm-type-attributes) nil) - source)) - -;; `define-helm-type-attribute' is public API. - -(defun helm-add-type-attribute (type definition) - (helm-aif (assq type helm-type-attributes) - (setq helm-type-attributes (delete it helm-type-attributes))) - (push (cons type definition) helm-type-attributes)) - -(defun helm-document-type-attribute (type doc) - (add-to-list 'helm-types type t) - (put type 'helm-typeattrdoc - (concat "- " (symbol-name type) "\n\n" doc "\n"))) - -;; Built-in plug-in: dummy -(defun helm-dummy-candidate (_candidate _source) - "Use `helm-pattern' as CANDIDATE in SOURCE." - ;; `source' is defined in filtered-candidate-transformer - (list helm-pattern)) - -(defun helm-compile-source--dummy (source) - (if (assoc 'dummy source) - (progn - (unless (helm-attr-defined - 'filtered-candidate-transformer source) - (helm-attrset 'filtered-candidate-transformer - 'helm-dummy-candidate source)) - (append source - '((candidates "dummy") - (accept-empty) - (match identity) - (volatile)))) - source)) - -;; Built-in plug-in: candidates-in-buffer -(defun helm-candidates-in-buffer (&optional source) - "Get candidates from the candidates buffer according to `helm-pattern'. - -BUFFER is `helm-candidate-buffer' by default. Each -candidate must be placed in one line. This function is meant to -be used in candidates-in-buffer or candidates attribute of an -helm source. Especially fast for many (1000+) candidates. - -eg. - '((name . \"many files\") - (init . (lambda () (with-current-buffer (helm-candidate-buffer 'local) - (insert-many-filenames)))) - (search re-search-forward) ; optional - (candidates-in-buffer) - (type . file)) - -+===============================================================+ -| The new way of making and narrowing candidates: Using buffers | -+===============================================================+ - -By default, `helm' makes candidates by evaluating the -candidates function, then narrows them by `string-match' for each -candidate. - -But this way is very slow for many candidates. The new way is -storing all candidates in a buffer and narrowing them by -`re-search-forward'. Search function is customizable by search -attribute. The important point is that buffer processing is MUCH -FASTER than string list processing and is the Emacs way. - -The init function writes all candidates to a newly-created -candidate buffer. The candidates buffer is created or specified -by `helm-candidate-buffer'. Candidates are stored in a line. - -The candidates function narrows all candidates, IOW creates a -subset of candidates dynamically. It is the task of -`helm-candidates-in-buffer'. As long as -`helm-candidate-buffer' is used,`(candidates-in-buffer)' is -sufficient in most cases. - -Note that `(candidates-in-buffer)' is shortcut of three attributes: - (candidates . helm-candidates-in-buffer) - (volatile) - (match identity) -And `(candidates-in-buffer . func)' is shortcut of three attributes: - (candidates . func) - (volatile) - (match identity) -The expansion is performed in `helm-get-sources'. - -The candidates-in-buffer attribute implies the volatile attribute. -The volatile attribute is needed because `helm-candidates-in-buffer' -creates candidates dynamically and need to be called everytime -`helm-pattern' changes. - -Because `helm-candidates-in-buffer' plays the role of `match' attribute -function, specifying `(match identity)' makes the source slightly faster. - -However if source contain match-part attribute, match is computed only -on part of candidate returned by the call of function provided by this attribute. -The function should have one arg, candidate, and return only -a specific part of candidate. - -To customize `helm-candidates-in-buffer' behavior, use `search', -`get-line', `match-part' and `search-from-end' attributes." - (let ((src (or source (helm-get-current-source)))) - (helm-candidates-in-buffer-1 - (helm-candidate-buffer) - helm-pattern - (or (assoc-default 'get-line src) - #'buffer-substring-no-properties) - (or (assoc-default 'search src) - (if (assoc 'search-from-end src) - '(helm-candidates-in-buffer-search-from-end) - '(helm-candidates-in-buffer-search-from-start))) - (helm-candidate-number-limit src) - (assoc 'search-from-end src) - (helm-attr 'match-part) - src))) - -(defun helm-candidates-in-buffer-search-from-start (pattern) - "Search PATTERN with `re-search-forward' with bound and noerror args." - (re-search-forward pattern nil t)) - -(defun helm-candidates-in-buffer-search-from-end (pattern) - "Search PATTERN with `re-search-backward' with bound and noerror args." - (re-search-backward pattern nil t)) - -(defun helm-candidates-in-buffer-1 (buffer pattern get-line-fn - search-fns limit search-from-end - match-part-fn source) - "Return the list of candidates inserted in BUFFER matching PATTERN." - ;; buffer == nil when candidates buffer does not exist. - (when buffer - (with-current-buffer buffer - (let ((start-point (if search-from-end - (1+ (point-max)) (1- (point-min)))) - (endp (if search-from-end #'bobp #'eobp)) - (inhibit-point-motion-hooks t)) - (goto-char start-point) - (if (string= pattern "") - (helm-initial-candidates-from-candidate-buffer - endp get-line-fn limit search-from-end) - (helm-search-from-candidate-buffer - pattern get-line-fn search-fns limit search-from-end - start-point match-part-fn source)))))) - -(defun helm-point-is-moved (proc) - "If point is moved after executing PROC, return t, otherwise nil." - (/= (point) (save-excursion (funcall proc) (point)))) - -(defun helm-search-from-candidate-buffer (pattern get-line-fn search-fns - limit search-from-end - start-point match-part-fn source) - (let (buffer-read-only - matches - newmatches - (case-fold-search (helm-set-case-fold-search))) - (helm-search-from-candidate-buffer-internal - (lambda () - (clrhash helm-cib-hash) - (cl-dolist (searcher search-fns) - (goto-char start-point) - (setq newmatches nil) - (cl-loop with item-count = 0 - while (funcall searcher pattern) - for cand = (funcall get-line-fn (point-at-bol) (point-at-eol)) - when (and (not (gethash cand helm-cib-hash)) - (or - ;; Always collect when cand is matched by searcher funcs - ;; and match-part attr is not present. - (not match-part-fn) - ;; If match-part attr is present, collect only if PATTERN - ;; match the part of CAND specified by the match-part func. - (helm-search-match-part cand pattern match-part-fn))) - do (helm--accumulate-candidates - cand newmatches helm-cib-hash item-count limit source) - unless (helm-point-is-moved - (lambda () - (if search-from-end - (goto-char (1- (point-at-bol))) - (forward-line 1)))) - return nil) - (setq matches (append matches (nreverse newmatches)))) - (delq nil matches))))) - -(defun helm-search-match-part (candidate pattern match-part-fn) - "Match PATTERN only on part of CANDIDATE returned by MATCH-PART-FN." - (let ((part (funcall match-part-fn candidate))) - (if (string-match " " pattern) - (cl-loop for i in (split-string pattern " " t) - always (string-match i part)) - (string-match pattern part)))) - -(defun helm-initial-candidates-from-candidate-buffer (endp - get-line-fn - limit search-from-end) - (delq nil (cl-loop with next-line-fn = - (if search-from-end - (lambda (_x) (goto-char (max (1- (point-at-bol)) 1))) - #'forward-line) - until (funcall endp) - for i from 1 to limit - collect (funcall get-line-fn (point-at-bol) (point-at-eol)) - do (funcall next-line-fn 1)))) - -(defun helm-search-from-candidate-buffer-internal (search-fn) - (goto-char (point-min)) - (insert "\n") - (goto-char (point-max)) - (insert "\n") - (unwind-protect - (funcall search-fn) - (goto-char (point-min)) - (delete-char 1) - (goto-char (1- (point-max))) - (delete-char 1) - (set-buffer-modified-p nil))) - -(defun helm-candidate-buffer (&optional create-or-buffer) - "Register and return a buffer containing candidates of current source. -`helm-candidate-buffer' searches buffer-local candidates buffer first, -then global candidates buffer. - -Acceptable values of CREATE-OR-BUFFER: - -- nil (omit) - Only return the candidates buffer. -- a buffer - Register a buffer as a candidates buffer. -- 'global - Create a new global candidates buffer, - named \" *helm candidates:SOURCE*\". -- other non-nil value - Create a new local candidates buffer, - named \" *helm candidates:SOURCE*HELM-CURRENT-BUFFER\"." - (let* ((global-bname (format " *helm candidates:%s*" - helm-source-name)) - (local-bname (format " *helm candidates:%s*%s" - helm-source-name - (buffer-name helm-current-buffer))) - (register-func #'(lambda () - (setq helm-candidate-buffer-alist - (cons (cons helm-source-name create-or-buffer) - (delete (assoc helm-source-name - helm-candidate-buffer-alist) - helm-candidate-buffer-alist))))) - (kill-buffers-func #'(lambda () - (cl-loop for b in (buffer-list) - if (string-match (format "^%s" (regexp-quote global-bname)) - (buffer-name b)) - do (kill-buffer b)))) - (create-func #'(lambda () - (with-current-buffer - (get-buffer-create (if (eq create-or-buffer 'global) - global-bname - local-bname)) - (buffer-disable-undo) - (erase-buffer) - (font-lock-mode -1)))) - (return-func #'(lambda () - (or (get-buffer local-bname) - (get-buffer global-bname) - (helm-aif (assoc-default helm-source-name - helm-candidate-buffer-alist) - (and (buffer-live-p it) it)))))) - (when create-or-buffer - (funcall register-func) - (unless (bufferp create-or-buffer) - (and (eq create-or-buffer 'global) (funcall kill-buffers-func)) - (funcall create-func))) - (funcall return-func))) - -(defun helm-init-candidates-in-buffer (buffer data) - "Register BUFFER with DATA for a helm candidates-in-buffer session. -Arg BUFFER can be a string, a buffer object (bufferp), or a symbol, -either 'local or 'global which is passed to `helm-candidate-buffer'. -Arg DATA can be either a list or a plain string. -Returns the resulting buffer." - (declare (indent 1)) - (let ((buf (helm-candidate-buffer - (if (or (stringp buffer) - (bufferp buffer)) - (get-buffer-create buffer) - buffer)))) ; a symbol. - (with-current-buffer buf - (erase-buffer) - (if (listp data) - (cl-loop for i in data - for str = (if (symbolp i) (symbol-name i) i) - do (insert (concat str "\n"))) - (and (stringp data) (insert data)))) - buf)) - -(defun helm-compile-source--candidates-in-buffer (source) - (helm-aif (assoc 'candidates-in-buffer source) - (append source - `((candidates . ,(or (cdr it) - (lambda () - (helm-candidates-in-buffer source)))) - (volatile) (match identity))) - source)) - - -;;; Resplit helm window -;; -;; -(defun helm-toggle-resplit-window () - "Toggle resplit helm window, vertically or horizontally." - (interactive) - (when helm-prevent-escaping-from-minibuffer - (helm-prevent-switching-other-window :enabled nil)) - (unwind-protect - (with-helm-window - (if (or helm-full-frame (one-window-p t)) - (message "Error: Attempt to resplit a single window") - (let ((before-height (window-height))) - (delete-window) - (set-window-buffer - (select-window - (if (= (window-height) before-height) ; initial split was horizontal. - ;; Split window vertically with `helm-buffer' placed - ;; on the good side according to actual value of - ;; `helm-split-window-default-side'. - (prog1 - (cond ((or (eq helm-split-window-default-side 'above) - (eq helm-split-window-default-side 'left)) - (split-window - (selected-window) nil 'above)) - (t (split-window-vertically))) - (setq helm-split-window-state 'vertical)) - ;; Split window vertically, same comment as above. - (setq helm-split-window-state 'horizontal) - (cond ((or (eq helm-split-window-default-side 'left) - (eq helm-split-window-default-side 'above)) - (split-window (selected-window) nil 'left)) - (t (split-window-horizontally))))) - helm-buffer))) - (setq helm--window-side-state (helm--get-window-side-state))) - (when helm-prevent-escaping-from-minibuffer - (helm-prevent-switching-other-window :enabled t)))) - -;; Utility: Resize helm window. -(defun helm-enlarge-window-1 (n) - "Enlarge or narrow helm window. -If N is positive enlarge, if negative narrow." - (unless helm-full-frame - (let ((horizontal-p (eq helm-split-window-state 'horizontal))) - (with-helm-window - (enlarge-window n horizontal-p))))) - -(defun helm-narrow-window () - "Narrow helm window." - (interactive) - (helm-enlarge-window-1 -1)) - -(defun helm-enlarge-window () - "Enlarge helm window." - (interactive) - (helm-enlarge-window-1 1)) - -(defun helm-swap-windows () - "Swap window holding `helm-buffer' with other window." - (interactive) - (if (and helm-full-frame (one-window-p t)) - (error "Error: Can't swap windows in a single window") - (let* ((w1 (helm-window)) - (split-state (eq helm-split-window-state 'horizontal)) - (w1size (window-total-size w1 split-state)) - (b1 (window-buffer w1)) ; helm-buffer - (s1 (window-start w1)) - (cur-frame (window-frame w1)) - (w2 (with-selected-window (helm-window) - ;; Don't try to display helm-buffer - ;; in a dedicated window. - (get-window-with-predicate - (lambda (w) (not (window-dedicated-p w))) - 1 cur-frame))) - (w2size (window-total-size w2 split-state)) - (b2 (window-buffer w2)) ; probably helm-current-buffer - (s2 (window-start w2)) - resize) - (with-selected-frame (window-frame w1) - (helm-replace-buffer-in-window w1 b1 b2) - (helm-replace-buffer-in-window w2 b2 b1) - (setq resize - (cond ( ;; helm-window is smaller than other window. - (< w1size w2size) - (- (- (max w2size w1size) - (min w2size w1size)))) - ( ;; helm-window is larger than other window. - (> w1size w2size) - (- (max w2size w1size) - (min w2size w1size))) - ( ;; windows have probably same size. - t nil))) - ;; Maybe resize the window holding helm-buffer. - (and resize (window-resize w2 resize split-state)) - (set-window-start w1 s2 t) - (set-window-start w2 s1 t)) - (setq helm--window-side-state (helm--get-window-side-state))))) - -(defun helm--get-window-side-state () - "Return the position of `helm-window' from `helm-current-buffer'. -Possible values are 'left 'right 'below or 'above." - (let ((side-list '(left right below above))) - (cl-loop for side in side-list - thereis (and (equal (helm-window) - (window-in-direction - side (get-buffer-window helm-current-buffer t) - t)) - side)))) - -(defun helm-replace-buffer-in-window (window buffer1 buffer2) - "Replace BUFFER1 by BUFFER2 in WINDOW registering BUFFER1." - (when (get-buffer-window buffer1) - (unrecord-window-buffer window buffer1) - (set-window-buffer window buffer2))) - -;; Utility: select another action by key -(defun helm-select-nth-action (n) - "Select the N nth action for the currently selected candidate." - (setq helm-saved-selection (helm-get-selection)) - (unless helm-saved-selection - (error "Nothing is selected")) - (setq helm-saved-action - (helm-get-nth-action - n - (if (get-buffer-window helm-action-buffer 'visible) - (assoc-default 'candidates (helm-get-current-source)) - (helm-get-actions-from-current-source)))) - (helm-maybe-exit-minibuffer)) - -(defun helm-get-nth-action (n action) - (cond ((and (zerop n) (functionp action)) - action) - ((listp action) - (or (cdr (elt action n)) - (error "No such action"))) - ((and (functionp action) (< 0 n)) - (error "Sole action")) - (t - (error "Error in `helm-select-nth-action'")))) - -;; Utility: Persistent Action -(defmacro with-helm-display-same-window (&rest body) - "Execute BODY in the window used for persistent action. -Make `pop-to-buffer' and `display-buffer' display in the same window." - (declare (indent 0) (debug t)) - `(let ((display-buffer-function 'helm-persistent-action-display-buffer)) - ,@body)) - -(defun helm-initialize-persistent-action () - (set (make-local-variable 'helm-persistent-action-display-window) nil)) - -(cl-defun helm-execute-persistent-action - (&optional (attr 'persistent-action) split-onewindow) - "Perform the associated action ATTR without quitting helm. -ATTR default is 'persistent-action', but it can be anything else. -In this case you have to add this new attribute to your source. - -When `helm-full-frame' or SPLIT-ONEWINDOW are non--nil, -and `helm-buffer' is displayed in only one window, -the helm window is splitted to display -`helm-select-persistent-action-window' in other window -and keep its visibility." - (interactive) - (helm-log "executing persistent-action") - (let* ((attr-val (assoc-default attr (helm-get-current-source))) - ;; If attr value is a cons, use its car as persistent function - ;; and its car to decide if helm window should be splitted. - (fn (if (and (consp attr-val) - ;; maybe a lambda. - (not (functionp attr-val))) - (car attr-val) attr-val)) - (no-split (and (consp attr-val) - (not (functionp attr-val)) - (cdr attr-val)))) - (with-helm-window - (save-selected-window - (if no-split - (helm-select-persistent-action-window) - (helm-select-persistent-action-window - (or split-onewindow helm-onewindow-p))) - (helm-log "current-buffer = %S" (current-buffer)) - (let ((helm-in-persistent-action t)) - (with-helm-display-same-window - (helm-execute-selection-action-1 - nil (or fn (helm-get-actions-from-current-source)) t) - (helm-log-run-hook 'helm-after-persistent-action-hook)) - ;; A typical case is when a persistent action delete - ;; the buffer already displayed in - ;; `helm-persistent-action-display-window' and `helm-full-frame' - ;; is enabled, we end up with the `helm-buffer' - ;; displayed in two windows. - (when (and helm-onewindow-p - (> (length (window-list)) 1) - (equal (buffer-name - (window-buffer - helm-persistent-action-display-window)) - (helm-buffer-get))) - (delete-other-windows))))))) - -(defun helm-persistent-action-display-window (&optional split-onewindow) - "Return the window that will be used for persistent action. -If SPLIT-ONEWINDOW is non--nil window will be splitted in persistent action." - (with-helm-window - (setq helm-persistent-action-display-window - (cond ((and (window-live-p helm-persistent-action-display-window) - (not (member helm-persistent-action-display-window - (get-buffer-window-list helm-buffer)))) - helm-persistent-action-display-window) - (split-onewindow (split-window)) - ((get-buffer-window helm-current-buffer)) - (t (next-window (selected-window) 1)))))) - -(defun helm-select-persistent-action-window (&optional split-onewindow) - "Select the window that will be used for persistent action. -See `helm-persistent-action-display-window' for how to use SPLIT-ONEWINDOW." - (select-window (get-buffer-window (helm-buffer-get))) - (select-window - (setq minibuffer-scroll-window - (helm-persistent-action-display-window split-onewindow)))) - -(defun helm-persistent-action-display-buffer (buf &optional action) - "Make `pop-to-buffer' and `display-buffer' display in the same window. -If `helm-persistent-action-use-special-display' is non-nil and -BUF is to be displayed by `special-display-function', use it. -Otherwise ignores `special-display-buffer-names' and `special-display-regexps'. -Argument ACTION if present will be used as second argument of `display-buffer'." - (let* ((name (buffer-name buf)) - display-buffer-function pop-up-windows pop-up-frames - ;; Disable `special-display-regexps' and `special-display-buffer-names' - ;; unless `helm-persistent-action-use-special-display' is non--nil. - (special-display-buffer-names - (and helm-persistent-action-use-special-display - special-display-buffer-names)) - (special-display-regexps - (and helm-persistent-action-use-special-display - special-display-regexps)) - (same-window-regexps - (unless (and helm-persistent-action-use-special-display - (or (member name - (mapcar (lambda (x) (or (car-safe x) x)) - special-display-buffer-names)) - (cl-loop for x in special-display-regexps - thereis (string-match (or (car-safe x) x) - name)))) - '(".")))) - ;; Don't loose minibuffer when displaying persistent window in - ;; another frame. - ;; This happen when the displayed persistent buffer-name is one of - ;; `special-display-buffer-names' or match `special-display-regexps' - ;; and `helm-persistent-action-use-special-display' is enabled. - (with-selected-window (if (or special-display-regexps - special-display-buffer-names) - (minibuffer-window) - (selected-window)) - ;; Be sure window of BUF is not dedicated. - (set-window-dedicated-p (get-buffer-window buf) nil) - (display-buffer buf action)))) - -;; scroll-other-window(-down)? for persistent-action -(defun helm-other-window-base (command &optional scroll-amount) - (setq scroll-amount (unless (eq scroll-amount 'noscroll) - helm-scroll-amount)) - (with-selected-window (helm-persistent-action-display-window) - (funcall command scroll-amount))) - -(defun helm-scroll-other-window () - "Scroll other window (not *Helm* window) upward." - (interactive) - (helm-other-window-base 'scroll-up)) - -(defun helm-scroll-other-window-down () - "Scroll other window (not *Helm* window) downward." - (interactive) - (helm-other-window-base 'scroll-down)) - -(defun helm-recenter-top-bottom-other-window () - "`recenter-top-bottom' in other window (not *Helm* window)." - (interactive) - (helm-other-window-base 'recenter-top-bottom 'noscroll)) - -(defun helm-reposition-window-other-window () - "`helm-reposition-window' in other window (not *Helm* window)." - (interactive) - (helm-other-window-base 'reposition-window 'noscroll)) - - - -;; Utility: Visible Mark - -(defun helm-clear-visible-mark () - (with-current-buffer (helm-buffer-get) - (mapc 'delete-overlay helm-visible-mark-overlays) - (set (make-local-variable 'helm-visible-mark-overlays) nil))) - -(defun helm-this-visible-mark () - (cl-loop for o in helm-visible-mark-overlays - when (equal (point-at-bol) (overlay-start o)) - return o)) - -(defun helm-delete-visible-mark (overlay) - (setq helm-marked-candidates - (remove - (cons (helm-get-current-source) (helm-get-selection)) - helm-marked-candidates)) - (delete-overlay overlay) - (setq helm-visible-mark-overlays - (delq overlay helm-visible-mark-overlays))) - -(defun helm-make-visible-mark () - (let ((o (make-overlay (point-at-bol) - (if (helm-pos-multiline-p) - (or (helm-get-next-candidate-separator-pos) - (point-max)) - (1+ (point-at-eol)))))) - (overlay-put o 'face 'helm-visible-mark) - (overlay-put o 'source (assoc-default 'name (helm-get-current-source))) - (overlay-put o 'string (buffer-substring (overlay-start o) (overlay-end o))) - (overlay-put o 'real (helm-get-selection)) - (add-to-list 'helm-visible-mark-overlays o)) - (push (cons (helm-get-current-source) (helm-get-selection)) - helm-marked-candidates)) - -(defun helm-toggle-visible-mark () - "Toggle helm visible mark at point." - (interactive) - (with-helm-window - (let ((nomark (assq 'nomark (helm-get-current-source)))) - (if nomark - (message "Marking not allowed in this source") - (helm-aif (helm-this-visible-mark) - (helm-delete-visible-mark it) - (helm-make-visible-mark)) - (unless (helm-end-of-source-p) - (helm-next-line)))))) - -(defun helm-mark-all () - "Mark all visible unmarked candidates in current source." - (interactive) - (require 'helm-files) - (with-helm-window - (let ((nomark (assq 'nomark (helm-get-current-source))) - (follow (if helm-follow-mode 1 -1))) - (helm-follow-mode -1) - (unwind-protect - (if nomark - (message "Marking not allowed in this source") - (save-excursion - (goto-char (helm-get-previous-header-pos)) - (helm-next-line) - (let* ((next-head (helm-get-next-header-pos)) - (end (and next-head - (save-excursion - (goto-char next-head) - (forward-line -1) - (point)))) - (maxpoint (or end (point-max)))) - (while (< (point) maxpoint) - (helm-mark-current-line) - (let* ((prefix (get-text-property (point-at-bol) 'display)) - (cand (helm-get-selection)) - (bn (and (helm-file-completion-source-p) - (helm-basename cand))) - (src-name (assoc-default 'name - (helm-get-current-source)))) - (when (and (not (helm-this-visible-mark)) - (not (or (string= prefix "[?]") - (string= prefix "[@]")))) - ;; Don't mark possibles directories ending with . or .. - ;; autosave files/links and non--existent file. - (unless - (and (or (helm-file-completion-source-p) - (string= - src-name "Files from Current Directory")) - (or (string-match - "^[.]?#.*#?$\\|[^#]*[.]\\{1,2\\}$" bn) - ;; We need to test here when not using - ;; a transformer that tag prefix - ;; (i.e on tramp). - (not (file-exists-p cand)))) - (helm-make-visible-mark)))) - (if (helm-pos-multiline-p) - (progn - (goto-char - (or (helm-get-next-candidate-separator-pos) - (point-max))) - (forward-line 1)) - (forward-line 1)) - (end-of-line)))) - (helm-mark-current-line) - (message "%s candidates marked" (length helm-marked-candidates))) - (helm-follow-mode follow) (message nil))))) - -(defun helm-unmark-all () - "Unmark all candidates in all sources of current helm session." - (interactive) - (with-helm-window - (let ((len (length helm-marked-candidates))) - (save-excursion - (helm-clear-visible-mark)) - (setq helm-marked-candidates nil) - (helm-mark-current-line) - (message "%s candidates unmarked" len)))) - -(defun helm-toggle-all-marks () - "Toggle all marks. -Mark all visible candidates of current source or unmark all candidates -visible or invisible in all sources of current helm session" - (interactive) - (let ((marked (helm-marked-candidates))) - (if (and (>= (length marked) 1) - (with-helm-window helm-visible-mark-overlays)) - (helm-unmark-all) - (helm-mark-all)))) - -(defun helm-display-all-visible-marks () - "Show all `helm' visible marks strings. -Only useful for debugging." - (interactive) - (with-helm-window - (let ((overlays (reverse helm-visible-mark-overlays))) - (helm-run-after-quit - (lambda () - (with-output-to-temp-buffer "*helm visible marks*" - (cl-dolist (o overlays) (princ (overlay-get o 'string))))))))) - -(cl-defun helm-marked-candidates (&key with-wildcard) - "Return marked candidates of current source if any. -Otherwise one element list of current selection. -When key WITH-WILDCARD is specified try to expand a wilcard if some." - (with-current-buffer helm-buffer - (cl-loop with current-src = (helm-get-current-source) - for (source . real) in - (or (reverse helm-marked-candidates) - (list (cons current-src (helm-get-selection)))) - when (equal current-src source) - ;; When real is a normal filename without wildcard - ;; file-expand-wildcards returns a list of one file. - ;; When real is a non--existent file it return nil. - append (let* ((elm (helm-coerce-selection real source)) - (c (and with-wildcard - (condition-case nil - (file-expand-wildcards elm t) - (error nil))))) - (or c (list elm))) - into cands - finally do (prog1 (cl-return cands) - (helm-log "Marked candidates = %S" cands))))) - -(defun helm-current-source-name= (name) - (save-excursion - (goto-char (helm-get-previous-header-pos)) - (equal name (helm-current-line-contents)))) - -(defun helm-revive-visible-mark () - "Restore marked candidates when helm update display." - (with-current-buffer helm-buffer - (cl-dolist (o helm-visible-mark-overlays) - (goto-char (point-min)) - (while (and (search-forward (overlay-get o 'string) nil t) - (helm-current-source-name= (overlay-get o 'source))) - ;; Calculate real value of candidate. - ;; It can be nil if candidate have only a display value. - (let ((real (get-text-property (point-at-bol 0) 'helm-realvalue))) - (if real - ;; Check if real value of current candidate is the same - ;; that the one stored in overlay. - (and (string= (overlay-get o 'real) real) - (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0)))) - (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0))))))))) -(add-hook 'helm-update-hook 'helm-revive-visible-mark) - -(defun helm-next-point-in-list (curpos points &optional prev) - (cond - ;; rule out special cases. - ((null points) curpos) - ((and prev (<= curpos (car points))) - (nth (1- (length points)) points)) - ((< (car (last points)) curpos) - (if prev (car (last points)) (nth 0 points))) - ((and (not prev) (>= curpos (car (last points)))) - (nth 0 points)) - (t - (nth (if prev - (cl-loop for pt in points - for i from 0 - if (<= curpos pt) return (1- i)) - (cl-loop for pt in points - for i from 0 - if (< curpos pt) return i)) - points)))) - -(defun helm-next-visible-mark (&optional prev) - "Move next helm visible mark. -If PREV is non-nil move to precedent." - (interactive) - (with-helm-window - (ignore-errors - (goto-char (helm-next-point-in-list - (point) - (sort (mapcar 'overlay-start helm-visible-mark-overlays) '<) - prev))) - (helm-mark-current-line))) - -(defun helm-prev-visible-mark () - "Move previous helm visible mark." - (interactive) - (helm-next-visible-mark t)) - -;;; Utility: Selection Paste -;; -(defun helm-yank-selection (arg) - "Set minibuffer contents to current display selection. -With a prefix arg set to real value of current selection." - (interactive "P") - (let ((str (helm-get-selection nil (not arg)))) - (kill-new str) - (helm-set-pattern str))) - -(defun helm-kill-selection-and-quit (arg) - "Store display value of current selection to kill ring. -With a prefix arg set to real value of current selection. -Display value is what you see in `helm-buffer' and real value -is what is used to perform actions." - (interactive "P") - (helm-run-after-quit - (lambda (sel) - (kill-new sel) - (message "Killed: %s" sel)) - (helm-get-selection nil (not arg)))) - -(defun helm-copy-to-buffer () - "Copy selection or marked candidates to `helm-current-buffer'." - (interactive) - (with-helm-buffer - (cl-loop for cand in (helm-marked-candidates) - do (with-helm-current-buffer - (insert cand "\n"))))) - - -;;; Follow-mode: Automatical execution of persistent-action -;; -;; -(defun helm-follow-mode (&optional arg) - "Execute persistent action everytime the cursor is moved when enabled. -The mode is enabled for the current source only, you will have to turn it -on again when you go to next source if you want it there also. -This mode can be enabled or disabled interactively at anytime during -helm session or enabled specifically by source by adding the `follow' -attribute to this source. -Even when the attribute `follow' exists in source, it is still possible -to disable/enable this mode interactively. -Note that when you disable it interactively and `follow' attribute exists, -`helm-follow-mode' will be disabled on next helm session even if `follow' -attribute is specified in source. To avoid this set your `follow' attribute -in source in `helm-before-initialize-hook'. - -e.g: - -\(add-hook 'helm-before-initialize-hook - #'(lambda () (helm-attrset 'follow 1 helm-source-buffers-list))) - -This will enable `helm-follow-mode' automatically in `helm-source-buffers-list'." - (interactive "p") - (with-current-buffer helm-buffer - (let* ((src (helm-get-current-source)) - (name (assoc-default 'name src)) - (sym (cl-loop for s in helm-sources - for sname = (and (symbolp s) - (assoc-default - 'name (symbol-value s))) - thereis (and sname (string= sname name) s))) - (fol-attr (assq 'follow src)) - (enabled (or - ;; If `helm-follow-mode' is called with a negative - ;; ARG, assume follow is already enabled. - ;; i.e turn it off now. - (< arg 0) - (eq (cdr fol-attr) 1) - helm-follow-mode))) - (if src - (progn - (if (eq (cdr fol-attr) 'never) - (message "helm-follow-mode not allowed in this source") - ;; Make follow attr persistent for this emacs session. - (helm-attrset 'follow (if enabled -1 1) src) - (setq helm-follow-mode (not enabled)) - (message "helm-follow-mode is %s" - (if helm-follow-mode - "enabled" "disabled")) - (helm-display-mode-line src)) - (unless helm-follow-mode-persistent - (and sym (set sym (remove (assq 'follow src) src))))) - (message "Not enough candidates for helm-follow-mode"))))) - -(defvar helm-follow-input-idle-delay nil - "`helm-follow-mode' will execute its persistent action after this delay. -Note that if the `follow-delay' attr is present in source, -it will take precedence on this.") -(defun helm-follow-execute-persistent-action-maybe () - "Execute persistent action in mode `helm-follow-mode'. -This happen after `helm-input-idle-delay' secs." - (let ((src (helm-get-current-source))) - (and (not (get-buffer-window helm-action-buffer 'visible)) - (eq (assoc-default 'follow src) 1) - (sit-for (or (assoc-default 'follow-delay src) - helm-follow-input-idle-delay - (and helm-input-idle-delay - (max helm-input-idle-delay 0.01)))) - (helm-window) - (helm-get-selection) - (save-excursion - (helm-execute-persistent-action))))) - - -(provide 'helm) - -;; Local Variables: -;; byte-compile-warnings: (not cl-functions obsolete) -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; helm.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/emacs-helm.sh b/emacs.d/elpa/helm-20150507.2215/emacs-helm.sh new file mode 100755 index 0000000..d24128d --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/emacs-helm.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + + +## Copyright (C) 2012 Thierry Volpiatto +## +## 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: + +# Preconfigured Emacs with a basic helm configuration. +# Useful to start quickly an emacs -Q with helm. +# Run it from this directory. + +TMP="/tmp/helm-cfg.el" +EMACS=emacs + +case $1 in + -P) + shift 1 + declare EMACS=$1 + shift 1 + ;; + -h) + echo "Usage: ${0##*/} [-P} Emacs path [-h} help [--] EMACS ARGS" + exit 2 + ;; +esac + +cd $(dirname "$0") + +# Check if autoload file exists. +# It is maybe in a different directory if +# emacs-helm.sh is a symlink. +LS=$(ls -l $0 | awk '{print $11}') +if [ ! -z $LS ]; then + AUTO_FILE="$(dirname $LS)/helm-autoloads.el" +else + AUTO_FILE="helm-autoloads.el" +fi +if [ ! -e "$AUTO_FILE" ]; then + echo No autoloads found, please run make first to generate autoload file + exit 2 +fi + + +cat > $TMP <\`helm-find-files'\n\ +;; - \`occur'(M-s o) =>\`helm-occur'\n\ +;; - \`list-buffers'(C-x C-b) =>\`helm-buffers-list'\n\ +;; - \`completion-at-point'(M-tab) =>\`helm-lisp-completion-at-point'[1]\n\ +;; - \`dabbrev-expand'(M-/) =>\`helm-dabbrev'\n\n\ +;; Some others native emacs commands are \"helmized\" by \`helm-mode'.\n\ +;; [1] Coming with emacs-24.4 \`completion-at-point' is \"helmized\" by \`helm-mode'\n\ +;; which provide helm completion in many other places like \`shell-mode'.\n\ +;; You will find embeded help for most helm commands with \`C-c ?'.\n\ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n")) + +(setq default-frame-alist '((vertical-scroll-bars . nil) + (tool-bar-lines . 0) + (menu-bar-lines . 0) + (fullscreen . nil))) +(blink-cursor-mode -1) +(add-to-list 'load-path (file-name-directory (file-truename "$0"))) +(require 'helm-config) +(helm-mode 1) +(define-key global-map [remap find-file] 'helm-find-files) +(define-key global-map [remap occur] 'helm-occur) +(define-key global-map [remap list-buffers] 'helm-buffers-list) +(define-key global-map [remap dabbrev-expand] 'helm-dabbrev) +(global-set-key (kbd "M-x") 'helm-M-x) +(unless (boundp 'completion-in-region-function) + (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point) + (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)) +(add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$TMP") (delete-file "$TMP")))) +EOF + +$EMACS -Q -l $TMP $@ + diff --git a/emacs.d/elpa/helm-20150507.2215/helm-adaptive.el b/emacs.d/elpa/helm-20150507.2215/helm-adaptive.el new file mode 100644 index 0000000..d7f0532 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-adaptive.el @@ -0,0 +1,243 @@ +;;; helm-adaptive.el --- Adaptive Sorting of Candidates. -*- lexical-binding: t -*- + +;; Original Author: Tamas Patrovics + +;; Copyright (C) 2007 Tamas Patrovics +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) + + +(defgroup helm-adapt nil + "Adaptative sorting of candidates for Helm." + :group 'helm) + +(defcustom helm-adaptive-history-file + "~/.emacs.d/helm-adaptive-history" + "Path of file where history information is stored." + :type 'string + :group 'helm-adapt) + +(defcustom helm-adaptive-history-length 50 + "Maximum number of candidates stored for a source." + :type 'number + :group 'helm-adapt) + + +;; Internal +(defvar helm-adaptive-done nil + "nil if history information is not yet stored for the current +selection.") + +(defvar helm-adaptive-history nil + "Contains the stored history information. +Format: ((SOURCE-NAME (SELECTED-CANDIDATE (PATTERN . NUMBER-OF-USE) ...) ...) ...)") + +(defun helm-adaptive-done-reset () + (setq helm-adaptive-done nil)) + +(define-minor-mode helm-adaptive-mode + "Toggle adaptive sorting in all sources." + :group 'helm-adapt + :require 'helm-adaptive + :global t + (if helm-adaptive-mode + (progn + (unless helm-adaptive-history + (helm-adaptive-maybe-load-history)) + (add-hook 'kill-emacs-hook 'helm-adaptive-save-history) + ;; Should run at beginning of `helm-initial-setup'. + (add-hook 'helm-before-initialize-hook 'helm-adaptive-done-reset) + ;; Should run at beginning of `helm-exit-minibuffer'. + (add-hook 'helm-before-action-hook 'helm-adaptive-store-selection) + ;; Should run at beginning of `helm-select-action'. + (add-hook 'helm-select-action-hook 'helm-adaptive-store-selection)) + (helm-adaptive-save-history) + (setq helm-adaptive-history nil) + (remove-hook 'kill-emacs-hook 'helm-adaptive-save-history) + (remove-hook 'helm-before-initialize-hook 'helm-adaptive-done-reset) + (remove-hook 'helm-before-action-hook 'helm-adaptive-store-selection) + (remove-hook 'helm-select-action-hook 'helm-adaptive-store-selection))) + +(defun helm-adapt-use-adaptive-p (&optional source-name) + "Return current source only if it use adaptive history, nil otherwise." + (when helm-adaptive-mode + (let* ((source (or source-name (helm-get-current-source))) + (adapt-source (or (assoc-default 'filtered-candidate-transformer + (assoc (assoc-default 'type source) + helm-type-attributes)) + (assoc-default 'candidate-transformer + (assoc (assoc-default 'type source) + helm-type-attributes)) + (assoc-default 'filtered-candidate-transformer source) + (assoc-default 'candidate-transformer source)))) + (if (listp adapt-source) + (and (member 'helm-adaptive-sort adapt-source) source) + (and (eq adapt-source 'helm-adaptive-sort) source))))) + +(defun helm-adaptive-store-selection () + "Store history information for the selected candidate." + (unless helm-adaptive-done + (setq helm-adaptive-done t) + (let ((source (helm-adapt-use-adaptive-p))) + (when source + (let* ((source-name (or (assoc-default 'type source) + (assoc-default 'name source))) + (source-info (or (assoc source-name helm-adaptive-history) + (progn + (push (list source-name) helm-adaptive-history) + (car helm-adaptive-history)))) + (selection (helm-get-selection)) + (selection-info (progn + (setcdr source-info + (cons + (let ((found (assoc selection (cdr source-info)))) + (if (not found) + ;; new entry + (list selection) + ;; move entry to the beginning of the + ;; list, so that it doesn't get + ;; trimmed when the history is + ;; truncated + (setcdr source-info + (delete found (cdr source-info))) + found)) + (cdr source-info))) + (cadr source-info))) + (pattern-info (progn + (setcdr selection-info + (cons + (let ((found (assoc helm-pattern (cdr selection-info)))) + (if (not found) + ;; new entry + (cons helm-pattern 0) + + ;; move entry to the beginning of the + ;; list, so if two patterns used the + ;; same number of times then the one + ;; used last appears first in the list + (setcdr selection-info + (delete found (cdr selection-info))) + found)) + (cdr selection-info))) + (cadr selection-info)))) + + ;; increase usage count + (setcdr pattern-info (1+ (cdr pattern-info))) + + ;; truncate history if needed + (if (> (length (cdr selection-info)) helm-adaptive-history-length) + (setcdr selection-info + (cl-subseq (cdr selection-info) 0 helm-adaptive-history-length)))))))) + +(defun helm-adaptive-maybe-load-history () + "Load `helm-adaptive-history-file' which contain `helm-adaptive-history'. +Returns nil if `helm-adaptive-history-file' doesn't exist." + (when (file-readable-p helm-adaptive-history-file) + (load-file helm-adaptive-history-file))) + +(defun helm-adaptive-save-history (&optional arg) + "Save history information to file given by `helm-adaptive-history-file'." + (interactive "p") + (with-temp-buffer + (insert + ";; -*- mode: emacs-lisp -*-\n" + ";; History entries used for helm adaptive display.\n") + (prin1 `(setq helm-adaptive-history ',helm-adaptive-history) + (current-buffer)) + (insert ?\n) + (write-region (point-min) (point-max) helm-adaptive-history-file nil + (unless arg 'quiet)))) + +(defun helm-adaptive-sort (candidates source) + "Sort the CANDIDATES for SOURCE by usage frequency. +This is a filtered candidate transformer you can use with the +`filtered-candidate-transformer' attribute." + (let* ((source-name (or (assoc-default 'type source) + (assoc-default 'name source))) + (source-info (assoc source-name helm-adaptive-history))) + (if source-info + (let ((usage + ;; ... assemble a list containing the (CANIDATE . USAGE-COUNT) + ;; pairs + (mapcar (lambda (candidate-info) + (let ((count 0)) + (cl-dolist (pattern-info (cdr candidate-info)) + (if (not (equal (car pattern-info) + helm-pattern)) + (cl-incf count (cdr pattern-info)) + + ;; if current pattern is equal to the previously + ;; used one then this candidate has priority + ;; (that's why its count is boosted by 10000) and + ;; it only has to compete with other candidates + ;; which were also selected with the same pattern + (setq count (+ 10000 (cdr pattern-info))) + (cl-return))) + (cons (car candidate-info) count))) + (cdr source-info)))) + (if (and usage (consp usage)) + ;; sort the list in descending order, so candidates with highest + ;; priorty come first + (progn + (setq usage (sort usage (lambda (first second) + (> (cdr first) (cdr second))))) + + ;; put those candidates first which have the highest usage count + (cl-loop for (info . _freq) in usage + for member = (cl-member info candidates + :test 'helm-adaptive-compare) + when member collect (car member) into sorted + and do + (setq candidates (cl-remove info candidates + :test 'helm-adaptive-compare)) + finally return (append sorted candidates))) + (message "Your `%s' is maybe corrupted or too old, \ +you should reinitialize it with `helm-reset-adaptive-history'" + helm-adaptive-history-file) + (sit-for 1) + candidates)) + ;; if there is no information stored for this source then do nothing + candidates))) + +;;;###autoload +(defun helm-reset-adaptive-history () + "Delete all `helm-adaptive-history' and his file. +Useful when you have a old or corrupted `helm-adaptive-history-file'." + (interactive) + (when (y-or-n-p "Really delete all your `helm-adaptive-history'? ") + (setq helm-adaptive-history nil) + (delete-file helm-adaptive-history-file))) + +(defun helm-adaptive-compare (x y) + "Compare candidates X and Y taking into account that the +candidate can be in (DISPLAY . REAL) format." + (equal (if (listp x) (cdr x) x) + (if (listp y) (cdr y) y))) + + +(provide 'helm-adaptive) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-adaptive.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-aliases.el b/emacs.d/elpa/helm-20150507.2215/helm-aliases.el new file mode 100644 index 0000000..5427920 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-aliases.el @@ -0,0 +1,778 @@ +;;; helm-aliases.el --- Helm aliases for helm obsoletes functions. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) + + +;;; Helper functions to create aliases with old helm definitions +;; prefixed with "helm-c-" +;; +(defun helm-alias-p (sym) + (cond ((boundp sym) + (not (eq (indirect-variable sym) sym))) + ((fboundp sym) + (symbolp (symbol-function sym))) + (t nil))) + +(defun helm-check-conflicting-prefixes () + (cl-loop for s in (all-completions "helm-c-" obarray) + for rep = (replace-regexp-in-string "helm-c-" "helm-" s) + when (or (and (not (helm-alias-p (intern s))) (fboundp (intern rep))) + (and (not (helm-alias-p (intern s))) (boundp (intern rep)))) + collect rep)) + +(defun helm-collect-functions-with-bad-prefix () + (cl-loop for s in (all-completions "helm-c-" obarray) + for sym = (intern s) + when (and (not (helm-alias-p sym)) (fboundp sym)) + collect s)) + +(defun helm-collect-vars-with-bad-prefix () + (cl-loop for s in (all-completions "helm-c-" obarray) + for sym = (intern s) + when (and (not (helm-alias-p sym)) (boundp sym)) + collect s)) + +(defun helm-insert-fn-aliases () + (cl-loop for s in (helm-collect-functions-with-bad-prefix) + for rep = (replace-regexp-in-string "helm-c-" "helm-" s) + do (insert (format "(defalias '%s '%s)\n(make-obsolete '%s '%s \"1.5.1\")\n" s rep s rep)))) + +(defun helm-insert-var-aliases () + (cl-loop for s in (helm-collect-vars-with-bad-prefix) + for rep = (replace-regexp-in-string "helm-c-" "helm-" s) + do (insert (format "(defvaralias '%s '%s)\n(make-obsolete-variable '%s '%s \"1.5.1\")\n" s rep s rep)))) + + +;;; Alias old functions prefixed with "helm-c-" +;; +;; +(defalias 'helm-c-etags-default-action 'helm-etags-default-action) +(make-obsolete 'helm-c-etags-default-action 'helm-etags-default-action "1.5.1") +(defalias 'helm-c-show-info-in-mode-line 'helm-show-info-in-mode-line) +(make-obsolete 'helm-c-show-info-in-mode-line 'helm-show-info-in-mode-line "1.5.1") +(defalias 'helm-c-grep-highlight-match 'helm-grep-highlight-match) +(make-obsolete 'helm-c-grep-highlight-match 'helm-grep-highlight-match "1.5.1") +(defalias 'helm-c-apropos 'helm-apropos) +(make-obsolete 'helm-c-apropos 'helm-apropos "1.5.1") +(defalias 'helm-c-grep-guess-extensions 'helm-grep-guess-extensions) +(make-obsolete 'helm-c-grep-guess-extensions 'helm-grep-guess-extensions "1.5.1") +(defalias 'helm-c-apt-reinstall 'helm-apt-reinstall) +(make-obsolete 'helm-c-apt-reinstall 'helm-apt-reinstall "1.5.1") +(defalias 'helm-c-reset-adaptive-history 'helm-reset-adaptive-history) +(make-obsolete 'helm-c-reset-adaptive-history 'helm-reset-adaptive-history "1.5.1") +(defalias 'helm-adaptative-mode 'helm-adaptive-mode) +(make-obsolete 'helm-adaptative-mode 'helm-adaptive-mode "1.6.2") +(defalias 'helm-c-highlight-bookmark 'helm-highlight-bookmark) +(make-obsolete 'helm-c-highlight-bookmark 'helm-highlight-bookmark "1.5.1") +(defalias 'helm-c-locate-init 'helm-locate-init) +(make-obsolete 'helm-c-locate-init 'helm-locate-init "1.5.1") +(defalias 'helm-c-delete-file 'helm-delete-file) +(make-obsolete 'helm-c-delete-file 'helm-delete-file "1.5.1") +(defalias 'helm-c-regexp-persistent-action 'helm-regexp-persistent-action) +(make-obsolete 'helm-c-regexp-persistent-action 'helm-regexp-persistent-action "1.5.1") +(defalias 'helm-c-grep-split-line 'helm-grep-split-line) +(make-obsolete 'helm-c-grep-split-line 'helm-grep-split-line "1.5.1") +(defalias 'helm-c-info-display-to-real 'helm-info-display-to-real) +(make-obsolete 'helm-c-info-display-to-real 'helm-info-display-to-real "1.5.1") +(defalias 'helm-c-symbolify 'helm-symbolify) +(make-obsolete 'helm-c-symbolify 'helm-symbolify "1.5.1") +(defalias 'helm-c-zgrep-buffers 'helm-zgrep-buffers) +(make-obsolete 'helm-c-zgrep-buffers 'helm-zgrep-buffers "1.5.1") +(defalias 'helm-c-apt-persistent-action 'helm-apt-persistent-action) +(make-obsolete 'helm-c-apt-persistent-action 'helm-apt-persistent-action "1.5.1") +(defalias 'helm-c-pdfgrep-init 'helm-pdfgrep-init) +(make-obsolete 'helm-c-pdfgrep-init 'helm-pdfgrep-init "1.5.1") +(defalias 'helm-c-walk-directory 'helm-walk-directory) +(make-obsolete 'helm-c-walk-directory 'helm-walk-directory "1.5.1") +(defalias 'helm-c-grep-init 'helm-grep-init) +(make-obsolete 'helm-c-grep-init 'helm-grep-init "1.5.1") +(defalias 'helm-c-ucs-forward-char 'helm-ucs-forward-char) +(make-obsolete 'helm-c-ucs-forward-char 'helm-ucs-forward-char "1.5.1") +(defalias 'helm-c-complete-file-name-at-point 'helm-complete-file-name-at-point) +(make-obsolete 'helm-c-complete-file-name-at-point 'helm-complete-file-name-at-point "1.5.1") +(defalias 'helm-c-timer-real-to-display 'helm-timer-real-to-display) +(make-obsolete 'helm-c-timer-real-to-display 'helm-timer-real-to-display "1.5.1") +(defalias 'helm-c-ucs-init 'helm-ucs-init) +(make-obsolete 'helm-c-ucs-init 'helm-ucs-init "1.5.1") +(defalias 'helm-c-bookmark-run-delete 'helm-bookmark-run-delete) +(make-obsolete 'helm-c-bookmark-run-delete 'helm-bookmark-run-delete "1.5.1") +(defalias 'helm-c-uniq-list 'helm-uniq-list) +(make-obsolete 'helm-c-uniq-list 'helm-uniq-list "1.5.1") +(defalias 'helm-c-pp-bookmarks 'helm-pp-bookmarks) +(make-obsolete 'helm-c-pp-bookmarks 'helm-pp-bookmarks "1.5.1") +(defalias 'helm-c-top-sh-persistent-action 'helm-top-sh-persistent-action) +(make-obsolete 'helm-c-top-sh-persistent-action 'helm-top-sh-persistent-action "1.5.1") +(defalias 'helm-c-grep-action 'helm-grep-action) +(make-obsolete 'helm-c-grep-action 'helm-grep-action "1.5.1") +(defalias 'helm-c-file-buffers 'helm-file-buffers) +(make-obsolete 'helm-c-file-buffers 'helm-file-buffers "1.5.1") +(defalias 'helm-c-google-suggest-fetch 'helm-google-suggest-fetch) +(make-obsolete 'helm-c-google-suggest-fetch 'helm-google-suggest-fetch "1.5.1") +(defalias 'helm-c-arrange-type-attribute 'helm-arrange-type-attribute) +(make-obsolete 'helm-c-arrange-type-attribute 'helm-arrange-type-attribute "1.5.1") +(defalias 'helm-c-yahoo-suggest-action 'helm-yahoo-suggest-action) +(make-obsolete 'helm-c-yahoo-suggest-action 'helm-yahoo-suggest-action "1.5.1") +(defalias 'helm-c-buffer-query-replace-1 'helm-buffer-query-replace-1) +(make-obsolete 'helm-c-buffer-query-replace-1 'helm-buffer-query-replace-1 "1.5.1") +(defalias 'helm-c-make-info-source 'helm-make-info-source) +(make-obsolete 'helm-c-make-info-source 'helm-make-info-source "1.5.1") +(defalias 'helm-c-open-dired 'helm-open-dired) +(make-obsolete 'helm-c-open-dired 'helm-open-dired "1.5.1") +(defalias 'helm-c-kill-ring-transformer 'helm-kill-ring-transformer) +(make-obsolete 'helm-c-kill-ring-transformer 'helm-kill-ring-transformer "1.5.1") +(defalias 'helm-c-etags-init 'helm-etags-init) +(make-obsolete 'helm-c-etags-init 'helm-etags-init "1.5.1") +(defalias 'helm-c-advice-update-current-display-string 'helm-advice-update-current-display-string) +(make-obsolete 'helm-c-advice-update-current-display-string 'helm-advice-update-current-display-string "1.5.1") +(defalias 'helm-c-regexp-get-line 'helm-regexp-get-line) +(make-obsolete 'helm-c-regexp-get-line 'helm-regexp-get-line "1.5.1") +(defalias 'helm-c-grep-run-other-window-action 'helm-grep-run-other-window-action) +(make-obsolete 'helm-c-grep-run-other-window-action 'helm-grep-run-other-window-action "1.5.1") +(defalias 'helm-c-regexp-kill-new 'helm-regexp-kill-new) +(make-obsolete 'helm-c-regexp-kill-new 'helm-regexp-kill-new "1.5.1") +(defalias 'helm-c-grep-run-default-action 'helm-grep-run-default-action) +(make-obsolete 'helm-c-grep-run-default-action 'helm-grep-run-default-action "1.5.1") +(defalias 'helm-c-define-info-index-sources 'helm-define-info-index-sources) +(make-obsolete 'helm-c-define-info-index-sources 'helm-define-info-index-sources "1.5.1") +(defalias 'helm-c-transform-file-browse-url 'helm-transform-file-browse-url) +(make-obsolete 'helm-c-transform-file-browse-url 'helm-transform-file-browse-url "1.5.1") +(defalias 'helm-c-shell-command-if-needed 'helm-shell-command-if-needed) +(make-obsolete 'helm-c-shell-command-if-needed 'helm-shell-command-if-needed "1.5.1") +(defalias 'helm-c-kill-regexp-as-sexp 'helm-kill-regexp-as-sexp) +(make-obsolete 'helm-c-kill-regexp-as-sexp 'helm-kill-regexp-as-sexp "1.5.1") +(defalias 'helm-c-goto-next-or-prec-file 'helm-goto-next-or-prec-file) +(make-obsolete 'helm-c-goto-next-or-prec-file 'helm-goto-next-or-prec-file "1.5.1") +(defalias 'helm-c-insert-file-name-completion-at-point 'helm-insert-file-name-completion-at-point) +(make-obsolete 'helm-c-insert-file-name-completion-at-point 'helm-insert-file-name-completion-at-point "1.5.1") +(defalias 'helm-c-point-file-in-dired 'helm-point-file-in-dired) +(make-obsolete 'helm-c-point-file-in-dired 'helm-point-file-in-dired "1.5.1") +(defalias 'helm-c-info-goto 'helm-info-goto) +(make-obsolete 'helm-c-info-goto 'helm-info-goto "1.5.1") +(defalias 'helm-c-apt-install 'helm-apt-install) +(make-obsolete 'helm-c-apt-install 'helm-apt-install "1.5.1") +(defalias 'helm-c-skip-boring-buffers 'helm-skip-boring-buffers) +(make-obsolete 'helm-c-skip-boring-buffers 'helm-skip-boring-buffers "1.5.1") +(defalias 'helm-c-register-candidates 'helm-register-candidates) +(make-obsolete 'helm-c-register-candidates 'helm-register-candidates "1.5.1") +(defalias 'helm-c-find-function 'helm-find-function) +(make-obsolete 'helm-c-find-function 'helm-find-function "1.5.1") +(defalias 'helm-c-apt-display-to-real 'helm-apt-display-to-real) +(make-obsolete 'helm-c-apt-display-to-real 'helm-apt-display-to-real "1.5.1") +(defalias 'helm-c-org-keywords-init 'helm-org-keywords-init) +(make-obsolete 'helm-c-org-keywords-init 'helm-org-keywords-init "1.5.1") +(defalias 'helm-c-xrandr-screen 'helm-xrandr-screen) +(make-obsolete 'helm-c-xrandr-screen 'helm-xrandr-screen "1.5.1") +(defalias 'helm-c-position 'helm-position) +(make-obsolete 'helm-c-position 'helm-position "1.5.1") +(defalias 'helm-c-imenu-candidates 'helm-imenu-candidates) +(make-obsolete 'helm-c-imenu-candidates 'helm-imenu-candidates "1.5.1") +(defalias 'helm-c-ucs-persistent-forward 'helm-ucs-persistent-forward) +(make-obsolete 'helm-c-ucs-persistent-forward 'helm-ucs-persistent-forward "1.5.1") +(defalias 'helm-c-basename 'helm-basename) +(make-obsolete 'helm-c-basename 'helm-basename "1.5.1") +(defalias 'helm-c-files-in-all-dired-candidates 'helm-files-in-all-dired-candidates) +(make-obsolete 'helm-c-files-in-all-dired-candidates 'helm-files-in-all-dired-candidates "1.5.1") +(defalias 'helm-c-grep-other-window 'helm-grep-other-window) +(make-obsolete 'helm-c-grep-other-window 'helm-grep-other-window "1.5.1") +(defalias 'helm-c-yahoo-suggest-fetch 'helm-yahoo-suggest-fetch) +(make-obsolete 'helm-c-yahoo-suggest-fetch 'helm-yahoo-suggest-fetch "1.5.1") +(defalias 'helm-c-external-commands-list-1 'helm-external-commands-list-1) +(make-obsolete 'helm-c-external-commands-list-1 'helm-external-commands-list-1 "1.5.1") +(defalias 'helm-c-buffers-list-persistent-action 'helm-buffers-list-persistent-action) +(make-obsolete 'helm-c-buffers-list-persistent-action 'helm-buffers-list-persistent-action "1.5.1") +(defalias 'helm-c-show-completion-init-overlay 'helm-show-completion-init-overlay) +(make-obsolete 'helm-c-show-completion-init-overlay 'helm-show-completion-init-overlay "1.5.1") +(defalias 'helm-c-shadow-boring-files 'helm-shadow-boring-files) +(make-obsolete 'helm-c-shadow-boring-files 'helm-shadow-boring-files "1.5.1") +(defalias 'helm-c-bookmark-local-files-setup-alist 'helm-bookmark-local-files-setup-alist) +(make-obsolete 'helm-c-bookmark-local-files-setup-alist 'helm-bookmark-local-files-setup-alist "1.5.1") +(defalias 'helm-c-highlight-local-use 'helm-highlight-local-use) +(make-obsolete 'helm-c-highlight-local-use 'helm-highlight-local-use "1.5.1") +(defalias 'helm-c-skip-current-file 'helm-skip-current-file) +(make-obsolete 'helm-c-skip-current-file 'helm-skip-current-file "1.5.1") +(defalias 'helm-c-goto-next-file 'helm-goto-next-file) +(make-obsolete 'helm-c-goto-next-file 'helm-goto-next-file "1.5.1") +(defalias 'helm-c-info-init 'helm-info-init) +(make-obsolete 'helm-c-info-init 'helm-info-init "1.5.1") +(defalias 'helm-c-query-replace-args 'helm-query-replace-args) +(make-obsolete 'helm-c-query-replace-args 'helm-query-replace-args "1.5.1") +(defalias 'helm-c-bookmark-info-setup-alist 'helm-bookmark-info-setup-alist) +(make-obsolete 'helm-c-bookmark-info-setup-alist 'helm-bookmark-info-setup-alist "1.5.1") +(defalias 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute) +(make-obsolete 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute "1.5.1") +(defalias 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward) +(make-obsolete 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward "1.5.1") +(defalias 'helm-c-info-pages-init 'helm-info-pages-init) +(make-obsolete 'helm-c-info-pages-init 'helm-info-pages-init "1.5.1") +(defalias 'helm-c-grep-save-results 'helm-grep-save-results) +(make-obsolete 'helm-c-grep-save-results 'helm-grep-save-results "1.5.1") +(defalias 'helm-c-read-file-name 'helm-read-file-name) +(make-obsolete 'helm-c-read-file-name 'helm-read-file-name "1.5.1") +(defalias 'helm-c-org-keywords-insert 'helm-org-keywords-insert) +(make-obsolete 'helm-c-org-keywords-insert 'helm-org-keywords-insert "1.5.1") +(defalias 'helm-c-call-interactively 'helm-call-interactively) +(make-obsolete 'helm-c-call-interactively 'helm-call-interactively "1.5.1") +(defalias 'helm-c-adaptative-compare 'helm-adaptive-compare) +(make-obsolete 'helm-c-adaptative-compare 'helm-adaptive-compare "1.5.1") +(defalias 'helm-c-buffer-list 'helm-buffer-list) +(make-obsolete 'helm-c-buffer-list 'helm-buffer-list "1.5.1") +(defalias 'helm-c-thing-before-point 'helm-thing-before-point) +(make-obsolete 'helm-c-thing-before-point 'helm-thing-before-point "1.5.1") +(defalias 'helm-c-ratpoison-commands-display-to-real 'helm-ratpoison-commands-display-to-real) +(make-obsolete 'helm-c-ratpoison-commands-display-to-real 'helm-ratpoison-commands-display-to-real "1.5.1") +(defalias 'helm-c-imenu-default-action 'helm-imenu-default-action) +(make-obsolete 'helm-c-imenu-default-action 'helm-imenu-default-action "1.5.1") +(defalias 'helm-c-describe-function 'helm-describe-function) +(make-obsolete 'helm-c-describe-function 'helm-describe-function "1.5.1") +(defalias 'helm-c-colors-get-name 'helm-colors-get-name) +(make-obsolete 'helm-c-colors-get-name 'helm-colors-get-name "1.5.1") +(defalias 'helm-c-bookmark-help 'helm-bookmark-help) +(make-obsolete 'helm-c-bookmark-help 'helm-bookmark-help "1.5.1") +(defalias 'helm-c-ucs-persistent-delete 'helm-ucs-persistent-delete) +(make-obsolete 'helm-c-ucs-persistent-delete 'helm-ucs-persistent-delete "1.5.1") +(defalias 'helm-c-set-variable 'helm-set-variable) +(make-obsolete 'helm-c-set-variable 'helm-set-variable "1.5.1") +(defalias 'helm-c-grep-save-results-1 'helm-grep-save-results-1) +(make-obsolete 'helm-c-grep-save-results-1 'helm-grep-save-results-1 "1.5.1") +(defalias 'helm-c-adaptative-maybe-load-history 'helm-adaptive-maybe-load-history) +(make-obsolete 'helm-c-adaptative-maybe-load-history 'helm-adaptive-maybe-load-history "1.5.1") +(defalias 'helm-c-w32-pathname-transformer 'helm-w32-pathname-transformer) +(make-obsolete 'helm-c-w32-pathname-transformer 'helm-w32-pathname-transformer "1.5.1") +(defalias 'helm-c-top-display-to-real 'helm-top-display-to-real) +(make-obsolete 'helm-c-top-display-to-real 'helm-top-display-to-real "1.5.1") +(defalias 'helm-c-open-file-externally 'helm-open-file-externally) +(make-obsolete 'helm-c-open-file-externally 'helm-open-file-externally "1.5.1") +(defalias 'helm-c-colors-get-rgb 'helm-colors-get-rgb) +(make-obsolete 'helm-c-colors-get-rgb 'helm-colors-get-rgb "1.5.1") +(defalias 'helm-c-stumpwm-commands-init 'helm-stumpwm-commands-init) +(make-obsolete 'helm-c-stumpwm-commands-init 'helm-stumpwm-commands-init "1.5.1") +(defalias 'helm-c-highlight-world 'helm-highlight-world) +(make-obsolete 'helm-c-highlight-world 'helm-highlight-world "1.5.1") +(defalias 'helm-c-top-sh 'helm-top-sh) +(make-obsolete 'helm-c-top-sh 'helm-top-sh "1.5.1") +(defalias 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action) +(make-obsolete 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action "1.5.1") +(defalias 'helm-c-latex-math-candidates 'helm-latex-math-candidates) +(make-obsolete 'helm-c-latex-math-candidates 'helm-latex-math-candidates "1.5.1") +(defalias 'helm-c-ucs-backward-char 'helm-ucs-backward-char) +(make-obsolete 'helm-c-ucs-backward-char 'helm-ucs-backward-char "1.5.1") +(defalias 'helm-c-calculate-ucs-max-len 'helm-calculate-ucs-max-len) +(make-obsolete 'helm-c-calculate-ucs-max-len 'helm-calculate-ucs-max-len "1.5.1") +(defalias 'helm-c-etags-mtime 'helm-etags-mtime) +(make-obsolete 'helm-c-etags-mtime 'helm-etags-mtime "1.5.1") +(defalias 'helm-c-google-suggest-action 'helm-google-suggest-action) +(make-obsolete 'helm-c-google-suggest-action 'helm-google-suggest-action "1.5.1") +(defalias 'helm-c-elisp-library-scan-init 'helm-elisp-library-scan-init) +(make-obsolete 'helm-c-elisp-library-scan-init 'helm-elisp-library-scan-init "1.5.1") +(defalias 'helm-c-apt-refresh 'helm-apt-refresh) +(make-obsolete 'helm-c-apt-refresh 'helm-apt-refresh "1.5.1") +(defalias 'helm-c-kill-regexp 'helm-kill-regexp) +(make-obsolete 'helm-c-kill-regexp 'helm-kill-regexp "1.5.1") +(defalias 'helm-c-grep-buffers-1 'helm-grep-buffers-1) +(make-obsolete 'helm-c-grep-buffers-1 'helm-grep-buffers-1 "1.5.1") +(defalias 'helm-c-adaptative-store-selection 'helm-adaptive-store-selection) +(make-obsolete 'helm-c-adaptative-store-selection 'helm-adaptive-store-selection "1.5.1") +(defalias 'helm-c-browse-url 'helm-browse-url) +(make-obsolete 'helm-c-browse-url 'helm-browse-url "1.5.1") +(defalias 'helm-c-google-suggest-emacs-lisp 'helm-google-suggest-emacs-lisp) +(make-obsolete 'helm-c-google-suggest-emacs-lisp 'helm-google-suggest-emacs-lisp "1.5.1") +(defalias 'helm-c-ucs-persistent-insert 'helm-ucs-persistent-insert) +(make-obsolete 'helm-c-ucs-persistent-insert 'helm-ucs-persistent-insert "1.5.1") +(defalias 'helm-c-xrandr-output 'helm-xrandr-output) +(make-obsolete 'helm-c-xrandr-output 'helm-xrandr-output "1.5.1") +(defalias 'helm-c-kill-ring-action 'helm-kill-ring-action) +(make-obsolete 'helm-c-kill-ring-action 'helm-kill-ring-action "1.5.1") +(defalias 'helm-c-org-keywords-candidates 'helm-org-keywords-candidates) +(make-obsolete 'helm-c-org-keywords-candidates 'helm-org-keywords-candidates "1.5.1") +(defalias 'helm-c-bookmark-jump 'helm-bookmark-jump) +(make-obsolete 'helm-c-bookmark-jump 'helm-bookmark-jump "1.5.1") +(defalias 'helm-c-shadow-boring-buffers 'helm-shadow-boring-buffers) +(make-obsolete 'helm-c-shadow-boring-buffers 'helm-shadow-boring-buffers "1.5.1") +(defalias 'helm-c-buffer-match-major-mode 'helm-buffer-match-major-mode) +(make-obsolete 'helm-c-buffer-match-major-mode 'helm-buffer-match-major-mode "1.5.1") +(defalias 'helm-c-highlight-bookmark-su 'helm-highlight-bookmark-su) +(make-obsolete 'helm-c-highlight-bookmark-su 'helm-highlight-bookmark-su "1.5.1") +(defalias 'helm-c-grep-other-frame 'helm-grep-other-frame) +(make-obsolete 'helm-c-grep-other-frame 'helm-grep-other-frame "1.5.1") +(defalias 'helm-c-jabber-online-contacts 'helm-jabber-online-contacts) +(make-obsolete 'helm-c-jabber-online-contacts 'helm-jabber-online-contacts "1.5.1") +(defalias 'helm-c-apt-purge 'helm-apt-purge) +(make-obsolete 'helm-c-apt-purge 'helm-apt-purge "1.5.1") +(defalias 'helm-c-adaptative-sort 'helm-adaptive-sort) +(make-obsolete 'helm-c-adaptative-sort 'helm-adaptive-sort "1.5.1") +(defalias 'helm-c-bmkext-addressbook-setup-alist 'helm-bmkext-addressbook-setup-alist) +(make-obsolete 'helm-c-bmkext-addressbook-setup-alist 'helm-bmkext-addressbook-setup-alist "1.5.1") +(defalias 'helm-c-bmkext-filter-setup-alist 'helm-bmkext-filter-setup-alist) +(make-obsolete 'helm-c-bmkext-filter-setup-alist 'helm-bmkext-filter-setup-alist "1.5.1") +(defalias 'helm-c-grep-buffers 'helm-grep-buffers) +(make-obsolete 'helm-c-grep-buffers 'helm-grep-buffers "1.5.1") +(defalias 'helm-c-apt-init 'helm-apt-init) +(make-obsolete 'helm-c-apt-init 'helm-apt-init "1.5.1") +(defalias 'helm-c-grep-run-save-buffer 'helm-grep-run-save-buffer) +(make-obsolete 'helm-c-grep-run-save-buffer 'helm-grep-run-save-buffer "1.5.1") +(defalias 'helm-c-ggs-set-number-result 'helm-ggs-set-number-result) +(make-obsolete 'helm-c-ggs-set-number-result 'helm-ggs-set-number-result "1.5.1") +(defalias 'helm-c-grep-prepare-candidates 'helm-grep-prepare-candidates) +(make-obsolete 'helm-c-grep-prepare-candidates 'helm-grep-prepare-candidates "1.5.1") +(defalias 'helm-c-grep-jump-elscreen 'helm-grep-jump-elscreen) +(make-obsolete 'helm-c-grep-jump-elscreen 'helm-grep-jump-elscreen "1.5.1") +(defalias 'helm-c-show-completion-display-function 'helm-show-completion-display-function) +(make-obsolete 'helm-c-show-completion-display-function 'helm-show-completion-display-function "1.5.1") +(defalias 'helm-c-find-variable 'helm-find-variable) +(make-obsolete 'helm-c-find-variable 'helm-find-variable "1.5.1") +(defalias 'helm-c-build-elvi-list 'helm-build-elvi-list) +(make-obsolete 'helm-c-build-elvi-list 'helm-build-elvi-list "1.5.1") +(defalias 'helm-c-advice-toggle 'helm-advice-toggle) +(make-obsolete 'helm-c-advice-toggle 'helm-advice-toggle "1.5.1") +(defalias 'helm-c-buffers-persistent-kill 'helm-buffers-persistent-kill) +(make-obsolete 'helm-c-buffers-persistent-kill 'helm-buffers-persistent-kill "1.5.1") +(defalias 'helm-c-register-action-transformer 'helm-register-action-transformer) +(make-obsolete 'helm-c-register-action-transformer 'helm-register-action-transformer "1.5.1") +(defalias 'helm-c-kill-ring-candidates 'helm-kill-ring-candidates) +(make-obsolete 'helm-c-kill-ring-candidates 'helm-kill-ring-candidates "1.5.1") +(defalias 'helm-c-generic-browser 'helm-generic-browser) +(make-obsolete 'helm-c-generic-browser 'helm-generic-browser "1.5.1") +(defalias 'helm-c-top-init 'helm-top-init) +(make-obsolete 'helm-c-top-init 'helm-top-init "1.5.1") +(defalias 'helm-c-ucs-delete-backward 'helm-ucs-delete-backward) +(make-obsolete 'helm-c-ucs-delete-backward 'helm-ucs-delete-backward "1.5.1") +(defalias 'helm-c-apt-generic-action 'helm-apt-generic-action) +(make-obsolete 'helm-c-apt-generic-action 'helm-apt-generic-action "1.5.1") +(defalias 'helm-c-pdfgrep-action-1 'helm-pdfgrep-action-1) +(make-obsolete 'helm-c-pdfgrep-action-1 'helm-pdfgrep-action-1 "1.5.1") +(defalias 'helm-c-buffer-query-replace-regexp 'helm-buffer-query-replace-regexp) +(make-obsolete 'helm-c-buffer-query-replace-regexp 'helm-buffer-query-replace-regexp "1.5.1") +(defalias 'helm-c-apropos-init 'helm-apropos-init) +(make-obsolete 'helm-c-apropos-init 'helm-apropos-init "1.5.1") +(defalias 'helm-c-kill-new 'helm-kill-new) +(make-obsolete 'helm-c-kill-new 'helm-kill-new "1.5.1") +(defalias 'helm-c-bookmark-gnus-setup-alist 'helm-bookmark-gnus-setup-alist) +(make-obsolete 'helm-c-bookmark-gnus-setup-alist 'helm-bookmark-gnus-setup-alist "1.5.1") +(defalias 'helm-c-quit-and-execute-action 'helm-quit-and-execute-action) +(make-obsolete 'helm-c-quit-and-execute-action 'helm-quit-and-execute-action "1.5.1") +(defalias 'helm-c-build-info-index-command 'helm-build-info-index-command) +(make-obsolete 'helm-c-build-info-index-command 'helm-build-info-index-command "1.5.1") +(defalias 'helm-c-ratpoison-commands-init 'helm-ratpoison-commands-init) +(make-obsolete 'helm-c-ratpoison-commands-init 'helm-ratpoison-commands-init "1.5.1") +(defalias 'helm-c-etags-select 'helm-etags-select) +(make-obsolete 'helm-c-etags-select 'helm-etags-select "1.5.1") +(defalias 'helm-c-etags-create-buffer 'helm-etags-create-buffer) +(make-obsolete 'helm-c-etags-create-buffer 'helm-etags-create-buffer "1.5.1") +(defalias 'helm-c-yahoo-suggest-set-candidates 'helm-yahoo-suggest-set-candidates) +(make-obsolete 'helm-c-yahoo-suggest-set-candidates 'helm-yahoo-suggest-set-candidates "1.5.1") +(defalias 'helm-c-org-keywords-show-help 'helm-org-keywords-show-help) +(make-obsolete 'helm-c-org-keywords-show-help 'helm-org-keywords-show-help "1.5.1") +(defalias 'helm-c-highlight-files 'helm-highlight-files) +(make-obsolete 'helm-c-highlight-files 'helm-highlight-files "1.5.1") +(defalias 'helm-c-get-pid-from-process-name 'helm-get-pid-from-process-name) +(make-obsolete 'helm-c-get-pid-from-process-name 'helm-get-pid-from-process-name "1.5.1") +(defalias 'helm-c-insert-latex-math 'helm-insert-latex-math) +(make-obsolete 'helm-c-insert-latex-math 'helm-insert-latex-math "1.5.1") +(defalias 'helm-c-buffer-query-replace 'helm-buffer-query-replace) +(make-obsolete 'helm-c-buffer-query-replace 'helm-buffer-query-replace "1.5.1") +(defalias 'helm-c-bmkext-run-edit 'helm-bmkext-run-edit) +(make-obsolete 'helm-c-bmkext-run-edit 'helm-bmkext-run-edit "1.5.1") +(defalias 'helm-c-skip-boring-files 'helm-skip-boring-files) +(make-obsolete 'helm-c-skip-boring-files 'helm-skip-boring-files "1.5.1") +(defalias 'helm-c-transform-file-load-el 'helm-transform-file-load-el) +(make-obsolete 'helm-c-transform-file-load-el 'helm-transform-file-load-el "1.5.1") +(defalias 'helm-c-ucs-insert-char 'helm-ucs-insert-char) +(make-obsolete 'helm-c-ucs-insert-char 'helm-ucs-insert-char "1.5.1") +(defalias 'helm-c-buffer-help 'helm-buffer-help) +(make-obsolete 'helm-c-buffer-help 'helm-buffer-help "1.5.1") +(defalias 'helm-c-current-directory 'helm-current-directory) +(make-obsolete 'helm-c-current-directory 'helm-current-directory "1.5.1") +(defalias 'helm-c-find-file-or-marked 'helm-find-file-or-marked) +(make-obsolete 'helm-c-find-file-or-marked 'helm-find-file-or-marked "1.5.1") +(defalias 'helm-c-query-replace-regexp 'helm-query-replace-regexp) +(make-obsolete 'helm-c-query-replace-regexp 'helm-query-replace-regexp "1.5.1") +(defalias 'helm-c-describe-variable 'helm-describe-variable) +(make-obsolete 'helm-c-describe-variable 'helm-describe-variable "1.5.1") +(defalias 'helm-c-advice-persistent-action 'helm-advice-persistent-action) +(make-obsolete 'helm-c-advice-persistent-action 'helm-advice-persistent-action "1.5.1") +(defalias 'helm-c-show-completion 'helm-show-completion) +(make-obsolete 'helm-c-show-completion 'helm-show-completion "1.5.1") +(defalias 'helm-c-google-suggest-set-candidates 'helm-google-suggest-set-candidates) +(make-obsolete 'helm-c-google-suggest-set-candidates 'helm-google-suggest-set-candidates "1.5.1") +(defalias 'helm-c-grep-persistent-action 'helm-grep-persistent-action) +(make-obsolete 'helm-c-grep-persistent-action 'helm-grep-persistent-action "1.5.1") +(defalias 'helm-c-open-file-with-default-tool 'helm-open-file-with-default-tool) +(make-obsolete 'helm-c-open-file-with-default-tool 'helm-open-file-with-default-tool "1.5.1") +(defalias 'helm-c-run-external-command 'helm-run-external-command) +(make-obsolete 'helm-c-run-external-command 'helm-run-external-command "1.5.1") +(defalias 'helm-c-bookmark-images-setup-alist 'helm-bookmark-images-setup-alist) +(make-obsolete 'helm-c-bookmark-images-setup-alist 'helm-bookmark-images-setup-alist "1.5.1") +(defalias 'helm-c-apt-candidate-transformer 'helm-apt-candidate-transformer) +(make-obsolete 'helm-c-apt-candidate-transformer 'helm-apt-candidate-transformer "1.5.1") +(defalias 'helm-c-grep-run-persistent-action 'helm-grep-run-persistent-action) +(make-obsolete 'helm-c-grep-run-persistent-action 'helm-grep-run-persistent-action "1.5.1") +(defalias 'helm-c-highlight-buffers 'helm-highlight-buffers) +(make-obsolete 'helm-c-highlight-buffers 'helm-highlight-buffers "1.5.1") +(defalias 'helm-c-man-default-action 'helm-man-default-action) +(make-obsolete 'helm-c-man-default-action 'helm-man-default-action "1.5.1") +(defalias 'helm-c-advice-candidates 'helm-advice-candidates) +(make-obsolete 'helm-c-advice-candidates 'helm-advice-candidates "1.5.1") +(defalias 'helm-c-stumpwm-commands-execute 'helm-stumpwm-commands-execute) +(make-obsolete 'helm-c-stumpwm-commands-execute 'helm-stumpwm-commands-execute "1.5.1") +(defalias 'helm-c-ucs-help 'helm-ucs-help) +(make-obsolete 'helm-c-ucs-help 'helm-ucs-help "1.5.1") +(defalias 'helm-c-apt-uninstall 'helm-apt-uninstall) +(make-obsolete 'helm-c-apt-uninstall 'helm-apt-uninstall "1.5.1") +(defalias 'helm-c-bookmark-run-jump-other-window 'helm-bookmark-run-jump-other-window) +(make-obsolete 'helm-c-bookmark-run-jump-other-window 'helm-bookmark-run-jump-other-window "1.5.1") +(defalias 'helm-c-elisp-library-scan-list 'helm-elisp-library-scan-list) +(make-obsolete 'helm-c-elisp-library-scan-list 'helm-elisp-library-scan-list "1.5.1") +(defalias 'helm-c-bookmark-man-setup-alist 'helm-bookmark-man-setup-alist) +(make-obsolete 'helm-c-bookmark-man-setup-alist 'helm-bookmark-man-setup-alist "1.5.1") +(defalias 'helm-c-etags-find-tag-file-directory 'helm-etags-find-tag-file-directory) +(make-obsolete 'helm-c-etags-find-tag-file-directory 'helm-etags-find-tag-file-directory "1.5.1") +(defalias 'helm-c-xrandr-info 'helm-xrandr-info) +(make-obsolete 'helm-c-xrandr-info 'helm-xrandr-info "1.5.1") +(defalias 'helm-c-stringify 'helm-stringify) +(make-obsolete 'helm-c-stringify 'helm-stringify "1.5.1") +(defalias 'helm-c-goto-precedent-file 'helm-goto-precedent-file) +(make-obsolete 'helm-c-goto-precedent-file 'helm-goto-precedent-file "1.5.1") +(defalias 'helm-c-apt-cache-show 'helm-apt-cache-show) +(make-obsolete 'helm-c-apt-cache-show 'helm-apt-cache-show "1.5.1") +(defalias 'helm-c-etags-file-modified-p 'helm-etags-file-modified-p) +(make-obsolete 'helm-c-etags-file-modified-p 'helm-etags-file-modified-p "1.5.1") +(defalias 'helm-c-etags-get-tag-file 'helm-etags-get-tag-file) +(make-obsolete 'helm-c-etags-get-tag-file 'helm-etags-get-tag-file "1.5.1") +(defalias 'helm-c-highlight-not-logged 'helm-highlight-not-logged) +(make-obsolete 'helm-c-highlight-not-logged 'helm-highlight-not-logged "1.5.1") +(defalias 'helm-c-pdfgrep-action 'helm-pdfgrep-action) +(make-obsolete 'helm-c-pdfgrep-action 'helm-pdfgrep-action "1.5.1") +(defalias 'helm-c-adaptative-save-history 'helm-adaptive-save-history) +(make-obsolete 'helm-c-adaptative-save-history 'helm-adaptive-save-history "1.5.1") +(defalias 'helm-c-get-first-line-documentation 'helm-get-first-line-documentation) +(make-obsolete 'helm-c-get-first-line-documentation 'helm-get-first-line-documentation "1.5.1") +(defalias 'helm-approximate-candidate-number 'helm-get-candidate-number) +(make-obsolete 'helm-approximate-candidate-number 'helm-get-candidate-number "1.5.5") +(defalias 'helm-org-headlines 'helm-org-in-buffer-headings) +(make-obsolete 'helm-org-headlines 'helm-org-in-buffer-headings "1.6.5") + + +;;; variables +;; +;; + + +(defvaralias 'helm-c-pdfgrep-default-command 'helm-pdfgrep-default-command) +(make-obsolete-variable 'helm-c-pdfgrep-default-command 'helm-pdfgrep-default-command "1.5.1") +(defvaralias 'helm-c-source-time-world 'helm-source-time-world) +(make-obsolete-variable 'helm-c-source-time-world 'helm-source-time-world "1.5.1") +(defvaralias 'helm-c-grep-default-command 'helm-grep-default-command) +(make-obsolete-variable 'helm-c-grep-default-command 'helm-grep-default-command "1.5.1") +(defvaralias 'helm-c-default-info-index-list 'helm-default-info-index-list) +(make-obsolete-variable 'helm-c-default-info-index-list 'helm-default-info-index-list "1.5.1") +(defvaralias 'helm-c-etags-tag-file-dir 'helm-etags-tag-file-dir) +(make-obsolete-variable 'helm-c-etags-tag-file-dir 'helm-etags-tag-file-dir "1.5.1") +(defvaralias 'helm-c-source-man-pages 'helm-source-man-pages) +(make-obsolete-variable 'helm-c-source-man-pages 'helm-source-man-pages "1.5.1") +(defvaralias 'helm-c-source-bookmark-info 'helm-source-bookmark-info) +(make-obsolete-variable 'helm-c-source-bookmark-info 'helm-source-bookmark-info "1.5.1") +(defvaralias 'helm-c-file-cache-files 'helm-file-cache-files) +(make-obsolete-variable 'helm-c-file-cache-files 'helm-file-cache-files "1.5.1") +(defvaralias 'helm-c-ucs-map 'helm-ucs-map) +(make-obsolete-variable 'helm-c-ucs-map 'helm-ucs-map "1.5.1") +(defvaralias 'helm-c-show-completion-min-window-height 'helm-show-completion-min-window-height) +(make-obsolete-variable 'helm-c-show-completion-min-window-height 'helm-show-completion-min-window-height "1.5.1") +(defvaralias 'helm-c-adaptative-history 'helm-adaptive-history) +(make-obsolete-variable 'helm-c-adaptative-history 'helm-adaptive-history "1.5.1") +(defvaralias 'helm-c-source-bookmarks-local 'helm-source-bookmarks-local) +(make-obsolete-variable 'helm-c-source-bookmarks-local 'helm-source-bookmarks-local "1.5.1") +(defvaralias 'helm-c-grep-map 'helm-grep-map) +(make-obsolete-variable 'helm-c-grep-map 'helm-grep-map "1.5.1") +(defvaralias 'helm-c-source-session 'helm-source-session) +(make-obsolete-variable 'helm-c-source-session 'helm-source-session "1.5.1") +(defvaralias 'helm-c-source-minibuffer-history 'helm-source-minibuffer-history) +(make-obsolete-variable 'helm-c-source-minibuffer-history 'helm-source-minibuffer-history "1.5.1") +(defvaralias 'helm-c-source-files-in-current-dir 'helm-source-files-in-current-dir) +(make-obsolete-variable 'helm-c-source-files-in-current-dir 'helm-source-files-in-current-dir "1.5.1") +(defvaralias 'helm-c-source-etags-select 'helm-source-etags-select) +(make-obsolete-variable 'helm-c-source-etags-select 'helm-source-etags-select "1.5.1") +(defvaralias 'helm-c-show-completion-overlay 'helm-show-completion-overlay) +(make-obsolete-variable 'helm-c-show-completion-overlay 'helm-show-completion-overlay "1.5.1") +(defvaralias 'helm-c-buffer-help-message 'helm-buffer-help-message) +(make-obsolete-variable 'helm-c-buffer-help-message 'helm-buffer-help-message "1.5.1") +(defvaralias 'helm-c-ucs-max-len 'helm-ucs-max-len) +(make-obsolete-variable 'helm-c-ucs-max-len 'helm-ucs-max-len "1.5.1") +(defvaralias 'helm-c-imenu-index-filter 'helm-imenu-index-filter) +(make-obsolete-variable 'helm-c-imenu-index-filter 'helm-imenu-index-filter "1.5.1") +(defvaralias 'helm-c-org-keywords-info-location 'helm-org-keywords-info-location) +(make-obsolete-variable 'helm-c-org-keywords-info-location 'helm-org-keywords-info-location "1.5.1") +(defvaralias 'helm-c-kill-ring-max-lines-number 'helm-kill-ring-max-lines-number) +(make-obsolete-variable 'helm-c-kill-ring-max-lines-number 'helm-kill-ring-max-lines-number "1.5.1") +(defvaralias 'helm-c-source-apt 'helm-source-apt) +(make-obsolete-variable 'helm-c-source-apt 'helm-source-apt "1.5.1") +(defvaralias 'helm-c-bookmark-map 'helm-bookmark-map) +(make-obsolete-variable 'helm-c-bookmark-map 'helm-bookmark-map "1.5.1") +(defvaralias 'helm-c-source-xfonts 'helm-source-xfonts) +(make-obsolete-variable 'helm-c-source-xfonts 'helm-source-xfonts "1.5.1") +(defvaralias 'helm-c-source-kill-ring 'helm-source-kill-ring) +(make-obsolete-variable 'helm-c-source-kill-ring 'helm-source-kill-ring "1.5.1") +(defvaralias 'helm-c-home-url 'helm-home-url) +(make-obsolete-variable 'helm-c-home-url 'helm-home-url "1.5.1") +(defvaralias 'helm-c-etags-cache 'helm-etags-cache) +(make-obsolete-variable 'helm-c-etags-cache 'helm-etags-cache "1.5.1") +(defvaralias 'helm-c-source-latex-math 'helm-source-latex-math) +(make-obsolete-variable 'helm-c-source-latex-math 'helm-source-latex-math "1.5.1") +(defvaralias 'helm-c-source-bookmark-files&dirs 'helm-source-bookmark-files&dirs) +(make-obsolete-variable 'helm-c-source-bookmark-files&dirs 'helm-source-bookmark-files&dirs "1.5.1") +(defvaralias 'helm-c-source-ratpoison-commands 'helm-source-ratpoison-commands) +(make-obsolete-variable 'helm-c-source-ratpoison-commands 'helm-source-ratpoison-commands "1.5.1") +(defvaralias 'helm-c-apt-show-command 'helm-apt-show-command) +(make-obsolete-variable 'helm-c-apt-show-command 'helm-apt-show-command "1.5.1") +(defvaralias 'helm-c-pdfgrep-default-function 'helm-pdfgrep-default-function) +(make-obsolete-variable 'helm-c-pdfgrep-default-function 'helm-pdfgrep-default-function "1.5.1") +(defvaralias 'helm-c-source-register 'helm-source-register) +(make-obsolete-variable 'helm-c-source-register 'helm-source-register "1.5.1") +(defvaralias 'helm-c-boring-buffer-regexp-list 'helm-boring-buffer-regexp-list) +(make-obsolete-variable 'helm-c-boring-buffer-regexp-list 'helm-boring-buffer-regexp-list "1.5.1") +(defvaralias 'helm-c-source-locate 'helm-source-locate) +(make-obsolete-variable 'helm-c-source-locate 'helm-source-locate "1.5.1") +(defvaralias 'helm-c-source-advice 'helm-source-advice) +(make-obsolete-variable 'helm-c-source-advice 'helm-source-advice "1.5.1") +(defvaralias 'helm-c-source-yaoddmuse-emacswiki-edit-or-view 'helm-source-yaoddmuse-emacswiki-edit-or-view) +(defvaralias 'helm-c-ucs-mode-line-string 'helm-ucs-mode-line-string) +(make-obsolete-variable 'helm-c-ucs-mode-line-string 'helm-ucs-mode-line-string "1.5.1") +(defvaralias 'helm-c-xfonts-cache 'helm-xfonts-cache) +(make-obsolete-variable 'helm-c-xfonts-cache 'helm-xfonts-cache "1.5.1") +(defvaralias 'helm-c-source-yahoo-suggest 'helm-source-yahoo-suggest) +(make-obsolete-variable 'helm-c-source-yahoo-suggest 'helm-source-yahoo-suggest "1.5.1") +(defvaralias 'helm-c-rzgrep-cache 'helm-rzgrep-cache) +(make-obsolete-variable 'helm-c-rzgrep-cache 'helm-rzgrep-cache "1.5.1") +(defvaralias 'helm-c-source-org-keywords 'helm-source-org-keywords) +(make-obsolete-variable 'helm-c-source-org-keywords 'helm-source-org-keywords "1.5.1") +(defvaralias 'helm-c-pdfgrep-map 'helm-pdfgrep-map) +(make-obsolete-variable 'helm-c-pdfgrep-map 'helm-pdfgrep-map "1.5.1") +(defvaralias 'helm-c-source-lacarte 'helm-source-lacarte) +(make-obsolete-variable 'helm-c-source-lacarte 'helm-source-lacarte "1.5.1") +(defvaralias 'helm-c-apt-search-command 'helm-apt-search-command) +(make-obsolete-variable 'helm-c-apt-search-command 'helm-apt-search-command "1.5.1") +(defvaralias 'helm-c-default-external-file-browser 'helm-default-external-file-browser) +(make-obsolete-variable 'helm-c-default-external-file-browser 'helm-default-external-file-browser "1.5.1") +(defvaralias 'helm-c-source-evaluation-result 'helm-source-evaluation-result) +(make-obsolete-variable 'helm-c-source-evaluation-result 'helm-source-evaluation-result "1.5.1") +(defvaralias 'helm-c-yahoo-suggest-search-url 'helm-yahoo-suggest-search-url) +(make-obsolete-variable 'helm-c-yahoo-suggest-search-url 'helm-yahoo-suggest-search-url "1.5.1") +(defvaralias 'helm-c-source-occur 'helm-source-occur) +(make-obsolete-variable 'helm-c-source-occur 'helm-source-occur "1.5.1") +(defvaralias 'helm-c-source-calculation-result 'helm-source-calculation-result) +(make-obsolete-variable 'helm-c-source-calculation-result 'helm-source-calculation-result "1.5.1") +(defvaralias 'helm-c-default-zgrep-command 'helm-default-zgrep-command) +(make-obsolete-variable 'helm-c-default-zgrep-command 'helm-default-zgrep-command "1.5.1") +(defvaralias 'helm-c-show-info-in-mode-line-delay 'helm-show-info-in-mode-line-delay) +(make-obsolete-variable 'helm-c-show-info-in-mode-line-delay 'helm-show-info-in-mode-line-delay "1.5.1") +(defvaralias 'helm-c-source-ido-virtual-buffers 'helm-source-ido-virtual-buffers) +(make-obsolete-variable 'helm-c-source-ido-virtual-buffers 'helm-source-ido-virtual-buffers "1.5.1") +(defvaralias 'helm-c-source-top 'helm-source-top) +(make-obsolete-variable 'helm-c-source-top 'helm-source-top "1.5.1") +(defvaralias 'helm-c-source-colors 'helm-source-colors) +(make-obsolete-variable 'helm-c-source-colors 'helm-source-colors "1.5.1") +(defvaralias 'helm-c-read-file-map 'helm-read-file-map) +(make-obsolete-variable 'helm-c-read-file-map 'helm-read-file-map "1.5.1") +(defvaralias 'helm-c-source-file-cache 'helm-source-file-cache) +(make-obsolete-variable 'helm-c-source-file-cache 'helm-source-file-cache "1.5.1") +(defvaralias 'helm-c-google-suggest-default-browser-function 'helm-google-suggest-default-browser-function) +(make-obsolete-variable 'helm-c-google-suggest-default-browser-function 'helm-google-suggest-default-browser-function "1.5.1") +(defvaralias 'helm-c-external-programs-associations 'helm-external-programs-associations) +(make-obsolete-variable 'helm-c-external-programs-associations 'helm-external-programs-associations "1.5.1") +(defvaralias 'helm-c-source-complex-command-history 'helm-source-complex-command-history) +(make-obsolete-variable 'helm-c-source-complex-command-history 'helm-source-complex-command-history "1.5.1") +(defvaralias 'helm-c-cached-imenu-candidates 'helm-cached-imenu-candidates) +(make-obsolete-variable 'helm-c-cached-imenu-candidates 'helm-cached-imenu-candidates "1.5.1") +(defvaralias 'helm-c-external-commands-list 'helm-external-commands-list) +(make-obsolete-variable 'helm-c-external-commands-list 'helm-external-commands-list "1.5.1") +(defvaralias 'helm-c-source-ucs 'helm-source-ucs) +(make-obsolete-variable 'helm-c-source-ucs 'helm-source-ucs "1.5.1") +(defvaralias 'helm-c-adaptative-history-length 'helm-adaptive-history-length) +(make-obsolete-variable 'helm-c-adaptative-history-length 'helm-adaptive-history-length "1.5.1") +(defvaralias 'helm-c-source-customize-face 'helm-source-customize-face) +(make-obsolete-variable 'helm-c-source-customize-face 'helm-source-customize-face "1.5.1") +(defvaralias 'helm-c-source-bookmarks-ssh 'helm-source-bookmarks-ssh) +(make-obsolete-variable 'helm-c-source-bookmarks-ssh 'helm-source-bookmarks-ssh "1.5.1") +(defvaralias 'helm-c-eldoc-in-minibuffer-show-fn 'helm-eldoc-in-minibuffer-show-fn) +(make-obsolete-variable 'helm-c-eldoc-in-minibuffer-show-fn 'helm-eldoc-in-minibuffer-show-fn "1.5.1") +(defvaralias 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url) +(make-obsolete-variable 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url "1.5.1") +(defvaralias 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook) +(make-obsolete-variable 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook "1.5.1") +(defvaralias 'helm-c-source-ctags 'helm-source-ctags) +(make-obsolete-variable 'helm-c-source-ctags 'helm-source-ctags "1.5.1") +(defvaralias 'helm-c-apt-installed-packages 'helm-apt-installed-packages) +(make-obsolete-variable 'helm-c-apt-installed-packages 'helm-apt-installed-packages "1.5.1") +(defvaralias 'helm-c-apt-all-packages 'helm-apt-all-packages) +(make-obsolete-variable 'helm-c-apt-all-packages 'helm-apt-all-packages "1.5.1") +(defvaralias 'helm-c-find-files-doc-header 'helm-find-files-doc-header) +(make-obsolete-variable 'helm-c-find-files-doc-header 'helm-find-files-doc-header "1.5.1") +(defvaralias 'helm-c-source-imenu 'helm-source-imenu) +(make-obsolete-variable 'helm-c-source-imenu 'helm-source-imenu "1.5.1") +(defvaralias 'helm-c-grep-default-function 'helm-grep-default-function) +(make-obsolete-variable 'helm-c-grep-default-function 'helm-grep-default-function "1.5.1") +(defvaralias 'helm-c-top-command 'helm-top-command) +(make-obsolete-variable 'helm-c-top-command 'helm-top-command "1.5.1") +(defvaralias 'helm-c-source-bookmark-man 'helm-source-bookmark-man) +(make-obsolete-variable 'helm-c-source-bookmark-man 'helm-source-bookmark-man "1.5.1") +(defvaralias 'helm-c-source-stumpwm-commands 'helm-source-stumpwm-commands) +(make-obsolete-variable 'helm-c-source-stumpwm-commands 'helm-source-stumpwm-commands "1.5.1") +(defvaralias 'helm-c-source-idle-time-timers 'helm-source-idle-time-timers) +(make-obsolete-variable 'helm-c-source-idle-time-timers 'helm-source-idle-time-timers "1.5.1") +(defvaralias 'helm-c-turn-on-show-completion 'helm-turn-on-show-completion) +(make-obsolete-variable 'helm-c-turn-on-show-completion 'helm-turn-on-show-completion "1.5.1") +(defvaralias 'helm-c-esh-help-message 'helm-esh-help-message) +(make-obsolete-variable 'helm-c-esh-help-message 'helm-esh-help-message "1.5.1") +(defvaralias 'helm-c-register-max-offset 'helm-register-max-offset) +(make-obsolete-variable 'helm-c-register-max-offset 'helm-register-max-offset "1.5.1") +(defvaralias 'helm-c-source-bookmark-set 'helm-source-bookmark-set) +(make-obsolete-variable 'helm-c-source-bookmark-set 'helm-source-bookmark-set "1.5.1") +(defvaralias 'helm-c-source-file-name-history 'helm-source-file-name-history) +(make-obsolete-variable 'helm-c-source-file-name-history 'helm-source-file-name-history "1.5.1") +(defvaralias 'helm-c-file-cache-initialized-p 'helm-file-cache-initialized-p) +(make-obsolete-variable 'helm-c-file-cache-initialized-p 'helm-file-cache-initialized-p "1.5.1") +(defvaralias 'helm-c-grep-max-length-history 'helm-grep-max-length-history) +(make-obsolete-variable 'helm-c-grep-max-length-history 'helm-grep-max-length-history "1.5.1") +(defvaralias 'helm-c-source-jabber-contacts 'helm-source-jabber-contacts) +(make-obsolete-variable 'helm-c-source-jabber-contacts 'helm-source-jabber-contacts "1.5.1") +(defvaralias 'helm-c-grep-use-ioccur-style-keys 'helm-grep-use-ioccur-style-keys) +(make-obsolete-variable 'helm-c-grep-use-ioccur-style-keys 'helm-grep-use-ioccur-style-keys "1.5.1") +(defvaralias 'helm-c-ctags-modes 'helm-ctags-modes) +(make-obsolete-variable 'helm-c-ctags-modes 'helm-ctags-modes "1.5.1") +(defvaralias 'helm-c-source-moccur 'helm-source-moccur) +(make-obsolete-variable 'helm-c-source-moccur 'helm-source-moccur "1.5.1") +(defvaralias 'helm-c-locate-command 'helm-locate-command) +(make-obsolete-variable 'helm-c-locate-command 'helm-locate-command "1.5.1") +(defvaralias 'helm-c-etags-tag-file-name 'helm-etags-tag-file-name) +(make-obsolete-variable 'helm-c-etags-tag-file-name 'helm-etags-tag-file-name "1.5.1") +(defvaralias 'helm-c-source-bookmarks-su 'helm-source-bookmarks-su) +(make-obsolete-variable 'helm-c-source-bookmarks-su 'helm-source-bookmarks-su "1.5.1") +(defvaralias 'helm-c-buffer-map 'helm-buffer-map) +(make-obsolete-variable 'helm-c-buffer-map 'helm-buffer-map "1.5.1") +(defvaralias 'helm-c-source-files-in-all-dired 'helm-source-files-in-all-dired) +(make-obsolete-variable 'helm-c-source-files-in-all-dired 'helm-source-files-in-all-dired "1.5.1") +(defvaralias 'helm-c-source-eshell-history 'helm-source-eshell-history) +(make-obsolete-variable 'helm-c-source-eshell-history 'helm-source-eshell-history "1.5.1") +(defvaralias 'helm-c-source-absolute-time-timers 'helm-source-absolute-time-timers) +(make-obsolete-variable 'helm-c-source-absolute-time-timers 'helm-source-absolute-time-timers "1.5.1") +(defvaralias 'helm-c-source-findutils 'helm-source-findutils) +(make-obsolete-variable 'helm-c-source-findutils 'helm-source-findutils "1.5.1") +(defvaralias 'helm-c-ucs-help-message 'helm-ucs-help-message) +(make-obsolete-variable 'helm-c-ucs-help-message 'helm-ucs-help-message "1.5.1") +(defvaralias 'helm-c-source-find-files 'helm-source-find-files) +(make-obsolete-variable 'helm-c-source-find-files 'helm-source-find-files "1.5.1") +(defvaralias 'helm-c-source-recentf 'helm-source-recentf) +(make-obsolete-variable 'helm-c-source-recentf 'helm-source-recentf "1.5.1") +(defvaralias 'helm-c-cache-world 'helm-cache-world) +(make-obsolete-variable 'helm-c-cache-world 'helm-cache-world "1.5.1") +(defvaralias 'helm-c-source-picklist 'helm-source-picklist) +(make-obsolete-variable 'helm-c-source-picklist 'helm-source-picklist "1.5.1") +(defvaralias 'helm-c-source-buffer-not-found 'helm-source-buffer-not-found) +(make-obsolete-variable 'helm-c-source-buffer-not-found 'helm-source-buffer-not-found "1.5.1") +(defvaralias 'helm-c-source-xrandr-change-resolution 'helm-source-xrandr-change-resolution) +(make-obsolete-variable 'helm-c-source-xrandr-change-resolution 'helm-source-xrandr-change-resolution "1.5.1") +(defvaralias 'helm-c-google-suggest-url 'helm-google-suggest-url) +(make-obsolete-variable 'helm-c-google-suggest-url 'helm-google-suggest-url "1.5.1") +(defvaralias 'helm-c-source-semantic 'helm-source-semantic) +(make-obsolete-variable 'helm-c-source-semantic 'helm-source-semantic "1.5.1") +(defvaralias 'helm-c-source-mark-ring 'helm-source-mark-ring) +(make-obsolete-variable 'helm-c-source-mark-ring 'helm-source-mark-ring "1.5.1") +(defvaralias 'helm-c-grep-preferred-ext 'helm-grep-preferred-ext) +(make-obsolete-variable 'helm-c-grep-preferred-ext 'helm-grep-preferred-ext "1.5.1") +(defvaralias 'helm-c-source-bookmarks 'helm-source-bookmarks) +(make-obsolete-variable 'helm-c-source-bookmarks 'helm-source-bookmarks "1.5.1") +(defvaralias 'helm-c-source-elisp-library-scan 'helm-source-elisp-library-scan) +(make-obsolete-variable 'helm-c-source-elisp-library-scan 'helm-source-elisp-library-scan "1.5.1") +(defvaralias 'helm-c-source-info-pages 'helm-source-info-pages) +(make-obsolete-variable 'helm-c-source-info-pages 'helm-source-info-pages "1.5.1") +(defvaralias 'helm-c-source-bookmark-gnus 'helm-source-bookmark-gnus) +(make-obsolete-variable 'helm-c-source-bookmark-gnus 'helm-source-bookmark-gnus "1.5.1") +(defvaralias 'helm-c-source-elscreen 'helm-source-elscreen) +(make-obsolete-variable 'helm-c-source-elscreen 'helm-source-elscreen "1.5.1") +(defvaralias 'helm-c-etags-mtime-alist 'helm-etags-mtime-alist) +(make-obsolete-variable 'helm-c-etags-mtime-alist 'helm-etags-mtime-alist "1.5.1") +(defvaralias 'helm-c-grep-default-recurse-command 'helm-grep-default-recurse-command) +(make-obsolete-variable 'helm-c-grep-default-recurse-command 'helm-grep-default-recurse-command "1.5.1") +(defvaralias 'helm-c-source-google-suggest 'helm-source-google-suggest) +(make-obsolete-variable 'helm-c-source-google-suggest 'helm-source-google-suggest "1.5.1") +(defvaralias 'helm-c-etags-tag-file-search-limit 'helm-etags-tag-file-search-limit) +(make-obsolete-variable 'helm-c-etags-tag-file-search-limit 'helm-etags-tag-file-search-limit "1.5.1") +(defvaralias 'helm-c-source-ff-file-name-history 'helm-source-ff-file-name-history) +(make-obsolete-variable 'helm-c-source-ff-file-name-history 'helm-source-ff-file-name-history "1.5.1") +(defvaralias 'helm-c-source-buffers-list 'helm-source-buffers-list) +(make-obsolete-variable 'helm-c-source-buffers-list 'helm-source-buffers-list "1.5.1") +(defvaralias 'helm-c-cached-imenu-alist 'helm-cached-imenu-alist) +(make-obsolete-variable 'helm-c-cached-imenu-alist 'helm-cached-imenu-alist "1.5.1") +(defvaralias 'helm-c-source-tracker-search 'helm-source-tracker-search) +(make-obsolete-variable 'helm-c-source-tracker-search 'helm-source-tracker-search "1.5.1") +(defvaralias 'helm-c-google-suggest-default-function 'helm-google-suggest-default-function) +(make-obsolete-variable 'helm-c-google-suggest-default-function 'helm-google-suggest-default-function "1.5.1") +(defvaralias 'helm-c-imenu-delimiter 'helm-imenu-delimiter) +(make-obsolete-variable 'helm-c-imenu-delimiter 'helm-imenu-delimiter "1.5.1") +(defvaralias 'helm-c-source-emacs-process 'helm-source-emacs-process) +(make-obsolete-variable 'helm-c-source-emacs-process 'helm-source-emacs-process "1.5.1") +(defvaralias 'helm-c-etags-map 'helm-etags-map) +(make-obsolete-variable 'helm-c-etags-map 'helm-etags-map "1.5.1") +(defvaralias 'helm-c-grep-history 'helm-grep-history) +(make-obsolete-variable 'helm-c-grep-history 'helm-grep-history "1.5.1") +(defvaralias 'helm-c-cached-imenu-tick 'helm-cached-imenu-tick) +(make-obsolete-variable 'helm-c-cached-imenu-tick 'helm-cached-imenu-tick "1.5.1") +(defvaralias 'helm-c-source-esh 'helm-source-esh) +(make-obsolete-variable 'helm-c-source-esh 'helm-source-esh "1.5.1") +(defvaralias 'helm-c-source-global-mark-ring 'helm-source-global-mark-ring) +(make-obsolete-variable 'helm-c-source-global-mark-ring 'helm-source-global-mark-ring "1.5.1") +(defvaralias 'helm-c-man-pages 'helm-man-pages) +(make-obsolete-variable 'helm-c-man-pages 'helm-man-pages "1.5.1") +(defvaralias 'helm-c-adaptative-done 'helm-adaptive-done) +(make-obsolete-variable 'helm-c-adaptative-done 'helm-adaptive-done "1.5.1") +(defvaralias 'helm-c-source-regexp 'helm-source-regexp) +(make-obsolete-variable 'helm-c-source-regexp 'helm-source-regexp "1.5.1") +(defvaralias 'helm-c-boring-file-regexp-list 'helm-boring-file-regexp-list) +(make-obsolete-variable 'helm-c-boring-file-regexp-list 'helm-boring-file-regexp-list "1.5.1") +(defvaralias 'helm-c-show-completion-use-special-display 'helm-show-completion-use-special-display) +(make-obsolete-variable 'helm-c-show-completion-use-special-display 'helm-show-completion-use-special-display "1.5.1") +(defvaralias 'helm-c-apt-query 'helm-apt-query) +(make-obsolete-variable 'helm-c-apt-query 'helm-apt-query "1.5.1") +(defvaralias 'helm-c-pdfgrep-default-read-command 'helm-pdfgrep-default-read-command) +(make-obsolete-variable 'helm-c-pdfgrep-default-read-command 'helm-pdfgrep-default-read-command "1.5.1") +(defvaralias 'helm-c-source-bookmark-images 'helm-source-bookmark-images) +(make-obsolete-variable 'helm-c-source-bookmark-images 'helm-source-bookmark-images "1.5.1") +(defvaralias 'helm-c-source-mac-spotlight 'helm-source-mac-spotlight) +(make-obsolete-variable 'helm-c-source-mac-spotlight 'helm-source-mac-spotlight "1.5.1") +(defvaralias 'helm-c-yahoo-suggest-url 'helm-yahoo-suggest-url) +(make-obsolete-variable 'helm-c-yahoo-suggest-url 'helm-yahoo-suggest-url "1.5.1") +(defvaralias 'helm-c-zgrep-recurse-flag 'helm-zgrep-recurse-flag) +(make-obsolete-variable 'helm-c-zgrep-recurse-flag 'helm-zgrep-recurse-flag "1.5.1") +(defvaralias 'helm-c-source-use-flags 'helm-source-use-flags) +(make-obsolete-variable 'helm-c-source-use-flags 'helm-source-use-flags "1.5.1") +(defvaralias 'helm-c-moccur-map 'helm-moccur-map) +(make-obsolete-variable 'helm-c-moccur-map 'helm-moccur-map "1.5.1") +(defvaralias 'helm-c-adaptative-history-file 'helm-adaptive-history-file) +(make-obsolete-variable 'helm-c-adaptative-history-file 'helm-adaptive-history-file "1.5.1") +(defvaralias 'helm-c-grep-default-directory-fn 'helm-grep-default-directory-fn) +(make-obsolete-variable 'helm-c-grep-default-directory-fn 'helm-grep-default-directory-fn "1.5.1") +(defvaralias 'helm-c-apt-input-history 'helm-apt-input-history) +(make-obsolete-variable 'helm-c-apt-input-history 'helm-apt-input-history "1.5.1") +(defvaralias 'helm-async-be-async 'dired-async-be-async) +(make-obsolete-variable 'helm-async-be-async 'dired-async-be-async "1.5.9") + + +(provide 'helm-aliases) + +;;; helm-aliases.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-apt.el b/emacs.d/elpa/helm-20150507.2215/helm-apt.el new file mode 100644 index 0000000..b667c5b --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-apt.el @@ -0,0 +1,292 @@ +;;; helm-apt.el --- Helm interface for Debian/Ubuntu packages (apt-*) -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) +(require 'helm-external) + +(declare-function term-line-mode "term") +(declare-function term-char-mode "term") +(declare-function term-send-input "term") +(declare-function term-send-eof "term") + + +(defgroup helm-apt nil + "Apt related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-apt-cache-show-function 'helm-apt-cache-show-1 + "Function of one argument used to show apt package. +Default is `helm-apt-cache-show-1' but you can use `apt-utils-show-package-1' +from `apt-utils.el' to have something more enhanced. +If nil default `helm-apt-cache-show-1' will be used." + :type 'function + :group 'helm-apt) + +(defface helm-apt-installed + '((t (:foreground "green"))) + "Face used for apt installed candidates." + :group 'helm-apt) + +(defface helm-apt-deinstalled + '((t (:foreground "DimGray"))) + "Face used for apt deinstalled candidates." + :group 'helm-apt) + + +(defvar helm-apt-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-apt-help) + (define-key map (kbd "M-I") 'helm-apt-show-only-installed) + (define-key map (kbd "M-U") 'helm-apt-show-only-not-installed) + (define-key map (kbd "M-D") 'helm-apt-show-only-deinstalled) + (define-key map (kbd "M-A") 'helm-apt-show-all) + map)) + + +(defvar helm-source-apt + `((name . "APT") + (init . helm-apt-init) + (candidates-in-buffer) + (candidate-transformer . helm-apt-candidate-transformer) + (display-to-real . helm-apt-display-to-real) + (update . helm-apt-refresh) + (keymap . ,helm-apt-map) + (mode-line . helm-apt-mode-line) + (action + ("Show package description" . helm-apt-cache-show) + ("Install package" . helm-apt-install) + ("Reinstall package" . helm-apt-reinstall) + ("Remove package" . helm-apt-uninstall) + ("Purge package" . helm-apt-purge)) + (persistent-action . helm-apt-persistent-action) + (persistent-help . "Show package description"))) + +;;; Internals vars +(defvar helm-apt-search-command "apt-cache search '%s'") +(defvar helm-apt-show-command "apt-cache show '%s'") +(defvar helm-apt-installed-packages nil) +(defvar helm-apt-all-packages nil) +(defvar helm-apt-input-history nil) +(defvar helm-apt-show-only 'all) +(defvar helm-apt-term-buffer nil) +(defvar helm-apt-default-archs nil) + +(defun helm-apt-refresh () + "Refresh installed candidates list." + (setq helm-apt-installed-packages nil) + (setq helm-apt-all-packages nil)) + +(defun helm-apt-persistent-action (candidate) + "Persistent action for APT source." + (helm-apt-cache-show candidate)) + +(defun helm-apt--installed-package-name (name) + (cl-loop for arch in helm-apt-default-archs + thereis (or (assoc-default + name helm-apt-installed-packages) + (assoc-default + (format "%s:%s" name arch) + helm-apt-installed-packages)))) + +(defun helm-apt-candidate-transformer (candidates) + "Show installed CANDIDATES and the ones to deinstall in a different color." + (cl-loop for cand in candidates + for name = (helm-apt-display-to-real cand) + for deinstall = (string= + (helm-apt--installed-package-name name) + "deinstall") + for install = (string= + (helm-apt--installed-package-name name) + "install") + for show = (cond ((and deinstall + (memq helm-apt-show-only '(all deinstalled))) + (propertize cand 'face 'helm-apt-deinstalled)) + ((and install + (memq helm-apt-show-only '(all installed))) + (propertize cand 'face 'helm-apt-installed)) + ((and (eq helm-apt-show-only 'noinstalled) + (not install)) cand) + ((eq helm-apt-show-only 'all) cand)) + when show collect show)) + +(defun helm-apt-show-only-installed () + (interactive) + (when helm-alive-p + (setq helm-apt-show-only 'installed) + (helm-update))) + +(defun helm-apt-show-only-not-installed () + (interactive) + (when helm-alive-p + (setq helm-apt-show-only 'noinstalled) + (helm-update))) + +(defun helm-apt-show-only-deinstalled () + (interactive) + (when helm-alive-p + (setq helm-apt-show-only 'deinstalled) + (helm-update))) + +(defun helm-apt-show-all () + (interactive) + (when helm-alive-p + (setq helm-apt-show-only 'all) + (helm-update))) + +(defun helm-apt-init () + "Initialize list of debian packages." + (let ((query "")) + (unless (and helm-apt-installed-packages + helm-apt-all-packages) + (message "Loading package list...") + (setq helm-apt-installed-packages + (with-temp-buffer + (call-process-shell-command "dpkg --get-selections" + nil (current-buffer)) + (cl-loop for i in (split-string (buffer-string) "\n" t) + for p = (split-string i) + collect (cons (car p) (cadr p))))) + (helm-init-candidates-in-buffer + 'global + (setq helm-apt-all-packages + (with-temp-buffer + (call-process-shell-command + (format helm-apt-search-command query) + nil (current-buffer)) + (buffer-string)))) + (message "Loading package list done") + (sit-for 0.5)))) + +(defun helm-apt-display-to-real (line) + "Return only name of a debian package. +LINE is displayed like: +package name - description." + (car (split-string line " - "))) + +(defvar helm-apt-show-current-package nil) +(define-derived-mode helm-apt-show-mode + special-mode "helm-apt-show" + "Mode to display infos on apt packages.") + +(defun helm-apt-cache-show (package) + "Show information on apt package PACKAGE." + (if (and (functionp helm-apt-cache-show-function) + (not (eq helm-apt-cache-show-function + 'helm-apt-cache-show))) + ;; A function, call it. + (funcall helm-apt-cache-show-function package) + ;; nil or whatever use default. + (helm-apt-cache-show-1 package))) + +(defun helm-apt-cache-show-1 (package) + (let* ((command (format helm-apt-show-command package)) + (buf (get-buffer-create "*helm apt show*"))) + (switch-to-buffer buf) + (unless (string= package helm-apt-show-current-package) + (let ((inhibit-read-only t)) + (erase-buffer) + (save-excursion + (call-process-shell-command + command nil (current-buffer) t)))) + (helm-apt-show-mode) + (set (make-local-variable 'helm-apt-show-current-package) + package))) + +(defun helm-apt-install (_package) + "Run 'apt-get install' shell command on PACKAGE." + (helm-apt-generic-action :action 'install)) + +(defun helm-apt-reinstall (_package) + "Run 'apt-get install --reinstall' shell command on PACKAGE." + (helm-apt-generic-action :action 'reinstall)) + +(defun helm-apt-uninstall (_package) + "Run 'apt-get remove' shell command on PACKAGE." + (helm-apt-generic-action :action 'uninstall)) + +(defun helm-apt-purge (_package) + "Run 'apt-get purge' shell command on PACKAGE." + (helm-apt-generic-action :action 'purge)) + +(cl-defun helm-apt-generic-action (&key action) + "Run 'apt-get ACTION'. +Support install, remove and purge actions." + (if (and helm-apt-term-buffer + (buffer-live-p (get-buffer helm-apt-term-buffer))) + (switch-to-buffer helm-apt-term-buffer) + (ansi-term (getenv "SHELL") "term apt") + (setq helm-apt-term-buffer (buffer-name))) + (term-line-mode) + (let ((command (cl-case action + (install "sudo apt-get install ") + (reinstall "sudo apt-get install --reinstall ") + (uninstall "sudo apt-get remove ") + (purge "sudo apt-get purge ") + (t (error "Unknown action")))) + (beg (point)) + end + (cand-list (mapconcat #'(lambda (x) (format "'%s'" x)) + (helm-marked-candidates) " "))) + (goto-char (point-max)) + (insert (concat command cand-list)) + (setq end (point)) + (if (y-or-n-p (format "%s package(s)" (symbol-name action))) + (progn + (setq helm-external-commands-list nil) + (setq helm-apt-installed-packages nil) + (term-char-mode) (term-send-input)) + (delete-region beg end)))) + +;;;###autoload +(defun helm-apt (arg) + "Preconfigured `helm' : frontend of APT package manager. +With a prefix arg reload cache." + (interactive "P") + (setq helm-apt-show-only 'all) + (unless helm-apt-default-archs + (setq helm-apt-default-archs + (append (split-string + (shell-command-to-string + "dpkg --print-architecture") + "\n" t) + (split-string + (shell-command-to-string + "dpkg --print-foreign-architectures") + "\n" t)))) + (let ((query (read-string "Search Package: " nil 'helm-apt-input-history))) + (when arg (helm-apt-refresh)) + (helm :sources 'helm-source-apt + :prompt "Search Package: " + :input query + :buffer "*helm apt*" + :history 'helm-apt-input-history))) + + +(provide 'helm-apt) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-apt.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-autoloads.el b/emacs.d/elpa/helm-20150507.2215/helm-autoloads.el new file mode 100644 index 0000000..2bbf41e --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-autoloads.el @@ -0,0 +1,1224 @@ +;;; helm-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "helm" "helm.el" (21837 24208 0 0)) +;;; Generated autoloads from helm.el + +(autoload 'helm-define-multi-key "helm" "\ +In KEYMAP, define key sequence KEY for function list FUNCTIONS. +Each function run sequentially each time the key KEY is pressed. +If DELAY is specified switch back to initial function of FUNCTIONS list +after DELAY seconds. +The functions in FUNCTIONS list are functions with no args. +e.g + (defun foo () + (message \"Run foo\")) + (defun bar () + (message \"Run bar\")) + (defun baz () + (message \"Run baz\")) + +\(helm-define-multi-key global-map \" q\" '(foo bar baz) 2) + +Each time \" q\" is pressed the next function is executed, if you wait +More than 2 seconds, next hit will run again the first function and so on. + +\(fn KEYMAP KEY FUNCTIONS &optional DELAY)" nil nil) + +(autoload 'helm-multi-key-defun "helm" "\ +Define NAME as a multi-key command running FUNS. +After DELAY seconds the FUNS list is reinitialised. +See `helm-define-multi-key'. + +\(fn NAME DOCSTRING FUNS &optional DELAY)" nil t) + +(put 'helm-multi-key-defun 'lisp-indent-function '2) + +(autoload 'helm-define-key-with-subkeys "helm" "\ +Allow defining in MAP a KEY and SUBKEY to COMMAND. + +This allow typing KEY to call COMMAND the first time and +type only SUBKEY on subsequent calls. + +Arg MAP is the keymap to use, SUBKEY is the initial short keybinding to +call COMMAND. + +Arg OTHER-SUBKEYS is an alist specifying other short keybindings +to use once started. +e.g: + +\(helm-define-key-with-subkeys global-map + (kbd \"C-x v n\") ?n 'git-gutter:next-hunk '((?p . git-gutter:previous-hunk))) + + +In this example, `C-x v n' will run `git-gutter:next-hunk' +subsequent hits on \"n\" will run this command again +and subsequent hits on \"p\" will run `git-gutter:previous-hunk'. + +Arg MENU is a string to display in minibuffer +to describe SUBKEY and OTHER-SUBKEYS. +Arg EXIT-FN specify a function to run on exit. + +Any other keys pressed run their assigned command defined in MAP +and exit the loop running EXIT-FN if specified. + +NOTE: SUBKEY and OTHER-SUBKEYS bindings support +only char syntax actually (e.g ?n) +so don't use strings, vectors or whatever to define them. + +\(fn MAP KEY SUBKEY COMMAND &optional OTHER-SUBKEYS MENU EXIT-FN)" nil nil) + +(put 'helm-define-key-with-subkeys 'lisp-indent-function '1) + +(autoload 'helm-debug-open-last-log "helm" "\ +Open helm log file of last helm session. +If `helm-last-log-file' is nil, switch to `helm-debug-buffer' . + +\(fn)" t nil) + +(autoload 'helm "helm" "\ +Main function to execute helm sources. + +Keywords supported: +:sources :input :prompt :resume :preselect +:buffer :keymap :default :history :allow-nest + +Extra LOCAL-VARS keywords are supported, see below. + +PLIST is a list like (:key1 val1 :key2 val2 ...) or +\(&optional sources input prompt resume + preselect buffer keymap default history). + +Basic keywords are the following: + +:sources + +A list of sources used for this session. It also accepts a +symbol, interpreted as a variable of a helm source +i.e (a symbol can be passed instead of a list of sources). +It also accepts an alist representing a helm source, which is +detected by (assq 'name ANY-SOURCES). +NOTE: In this case the source is embedded in the helm command and +have no symbol name, so it is not reachable from outside. +It will be referenced in `helm-sources' as a whole alist. + +:input + +Temporary value of `helm-pattern', ie. initial input of minibuffer. + +:prompt + +Prompt other than \"pattern: \". + +:resume + +If t, Resurrect previously instance of `helm'. Skip the initialization. +If 'noresume, this instance of `helm' cannot be resumed. + +:preselect + +Initially selected candidate. Specified by exact candidate or a regexp. + +:buffer + +`helm-buffer' instead of *helm*. + +:keymap + +`helm-map' for current `helm' session. + +:default + +A default argument that will be inserted in minibuffer with \\\\[next-history-element]. +When nil or not present `thing-at-point' will be used instead. +If `helm-maybe-use-default-as-input' is non--nil display will be +updated using :default arg as input unless :input is specified, +which in this case will take precedence on :default +This is a string or a list, in this case the car of the list will +be used as initial default input, but you will be able to cycle in this +list with \\\\[next-history-element]. + +:history + +By default all minibuffer input is pushed to `minibuffer-history', +if an argument HISTORY is provided, input will be pushed to HISTORY. +History element should be a symbol. + +:allow-nest + +Allow running this helm command within a running helm session. + +Of course, conventional arguments are supported, the two are same. + +\(helm :sources sources :input input :prompt prompt :resume resume + :preselect preselect :buffer buffer :keymap keymap :default default + :history history) + +and + +\(helm sources input prompt resume preselect buffer keymap default history) + +are the same. + +However the use of non keyword args is deprecated and should not be used. + +Other keywords are interpreted as local variables of this helm session. +The `helm-' prefix can be omitted. For example, + +\(helm :sources 'helm-source-buffers-list + :buffer \"*buffers*\" :candidate-number-limit 10) + +means starting helm session with `helm-source-buffers' +source in *buffers* buffer and set variable `helm-candidate-number-limit' +to 10 as session local variable. + +\(fn &key SOURCES INPUT PROMPT RESUME PRESELECT BUFFER KEYMAP DEFAULT HISTORY ALLOW-NEST OTHER-LOCAL-VARS)" nil nil) + +(autoload 'helm-other-buffer "helm" "\ +Simplified interface of `helm' with other `helm-buffer'. +Call `helm' with only ANY-SOURCES and ANY-BUFFER as args. + +\(fn ANY-SOURCES ANY-BUFFER)" nil nil) + +;;;*** + +;;;### (autoloads nil "helm-adaptive" "helm-adaptive.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-adaptive.el + +(autoload 'helm-reset-adaptive-history "helm-adaptive" "\ +Delete all `helm-adaptive-history' and his file. +Useful when you have a old or corrupted `helm-adaptive-history-file'. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-apt" "helm-apt.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-apt.el + +(autoload 'helm-apt "helm-apt" "\ +Preconfigured `helm' : frontend of APT package manager. +With a prefix arg reload cache. + +\(fn ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-bookmark" "helm-bookmark.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-bookmark.el + +(autoload 'helm-bookmarks "helm-bookmark" "\ +Preconfigured `helm' for bookmarks. + +\(fn)" t nil) + +(autoload 'helm-pp-bookmarks "helm-bookmark" "\ +Preconfigured `helm' for bookmarks (pretty-printed). + +\(fn)" t nil) + +(autoload 'helm-filtered-bookmarks "helm-bookmark" "\ +Preconfigured helm for bookmarks (filtered by category). +Optional source `helm-source-bookmark-addressbook' is loaded +only if external library addressbook-bookmark.el is available. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-buffers" "helm-buffers.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-buffers.el + +(autoload 'helm-buffers-list "helm-buffers" "\ +Preconfigured `helm' to list buffers. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-color" "helm-color.el" (21837 24208 0 +;;;;;; 0)) +;;; Generated autoloads from helm-color.el + +(autoload 'helm-colors "helm-color" "\ +Preconfigured `helm' for color. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-command" "helm-command.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-command.el + +(autoload 'helm-M-x "helm-command" "\ +Preconfigured `helm' for Emacs commands. +It is `helm' replacement of regular `M-x' `execute-extended-command'. + +Unlike regular `M-x' emacs vanilla `execute-extended-command' command, +the prefix args if needed, are passed AFTER starting `helm-M-x'. + +You can get help on each command by persistent action. + +\(fn ARG &optional COMMAND-NAME)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-config" "helm-config.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-config.el + +(autoload 'helm-configuration "helm-config" "\ +Customize `helm'. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-dabbrev" "helm-dabbrev.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-dabbrev.el + +(autoload 'helm-dabbrev "helm-dabbrev" "\ + + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-elisp" "helm-elisp.el" (21837 24208 0 +;;;;;; 0)) +;;; Generated autoloads from helm-elisp.el + +(autoload 'helm-lisp-completion-at-point "helm-elisp" "\ +Helm lisp symbol completion at point. + +\(fn)" t nil) + +(autoload 'helm-complete-file-name-at-point "helm-elisp" "\ +Complete file name at point. + +\(fn &optional FORCE)" t nil) + +(autoload 'helm-lisp-indent "helm-elisp" "\ + + +\(fn)" t nil) + +(autoload 'helm-lisp-completion-or-file-name-at-point "helm-elisp" "\ +Complete lisp symbol or filename at point. +Filename completion happen if string start after or between a double quote. + +\(fn)" t nil) + +(autoload 'helm-apropos "helm-elisp" "\ +Preconfigured helm to describe commands, functions, variables and faces. + +\(fn)" t nil) + +(autoload 'helm-manage-advice "helm-elisp" "\ +Preconfigured `helm' to disable/enable function advices. + +\(fn)" t nil) + +(autoload 'helm-locate-library "helm-elisp" "\ + + +\(fn)" t nil) + +(autoload 'helm-timers "helm-elisp" "\ +Preconfigured `helm' for timers. + +\(fn)" t nil) + +(autoload 'helm-complex-command-history "helm-elisp" "\ + + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-elisp-package" "helm-elisp-package.el" +;;;;;; (21837 24208 0 0)) +;;; Generated autoloads from helm-elisp-package.el + +(autoload 'helm-list-elisp-packages "helm-elisp-package" "\ + + +\(fn ARG)" t nil) + +(autoload 'helm-list-elisp-packages-no-fetch "helm-elisp-package" "\ + + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-elscreen" "helm-elscreen.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-elscreen.el + +(autoload 'helm-elscreen "helm-elscreen" "\ +Preconfigured helm to list elscreen. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-eshell" "helm-eshell.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-eshell.el + +(autoload 'helm-esh-pcomplete "helm-eshell" "\ +Preconfigured helm to provide helm completion in eshell. + +\(fn)" t nil) + +(autoload 'helm-eshell-history "helm-eshell" "\ +Preconfigured helm for eshell history. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-eval" "helm-eval.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-eval.el + +(autoload 'helm-eval-expression "helm-eval" "\ +Preconfigured helm for `helm-source-evaluation-result'. + +\(fn ARG)" t nil) + +(autoload 'helm-eval-expression-with-eldoc "helm-eval" "\ +Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support. + +\(fn)" t nil) + +(autoload 'helm-calcul-expression "helm-eval" "\ +Preconfigured helm for `helm-source-calculation-result'. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-external" "helm-external.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-external.el + +(autoload 'helm-run-external-command "helm-external" "\ +Preconfigured `helm' to run External PROGRAM asyncronously from Emacs. +If program is already running exit with error. +You can set your own list of commands with +`helm-external-commands-list'. + +\(fn PROGRAM)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-files" "helm-files.el" (21837 24208 0 +;;;;;; 0)) +;;; Generated autoloads from helm-files.el + +(autoload 'helm-browse-project "helm-files" "\ +Browse files and see status of project with its vcs. +Only HG and GIT are supported for now. +Fall back to `helm-find-files' or `helm-browse-project-find-files' +if current directory is not under control of one of those vcs. +With a prefix ARG browse files recursively, with two prefix ARG +rebuild the cache. +If the current directory is found in the cache, start +`helm-browse-project-find-files' even with no prefix ARG. +NOTE: The prefix ARG have no effect on the VCS controlled directories. + +Needed dependencies for VCS: + +and +. + +\(fn ARG)" t nil) + +(autoload 'helm-find "helm-files" "\ +Preconfigured `helm' for the find shell command. + +\(fn ARG)" t nil) + +(autoload 'helm-find-files "helm-files" "\ +Preconfigured `helm' for helm implementation of `find-file'. +Called with a prefix arg show history if some. +Don't call it from programs, use `helm-find-files-1' instead. +This is the starting point for nearly all actions you can do on files. + +\(fn ARG)" t nil) + +(autoload 'helm-for-files "helm-files" "\ +Preconfigured `helm' for opening files. +Run all sources defined in `helm-for-files-preferred-list'. + +\(fn)" t nil) + +(autoload 'helm-multi-files "helm-files" "\ +Same as `helm-for-files' but allow toggling from locate to others sources. + +\(fn)" t nil) + +(autoload 'helm-recentf "helm-files" "\ +Preconfigured `helm' for `recentf'. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-font" "helm-font.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-font.el + +(autoload 'helm-select-xfont "helm-font" "\ +Preconfigured `helm' to select Xfont. + +\(fn)" t nil) + +(autoload 'helm-ucs "helm-font" "\ +Preconfigured helm for `ucs-names' math symbols. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-grep" "helm-grep.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-grep.el + +(autoload 'helm-goto-precedent-file "helm-grep" "\ +Go to precedent file in helm grep/etags buffers. + +\(fn)" t nil) + +(autoload 'helm-goto-next-file "helm-grep" "\ +Go to precedent file in helm grep/etags buffers. + +\(fn)" t nil) + +(autoload 'helm-grep-run-save-buffer "helm-grep" "\ +Run grep save results action from `helm-do-grep-1'. + +\(fn)" t nil) + +(autoload 'helm-grep-mode "helm-grep" "\ +Major mode to provide actions in helm grep saved buffer. + +Special commands: +\\{helm-grep-mode-map} + +\(fn)" t nil) + +(autoload 'helm-gm-next-file "helm-grep" "\ + + +\(fn)" t nil) + +(autoload 'helm-gm-precedent-file "helm-grep" "\ + + +\(fn)" t nil) + +(autoload 'helm-grep-mode-jump "helm-grep" "\ + + +\(fn)" t nil) + +(autoload 'helm-grep-mode-jump-other-window-forward "helm-grep" "\ + + +\(fn)" t nil) + +(autoload 'helm-grep-mode-jump-other-window-backward "helm-grep" "\ + + +\(fn)" t nil) + +(autoload 'helm-grep-mode-jump-other-window "helm-grep" "\ + + +\(fn)" t nil) + +(autoload 'helm-do-grep "helm-grep" "\ +Preconfigured helm for grep. +Contrarily to Emacs `grep', no default directory is given, but +the full path of candidates in ONLY. +That allow to grep different files not only in `default-directory' but anywhere +by marking them (C-). If one or more directory is selected +grep will search in all files of these directories. +You can also use wildcard in the base name of candidate. +If a prefix arg is given use the -r option of grep (recurse). +The prefix arg can be passed before or after start file selection. +See also `helm-do-grep-1'. + +\(fn)" t nil) + +(autoload 'helm-do-zgrep "helm-grep" "\ +Preconfigured helm for zgrep. + +\(fn)" t nil) + +(autoload 'helm-do-pdfgrep "helm-grep" "\ +Preconfigured helm for pdfgrep. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-help" "helm-help.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-help.el + +(autoload 'helm-documentation "helm-help" "\ +Helm documentation. +With a prefix arg refresh the documentation. + +Find here the documentation of all sources actually documented. + +\(fn ARG)" t nil) + +(autoload 'helm-help "helm-help" "\ +Help of `helm'. + +\(fn)" t nil) + +(autoload 'helm-buffer-help "helm-help" "\ +Help command for helm buffers. + +\(fn)" t nil) + +(autoload 'helm-ff-help "helm-help" "\ +Help command for `helm-find-files'. + +\(fn)" t nil) + +(autoload 'helm-read-file-name-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-generic-file-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-grep-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-pdfgrep-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-etags-help "helm-help" "\ +The help function for etags. + +\(fn)" t nil) + +(autoload 'helm-ucs-help "helm-help" "\ +Help command for `helm-ucs'. + +\(fn)" t nil) + +(autoload 'helm-bookmark-help "helm-help" "\ +Help command for bookmarks. + +\(fn)" t nil) + +(autoload 'helm-esh-help "helm-help" "\ +Help command for `helm-find-files-eshell-command-on-file'. + +\(fn)" t nil) + +(autoload 'helm-buffers-ido-virtual-help "helm-help" "\ +Help command for ido virtual buffers. + +\(fn)" t nil) + +(autoload 'helm-moccur-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-top-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-apt-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-el-package-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-M-x-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-imenu-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-color-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-semantic-help "helm-help" "\ + + +\(fn)" t nil) + +(autoload 'helm-kmacro-help "helm-help" "\ + + +\(fn)" t nil) + +(defvar helm-buffer-mode-line-string '("Buffer(s)" "\\\\[helm-buffer-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "String displayed in mode-line in `helm-source-buffers-list'")) + +(defvar helm-color-mode-line-string '("Colors" "\\\\[helm-color-help]:Help/\\[helm-color-run-insert-name]:Insert name/\\[helm-color-run-insert-rgb]:Insert RGB/with shift: Kill")) + +(defvar helm-buffers-ido-virtual-mode-line-string '("Killed Buffer(s)" "\\\\[helm-buffers-ido-virtual-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "String displayed in mode-line in `helm-source-buffers-list'")) + +(defvar helm-ff-mode-line-string "\\\\[helm-ff-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ +String displayed in mode-line in `helm-source-find-files'") + +(defvar helm-read-file-name-mode-line-string "\\\\[helm-read-file-name-help]:Help C/\\[helm-cr-empty-string]:Empty \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ +String displayed in mode-line in `helm-source-find-files'.") + +(defvar helm-generic-file-mode-line-string "\\\\[helm-generic-file-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend" "\ +String displayed in mode-line in Locate.") + +(defvar helm-grep-mode-line-string "\\\\[helm-grep-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend" "\ +String displayed in mode-line in `helm-do-grep'.") + +(defvar helm-pdfgrep-mode-line-string "\\\\[helm-pdfgrep-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend" "\ +String displayed in mode-line in `helm-do-pdfgrep'.") + +(defvar helm-etags-mode-line-string "\\\\[helm-etags-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ +String displayed in mode-line in `helm-etags-select'.") + +(defvar helm-ucs-mode-line-string "\\\\[helm-ucs-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct" "\ +String displayed in mode-line in `helm-ucs'.") + +(defvar helm-bookmark-mode-line-string '("Bookmark(s)" "\\\\[helm-bookmark-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct") "\ +String displayed in mode-line in `helm-source-buffers-list'") + +(defvar helm-occur-mode-line "\\\\[helm-help]:Help \\\\[helm-occur-run-query-replace-regexp]:Query replace regexp \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-moccur-mode-line "\\\\[helm-moccur-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-comp-read-mode-line "\\C/\\[helm-cr-empty-string]:Empty \\\\[helm-help]:Help \\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct") + +(defvar helm-top-mode-line "\\\\[helm-top-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-apt-mode-line "\\\\[helm-apt-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-el-package-mode-line "\\\\[helm-el-package-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-M-x-mode-line "\\\\[helm-M-x-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-imenu-mode-line "\\\\[helm-imenu-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(defvar helm-semantic-mode-line "\\\\[helm-semantic-help]:Help \\\\[helm-select-action]:Act \\[helm-maybe-exit-minibuffer]/f1/f2/f-n:NthAct \\[helm-toggle-suspend-update]:Tog.suspend") + +(autoload 'helm-describe-helm-attribute "helm-help" "\ +Display the full documentation of HELM-ATTRIBUTE. +HELM-ATTRIBUTE should be a symbol. + +\(fn HELM-ATTRIBUTE)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-imenu" "helm-imenu.el" (21837 24208 0 +;;;;;; 0)) +;;; Generated autoloads from helm-imenu.el + +(autoload 'helm-imenu "helm-imenu" "\ +Preconfigured `helm' for `imenu'. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-info" "helm-info.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-info.el + +(autoload 'helm-info-at-point "helm-info" "\ +Preconfigured `helm' for searching info at point. +With a prefix-arg insert symbol at point. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-locate" "helm-locate.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-locate.el + +(autoload 'helm-locate-read-file-name "helm-locate" "\ + + +\(fn PROMPT)" nil nil) + +(autoload 'helm-locate "helm-locate" "\ +Preconfigured `helm' for Locate. +Note: you can add locate options after entering pattern. +See 'man locate' for valid options and also `helm-locate-command'. + +You can specify a local database with prefix argument ARG. +With two prefix arg, refresh the current local db or create it +if it doesn't exists. +Many databases can be used: navigate and mark them. +See also `helm-locate-with-db'. + +To create a user specific db, use +\"updatedb -l 0 -o db_path -U directory\". +Where db_path is a filename matched by +`helm-locate-db-file-regexp'. + +\(fn ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-man" "helm-man.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-man.el + +(autoload 'helm-man-woman "helm-man" "\ +Preconfigured `helm' for Man and Woman pages. +With a prefix arg reinitialize the cache. + +\(fn ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-misc" "helm-misc.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-misc.el + +(autoload 'helm-browse-menubar "helm-misc" "\ +Helm interface to the menubar using lacarte.el. + +\(fn)" t nil) + +(autoload 'helm-world-time "helm-misc" "\ +Preconfigured `helm' to show world time. + +\(fn)" t nil) + +(autoload 'helm-insert-latex-math "helm-misc" "\ +Preconfigured helm for latex math symbols completion. + +\(fn)" t nil) + +(autoload 'helm-ratpoison-commands "helm-misc" "\ +Preconfigured `helm' to execute ratpoison commands. + +\(fn)" t nil) + +(autoload 'helm-stumpwm-commands "helm-misc" "\ + + +\(fn)" t nil) + +(autoload 'helm-mini "helm-misc" "\ +Preconfigured `helm' lightweight version (buffer -> recentf). + +\(fn)" t nil) + +(autoload 'helm-minibuffer-history "helm-misc" "\ +Preconfigured `helm' for `minibuffer-history'. + +\(fn)" t nil) + +(autoload 'helm-comint-input-ring "helm-misc" "\ +Predefined `helm' that provide completion of `comint' history. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-mode" "helm-mode.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-mode.el + +(autoload 'helm-comp-read "helm-mode" "\ +Read a string in the minibuffer, with helm completion. + +It is helm `completing-read' equivalent. + +- PROMPT is the prompt name to use. + +- COLLECTION can be a list, vector, obarray or hash-table. + It can be also a function that receives three arguments: + the values string, predicate and t. See `all-completions' for more details. + +Keys description: + +- TEST: A predicate called with one arg i.e candidate. + +- INITIAL-INPUT: Same as input arg in `helm'. + +- PRESELECT: See preselect arg of `helm'. + +- DEFAULT: This option is used only for compatibility with regular + Emacs `completing-read' (Same as DEFAULT arg of `completing-read'). + +- BUFFER: Name of helm-buffer. + +- MUST-MATCH: Candidate selected must be one of COLLECTION. + +- REVERSE-HISTORY: When non--nil display history source after current + source completion. + +- REQUIRES-PATTERN: Same as helm attribute, default is 0. + +- HISTORY: A list containing specific history, default is nil. + When it is non--nil, all elements of HISTORY are displayed in + a special source before COLLECTION. + +- INPUT-HISTORY: A symbol. the minibuffer input history will be + stored there, if nil or not provided, `minibuffer-history' + will be used instead. + +- CASE-FOLD: Same as `helm-case-fold-search'. + +- DEL-INPUT: Boolean, when non--nil (default) remove the partial + minibuffer input from HISTORY is present. + +- PERSISTENT-ACTION: A function called with one arg i.e candidate. + +- PERSISTENT-HELP: A string to document PERSISTENT-ACTION. + +- MODE-LINE: A string or list to display in mode line. + Default is `helm-comp-read-mode-line'. + +- KEYMAP: A keymap to use in this `helm-comp-read'. + (the keymap will be shared with history source) + +- NAME: The name related to this local source. + +- EXEC-WHEN-ONLY-ONE: Bound `helm-execute-action-at-once-if-one' + to non--nil. (possibles values are t or nil). + +- VOLATILE: Use volatile attribute (enabled by default). + +- SORT: A predicate to give to `sort' e.g `string-lessp'. + +- FC-TRANSFORMER: A `filtered-candidate-transformer' function. + +- HIST-FC-TRANSFORMER: A `filtered-candidate-transformer' + function for the history source. + +- MARKED-CANDIDATES: If non--nil return candidate or marked candidates as a list. + +- NOMARK: When non--nil don't allow marking candidates. + +- ALISTP: (default is non--nil) See `helm-comp-read-get-candidates'. + +- CANDIDATES-IN-BUFFER: when non--nil use a source build with + `helm-candidates-in-buffer' which is much faster. + Argument VOLATILE have no effect when CANDIDATES-IN-BUFFER is non--nil. + +Any prefix args passed during `helm-comp-read' invocation will be recorded +in `helm-current-prefix-arg', otherwise if prefix args were given before +`helm-comp-read' invocation, the value of `current-prefix-arg' will be used. +That's mean you can pass prefix args before or after calling a command +that use `helm-comp-read' See `helm-M-x' for example. + +\(fn PROMPT COLLECTION &key TEST INITIAL-INPUT DEFAULT PRESELECT (buffer \"*Helm Completions*\") MUST-MATCH FUZZY REVERSE-HISTORY (requires-pattern 0) HISTORY INPUT-HISTORY (case-fold helm-comp-read-case-fold-search) (del-input t) (persistent-action nil) (persistent-help \"DoNothing\") (mode-line helm-comp-read-mode-line) (keymap helm-comp-read-map) (name \"Helm Completions\") CANDIDATES-IN-BUFFER EXEC-WHEN-ONLY-ONE QUIT-WHEN-NO-CAND (volatile t) SORT (fc-transformer (quote helm-cr-default-transformer)) HIST-FC-TRANSFORMER MARKED-CANDIDATES NOMARK (alistp t))" nil nil) + +(defvar helm-mode nil "\ +Non-nil if Helm mode is enabled. +See the command `helm-mode' for a description of this minor mode. +Setting this variable directly does not take effect; +either customize it (see the info node `Easy Customization') +or call the function `helm-mode'.") + +(custom-autoload 'helm-mode "helm-mode" nil) + +(autoload 'helm-mode "helm-mode" "\ +Toggle generic helm completion. + +All functions in Emacs that use `completing-read' +or `read-file-name' and friends will use helm interface +when this mode is turned on. +However you can modify this behavior for functions of your choice +with `helm-completing-read-handlers-alist'. + +Called with a positive arg, turn on unconditionally, with a +negative arg turn off. +You can turn it on with `helm-mode'. + +Some crap emacs functions may not be supported, +e.g `ffap-alternate-file' and maybe others +You can add such functions to `helm-completing-read-handlers-alist' +with a nil value. + +Note: This mode is incompatible with Emacs23. + +\(fn &optional ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-net" "helm-net.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-net.el + +(autoload 'helm-surfraw "helm-net" "\ +Preconfigured `helm' to search PATTERN with search ENGINE. + +\(fn PATTERN ENGINE)" t nil) + +(autoload 'helm-google-suggest "helm-net" "\ +Preconfigured `helm' for google search with google suggest. + +\(fn)" t nil) + +(autoload 'helm-yahoo-suggest "helm-net" "\ +Preconfigured `helm' for Yahoo searching with Yahoo suggest. + +\(fn)" t nil) + +(autoload 'helm-wikipedia-suggest "helm-net" "\ +Preconfigured `helm' for Wikipedia lookup with Wikipedia suggest. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-org" "helm-org.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-org.el + +(autoload 'helm-org-agenda-files-headings "helm-org" "\ + + +\(fn)" t nil) + +(autoload 'helm-org-in-buffer-headings "helm-org" "\ + + +\(fn)" t nil) + +(autoload 'helm-org-capture-templates "helm-org" "\ + + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-regexp" "helm-regexp.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-regexp.el + +(autoload 'helm-moccur-run-save-buffer "helm-regexp" "\ +Run grep save results action from `helm-do-grep-1'. + +\(fn)" t nil) + +(autoload 'helm-moccur-mode "helm-regexp" "\ +Major mode to provide actions in helm moccur saved buffer. + +Special commands: +\\{helm-moccur-mode-map} + +\(fn)" t nil) + +(autoload 'helm-regexp "helm-regexp" "\ +Preconfigured helm to build regexps. +`query-replace-regexp' can be run from there against found regexp. + +\(fn)" t nil) + +(autoload 'helm-occur "helm-regexp" "\ +Preconfigured helm for Occur. + +\(fn)" t nil) + +(autoload 'helm-occur-from-isearch "helm-regexp" "\ +Invoke `helm-occur' from isearch. + +\(fn)" t nil) + +(autoload 'helm-multi-occur "helm-regexp" "\ +Preconfigured helm for multi occur. + + BUFFERS is a list of buffers to search through. +With a prefix arg, reverse the behavior of +`helm-moccur-always-search-in-current'. +The prefix arg can be set before calling `helm-multi-occur' +or during the buffer selection. + +\(fn BUFFERS)" t nil) + +(autoload 'helm-multi-occur-from-isearch "helm-regexp" "\ +Invoke `helm-multi-occur' from isearch. + +With a prefix arg, reverse the behavior of +`helm-moccur-always-search-in-current'. +The prefix arg can be set before calling +`helm-multi-occur-from-isearch' or during the buffer selection. + +\(fn &optional ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-ring" "helm-ring.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-ring.el + +(autoload 'helm-mark-ring "helm-ring" "\ +Preconfigured `helm' for `helm-source-mark-ring'. + +\(fn)" t nil) + +(autoload 'helm-global-mark-ring "helm-ring" "\ +Preconfigured `helm' for `helm-source-global-mark-ring'. + +\(fn)" t nil) + +(autoload 'helm-all-mark-rings "helm-ring" "\ +Preconfigured `helm' for `helm-source-global-mark-ring' and `helm-source-mark-ring'. + +\(fn)" t nil) + +(autoload 'helm-register "helm-ring" "\ +Preconfigured `helm' for Emacs registers. + +\(fn)" t nil) + +(autoload 'helm-show-kill-ring "helm-ring" "\ +Preconfigured `helm' for `kill-ring'. +It is drop-in replacement of `yank-pop'. + +First call open the kill-ring browser, next calls move to next line. + +\(fn)" t nil) + +(autoload 'helm-execute-kmacro "helm-ring" "\ +Keyboard macros with helm interface. +Define your macros with `f3' and `f4'. +See (info \"(emacs) Keyboard Macros\") for detailed infos. +This command is useful when used with persistent action. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-semantic" "helm-semantic.el" (21837 24208 +;;;;;; 0 0)) +;;; Generated autoloads from helm-semantic.el + +(autoload 'helm-semantic "helm-semantic" "\ +Preconfigured `helm' for `semantic'. +If ARG is supplied, pre-select symbol at point instead of current + +\(fn ARG)" t nil) + +(autoload 'helm-semantic-or-imenu "helm-semantic" "\ +Run `helm' with `semantic' or `imenu'. +If ARG is supplied, pre-select symbol at point instead of current +semantic tag in scope. + +If `semantic-mode' is active in the current buffer, then use +semantic for generating tags, otherwise fall back to `imenu'. +Fill in the symbol at point by default. + +\(fn ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-sys" "helm-sys.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-sys.el + +(autoload 'helm-top "helm-sys" "\ +Preconfigured `helm' for top command. + +\(fn)" t nil) + +(autoload 'helm-list-emacs-process "helm-sys" "\ +Preconfigured `helm' for emacs process. + +\(fn)" t nil) + +(autoload 'helm-xrandr-set "helm-sys" "\ + + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-tags" "helm-tags.el" (21837 24208 0 0)) +;;; Generated autoloads from helm-tags.el + +(autoload 'helm-etags-select "helm-tags" "\ +Preconfigured helm for etags. +If called with a prefix argument or if any of the tag files have +been modified, reinitialize cache. + +This function aggregates three sources of tag files: + + 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. + 2) `tags-file-name', which is commonly set by `find-tag' command. + 3) `tags-table-list' which is commonly set by `visit-tags-table' command. + +\(fn ARG)" t nil) + +;;;*** + +;;;### (autoloads nil "helm-utils" "helm-utils.el" (21837 24208 0 +;;;;;; 0)) +;;; Generated autoloads from helm-utils.el + +(autoload 'helm-show-all-in-this-source-only "helm-utils" "\ +Show only current source of this helm session with all its candidates. +With a numeric prefix arg show only the ARG number of candidates. + +\(fn ARG)" t nil) + +(autoload 'helm-display-all-sources "helm-utils" "\ +Display all sources previously hidden by `helm-set-source-filter'. + +\(fn)" t nil) + +(autoload 'helm-quit-and-find-file "helm-utils" "\ +Drop into `helm-find-files' from `helm'. +If current selection is a buffer or a file, `helm-find-files' +from its directory. + +\(fn)" t nil) + +(autoload 'helm-w32-shell-execute-open-file "helm-utils" "\ + + +\(fn FILE)" t nil) + +(autoload 'helm-yank-text-at-point "helm-utils" "\ +Yank text at point in `helm-current-buffer' into minibuffer. +If `helm-yank-symbol-first' is non--nil the first yank +grabs the entire symbol. + +\(fn)" t nil) + +;;;*** + +;;;### (autoloads nil nil ("helm-aliases.el" "helm-match-plugin.el" +;;;;;; "helm-pkg.el" "helm-plugin.el" "helm-source.el") (21837 24208 +;;;;;; 503267 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; helm-autoloads.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-bookmark.el b/emacs.d/elpa/helm-20150507.2215/helm-bookmark.el new file mode 100644 index 0000000..5b5efe2 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-bookmark.el @@ -0,0 +1,793 @@ +;;; helm-bookmark.el --- Helm for Emacs regular Bookmarks. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'bookmark) +(require 'helm) +(require 'helm-utils) +(require 'helm-info) +(require 'helm-adaptive) +(require 'helm-net) + +(declare-function addressbook-bookmark-edit "ext:addressbook-bookmark.el" (bookmark)) +(declare-function message-buffers "message.el") +(declare-function addressbook-set-mail-buffer-1 "ext:addressbook-bookmark.el" + (&optional bookmark-name append cc)) + + +(defgroup helm-bookmark nil + "Predefined configurations for `helm.el'." + :group 'helm) + +(defcustom helm-bookmark-show-location nil + "Show location of bookmark on display." + :group 'helm-bookmark + :type 'boolean) + +(defcustom helm-bookmark-default-filtered-sources + (append '(helm-source-bookmark-files&dirs + helm-source-bookmark-helm-find-files + helm-source-bookmark-info + helm-source-bookmark-gnus + helm-source-bookmark-man + helm-source-bookmark-images + helm-source-bookmark-w3m) + (and (locate-library "addressbook-bookmark") + (list 'helm-source-bookmark-addressbook)) + (list 'helm-source-bookmark-uncategorized + 'helm-source-bookmark-set)) + "List of sources to use in `helm-filtered-bookmarks'." + :group 'helm-bookmark + :type '(repeat (choice symbol))) + + +(defface helm-bookmark-info + '((t (:foreground "green"))) + "Face used for W3m Emacs bookmarks (not w3m bookmarks)." + :group 'helm-bookmark) + +(defface helm-bookmark-w3m + '((t (:foreground "yellow"))) + "Face used for W3m Emacs bookmarks (not w3m bookmarks)." + :group 'helm-bookmark) + +(defface helm-bookmark-gnus + '((t (:foreground "magenta"))) + "Face used for Gnus bookmarks." + :group 'helm-bookmark) + +(defface helm-bookmark-man + '((t (:foreground "Orange4"))) + "Face used for Woman/man bookmarks." + :group 'helm-bookmark) + +(defface helm-bookmark-file + '((t (:foreground "Deepskyblue2"))) + "Face used for file bookmarks." + :group 'helm-bookmark) + +(defface helm-bookmark-directory + '((t (:inherit helm-ff-directory))) + "Face used for file bookmarks." + :group 'helm-bookmark) + +(defface helm-bookmark-addressbook + '((t (:foreground "tomato"))) + "Face used for addressbook bookmarks." + :group 'helm-bookmark) + + +(defvar helm-bookmark-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c o") 'helm-bookmark-run-jump-other-window) + (define-key map (kbd "C-d") 'helm-bookmark-run-delete) + (define-key map (kbd "C-]") 'helm-bookmark-toggle-filename) + (define-key map (kbd "M-e") 'helm-bookmark-run-edit) + (define-key map (kbd "C-c ?") 'helm-bookmark-help) + map) + "Generic Keymap for emacs bookmark sources.") + +(defclass helm-source-basic-bookmarks (helm-source-in-buffer helm-type-bookmark) + ((init :initform (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global + (bookmark-all-names)))) + (filtered-candidate-transformer :initform 'helm-bookmark-transformer) + (search :initform 'helm-bookmark-search-fn))) + +(defvar helm-source-bookmarks + (helm-make-source "Bookmarks" 'helm-source-basic-bookmarks) + "See (info \"(emacs)Bookmarks\").") + +(defun helm-bookmark-transformer (candidates _source) + (cl-loop for i in candidates + for loc = (bookmark-location i) + for len = (string-width i) + for trunc = (if (> len bookmark-bmenu-file-column) + (helm-substring i bookmark-bmenu-file-column) + i) + for sep = (make-string (- (+ bookmark-bmenu-file-column 2) + (length trunc)) + ? ) + if helm-bookmark-show-location + collect (cons (concat trunc sep (if (listp loc) (car loc) loc)) i) + else collect i)) + +(defun helm-bookmark-match-fn (candidate) + "Match function for bookmark sources using `candidates'." + (if helm-bookmark-show-location + ;; match only location, match-plugin will match also name. + (string-match helm-pattern (bookmark-location candidate)) + (string-match helm-pattern candidate))) + +(defun helm-bookmark-toggle-filename-1 (_candidate) + (let* ((real (helm-get-selection helm-buffer)) + (trunc (if (> (string-width real) bookmark-bmenu-file-column) + (helm-substring real bookmark-bmenu-file-column) + real)) + (loc (bookmark-location real))) + (setq helm-bookmark-show-location (not helm-bookmark-show-location)) + (helm-force-update (if helm-bookmark-show-location + (concat (regexp-quote trunc) + " +" + (regexp-quote + (if (listp loc) (car loc) loc))) + real)))) + +(defun helm-bookmark-toggle-filename () + "Toggle bookmark location visibility." + (interactive) + (with-helm-alive-p + (helm-attrset 'toggle-filename + '(helm-bookmark-toggle-filename-1 . never-split)) + (helm-execute-persistent-action 'toggle-filename))) + +(defun helm-bookmark-jump (candidate) + "Jump to bookmark from keyboard." + (let ((current-prefix-arg helm-current-prefix-arg) + non-essential) + (bookmark-jump candidate))) + +(defun helm-bookmark-jump-other-window (candidate) + (let (non-essential) + (bookmark-jump-other-window candidate))) + + +;;; bookmark-set +;; +(defvar helm-source-bookmark-set + '((name . "Set Bookmark") + (dummy) + (action . bookmark-set)) + "See (info \"(emacs)Bookmarks\").") + + +;;; Colorize bookmarks by category +;; +(defvar helm-source-pp-bookmarks + '((name . "PP-Bookmarks") + (init . (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (cl-loop for b in (bookmark-all-names) collect + (propertize b 'location (bookmark-location b)))))) + (candidates-in-buffer) + (search helm-bookmark-search-fn) + (match-part . helm-pp-bookmark-match-fn) + (filtered-candidate-transformer + helm-adaptive-sort + helm-highlight-bookmark) + (type . bookmark)) + "See (info \"(emacs)Bookmarks\").") + +(defun helm-bookmark-search-fn (pattern) + "Search function for bookmark sources using `candidates-in-buffer'. +Should be used with `helm-pp-bookmark-match-fn' as `match-part' function." + (if helm-bookmark-show-location + (helm-aif (next-single-property-change (point) 'location) + (goto-char it)) + (re-search-forward pattern nil t))) + +(defun helm-pp-bookmark-match-fn (candidate) + "Search function for bookmark sources using `candidates-in-buffer'. +Should be used with `helm-bookmark-search-fn' as `search' function." + (helm-aif (and helm-bookmark-show-location + (bookmark-location candidate)) + ;; Match against bookmark-name and location. + (concat candidate " " it) + ;; Match against bookmark-name. + candidate)) + + +;;; Predicates +;; +(defconst helm-bookmark--non-file-filename " - no file -" + "Name to use for `filename' entry, for non-file bookmarks.") + +(defun helm-bookmark-gnus-bookmark-p (bookmark) + "Return non-nil if BOOKMARK is a Gnus bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-gnus) + (eq (bookmark-get-handler bookmark) 'gnus-summary-bookmark-jump) + (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-gnus))) + +(defun helm-bookmark-w3m-bookmark-p (bookmark) + "Return non-nil if BOOKMARK is a W3m bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-w3m) + (eq (bookmark-get-handler bookmark) 'bookmark-w3m-bookmark-jump) + (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-w3m))) + +(defun helm-bookmark-woman-bookmark-p (bookmark) + "Return non-nil if BOOKMARK is a Woman bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-woman) + (eq (bookmark-get-handler bookmark) 'woman-bookmark-jump) + (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-woman))) + +(defun helm-bookmark-man-bookmark-p (bookmark) + "Return non-nil if BOOKMARK is a Man bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-man) + (eq (bookmark-get-handler bookmark) 'Man-bookmark-jump) + (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-man))) + +(defun helm-bookmark-woman-man-bookmark-p (bookmark) + "Return non-nil if BOOKMARK is a Man or Woman bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (or (helm-bookmark-man-bookmark-p bookmark) + (helm-bookmark-woman-bookmark-p bookmark))) + +(defun helm-bookmark-info-bookmark-p (bookmark) + "Return non-nil if BOOKMARK is an Info bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (eq (bookmark-get-handler bookmark) 'Info-bookmark-jump)) + +(defun helm-bookmark-image-bookmark-p (bookmark) + "Return non-nil if BOOKMARK bookmarks an image file." + (if (stringp bookmark) + (assoc 'image-type (assoc bookmark bookmark-alist)) + (assoc 'image-type bookmark))) + +(defun helm-bookmark-file-p (bookmark) + "Return non-nil if BOOKMARK bookmarks a file or directory. +BOOKMARK is a bookmark name or a bookmark record. +This excludes bookmarks of a more specific kind (Info, Gnus, and W3m)." + (let* ((filename (bookmark-get-filename bookmark)) + (isnonfile (equal filename helm-bookmark--non-file-filename))) + (and filename (not isnonfile) (not (bookmark-get-handler bookmark))))) + +(defun helm-bookmark-helm-find-files-p (bookmark) + "Return non-nil if BOOKMARK bookmarks a `helm-find-files' session. +BOOKMARK is a bookmark name or a bookmark record." + (eq (bookmark-get-handler bookmark) 'helm-ff-bookmark-jump)) + +(defun helm-bookmark-addressbook-p (bookmark) + "Return non--nil if BOOKMARK is a contact recorded with addressbook-bookmark. +BOOKMARK is a bookmark name or a bookmark record." + (if (listp bookmark) + (string= (assoc-default 'type bookmark) "addressbook") + (string= (assoc-default + 'type (assoc bookmark bookmark-alist)) "addressbook"))) + +(defun helm-bookmark-uncategorized-bookmark-p (bookmark) + "Return non--nil if BOOKMARK match no known category." + (cl-loop for pred in '(helm-bookmark-addressbook-p + helm-bookmark-gnus-bookmark-p + helm-bookmark-w3m-bookmark-p + helm-bookmark-woman-man-bookmark-p + helm-bookmark-info-bookmark-p + helm-bookmark-image-bookmark-p + helm-bookmark-file-p + helm-bookmark-helm-find-files-p + helm-bookmark-addressbook-p) + never (funcall pred bookmark))) + +(defun helm-bookmark-filter-setup-alist (fn) + "Return a filtered `bookmark-alist' sorted alphabetically." + (cl-loop with alist = (cl-loop for b in bookmark-alist + when (funcall fn b) collect b) + for bmk in alist + for name = (car bmk) + collect (propertize name 'location (bookmark-location name)))) + + +;;; Bookmark handlers +;; +(defvar w3m-async-exec) +(defun helm-bookmark-jump-w3m (bookmark) + "Jump to W3m bookmark BOOKMARK, setting a new tab. +If `browse-url-browser-function' is set to something else +than `w3m-browse-url' use it." + (require 'helm-net) + (let ((file (or (bookmark-prop-get bookmark 'filename) + (bookmark-prop-get bookmark 'url))) + (buf (generate-new-buffer-name "*w3m*")) + (w3m-async-exec nil) + (really-use-w3m (equal browse-url-browser-function 'w3m-browse-url))) + (helm-browse-url file really-use-w3m) + (when really-use-w3m + (bookmark-default-handler + `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark)))))) + +;; All bookmarks recorded with the handler provided with w3m +;; (`bookmark-w3m-bookmark-jump') will use our handler which open +;; the bookmark in a new tab or in an external browser depending +;; on `browse-url-browser-function'. +(defalias 'bookmark-w3m-bookmark-jump 'helm-bookmark-jump-w3m) + +;; Provide compatibility with old handlers provided in external +;; packages bookmark-extensions.el and bookmark+. +(defalias 'bmkext-jump-woman 'woman-bookmark-jump) +(defalias 'bmkext-jump-man 'Man-bookmark-jump) +(defalias 'bmkext-jump-w3m 'helm-bookmark-jump-w3m) +(defalias 'bmkext-jump-gnus 'gnus-summary-bookmark-jump) +(defalias 'bookmarkp-jump-gnus 'gnus-summary-bookmark-jump) +(defalias 'bookmarkp-jump-w3m 'helm-bookmark-jump-w3m) +(defalias 'bookmarkp-jump-woman 'woman-bookmark-jump) +(defalias 'bookmarkp-jump-man 'Man-bookmark-jump) + + +;;;; Filtered bookmark sources +;; +;; +(defclass helm-source-filtered-bookmarks (helm-source-in-buffer helm-type-bookmark) + ((search :initform #'helm-bookmark-search-fn) + (match-part :initform #'helm-pp-bookmark-match-fn) + (filtered-candidate-transformer + :initform '(helm-adaptive-sort + helm-highlight-bookmark)))) + +;;; W3m bookmarks. +;; +(defun helm-bookmark-w3m-setup-alist () + "Specialized filter function for bookmarks w3m." + (helm-bookmark-filter-setup-alist 'helm-bookmark-w3m-bookmark-p)) + +(defvar helm-source-bookmark-w3m + (helm-make-source "Bookmark W3m" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-w3m-setup-alist))))) + +;;; Images +;; +(defun helm-bookmark-images-setup-alist () + "Specialized filter function for images bookmarks." + (helm-bookmark-filter-setup-alist 'helm-bookmark-image-bookmark-p)) + +(defvar helm-source-bookmark-images + (helm-make-source "Bookmark Images" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-images-setup-alist))))) + +;;; Woman Man +;; +(defun helm-bookmark-man-setup-alist () + "Specialized filter function for bookmarks w3m." + (helm-bookmark-filter-setup-alist 'helm-bookmark-woman-man-bookmark-p)) + +(defvar helm-source-bookmark-man + (helm-make-source "Bookmark Woman&Man" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-man-setup-alist))))) + +;;; Gnus +;; +(defun helm-bookmark-gnus-setup-alist () + "Specialized filter function for bookmarks gnus." + (helm-bookmark-filter-setup-alist 'helm-bookmark-gnus-bookmark-p)) + +(defvar helm-source-bookmark-gnus + (helm-make-source "Bookmark Gnus" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-gnus-setup-alist))))) + +;;; Info +;; +(defun helm-bookmark-info-setup-alist () + "Specialized filter function for bookmarks info." + (helm-bookmark-filter-setup-alist 'helm-bookmark-info-bookmark-p)) + +(defvar helm-source-bookmark-info + (helm-make-source "Bookmark Info" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-info-setup-alist))))) + +;;; Files and directories +;; +(defun helm-bookmark-local-files-setup-alist () + "Specialized filter function for bookmarks locals files." + (helm-bookmark-filter-setup-alist 'helm-bookmark-file-p)) + +(defvar helm-source-bookmark-files&dirs + (helm-make-source "Bookmark Files&Directories" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-local-files-setup-alist))))) + +;;; Helm find files sessions. +;; +(defun helm-bookmark-helm-find-files-setup-alist () + "Specialized filter function for `helm-find-files' bookmarks." + (helm-bookmark-filter-setup-alist 'helm-bookmark-helm-find-files-p)) + +(defvar helm-source-bookmark-helm-find-files + (helm-make-source "Bookmark helm-find-files sessions" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-helm-find-files-setup-alist))))) + +;;; Uncategorized bookmarks +;; +(defun helm-bookmark-uncategorized-setup-alist () + "Specialized filter function for uncategorized bookmarks." + (helm-bookmark-filter-setup-alist 'helm-bookmark-uncategorized-bookmark-p)) + +(defvar helm-source-bookmark-uncategorized + (helm-make-source "Bookmark uncategorized" 'helm-source-filtered-bookmarks + :init (lambda () + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global (helm-bookmark-uncategorized-setup-alist))))) + +;;; Addressbook. +;; +;; +(defclass helm-bookmark-addressbook-class (helm-source-in-buffer) + ((init :initform (lambda () + (require 'addressbook-bookmark nil t) + (bookmark-maybe-load-default-file) + (helm-init-candidates-in-buffer + 'global + (helm-bookmark-addressbook-setup-alist)))) + (search :initform #'helm-bookmark-search-fn) + (match-part :initform #'helm-pp-bookmark-match-fn) + (persistent-action :initform + (lambda (candidate) + (let ((bmk (helm-bookmark-get-bookmark-from-name + candidate))) + (bookmark--jump-via bmk 'switch-to-buffer)))) + (persistent-help :initform "Show contact - Prefix with C-u to append") + (filtered-candidate-transformer :initform + '(helm-adaptive-sort + helm-highlight-bookmark)) + (action :initform (("Show Contact(s)" + . (lambda (candidate) + (let* ((contacts (helm-marked-candidates)) + (current-prefix-arg helm-current-prefix-arg)) + (bookmark-jump + (helm-bookmark-get-bookmark-from-name (car contacts))) + (helm-aif (cdr contacts) + (let ((current-prefix-arg '(4))) + (cl-loop for bmk in it do + (bookmark-jump + (helm-bookmark-get-bookmark-from-name bmk)))))))) + ("Mail To" . helm-bookmark-addressbook-send-mail-1) + ("Mail Cc" . (lambda (_candidate) + (helm-bookmark-addressbook-send-mail-1 nil 'cc))) + ("Mail Bcc" . (lambda (_candidate) + (helm-bookmark-addressbook-send-mail-1 nil 'bcc))) + ("Edit Bookmark" + . (lambda (candidate) + (let ((bmk (helm-bookmark-get-bookmark-from-name + candidate))) + (addressbook-bookmark-edit + (assoc bmk bookmark-alist))))) + ("Delete bookmark(s)" . helm-delete-marked-bookmarks) + ("Insert Email at point" + . (lambda (candidate) + (let* ((bmk (helm-bookmark-get-bookmark-from-name + candidate)) + (mlist (split-string + (assoc-default + 'email (assoc bmk bookmark-alist)) + ", "))) + (insert + (if (> (length mlist) 1) + (helm-comp-read + "Insert Mail Address: " mlist :must-match t) + (car mlist)))))) + ("Show annotation" + . (lambda (candidate) + (let ((bmk (helm-bookmark-get-bookmark-from-name + candidate))) + (bookmark-show-annotation bmk)))) + ("Edit annotation" + . (lambda (candidate) + (let ((bmk (helm-bookmark-get-bookmark-from-name + candidate))) + (bookmark-edit-annotation bmk)))) + ("Show Google map" + . (lambda (candidate) + (let* ((bmk (helm-bookmark-get-bookmark-from-name + candidate)) + (full-bmk (assoc bmk bookmark-alist))) + (addressbook-google-map full-bmk)))))))) + +(defun helm-bookmark-addressbook-send-mail-1 (_candidate &optional cc) + (let* ((contacts (helm-marked-candidates)) + (bookmark (helm-bookmark-get-bookmark-from-name + (car contacts))) + (append (message-buffers))) + (addressbook-set-mail-buffer-1 bookmark append) + (helm-aif (cdr contacts) + (progn + (when cc (addressbook-set-mail-buffer-1 (car it) nil cc)) + (cl-loop for bmk in (cdr it) do + (addressbook-set-mail-buffer-1 + (helm-bookmark-get-bookmark-from-name bmk) 'append cc)))))) + +(defun helm-bookmark-addressbook-setup-alist () + "Specialized filter function for addressbook bookmarks." + (helm-bookmark-filter-setup-alist 'helm-bookmark-addressbook-p)) + +(defvar helm-source-bookmark-addressbook + (helm-make-source "Bookmark Addressbook" 'helm-bookmark-addressbook-class)) + +;;; Transformer +;; + +(defun helm-highlight-bookmark (bookmarks _source) + "Used as `filtered-candidate-transformer' to colorize bookmarks. +Work both with standard Emacs bookmarks and bookmark-extensions.el." + (let ((non-essential t)) + (cl-loop for i in bookmarks + for isfile = (bookmark-get-filename i) + for hff = (helm-bookmark-helm-find-files-p i) + for handlerp = (and (fboundp 'bookmark-get-handler) + (bookmark-get-handler i)) + for isw3m = (and (fboundp 'helm-bookmark-w3m-bookmark-p) + (helm-bookmark-w3m-bookmark-p i)) + for isgnus = (and (fboundp 'helm-bookmark-gnus-bookmark-p) + (helm-bookmark-gnus-bookmark-p i)) + for isman = (and (fboundp 'helm-bookmark-man-bookmark-p) ; Man + (helm-bookmark-man-bookmark-p i)) + for iswoman = (and (fboundp 'helm-bookmark-woman-bookmark-p) ; Woman + (helm-bookmark-woman-bookmark-p i)) + for isannotation = (bookmark-get-annotation i) + for isabook = (string= (bookmark-prop-get i 'type) + "addressbook") + for isinfo = (eq handlerp 'Info-bookmark-jump) + for loc = (bookmark-location i) + for len = (string-width i) + for trunc = (if (and helm-bookmark-show-location + (> len bookmark-bmenu-file-column)) + (helm-substring + i bookmark-bmenu-file-column) + i) + ;; Add a * if bookmark have annotation + if (and isannotation (not (string-equal isannotation ""))) + do (setq trunc (concat "*" (if helm-bookmark-show-location trunc i))) + for sep = (and helm-bookmark-show-location + (make-string (- (+ bookmark-bmenu-file-column 2) + (string-width trunc)) + ? )) + for bmk = (cond ( ;; info buffers + isinfo + (propertize trunc 'face 'helm-bookmark-info + 'help-echo isfile)) + ( ;; w3m buffers + isw3m + (propertize trunc 'face 'helm-bookmark-w3m + 'help-echo isfile)) + ( ;; gnus buffers + isgnus + (propertize trunc 'face 'helm-bookmark-gnus + 'help-echo isfile)) + ( ;; Man Woman + (or iswoman isman) + (propertize trunc 'face 'helm-bookmark-man + 'help-echo isfile)) + ( ;; Addressbook + isabook + (propertize trunc 'face 'helm-bookmark-addressbook)) + ( ;; directories + (and isfile + (or hff + ;; This is needed because `non-essential' + ;; is not working on Emacs-24.2 and the behavior + ;; of tramp seems to have changed since previous + ;; versions (Need to reenter password even if a + ;; first connection have been established, + ;; probably when host is named differently + ;; i.e machine/localhost) + (and (not (file-remote-p isfile)) + (file-directory-p isfile)))) + (propertize trunc 'face 'helm-bookmark-directory + 'help-echo isfile)) + ( ;; regular files + t + (propertize trunc 'face 'helm-bookmark-file + 'help-echo isfile))) + collect (if helm-bookmark-show-location + (cons (concat bmk sep (if (listp loc) (car loc) loc)) + i) + (cons bmk i))))) + +(defun helm-bookmark-edit-bookmark (bookmark-name) + "Edit bookmark's name and file name, and maybe save them. +BOOKMARK-NAME is the current (old) name of the bookmark to be renamed." + (let ((bmk (helm-bookmark-get-bookmark-from-name bookmark-name)) + (handler (bookmark-prop-get bookmark-name 'handler))) + (if (eq handler 'addressbook-bookmark-jump) + (addressbook-bookmark-edit + (assoc bmk bookmark-alist)) + (helm-bookmark-edit-bookmark-1 bookmark-name handler)))) + +(defun helm-bookmark-edit-bookmark-1 (bookmark-name handler) + (let* ((helm--reading-passwd-or-string t) + (bookmark-fname (bookmark-get-filename bookmark-name)) + (bookmark-loc (bookmark-prop-get bookmark-name 'location)) + (new-name (read-from-minibuffer "Name: " bookmark-name)) + (new-loc (read-from-minibuffer "FileName or Location: " + (or bookmark-fname + (if (consp bookmark-loc) + (car bookmark-loc) + bookmark-loc)))) + (docid (and (eq handler 'mu4e-bookmark-jump) + (read-number "Docid: " (cdr bookmark-loc))))) + (when docid + (setq new-loc (cons new-loc docid))) + (when (and (not (equal new-name "")) (not (equal new-loc "")) + (y-or-n-p "Save changes? ")) + (if bookmark-fname + (progn + (helm-bookmark-rename bookmark-name new-name 'batch) + (bookmark-set-filename new-name new-loc)) + (bookmark-prop-set + (bookmark-get-bookmark bookmark-name) 'location new-loc) + (helm-bookmark-rename bookmark-name new-name 'batch)) + (helm-bookmark-maybe-save-bookmark) + (list new-name new-loc)))) + +(defun helm-bookmark-maybe-save-bookmark () + "Increment save counter and maybe save `bookmark-alist'." + (setq bookmark-alist-modification-count (1+ bookmark-alist-modification-count)) + (when (bookmark-time-to-save-p) (bookmark-save))) + +(defun helm-bookmark-rename (old &optional new batch) + "Change bookmark's name from OLD to NEW. +Interactively: + If called from the keyboard, then prompt for OLD. + If called from the menubar, select OLD from a menu. +If NEW is nil, then prompt for its string value. + +If BATCH is non-nil, then do not rebuild the menu list. + +While the user enters the new name, repeated `C-w' inserts consecutive +words from the buffer into the new bookmark name." + (interactive (list (bookmark-completing-read "Old bookmark name"))) + (bookmark-maybe-historicize-string old) + (bookmark-maybe-load-default-file) + (save-excursion (skip-chars-forward " ") (setq bookmark-yank-point (point))) + (setq bookmark-current-buffer (current-buffer)) + (let ((newname (or new (read-from-minibuffer + "New name: " nil + (let ((now-map (copy-keymap minibuffer-local-map))) + (define-key now-map "\C-w" 'bookmark-yank-word) + now-map) + nil 'bookmark-history)))) + (bookmark-set-name old newname) + (setq bookmark-current-bookmark newname) + (unless batch (bookmark-bmenu-surreptitiously-rebuild-list)) + (helm-bookmark-maybe-save-bookmark) newname)) + +(defun helm-bookmark-run-edit () + "Run `helm-bookmark-edit-bookmark' from keyboard." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-bookmark-edit-bookmark))) + + +;;; Bookmarks attributes +;; +(define-helm-type-attribute 'bookmark + `((coerce . helm-bookmark-get-bookmark-from-name) + (action . ,(helm-make-actions + "Jump to bookmark" 'helm-bookmark-jump + "Jump to BM other window" 'helm-bookmark-jump-other-window + "Bookmark edit annotation" 'bookmark-edit-annotation + "Bookmark show annotation" 'bookmark-show-annotation + "Delete bookmark(s)" 'helm-delete-marked-bookmarks + "Edit Bookmark" 'helm-bookmark-edit-bookmark + "Rename bookmark" 'helm-bookmark-rename + "Relocate bookmark" 'bookmark-relocate)) + (keymap . ,helm-bookmark-map) + (mode-line . helm-bookmark-mode-line-string)) + "Bookmark name.") + + +(defun helm-bookmark-run-jump-other-window () + "Jump to bookmark from keyboard." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'bookmark-jump-other-window))) + +(defun helm-bookmark-run-delete () + "Delete bookmark from keyboard." + (interactive) + (with-helm-alive-p + (when (y-or-n-p "Delete bookmark(s)?") + (helm-quit-and-execute-action 'helm-delete-marked-bookmarks)))) + +(defun helm-bookmark-get-bookmark-from-name (bmk) + "Return bookmark name even if it is a bookmark with annotation. +e.g prepended with *." + (let ((bookmark (replace-regexp-in-string "\\`\\*" "" bmk))) + (if (assoc bookmark bookmark-alist) bookmark bmk))) + +(defun helm-delete-marked-bookmarks (_ignore) + "Delete this bookmark or all marked bookmarks." + (cl-dolist (i (helm-marked-candidates)) + (bookmark-delete (helm-bookmark-get-bookmark-from-name i) + 'batch))) + + +;;;###autoload +(defun helm-bookmarks () + "Preconfigured `helm' for bookmarks." + (interactive) + (helm :sources '(helm-source-bookmarks + helm-source-bookmark-set) + :buffer "*helm bookmarks*" + :default (buffer-name helm-current-buffer))) + +;;;###autoload +(defun helm-pp-bookmarks () + "Preconfigured `helm' for bookmarks (pretty-printed)." + (interactive) + (helm :sources '(helm-source-pp-bookmarks + helm-source-bookmark-set) + :buffer "*helm pp bookmarks*" + :default (buffer-name helm-current-buffer))) + +;;;###autoload +(defun helm-filtered-bookmarks () + "Preconfigured helm for bookmarks (filtered by category). +Optional source `helm-source-bookmark-addressbook' is loaded +only if external library addressbook-bookmark.el is available." + (interactive) + (helm :sources helm-bookmark-default-filtered-sources + :prompt "Search Bookmark: " + :buffer "*helm filtered bookmarks*" + :default (list (thing-at-point 'symbol) + (buffer-name helm-current-buffer)))) + +(provide 'helm-bookmark) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-bookmark.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-buffers.el b/emacs.d/elpa/helm-20150507.2215/helm-buffers.el new file mode 100644 index 0000000..6775f32 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-buffers.el @@ -0,0 +1,854 @@ +;;; helm-buffers.el --- helm support for buffers. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) +(require 'helm-elscreen) +(require 'helm-grep) +(require 'helm-plugin) +(require 'helm-regexp) +(require 'helm-help) + +(declare-function ido-make-buffer-list "ido" (default)) +(declare-function ido-add-virtual-buffers-to-list "ido") +(declare-function helm-comp-read "helm-mode") + + +(defgroup helm-buffers nil + "Buffers related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-boring-buffer-regexp-list + '("\\` " "\\*helm" "\\*helm-mode" "\\*Echo Area" "\\*Minibuf") + "The regexp list that match boring buffers. +Buffer candidates matching these regular expression will be +filtered from the list of candidates if the +`helm-skip-boring-buffers' candidate transformer is used." + :type '(repeat (choice regexp)) + :group 'helm-buffers) + +(defcustom helm-buffers-favorite-modes '(lisp-interaction-mode + emacs-lisp-mode + text-mode + org-mode) + "List of preferred mode to open new buffers with." + :type '(repeat (choice function)) + :group 'helm-buffers) + +(defcustom helm-buffer-max-length 20 + "Max length of buffer names before truncate. +When disabled (nil) use the longest buffer-name length found." + :group 'helm-buffers + :type '(choice (const :tag "Disabled" nil) + (integer :tag "Length before truncate"))) + +(defcustom helm-buffer-details-flag t + "Always show details in buffer list when non--nil." + :group 'helm-buffers + :type 'boolean) + +(defcustom helm-buffers-fuzzy-matching nil + "Fuzzy matching buffer names when non--nil. +Only buffer names are fuzzy matched when this is enabled, +`major-mode' matching is not affected by this." + :group 'helm-buffers + :type 'boolean) + +(defcustom helm-buffer-skip-remote-checking nil + "Ignore checking for `file-exists-p' on remote files." + :group 'helm-buffers + :type 'boolean) + +;;; Faces +;; +;; +(defgroup helm-buffers-faces nil + "Customize the appearance of helm-buffers." + :prefix "helm-" + :group 'helm-buffers + :group 'helm-faces) + +(defface helm-buffer-saved-out + '((t (:foreground "red" :background "black"))) + "Face used for buffer files modified outside of emacs." + :group 'helm-buffers-faces) + +(defface helm-buffer-not-saved + '((t (:foreground "Indianred2"))) + "Face used for buffer files not already saved on disk." + :group 'helm-buffers-faces) + +(defface helm-buffer-size + '((((background dark)) :foreground "RosyBrown") + (((background light)) :foreground "SlateGray")) + "Face used for buffer size." + :group 'helm-buffers-faces) + +(defface helm-buffer-process + '((t (:foreground "Sienna3"))) + "Face used for process status in buffer." + :group 'helm-buffers-faces) + +(defface helm-buffer-directory + '((t (:foreground "DarkRed" :background "LightGray"))) + "Face used for directories in `helm-buffers-list'." + :group 'helm-buffers-faces) + +(defface helm-buffer-file + '((t :inherit font-lock-builtin-face)) + "Face for buffer file names in `helm-buffers-list'." + :group 'helm-buffers-faces) + + +;;; Buffers keymap +;; +(defvar helm-buffer-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-buffer-help) + ;; No need to have separate command for grep and zgrep + ;; as we don't use recursivity for buffers. + ;; So use zgrep for both as it is capable to handle non--compressed files. + (define-key map (kbd "M-g s") 'helm-buffer-run-zgrep) + (define-key map (kbd "C-s") 'helm-buffers-run-multi-occur) + (define-key map (kbd "C-c o") 'helm-buffer-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-buffer-switch-other-frame) + (define-key map (kbd "C-c =") 'helm-buffer-run-ediff) + (define-key map (kbd "M-=") 'helm-buffer-run-ediff-merge) + (define-key map (kbd "C-=") 'helm-buffer-diff-persistent) + (define-key map (kbd "M-U") 'helm-buffer-revert-persistent) + (define-key map (kbd "C-c d") 'helm-buffer-run-kill-persistent) + (define-key map (kbd "M-D") 'helm-buffer-run-kill-buffers) + (define-key map (kbd "C-x C-s") 'helm-buffer-save-persistent) + (define-key map (kbd "C-M-%") 'helm-buffer-run-query-replace-regexp) + (define-key map (kbd "M-%") 'helm-buffer-run-query-replace) + (define-key map (kbd "M-m") 'helm-toggle-all-marks) + (define-key map (kbd "M-a") 'helm-mark-all) + (define-key map (kbd "C-]") 'helm-toggle-buffers-details) + (define-key map (kbd "C-c a") 'helm-buffers-toggle-show-hidden-buffers) + (define-key map (kbd "") 'helm-buffers-mark-similar-buffers) + map) + "Keymap for buffer sources in helm.") + +(defvar helm-buffers-ido-virtual-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-buffers-ido-virtual-help) + (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame) + (define-key map (kbd "M-g s") 'helm-ff-run-grep) + (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) + (define-key map (kbd "M-D") 'helm-ff-run-delete-file) + (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) + map)) + + +(defvar helm-buffers-list-cache nil) +(defvar helm-buffer-max-len-mode nil) +(defclass helm-source-buffers (helm-source-sync helm-type-buffer) + ((buffer-list + :initarg :buffer-list + :initform #'helm-buffer-list + :custom function + :documentation + " A function with no arguments to create buffer list.") + (init :initform (lambda () + ;; Issue #51 Create the list before `helm-buffer' creation. + (setq helm-buffers-list-cache (funcall (helm-attr 'buffer-list))) + (let ((result (cl-loop for b in helm-buffers-list-cache + maximize (length b) into len-buf + maximize (length (with-current-buffer b + (symbol-name major-mode))) + into len-mode + finally return (cons len-buf len-mode)))) + (unless helm-buffer-max-length + (setq helm-buffer-max-length (car result))) + (unless helm-buffer-max-len-mode + ;; If a new buffer is longer that this value + ;; this value will be updated + (setq helm-buffer-max-len-mode (cdr result)))))) + (candidates :initform helm-buffers-list-cache) + (matchplugin :initform nil) + ;(nohighlight :initform t) + (match :initform 'helm-buffers-match-function) + (persistent-action :initform 'helm-buffers-list-persistent-action) + (resume :initform (lambda () + (run-with-idle-timer + 0.1 nil (lambda () + (with-helm-buffer + (helm-force-update)))))) + (keymap :initform helm-buffer-map) + (volatile :initform t) + (mode-line :initform helm-buffer-mode-line-string) + (persistent-help + :initform + "Show this buffer / C-u \\[helm-execute-persistent-action]: Kill this buffer"))) + +(defvar helm-source-buffers-list nil) + +(defvar helm-source-buffer-not-found + (helm-build-dummy-source + "Create buffer" + :action (helm-make-actions + "Create buffer (C-u choose mode)" + (lambda (candidate) + (let ((mjm (or (and helm-current-prefix-arg + (intern-soft (helm-comp-read + "Major-mode: " + helm-buffers-favorite-modes))) + (cl-loop for (r . m) in auto-mode-alist + when (string-match r candidate) + return m))) + (buffer (get-buffer-create candidate))) + (if mjm + (with-current-buffer buffer (funcall mjm)) + (set-buffer-major-mode buffer)) + (switch-to-buffer buffer)))))) + +(defvar ido-temp-list) +(defvar ido-ignored-list) +(defvar ido-process-ignore-lists) +(defvar ido-use-virtual-buffers) +(defvar ido-virtual-buffers) + +(defvar helm-source-ido-virtual-buffers + (helm-build-sync-source "Ido virtual buffers" + :candidates (lambda () + (let (ido-temp-list + ido-ignored-list + (ido-process-ignore-lists t)) + (when ido-use-virtual-buffers + (ido-add-virtual-buffers-to-list) + ido-virtual-buffers))) + :fuzzy-match helm-buffers-fuzzy-matching + :keymap helm-buffers-ido-virtual-map + :mode-line helm-buffers-ido-virtual-mode-line-string + :action '(("Find file" . helm-find-many-files) + ("Find file other window" . find-file-other-window) + ("Find file other frame" . find-file-other-frame) + ("Find file as root" . helm-find-file-as-root) + ("Grep File(s) `C-u recurse'" . helm-find-files-grep) + ("Zgrep File(s) `C-u Recurse'" . helm-ff-zgrep) + ("View file" . view-file) + ("Delete file(s)" . helm-delete-marked-files) + ("Open file externally (C-u to choose)" + . helm-open-file-externally)))) + + +(defvar ido-use-virtual-buffers) +(defun helm-buffer-list () + "Return the current list of buffers. +Currently visible buffers are put at the end of the list. +See `ido-make-buffer-list' for more infos." + (require 'ido) + (let ((ido-process-ignore-lists t) + ido-ignored-list + ido-use-virtual-buffers) + (ido-make-buffer-list nil))) + +(defun helm-buffer-size (buffer) + "Return size of BUFFER." + (with-current-buffer buffer + (save-restriction + (widen) + (helm-file-human-size + (- (position-bytes (point-max)) + (position-bytes (point-min))))))) + +(defun helm-buffer--show-details (buf-name prefix help-echo + size mode dir face1 face2 + proc details type) + (append + (list + (concat prefix + (propertize buf-name 'face face1 + 'help-echo help-echo + 'type type))) + (and details + (list size mode + (propertize + (if proc + (format "(%s %s in `%s')" + (process-name proc) + (process-status proc) dir) + (format "(in `%s')" dir)) + 'face face2))))) + +(defun helm-buffer--details (buffer &optional details) + (let* ((mode (with-current-buffer buffer (format-mode-line mode-name))) + (buf (get-buffer buffer)) + (size (propertize (helm-buffer-size buf) + 'face 'helm-buffer-size)) + (proc (get-buffer-process buf)) + (dir (with-current-buffer buffer (abbreviate-file-name default-directory))) + (file-name (helm-aif (buffer-file-name buf) (abbreviate-file-name it))) + (name (buffer-name buf)) + (name-prefix (when (file-remote-p dir) + (propertize "@ " 'face 'helm-ff-prefix)))) + ;; No fancy things on remote buffers. + (if (and name-prefix helm-buffer-skip-remote-checking) + (helm-buffer--show-details + name name-prefix file-name size mode dir + 'helm-buffer-file 'helm-buffer-process nil details 'filebuf) + (cond + ( ;; A dired buffer. + (rassoc buf dired-buffers) + (helm-buffer--show-details + name name-prefix dir size mode dir + 'helm-buffer-directory 'helm-buffer-process nil details 'dired)) + ;; A buffer file modified somewhere outside of emacs.=>red + ((and file-name + (file-exists-p file-name) + (not (verify-visited-file-modtime buf))) + (helm-buffer--show-details + name name-prefix file-name size mode dir + 'helm-buffer-saved-out 'helm-buffer-process nil details 'modout)) + ;; A new buffer file not already saved on disk.=>indianred2 + ((and file-name + (not (verify-visited-file-modtime buf))) + (helm-buffer--show-details + name name-prefix file-name size mode dir + 'helm-buffer-not-saved 'helm-buffer-process nil details 'notsaved)) + ;; A buffer file modified and not saved on disk.=>orange + ((and file-name (buffer-modified-p buf)) + (helm-buffer--show-details + name name-prefix file-name size mode dir + 'helm-ff-symlink 'helm-buffer-process nil details 'mod)) + ;; A buffer file not modified and saved on disk.=>green + (file-name + (helm-buffer--show-details + name name-prefix file-name size mode dir + 'helm-buffer-file 'helm-buffer-process nil details 'filebuf)) + ;; Any non--file buffer.=>grey italic + (t + (helm-buffer--show-details + name (and proc name-prefix) dir size mode dir + 'italic 'helm-buffer-process proc details 'nofile)))))) + +(defun helm-highlight-buffers (buffers _source) + "Transformer function to highlight BUFFERS list. +Should be called after others transformers i.e (boring buffers)." + (cl-loop for i in buffers + for (name size mode meta) = (if helm-buffer-details-flag + (helm-buffer--details i 'details) + (helm-buffer--details i)) + for truncbuf = (if (> (string-width name) helm-buffer-max-length) + (helm-substring-by-width + name helm-buffer-max-length) + (concat name (make-string + (- (+ helm-buffer-max-length 3) + (string-width name)) ? ))) + for len = (length mode) + when (> len helm-buffer-max-len-mode) + do (setq helm-buffer-max-len-mode len) + for fmode = (concat (make-string + (- (max helm-buffer-max-len-mode len) len) ? ) + mode) + ;; The max length of a number should be 1023.9X where X is the + ;; units, this is 7 characters. + for formatted-size = (and size (format "%7s" size)) + collect (cons (if helm-buffer-details-flag + (concat truncbuf "\t" formatted-size + " " fmode " " meta) + name) + (get-buffer i)))) + +(defun helm-buffer--get-preselection (buffer) + (let ((bufname (buffer-name buffer))) + (concat "^" + (if (and (null helm-buffer-details-flag) + (numberp helm-buffer-max-length) + (> (string-width bufname) + helm-buffer-max-length)) + (regexp-quote + (helm-substring-by-width + bufname helm-buffer-max-length)) + (concat (regexp-quote bufname) + (if helm-buffer-details-flag + "$" "[[:blank:]]+")))))) + +(defun helm-toggle-buffers-details () + (interactive) + (let ((preselect (helm-buffer--get-preselection + (helm-get-selection)))) + (when helm-alive-p + (setq helm-buffer-details-flag (not helm-buffer-details-flag)) + (helm-force-update preselect)))) + +(defun helm-buffers-sort-transformer (candidates _source) + (if (string= helm-pattern "") + candidates + (sort candidates + #'(lambda (s1 s2) + (< (string-width s1) (string-width s2)))))) + +(defun helm-buffers-mark-similar-buffers-1 () + (with-helm-window + (let ((type (get-text-property + 0 'type (helm-get-selection nil 'withprop)))) + (save-excursion + (goto-char (helm-get-previous-header-pos)) + (helm-next-line) + (let* ((next-head (helm-get-next-header-pos)) + (end (and next-head + (save-excursion + (goto-char next-head) + (forward-line -1) + (point)))) + (maxpoint (or end (point-max)))) + (while (< (point) maxpoint) + (helm-mark-current-line) + (let ((cand (helm-get-selection nil 'withprop))) + (when (and (not (helm-this-visible-mark)) + (eq (get-text-property 0 'type cand) type)) + (helm-make-visible-mark))) + (forward-line 1) (end-of-line)))) + (helm-mark-current-line) + (message "%s candidates marked" (length helm-marked-candidates))))) + +(defun helm-buffers-mark-similar-buffers () + "Mark All buffers that have same property `type' than current. +i.e same color." + (interactive) + (let ((marked (helm-marked-candidates))) + (if (and (>= (length marked) 1) + (with-helm-window helm-visible-mark-overlays)) + (helm-unmark-all) + (helm-buffers-mark-similar-buffers-1)))) + + +;;; match functions +;; +(defun helm-buffer--match-mjm (pattern mjm) + (when (string-match "\\`\\*" pattern) + (cl-loop with patterns = (split-string (substring pattern 1) ",") + for pat in patterns + if (string-match "\\`!" pat) + collect (string-match (substring pat 1) mjm) into neg + else collect (string-match pat mjm) into pos + finally return + (let ((neg-test (cl-loop for i in neg thereis (numberp i))) + (pos-test (cl-loop for i in pos thereis (numberp i)))) + (or + (and neg (not pos) (not neg-test)) + (and pos pos-test) + (and neg neg-test (not neg-test))))))) + +(defun helm-buffer--match-pattern (pattern candidate) + (let ((fun (if (and helm-buffers-fuzzy-matching + (not (string-match "\\`\\^" pattern))) + #'helm--mapconcat-pattern + #'identity))) + (if (string-match "\\`!" pattern) + (not (string-match (funcall fun (substring pattern 1)) + candidate)) + (string-match (funcall fun pattern) candidate)))) + +(defun helm-buffers--match-from-mjm (candidate) + (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate)) + (buf (get-buffer cand)) + (regexp (cl-loop with pattern = helm-pattern + for p in (split-string pattern) + when (string-match "\\`\\*" p) + return p))) + (if regexp + (when buf + (with-current-buffer buf + (let ((mjm (format-mode-line mode-name))) + (helm-buffer--match-mjm regexp mjm)))) + t))) + +(defun helm-buffers--match-from-pat (candidate) + (let ((regexp-list (cl-loop with pattern = helm-pattern + for p in (split-string pattern) + unless (string-match + "\\`\\(\\*\\)\\|\\(/\\)\\|\\(@\\)" p) + collect p))) + (if regexp-list + (cl-loop for re in regexp-list + always (helm-buffer--match-pattern re candidate)) + t))) + +(defun helm-buffers--match-from-inside (candidate) + (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate)) + (buf (get-buffer cand)) + (regexp (cl-loop with pattern = helm-pattern + for p in (split-string pattern) + when (string-match "\\`@\\(.*\\)" p) + return (match-string 1 p)))) + (if regexp + (with-current-buffer buf + (save-excursion + (goto-char (point-min)) + (re-search-forward regexp nil t))) + t))) + +(defun helm-buffers--match-from-directory (candidate) + (let* ((cand (replace-regexp-in-string "^\\s-\\{1\\}" "" candidate)) + (buf (get-buffer cand)) + (buf-fname (buffer-file-name buf)) + (regexps (cl-loop with pattern = helm-pattern + for p in (split-string pattern) + when (string-match "\\`/" p) + collect p))) + (if regexps + (cl-loop for re in regexps + thereis + (and buf-fname + (string-match + (substring re 1) (helm-basedir buf-fname)))) + t))) + +(defun helm-buffers-match-function (candidate) + "Default function to match buffers." + (and (helm-buffers--match-from-pat candidate) + (helm-buffers--match-from-mjm candidate) + (helm-buffers--match-from-inside candidate) + (helm-buffers--match-from-directory candidate))) + + +(defun helm-buffer-query-replace-1 (&optional regexp-flag buffers) + "Query replace in marked buffers. +If REGEXP-FLAG is given use `query-replace-regexp'." + (let ((fn (if regexp-flag 'query-replace-regexp 'query-replace)) + (prompt (if regexp-flag "Query replace regexp" "Query replace")) + (bufs (or buffers (helm-marked-candidates))) + (helm--reading-passwd-or-string t)) + (cl-loop with replace = (query-replace-read-from prompt regexp-flag) + with tostring = (unless (consp replace) + (query-replace-read-to + replace prompt regexp-flag)) + for buf in bufs + do + (save-window-excursion + (switch-to-buffer buf) + (save-excursion + (let ((case-fold-search t)) + (goto-char (point-min)) + (if (consp replace) + (apply fn (list (car replace) (cdr replace))) + (apply fn (list replace tostring))))))))) + +(defun helm-buffer-query-replace-regexp (_candidate) + (helm-buffer-query-replace-1 'regexp)) + +(defun helm-buffer-query-replace (_candidate) + (helm-buffer-query-replace-1)) + +(defun helm-buffer-toggle-diff (candidate) + "Toggle diff buffer CANDIDATE with it's file." + (let (helm-persistent-action-use-special-display) + (helm-aif (get-buffer-window "*Diff*") + (progn (kill-buffer "*Diff*") + (set-window-buffer it helm-current-buffer)) + (diff-buffer-with-file (get-buffer candidate))))) + +(defun helm-buffer-diff-persistent () + "Toggle diff buffer without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'diff-action 'helm-buffer-toggle-diff) + (helm-execute-persistent-action 'diff-action))) + +(defun helm-revert-buffer (candidate) + (with-current-buffer candidate + (helm-aif (buffer-file-name) + (and (file-exists-p it) (revert-buffer t t))))) + +(defun helm-revert-marked-buffers (_ignore) + (mapc 'helm-revert-buffer (helm-marked-candidates))) + +(defun helm-buffer-revert-and-update (_candidate) + (let ((marked (helm-marked-candidates)) + (preselect (helm-buffers--quote-truncated-buffer + (helm-get-selection)))) + (cl-loop for buf in marked do (helm-revert-buffer buf)) + (when (> (length marked) 1) (helm-unmark-all)) + (helm-force-update preselect))) + +(defun helm-buffer-revert-persistent () + "Revert buffer without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'revert-action '(helm-buffer-revert-and-update . never-split)) + (helm-execute-persistent-action 'revert-action))) + +(defun helm-buffer-save-and-update (_candidate) + (let ((marked (helm-marked-candidates)) + (preselect (helm-get-selection nil t)) + (enable-recursive-minibuffers t)) + (cl-loop for buf in marked do + (with-current-buffer (get-buffer buf) + (when (buffer-file-name) (save-buffer)))) + (when (> (length marked) 1) (helm-unmark-all)) + (helm-force-update (regexp-quote preselect)))) + +(defun helm-buffer-save-persistent () + "Save buffer without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'save-action '(helm-buffer-save-and-update . never-split)) + (helm-execute-persistent-action 'save-action))) + +(defun helm-buffer-run-kill-persistent () + "Kill buffer without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'kill-action '(helm-buffers-persistent-kill . never-split)) + (helm-execute-persistent-action 'kill-action))) + +(defun helm-kill-marked-buffers (_ignore) + (mapc 'kill-buffer (helm-marked-candidates)) + (with-helm-buffer + (setq helm-marked-candidates nil + helm-visible-mark-overlays nil))) + +(defun helm-buffer-run-kill-buffers () + "Run kill buffer action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-kill-marked-buffers))) + +(defun helm-buffer-run-grep () + "Run Grep action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-grep-buffers))) + +(defun helm-buffer-run-zgrep () + "Run Grep action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-zgrep-buffers))) + +(defun helm-buffer-run-query-replace-regexp () + "Run Query replace regexp action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-buffer-query-replace-regexp))) + +(defun helm-buffer-run-query-replace () + "Run Query replace action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-buffer-query-replace))) + +(defun helm-buffer-switch-other-window () + "Run switch to other window action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-switch-to-buffers-other-window))) + +(defun helm-buffer-switch-other-frame () + "Run switch to other frame action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'switch-to-buffer-other-frame))) + +(defun helm-buffer-switch-to-elscreen () + "Run switch to elscreen action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-buffer-on-elscreen))) + +(defun helm-buffer-run-ediff () + "Run ediff action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ediff-marked-buffers))) + +(defun helm-buffer-run-ediff-merge () + "Run ediff action from `helm-source-buffers-list'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ediff-marked-buffers-merge))) + +(defun helm-buffers-persistent-kill-1 (buffer) + "Persistent action to kill buffer." + (with-current-buffer (get-buffer buffer) + (if (and (buffer-modified-p) + (buffer-file-name (current-buffer))) + (progn + (save-buffer) + (kill-buffer buffer)) + (kill-buffer buffer))) + (helm-delete-current-selection) + (with-helm-temp-hook 'helm-after-persistent-action-hook + (helm-force-update (regexp-quote (helm-get-selection nil t))))) + +(defun helm-buffers--quote-truncated-buffer (buffer) + (let ((bufname (and (bufferp buffer) + (buffer-name buffer)))) + (when bufname + (regexp-quote + (if helm-buffer-max-length + (helm-substring-by-width + bufname helm-buffer-max-length + "") + bufname))))) + +(defun helm-buffers-persistent-kill (_buffer) + (let ((marked (helm-marked-candidates))) + (unwind-protect + (cl-loop for b in marked + do (progn (helm-preselect + (format "^%s" + (helm-buffers--quote-truncated-buffer b))) + (when (y-or-n-p (format "kill buffer (%s)? " b)) + (helm-buffers-persistent-kill-1 b)) + (message nil))) + (with-helm-buffer + (setq helm-marked-candidates nil + helm-visible-mark-overlays nil)) + (helm-force-update (helm-buffers--quote-truncated-buffer + (helm-get-selection)))))) + +(defun helm-buffers-list-persistent-action (candidate) + (if current-prefix-arg + (helm-buffers-persistent-kill candidate) + (switch-to-buffer candidate))) + +(defun helm-ediff-marked-buffers (_candidate &optional merge) + "Ediff 2 marked buffers or CANDIDATE and `helm-current-buffer'. +With optional arg MERGE call `ediff-merge-buffers'." + (let ((lg-lst (length (helm-marked-candidates))) + buf1 buf2) + (cl-case lg-lst + (0 + (error "Error:You have to mark at least 1 buffer")) + (1 + (setq buf1 helm-current-buffer + buf2 (cl-first (helm-marked-candidates)))) + (2 + (setq buf1 (cl-first (helm-marked-candidates)) + buf2 (cl-second (helm-marked-candidates)))) + (t + (error "Error:To much buffers marked!"))) + (if merge + (ediff-merge-buffers buf1 buf2) + (ediff-buffers buf1 buf2)))) + +(defun helm-ediff-marked-buffers-merge (candidate) + "Ediff merge `helm-current-buffer' with CANDIDATE. +See `helm-ediff-marked-buffers'." + (helm-ediff-marked-buffers candidate t)) + +(defun helm-multi-occur-as-action (_candidate) + "Multi occur action for `helm-source-buffers-list'. +Can be used by any source that list buffers." + (let ((helm-moccur-always-search-in-current + (if helm-current-prefix-arg + (not helm-moccur-always-search-in-current) + helm-moccur-always-search-in-current)) + (buffers (helm-marked-candidates)) + (input (cl-loop for i in (split-string helm-pattern " " t) + thereis (and (string-match "\\`@\\(.*\\)" i) + (match-string 1 i))))) + (helm-multi-occur-1 buffers input))) + +(defun helm-buffers-run-multi-occur () + "Run `helm-multi-occur-as-action' by key." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-multi-occur-as-action))) + +(defun helm-buffers-toggle-show-hidden-buffers () + (interactive) + (with-helm-alive-p + (let ((filter-attrs (helm-attr 'filtered-candidate-transformer + helm-source-buffers-list))) + (if (memq 'helm-shadow-boring-buffers filter-attrs) + (helm-attrset 'filtered-candidate-transformer + (cons 'helm-skip-boring-buffers + (remove 'helm-shadow-boring-buffers + filter-attrs)) + helm-source-buffers-list t) + (helm-attrset 'filtered-candidate-transformer + (cons 'helm-shadow-boring-buffers + (remove 'helm-skip-boring-buffers + filter-attrs)) + helm-source-buffers-list t)) + (helm-force-update)))) + + +;;; Candidate Transformers +;; +;; +(defun helm-skip-boring-buffers (buffers _source) + (helm-skip-entries buffers helm-boring-buffer-regexp-list)) + +(defun helm-shadow-boring-buffers (buffers _source) + "Buffers matching `helm-boring-buffer-regexp' will be +displayed with the `file-name-shadow' face if available." + (helm-shadow-entries buffers helm-boring-buffer-regexp-list)) + + +(define-helm-type-attribute 'buffer + `((action + . ,(helm-make-actions + "Switch to buffer" 'switch-to-buffer + (lambda () (and (locate-library "popwin") "Switch to buffer in popup window")) + 'popwin:popup-buffer + "Switch to buffer other window `C-c o'" 'switch-to-buffer-other-window + "Switch to buffer other frame `C-c C-o'" 'switch-to-buffer-other-frame + (lambda () (and (locate-library "elscreen") "Display buffer in Elscreen")) + 'helm-find-buffer-on-elscreen + "Query replace regexp `C-M-%'" 'helm-buffer-query-replace-regexp + "Query replace `M-%'" 'helm-buffer-query-replace + "View buffer" 'view-buffer + "Display buffer" 'display-buffer + "Grep buffers `M-g s' (C-u grep all buffers)" 'helm-zgrep-buffers + "Multi occur buffer(s) `C-s'" 'helm-multi-occur-as-action + "Revert buffer(s) `M-U'" 'helm-revert-marked-buffers + "Insert buffer" 'insert-buffer + "Kill buffer(s) `M-D'" 'helm-kill-marked-buffers + "Diff with file" 'diff-buffer-with-file + "Ediff Marked buffers `C-c ='" 'helm-ediff-marked-buffers + "Ediff Merge marked buffers `M-='" (lambda (candidate) + (helm-ediff-marked-buffers candidate t)))) + (persistent-help . "Show this buffer") + (filtered-candidate-transformer helm-skip-boring-buffers + helm-buffers-sort-transformer + helm-highlight-buffers)) + "Buffer or buffer name.") + +;;;###autoload +(defun helm-buffers-list () + "Preconfigured `helm' to list buffers." + (interactive) + (unless helm-source-buffers-list + (setq helm-source-buffers-list + (helm-make-source "Buffers" 'helm-source-buffers))) + (helm :sources '(helm-source-buffers-list + helm-source-ido-virtual-buffers + helm-source-buffer-not-found) + :buffer "*helm buffers*" + :keymap helm-buffer-map + :truncate-lines t)) + +(provide 'helm-buffers) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-buffers.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-color.el b/emacs.d/elpa/helm-20150507.2215/helm-color.el new file mode 100644 index 0000000..af4af76 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-color.el @@ -0,0 +1,163 @@ +;;; helm-color.el --- colors and faces -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) + +;;; Customize Face +;; +;; +(defun helm-custom-faces-init () + "Initialize buffer for `helm-source-customize-face'." + (unless (helm-candidate-buffer) + (save-selected-window + (list-faces-display) + (message nil)) + (helm-init-candidates-in-buffer + 'global + (with-current-buffer (get-buffer "*Faces*") + (buffer-substring + (next-single-char-property-change (point-min) 'face) + (point-max)))) + (kill-buffer "*Faces*"))) + +(defvar helm-source-customize-face + '((name . "Customize Face") + (init . helm-custom-faces-init) + (candidates-in-buffer) + (get-line . buffer-substring) + (action . (("Customize" + . (lambda (line) + (customize-face (intern (car (split-string line)))))) + ("Copy name" + . (lambda (line) + (kill-new (car (split-string line " " t)))))))) + "See (info \"(emacs)Faces\")") + +;;; Colors browser +;; +;; +(defun helm-colors-init () + (unless (helm-candidate-buffer) + (save-selected-window + (list-colors-display) + (message nil)) + (helm-init-candidates-in-buffer + 'global + (with-current-buffer (get-buffer "*Colors*") + (buffer-string))) + (kill-buffer "*Colors*"))) + +(defun helm-color-insert-name (candidate) + (with-helm-current-buffer + (insert (helm-colors-get-name candidate)))) + +(defun helm-color-kill-name (candidate) + (kill-new (helm-colors-get-name candidate))) + +(defun helm-color-insert-rgb (candidate) + (with-helm-current-buffer + (insert (helm-colors-get-rgb candidate)))) + +(defun helm-color-kill-rgb (candidate) + (kill-new (helm-colors-get-rgb candidate))) + +(defun helm-color-run-insert-name () + "Insert name of color from `helm-source-colors'" + (interactive) + (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-insert-name))) + +(defun helm-color-run-kill-name () + "Kill name of color from `helm-source-colors'" + (interactive) + (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-kill-name))) + +(defun helm-color-run-insert-rgb () + "Insert RGB of color from `helm-source-colors'" + (interactive) + (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-insert-rgb))) + +(defun helm-color-run-kill-rgb () + "Kill RGB of color from `helm-source-colors'" + (interactive) + (with-helm-alive-p (helm-quit-and-execute-action 'helm-color-kill-rgb))) + +(defvar helm-color-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c n") 'helm-color-run-insert-name) + (define-key map (kbd "C-c N") 'helm-color-run-kill-name) + (define-key map (kbd "C-c r") 'helm-color-run-insert-rgb) + (define-key map (kbd "C-c R") 'helm-color-run-kill-rgb) + (define-key map (kbd "C-c ?") 'helm-color-help) + map)) + +(defvar helm-source-colors + `((name . "Colors") + (init . helm-colors-init) + (candidates-in-buffer) + (get-line . buffer-substring) + (keymap . ,helm-color-map) + (persistent-help . "Kill entry in RGB format.") + (persistent-action . helm-color-kill-rgb) + (mode-line . helm-color-mode-line-string) + (action + ("Copy Name (C-c N)" . helm-color-kill-name) + ("Copy RGB (C-c R)" . helm-color-kill-rgb) + ("Insert Name (C-c n)" . helm-color-insert-name) + ("Insert RGB (C-c r)" . helm-color-insert-rgb)))) + +(defun helm-colors-get-name (candidate) + "Get color name." + (replace-regexp-in-string + " " "" + (with-temp-buffer + (insert (capitalize candidate)) + (goto-char (point-min)) + (search-forward-regexp "\\s-\\{2,\\}") + (delete-region (point) (point-max)) + (buffer-string)))) + +(defun helm-colors-get-rgb (candidate) + "Get color RGB." + (replace-regexp-in-string + " " "" + (with-temp-buffer + (insert (capitalize candidate)) + (goto-char (point-max)) + (search-backward-regexp "\\s-\\{2,\\}") + (delete-region (point) (point-min)) + (buffer-string)))) + +;;;###autoload +(defun helm-colors () + "Preconfigured `helm' for color." + (interactive) + (helm-other-buffer + '(helm-source-colors helm-source-customize-face) + "*helm colors*")) + +(provide 'helm-color) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-color.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-command.el b/emacs.d/elpa/helm-20150507.2215/helm-command.el new file mode 100644 index 0000000..e17d2a0 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-command.el @@ -0,0 +1,254 @@ +;;; helm-command.el --- Helm execute-exended-command. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-mode) +(require 'helm-elisp) + + +(defgroup helm-command nil + "Emacs command related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-M-x-requires-pattern 0 + "Value of requires-pattern for `helm-M-x'. +Show all candidates on startup when 0 (default)." + :group 'helm-command + :type 'boolean) + +(defcustom helm-M-x-always-save-history nil + "`helm-M-x' Save command in `extended-command-history' even when it fail." + :group 'helm-command + :type 'boolean) + +(defcustom helm-M-x-reverse-history nil + "The history source of `helm-M-x' appear in second position when non--nil." + :group 'helm-command + :type 'boolean) + +(defcustom helm-M-x-fuzzy-match nil + "Enable fuzzy matching in `helm-M-x' when non--nil.") + + +;;; Faces +;; +;; +(defgroup helm-command-faces nil + "Customize the appearance of helm-command." + :prefix "helm-" + :group 'helm-command + :group 'helm-faces) + +(defface helm-M-x-key '((t (:foreground "orange" :underline t))) + "Face used in helm-M-x to show keybinding." + :group 'helm-command-faces) + + +(defvar helm-M-x-input-history nil) + +(defvar helm-M-x-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-M-x-help) + map) + "Keymap for `helm-M-x'.") + + +(cl-defun helm-M-x-get-major-mode-command-alist (mode-map) + "Return alist of MODE-MAP." + (cl-loop for key being the key-seqs of mode-map using (key-bindings com) + for str-key = (key-description key) + for ismenu = (string-match "" str-key) + unless ismenu collect (cons str-key com))) + +(defun helm-get-mode-map-from-mode (mode) + "Guess the mode-map name according to MODE. +Some modes don't use conventional mode-map name +so we need to guess mode-map name. e.g python-mode ==> py-mode-map. +Return nil if no mode-map found." + (cl-loop ;; Start with a conventional mode-map name. + with mode-map = (intern-soft (format "%s-map" mode)) + with mode-string = (symbol-name mode) + with mode-name = (replace-regexp-in-string "-mode" "" mode-string) + while (not mode-map) + for count downfrom (length mode-name) + ;; Return when no result after parsing entire string. + when (eq count 0) return nil + for sub-name = (substring mode-name 0 count) + do (setq mode-map (intern-soft (format "%s-map" (concat sub-name "-mode")))) + finally return mode-map)) + +(defun helm-M-x-current-mode-map-alist () + "Return mode-map alist of current `major-mode'." + (let ((map (helm-get-mode-map-from-mode major-mode))) + (when (and map (boundp map)) + (helm-M-x-get-major-mode-command-alist (symbol-value map))))) + + +(defun helm-M-x-transformer-1 (candidates &optional sort) + "Transformer function to show bindings in emacs commands. +Show global bindings and local bindings according to current `major-mode'. +If SORT is non nil sort list with `helm-generic-sort-fn'. +Note that SORT should not be used when fuzzy matching because +fuzzy matching is running its own sort function with a different algorithm." + (with-helm-current-buffer + (cl-loop with local-map = (helm-M-x-current-mode-map-alist) + for cand in candidates + for local-key = (car (rassq cand local-map)) + for key = (substitute-command-keys (format "\\[%s]" cand)) + collect + (cons (cond ((and (string-match "^M-x" key) local-key) + (format "%s (%s)" + cand (propertize + local-key + 'face 'helm-M-x-key))) + ((string-match "^M-x" key) cand) + (t (format "%s (%s)" + cand (propertize + key + 'face 'helm-M-x-key)))) + cand) + into ls + finally return + (if sort (sort ls #'helm-generic-sort-fn) ls)))) + +(defun helm-M-x-transformer (candidates _source) + "Transformer function for `helm-M-x' candidates." + (helm-M-x-transformer-1 candidates (null helm--in-fuzzy))) + +(defun helm-M-x-transformer-hist (candidates _source) + "Transformer function for `helm-M-x' candidates." + (helm-M-x-transformer-1 candidates)) + +(defun helm-M-x--notify-prefix-arg () + ;; Notify a prefix-arg set AFTER calling M-x. + (when prefix-arg + (with-helm-window + (helm-display-mode-line (helm-get-current-source) 'force)))) + +(defun helm-M-x-read-extended-command () + "Read command name to invoke in `helm-M-x'. +Helm completion is not provided when executing or defining +kbd macros." + (if (or defining-kbd-macro executing-kbd-macro) + (if helm-mode + (unwind-protect + (progn + (helm-mode -1) + (read-extended-command)) + (helm-mode 1)) + (read-extended-command)) + (let* (in-help + help-cand + (orig-fuzzy-sort-fn helm-fuzzy-sort-fn) + (helm-fuzzy-sort-fn (lambda (candidates source) + (funcall orig-fuzzy-sort-fn + candidates source 'real))) + (helm--mode-line-display-prefarg t) + (pers-help + #'(lambda (candidate) + (let ((hbuf (get-buffer (help-buffer)))) + (if (and in-help (string= candidate help-cand) + (null helm-persistent-action-use-special-display)) + (progn + ;; When M-x is started from a help buffer, + ;; Don't kill it as it is helm-current-buffer. + (unless (equal hbuf helm-current-buffer) + (kill-buffer hbuf) + (set-window-buffer (get-buffer-window hbuf) + helm-current-buffer)) + (setq in-help nil)) + (helm-describe-function candidate) + (setq in-help t)) + (setq help-cand candidate)))) + (tm (run-at-time 1 0.1 'helm-M-x--notify-prefix-arg))) + (setq extended-command-history + (cl-loop for i in extended-command-history + when (commandp (intern i)) + do (set-text-properties 0 (length i) nil i) + and collect i)) + (unwind-protect + (let ((msg "Error: Specifying a prefix arg before calling `helm-M-x'")) + (when current-prefix-arg + (ding) + (message "%s" msg) + (while (not (sit-for 1)) + (discard-input)) + (user-error msg)) + (setq current-prefix-arg nil) + (helm-comp-read + "M-x " obarray + :test 'commandp + :requires-pattern helm-M-x-requires-pattern + :name "Emacs Commands" + :buffer "*helm M-x*" + :persistent-action pers-help + :persistent-help "Describe this command" + :history extended-command-history + :reverse-history helm-M-x-reverse-history + :del-input nil + :mode-line helm-M-x-mode-line + :must-match t + :fuzzy helm-M-x-fuzzy-match + :nomark t + :keymap helm-M-x-map + :candidates-in-buffer t + :fc-transformer 'helm-M-x-transformer + :hist-fc-transformer 'helm-M-x-transformer-hist)) + (cancel-timer tm) + (setq helm--mode-line-display-prefarg nil))))) + +;;;###autoload +(defun helm-M-x (arg &optional command-name) + "Preconfigured `helm' for Emacs commands. +It is `helm' replacement of regular `M-x' `execute-extended-command'. + +Unlike regular `M-x' emacs vanilla `execute-extended-command' command, +the prefix args if needed, are passed AFTER starting `helm-M-x'. + +You can get help on each command by persistent action." + (interactive (list current-prefix-arg (helm-M-x-read-extended-command))) + (let ((sym-com (and (stringp command-name) (intern-soft command-name)))) + ;; Avoid having `this-command' set to *exit-minibuffer. + (setq this-command sym-com + ;; Handle C-x z (repeat) Issue #322 + real-this-command sym-com) + ;; If helm-M-x is called with regular emacs completion (kmacro) + ;; use the value of arg otherwise use helm-current-prefix-arg. + (let ((prefix-arg (or helm-current-prefix-arg arg))) + ;; This ugly construct is to save history even on error. + (unless helm-M-x-always-save-history + (command-execute sym-com 'record)) + (setq extended-command-history + (cons command-name + (delete command-name extended-command-history))) + (when helm-M-x-always-save-history + (command-execute sym-com 'record))))) + + +(provide 'helm-command) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-command.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-config.el b/emacs.d/elpa/helm-20150507.2215/helm-config.el new file mode 100644 index 0000000..35d043c --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-config.el @@ -0,0 +1,216 @@ +;;; helm-config.el --- Applications library for `helm.el' -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + + +;;; Require +;; +;; +(require 'easymenu) +(require 'helm-aliases) +(require 'async-bytecomp nil t) + + +(defgroup helm-config nil + "Various configurations for Helm." + :group 'helm) + +(defcustom helm-command-prefix-key "C-x c" + "The key `helm-command-prefix' is bound to in the global map." + :type '(choice (string :tag "Key") (const :tag "no binding")) + :group 'helm-config + :set + (lambda (var key) + (when (and (boundp var) (symbol-value var)) + (define-key (current-global-map) + (read-kbd-macro (symbol-value var)) nil)) + (when key + (define-key (current-global-map) + (read-kbd-macro key) 'helm-command-prefix)) + (set var key))) + +(defcustom helm-minibuffer-history-key "C-r" + "The key `helm-minibuffer-history' is bound to in minibuffer local maps." + :type '(choice (string :tag "Key") (const :tag "no binding")) + :group 'helm-config + :set + (lambda (var key) + (cl-dolist (map '(minibuffer-local-completion-map + minibuffer-local-filename-completion-map + minibuffer-local-filename-must-match-map ; Emacs 23.1.+ + minibuffer-local-isearch-map + minibuffer-local-map + minibuffer-local-must-match-filename-map ; Older Emacsen + minibuffer-local-must-match-map + minibuffer-local-ns-map)) + (when (and (boundp map) (keymapp (symbol-value map))) + (when (and (boundp var) (symbol-value var)) + (define-key (symbol-value map) + (read-kbd-macro (symbol-value var)) nil)) + (when key + (define-key (symbol-value map) + (read-kbd-macro key) 'helm-minibuffer-history)))) + (set var key))) + +;;; Command Keymap +;; +;; +(defvar helm-command-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "a") 'helm-apropos) + (define-key map (kbd "e") 'helm-etags-select) + (define-key map (kbd "l") 'helm-locate) + (define-key map (kbd "s") 'helm-surfraw) + (define-key map (kbd "r") 'helm-regexp) + (define-key map (kbd "m") 'helm-man-woman) + (define-key map (kbd "t") 'helm-top) + (define-key map (kbd "/") 'helm-find) + (define-key map (kbd "i") 'helm-semantic-or-imenu) + (define-key map (kbd "") 'helm-lisp-completion-at-point) + (define-key map (kbd "p") 'helm-list-emacs-process) + (define-key map (kbd "C-x r b") 'helm-filtered-bookmarks) + (define-key map (kbd "M-y") 'helm-show-kill-ring) + (define-key map (kbd "C-c ") 'helm-all-mark-rings) + (define-key map (kbd "C-x C-f") 'helm-find-files) + (define-key map (kbd "f") 'helm-multi-files) + (define-key map (kbd "C-:") 'helm-eval-expression-with-eldoc) + (define-key map (kbd "C-,") 'helm-calcul-expression) + (define-key map (kbd "M-x") 'helm-M-x) + (define-key map (kbd "M-s o") 'helm-occur) + (define-key map (kbd "M-g s") 'helm-do-grep) + (define-key map (kbd "c") 'helm-colors) + (define-key map (kbd "F") 'helm-select-xfont) + (define-key map (kbd "8") 'helm-ucs) + (define-key map (kbd "C-c f") 'helm-recentf) + (define-key map (kbd "C-c g") 'helm-google-suggest) + (define-key map (kbd "h i") 'helm-info-at-point) + (define-key map (kbd "h r") 'helm-info-emacs) + (define-key map (kbd "h g") 'helm-info-gnus) + (define-key map (kbd "C-x C-b") 'helm-buffers-list) + (define-key map (kbd "C-x r i") 'helm-register) + (define-key map (kbd "C-c C-x") 'helm-run-external-command) + (define-key map (kbd "b") 'helm-resume) + map)) + +;; Don't override the keymap we just defined with an empty +;; keymap. This also protect bindings changed by the user. +(defvar helm-command-prefix) +(define-prefix-command 'helm-command-prefix) +(fset 'helm-command-prefix helm-command-map) +(setq helm-command-prefix helm-command-map) + + +;;; Menu +;; +;; +(easy-menu-add-item + nil '("Tools") + '("Helm" + ["Find any Files/Buffers" helm-multi-files t] + ["Helm Everywhere (Toggle)" helm-mode t] + ["Helm resume" helm-resume t] + "----" + ("Files" + ["Find files" helm-find-files t] + ["Recent Files" helm-recentf t] + ["Locate" helm-locate t] + ["Search Files with find" helm-find t] + ["Bookmarks" helm-filtered-bookmarks t]) + ("Buffers" + ["Find buffers" helm-buffers-list t]) + ("Commands" + ["Emacs Commands" helm-M-x t] + ["Externals Commands" helm-run-external-command t]) + ("Help" + ["Helm Apropos" helm-apropos t]) + ("Info" + ["Info at point" helm-info-at-point t] + ["Emacs Manual index" helm-info-emacs t] + ["Gnus Manual index" helm-info-gnus t]) + ("Org" + ["Org keywords" helm-org-keywords t] + ["Org headlines" helm-org-headlines t]) + ("Tools" + ["Occur" helm-occur t] + ["Grep" helm-do-grep t] + ["Etags" helm-etags-select t] + ["Lisp complete at point" helm-lisp-completion-at-point t] + ["Browse Kill ring" helm-show-kill-ring t] + ["Browse register" helm-register t] + ["Mark Ring" helm-all-mark-rings t] + ["Regexp handler" helm-regexp t] + ["Colors & Faces" helm-colors t] + ["Show xfonts" helm-select-xfont t] + ["Ucs Symbols" helm-ucs t] + ["Imenu" helm-imenu t] + ["Semantic or Imenu" helm-semantic-or-imenu t] + ["Google Suggest" helm-google-suggest t] + ["Eval expression" helm-eval-expression-with-eldoc t] + ["Calcul expression" helm-calcul-expression t] + ["Man pages" helm-man-woman t] + ["Top externals process" helm-top t] + ["Emacs internals process" helm-list-emacs-process t]) + "----" + ["Preferred Options" helm-configuration t]) + "Spell Checking") + +(easy-menu-add-item nil '("Tools") '("----") "Spell Checking") + + +;;;###autoload +(defun helm-configuration () + "Customize `helm'." + (interactive) + (customize-group "helm")) + + +;;; Fontlock +(cl-dolist (mode '(emacs-lisp-mode lisp-interaction-mode)) + (font-lock-add-keywords + mode + '(("(\\<\\(with-helm-after-update-hook\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-temp-hook\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-window\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-quittable\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-current-buffer\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-buffer\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-show-completion\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-default-directory\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-display-same-window\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(with-helm-restore-variables\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(define-helm-type-attribute\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-multi-key-defun\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-while-no-input\\)\\>" 1 font-lock-keyword-face) + ("(\\<\\(helm-aif\\)\\>" 1 font-lock-keyword-face)))) + + +;;; Load the autoload file +;; It should have been generated either by +;; package.el or the make file. + +(load "helm-autoloads" nil t) + +(provide 'helm-config) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-config.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-dabbrev.el b/emacs.d/elpa/helm-20150507.2215/helm-dabbrev.el new file mode 100644 index 0000000..e30cc7e --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-dabbrev.el @@ -0,0 +1,354 @@ +;;; helm-dabbrev.el --- Helm implementation of dabbrev. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'helm) +(require 'helm-elisp) ; For show-completion. + +(defgroup helm-dabbrev nil + "Dabbrev related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-dabbrev-always-search-all t + "Always search in all buffers when non--nil. +Note that even if nil, a search in all buffers +will occur if the length of candidates is <= than +`helm-dabbrev-max-length-result'." + :group 'helm-dabbrev + :type 'boolean) + +(defcustom helm-dabbrev-max-length-result 20 + "Max length of candidates before searching in all buffers. +If number of candidates found in current-buffer is <= to this, +search in all buffers. +Have no effect when `helm-dabbrev-always-search-all' is non--nil." + :group 'helm-dabbrev + :type 'integer) + +(defcustom helm-dabbrev-ignored-buffers-regexps + '("\\*helm" "\\*Messages" "\\*Echo Area" "\\*Buffer List") + "List of regexps matching names of buffers that helm-dabbrev should not check." + :group 'helm-dabbrev + :type '(repeat regexp)) + +(defcustom helm-dabbrev-related-buffer-fn #'helm-dabbrev--same-major-mode-p + "A function that decide if a buffer to search in is related to `current-buffer'. +This is actually determined by comparing `major-mode' of the buffer to search +and the `current-buffer'. +The function take one arg, the buffer which is current, look at +`helm-dabbrev--same-major-mode-p' for example. + +When nil all buffers are considered related to `current-buffer'." + :group 'helm-dabbrev + :type 'function) + +(defcustom helm-dabbrev-major-mode-assoc + '((emacs-lisp-mode . lisp-interaction-mode)) + "Major mode association alist. +This allow helm-dabbrev searching in buffers with the associated `major-mode'. +e.g \(emacs-lisp-mode . lisp-interaction-mode\) +will allow searching in the lisp-interaction-mode buffer when `current-buffer' +is an `emacs-lisp-mode' buffer and vice versa i.e +no need to provide \(lisp-interaction-mode . emacs-lisp-mode\) association. + +When nil check is the searched buffer have same `major-mode' +than the `current-buffer'. +This have no effect when `helm-dabbrev-related-buffer-fn' is nil or of course +bound to a function that doesn't handle this var." + :type '(alist :key-type symbol :value-type symbol) + :group 'helm-dabbrev) + +(defcustom helm-dabbrev-lineno-around 30 + "Search first in this number of lines before an after point." + :group 'helm-dabbrev + :type 'integer) + +(defcustom helm-dabbrev-cycle-threshold nil + "Number of time helm-dabbrev cycle before displaying helm completion. +When nil or 0 disable cycling." + :group 'helm-dabbrev + :type '(choice (const :tag "Cycling disabled" nil) integer)) + +(defcustom helm-dabbrev-case-fold-search 'smart + "Set `case-fold-search' in `helm-dabbrev'. +Same as `helm-case-fold-search' but for `helm-dabbrev'. +Note that this is not affecting searching in helm buffer, +but the initial search for all candidates in buffer(s)." + :group 'helm-dabbrev + :type '(choice (const :tag "Ignore case" t) + (const :tag "Respect case" nil) + (other :tag "Smart" 'smart))) + + +(defvar helm-dabbrev-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-/") 'helm-next-line) + (define-key map (kbd "M-:") 'helm-previous-line) + map)) + +;; Internal +(defvar helm-dabbrev--exclude-current-buffer-flag nil) +(defvar helm-dabbrev--cache nil) +(defvar helm-dabbrev--data nil) +(defvar helm-dabbrev--regexp "\\s-\\|\t\\|[(\[\{\"'`=<$;.]\\|\\s\\\\|^") +(cl-defstruct helm-dabbrev-info dabbrev limits iterator) + + +(defun helm-dabbrev--buffer-list () + (cl-loop with lst = (buffer-list) + for buf in (if helm-dabbrev--exclude-current-buffer-flag + (cdr lst) lst) + unless (cl-loop for r in helm-dabbrev-ignored-buffers-regexps + thereis (string-match r (buffer-name buf))) + collect buf)) + +(defun helm-dabbrev--same-major-mode-p (start-buffer) + ;; START-BUFFER is the current-buffer where we start searching. + ;; Determine the major-mode of START-BUFFER as `cur-maj-mode'. + ;; Each time the loop go in another buffer we try to find if its + ;; `major-mode' is: + ;; - same as the `cur-maj-mode' + ;; - derived from `cur-maj-mode' + ;; - have an assoc entry (major-mode . cur-maj-mode) + ;; - have an rassoc entry (cur-maj-mode . major-mode) + ;; - check if one of these entries inherit from another one in + ;; `helm-dabbrev-major-mode-assoc'. + (let* ((cur-maj-mode (with-current-buffer start-buffer major-mode)) + (c-assoc-mode (assq cur-maj-mode helm-dabbrev-major-mode-assoc)) + (c-rassoc-mode (rassq cur-maj-mode helm-dabbrev-major-mode-assoc)) + (o-assoc-mode (assq major-mode helm-dabbrev-major-mode-assoc)) + (o-rassoc-mode (rassq major-mode helm-dabbrev-major-mode-assoc)) + (cdr-c-assoc-mode (cdr c-assoc-mode)) + (cdr-o-assoc-mode (cdr o-assoc-mode))) + (or (eq major-mode cur-maj-mode) + (derived-mode-p cur-maj-mode) + (or (eq cdr-c-assoc-mode major-mode) + (eq (car c-rassoc-mode) major-mode) + (eq (cdr (assq cdr-c-assoc-mode helm-dabbrev-major-mode-assoc)) + major-mode) + (eq (car (rassq cdr-c-assoc-mode helm-dabbrev-major-mode-assoc)) + major-mode)) + (or (eq cdr-o-assoc-mode cur-maj-mode) + (eq (car o-rassoc-mode) cur-maj-mode) + (eq (cdr (assq cdr-o-assoc-mode helm-dabbrev-major-mode-assoc)) + cur-maj-mode) + (eq (car (rassq cdr-o-assoc-mode helm-dabbrev-major-mode-assoc)) + cur-maj-mode))))) + +(defun helm-dabbrev--collect (str limit ignore-case all) + (let* ((case-fold-search ignore-case) + (buffer1 (current-buffer)) ; start buffer. + (minibuf (minibufferp buffer1)) + result pos-before pos-after + (search-and-store + #'(lambda (pattern direction) + (while (cl-case direction + (1 (search-forward pattern nil t)) + (-1 (search-backward pattern nil t)) + (2 (let ((pos + (save-excursion + (forward-line + helm-dabbrev-lineno-around) + (point)))) + (setq pos-after pos) + (search-forward pattern pos t))) + (-2 (let ((pos + (save-excursion + (forward-line + (- helm-dabbrev-lineno-around)) + (point)))) + (setq pos-before pos) + (search-backward pattern pos t)))) + (let* ((replace-regexp (concat "\\(" helm-dabbrev--regexp "\\)\\'")) + (match-1 (helm-aif (thing-at-point 'symbol) + ;; `thing-at-point' returns + ;; the quote outside of e-lisp mode, + ;; e.g in message mode, + ;; `foo' => foo' + ;; but in e-lisp like modes: + ;; `foo' => foo + ;; so remove it [1]. + (replace-regexp-in-string + replace-regexp + "" (substring-no-properties it)))) + (match-2 (helm-aif (thing-at-point 'filename) + ;; Same as in [1]. + (replace-regexp-in-string + replace-regexp + "" (substring-no-properties it)))) + (lst (if (string= match-1 match-2) + (list match-1) + (list match-1 match-2)))) + (cl-loop for match in lst + unless (or (string= str match) + (member match result)) + do (push match result))))))) + (cl-loop for buf in (if all (helm-dabbrev--buffer-list) + (list (current-buffer))) + + do (with-current-buffer buf + (when (or minibuf ; check against all buffers when in minibuffer. + (if helm-dabbrev-related-buffer-fn + (funcall helm-dabbrev-related-buffer-fn buffer1) + t)) + (save-excursion + ;; Start searching before thing before point. + (goto-char (- (point) (length str))) + ;; Search the last 30 lines before point. + (funcall search-and-store str -2)) ; store pos [1] + (save-excursion + ;; Search the next 30 lines after point. + (funcall search-and-store str 2)) ; store pos [2] + (save-excursion + ;; Search all before point. + (goto-char pos-before) ; start from [1] + (funcall search-and-store str -1)) + (save-excursion + ;; Search all after point. + (goto-char pos-after) ; start from [2] + (funcall search-and-store str 1)))) + when (> (length result) limit) return (nreverse result) + finally return (nreverse result)))) + +(defun helm-dabbrev--get-candidates (abbrev) + (cl-assert abbrev nil "[No Match]") + (with-current-buffer (current-buffer) + (let* ((dabbrev-get #'(lambda (str all-bufs) + (helm-dabbrev--collect + str helm-candidate-number-limit + (cl-case helm-dabbrev-case-fold-search + (smart (helm-set-case-fold-search-1 abbrev)) + (t helm-dabbrev-case-fold-search)) + all-bufs))) + (lst (funcall dabbrev-get abbrev helm-dabbrev-always-search-all))) + (if (and (not helm-dabbrev-always-search-all) + (<= (length lst) helm-dabbrev-max-length-result)) + ;; Search all but don't recompute current-buffer. + (let ((helm-dabbrev--exclude-current-buffer-flag t)) + (append lst (funcall dabbrev-get abbrev 'all-bufs))) + lst)))) + +(defun helm-dabbrev-default-action (candidate) + (with-helm-current-buffer + (let* ((limits (helm-bounds-of-thing-before-point + helm-dabbrev--regexp)) + (beg (car limits)) + (end (point))) + (run-with-timer + 0.01 nil + 'helm-insert-completion-at-point + beg end candidate)))) + +;;;###autoload +(defun helm-dabbrev () + (interactive) + (let ((dabbrev (helm-thing-before-point nil helm-dabbrev--regexp)) + (limits (helm-bounds-of-thing-before-point helm-dabbrev--regexp)) + (enable-recursive-minibuffers t) + (cycling-disabled-p (or (null helm-dabbrev-cycle-threshold) + (zerop helm-dabbrev-cycle-threshold))) + (helm-execute-action-at-once-if-one t) + (helm-quit-if-no-candidate + #'(lambda () + (message "[Helm-dabbrev: No expansion found]")))) + (cl-assert (and (stringp dabbrev) (not (string= dabbrev ""))) + nil "[Helm-dabbrev: Nothing found before point]") + (when (and + ;; have been called at least once. + (helm-dabbrev-info-p helm-dabbrev--data) + ;; But user have moved with some other command + ;; in the meaning time. + (not (eq last-command 'helm-dabbrev))) + (setq helm-dabbrev--data nil)) + (when cycling-disabled-p + (setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev))) + (unless (or cycling-disabled-p + (helm-dabbrev-info-p helm-dabbrev--data)) + (setq helm-dabbrev--cache (helm-dabbrev--get-candidates dabbrev)) + (setq helm-dabbrev--data + (make-helm-dabbrev-info + :dabbrev dabbrev + :limits limits + :iterator + (helm-iter-list + (cl-loop for i in helm-dabbrev--cache when + (and i (string-match + (concat "^" (regexp-quote dabbrev)) i)) + collect i into selection + when (and selection + (= (length selection) + helm-dabbrev-cycle-threshold)) + ;; When selection len reach + ;; `helm-dabbrev-cycle-threshold' + ;; return selection. + return selection + ;; selection len never reach + ;; `helm-dabbrev-cycle-threshold' + ;; return selection. + finally return selection))))) + (let ((iter (and (helm-dabbrev-info-p helm-dabbrev--data) + (helm-dabbrev-info-iterator helm-dabbrev--data))) + deactivate-mark) + ;; Cycle until iterator is consumed. + (helm-aif (and iter (helm-iter-next iter)) + (progn + (helm-insert-completion-at-point + (car (helm-dabbrev-info-limits helm-dabbrev--data)) + (cdr limits) it) + ;; Move already tried candidates to end of list. + (setq helm-dabbrev--cache (append (remove it helm-dabbrev--cache) + (list it)))) + ;; If the length of candidates is only one when computed + ;; that's mean the unique matched item have already been + ;; inserted by the iterator, so no need to reinsert the old dabbrev, + ;; just let helm exiting with "No expansion found". + (let ((old-dabbrev (if (helm-dabbrev-info-p helm-dabbrev--data) + (helm-dabbrev-info-dabbrev helm-dabbrev--data) + dabbrev))) + (unless (cdr (all-completions old-dabbrev helm-dabbrev--cache)) + (setq cycling-disabled-p t)) + ;; Iterator is now empty, reset dabbrev to initial value + ;; and start helm completion. + (unless cycling-disabled-p + (setq dabbrev old-dabbrev + limits (helm-dabbrev-info-limits helm-dabbrev--data)) + (setq helm-dabbrev--data nil) + (delete-region (car limits) (point)) + (insert dabbrev)) + (with-helm-show-completion (car limits) (cdr limits) + (helm :sources (helm-build-in-buffer-source "Dabbrev Expand" + :data helm-dabbrev--cache + :persistent-action 'ignore + :persistent-help "DoNothing" + :keymap helm-dabbrev-map + :action 'helm-dabbrev-default-action) + :buffer "*helm dabbrev*" + :input (concat "^" dabbrev " ") + :resume 'noresume + :allow-nest t))))))) + +(provide 'helm-dabbrev) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-dabbrev.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-elisp-package.el b/emacs.d/elpa/helm-20150507.2215/helm-elisp-package.el new file mode 100644 index 0000000..dfb33a3 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-elisp-package.el @@ -0,0 +1,315 @@ +;;; helm-elisp-package.el --- helm interface for package.el -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) +(require 'package) + +(defgroup helm-el-package nil + "helm elisp packages." + :group 'helm) + +(defcustom helm-el-package-initial-filter 'all + "Show only installed, upgraded or all packages at startup." + :group 'helm-el-package + :type '(radio :tag "Initial filter for elisp packages" + (const :tag "Show all packages" all) + (const :tag "Show installed packages" installed) + (const :tag "Show upgradable packages" upgrade))) + +;; internals vars +(defvar helm-el-package--show-only 'all) +(defvar helm-el-package--initialized-p nil) +(defvar helm-el-package--tabulated-list nil) +(defvar helm-el-package--upgrades nil) +(defvar helm-el-package--removable-packages nil) + +(defun helm-el-package--init () + (when (null package-alist) + (setq helm-el-package--show-only 'all)) + (when (fboundp 'package--removable-packages) + (setq helm-el-package--removable-packages + (package--removable-packages))) + (save-selected-window + (list-packages helm-el-package--initialized-p) + (setq helm-el-package--initialized-p t) + (message nil)) + (helm-init-candidates-in-buffer + 'global + (with-current-buffer (get-buffer "*Packages*") + (setq helm-el-package--tabulated-list tabulated-list-entries) + (buffer-string))) + (setq helm-el-package--upgrades (helm-el-package-menu--find-upgrades)) + (if helm-force-updating-p + (message "Refreshing packages list done") + (setq helm-el-package--show-only helm-el-package-initial-filter)) + (kill-buffer "*Packages*")) + +(defun helm-el-package-describe (candidate) + (let ((id (get-text-property 0 'tabulated-list-id candidate))) + (describe-package (if (fboundp 'package-desc-name) + (package-desc-name id) + (car id))))) + +(defun helm-el-package-install-1 (pkg-list) + (cl-loop with mkd = pkg-list + for p in mkd + for id = (get-text-property 0 'tabulated-list-id p) + do (package-install + (if (fboundp 'package-desc-name) + (package-desc-name id) + (car id))) + collect (if (fboundp 'package-desc-full-name) + id + (car id)) + into installed-list + finally do (progn + (when (boundp 'package-selected-packages) + (customize-save-variable + 'package-selected-packages + (append (mapcar 'package-desc-name installed-list) + package-selected-packages))) + (if (fboundp 'package-desc-full-name) + (message (format "%d packages installed:\n(%s)" + (length installed-list) + (mapconcat #'package-desc-full-name + installed-list ", "))) + (message (format "%d packages installed:\n(%s)" + (length installed-list) + (mapconcat 'symbol-name installed-list ", "))))))) + +(defun helm-el-package-install (_candidate) + (helm-el-package-install-1 (helm-marked-candidates))) + +(defun helm-el-package-uninstall-1 (pkg-list) + (cl-loop with mkd = pkg-list + for p in mkd + for id = (get-text-property 0 'tabulated-list-id p) + do + (condition-case-unless-debug err + (with-no-warnings + (if (fboundp 'package-desc-full-name) + ;; emacs 24.4 + (package-delete id) + ;; emacs 24.3 + (package-delete (symbol-name (car id)) + (package-version-join (cdr id))))) + (error (message (cadr err)))) + unless (assoc (elt id 1) package-alist) + collect (if (fboundp 'package-desc-full-name) + id + (cons (symbol-name (car id)) + (package-version-join (cdr id)))) + into delete-list + finally do (if delete-list + (if (fboundp 'package-desc-full-name) + ;; emacs 24.4 + (message (format "%d packages deleted:\n(%s)" + (length delete-list) + (mapconcat #'package-desc-full-name + delete-list ", "))) + ;; emacs 24.3 + (message (format "%d packages deleted:\n(%s)" + (length delete-list) + (mapconcat (lambda (x) + (concat (car x) "-" (cdr x))) + delete-list ", "))) + ;; emacs 24.3 doesn't update + ;; its `package-alist' after deleting. + (cl-loop for p in package-alist + when (assq (symbol-name (car p)) delete-list) + do (setq package-alist (delete p package-alist)))) + "No package deleted"))) + +(defun helm-el-package-uninstall (_candidate) + (helm-el-package-uninstall-1 (helm-marked-candidates))) + +(defun helm-el-package-menu--find-upgrades () + (cl-loop for entry in helm-el-package--tabulated-list + for pkg-desc = (car entry) + for status = (package-desc-status pkg-desc) + when (member status '("installed" "unsigned" "dependency")) + collect pkg-desc + into installed + when (member status '("available" "new")) + collect (cons (package-desc-name pkg-desc) pkg-desc) + into available + finally return + (cl-loop for pkg in installed + for avail-pkg = (assq (package-desc-name pkg) available) + when (and avail-pkg + (version-list-< (package-desc-version pkg) + (package-desc-version + (cdr avail-pkg)))) + collect avail-pkg))) + +(defun helm-el-package-upgrade-1 (pkg-list) + (cl-loop for p in pkg-list + for pkg-desc = (car p) + for upgrade = (cdr (assq (package-desc-name pkg-desc) + helm-el-package--upgrades)) + do + (cond ((null upgrade) + (ignore)) + ((equal pkg-desc upgrade) + ;;Install. + (package-install pkg-desc)) + (t + ;; Delete. + (if (boundp 'package-selected-packages) + (with-no-warnings + (package-delete pkg-desc t t)) + (package-delete pkg-desc)))))) + +(defun helm-el-package-upgrade (_candidate) + (helm-el-package-upgrade-1 + (cl-loop with pkgs = (helm-marked-candidates) + for p in helm-el-package--tabulated-list + for pkg = (car p) + if (member (symbol-name (package-desc-name pkg)) pkgs) + collect p))) + +(defun helm-el-package-upgrade-all () + (if helm-el-package--upgrades + (with-helm-display-marked-candidates + helm-marked-buffer-name (mapcar (lambda (x) (symbol-name (car x))) + helm-el-package--upgrades) + (when (y-or-n-p "Upgrade all packages? ") + (helm-el-package-upgrade-1 helm-el-package--tabulated-list))) + (message "No packages to upgrade actually!"))) + +(defun helm-el-package-upgrade-all-action (_candidate) + (helm-el-package-upgrade-all)) + +(defun helm-el-package--transformer (candidates _source) + (cl-loop for c in candidates + for id = (get-text-property 0 'tabulated-list-id c) + for name = (if (fboundp 'package-desc-name) + (package-desc-name id) + (car id)) + for installed-p = (assq name package-alist) + for upgrade-p = (assq name helm-el-package--upgrades) + for user-installed-p = (and (boundp 'package-selected-packages) + (memq name package-selected-packages)) + do (when user-installed-p (put-text-property 0 2 'display "S " c)) + do (when (memq name helm-el-package--removable-packages) + (put-text-property 0 2 'display "U " c) + (put-text-property + 2 (+ (length (symbol-name name)) 2) + 'face 'font-lock-variable-name-face c)) + for cand = (cons c (car (split-string c))) + when (or (and upgrade-p + (eq helm-el-package--show-only 'upgrade)) + (and installed-p + (eq helm-el-package--show-only 'installed)) + (and (not installed-p) + (eq helm-el-package--show-only 'uninstalled)) + (eq helm-el-package--show-only 'all)) + collect cand)) + +(defun helm-el-package-show-upgrade () + (interactive) + (with-helm-alive-p + (setq helm-el-package--show-only 'upgrade) + (helm-update))) + +(defun helm-el-package-show-installed () + (interactive) + (with-helm-alive-p + (setq helm-el-package--show-only 'installed) + (helm-update))) + +(defun helm-el-package-show-all () + (interactive) + (with-helm-alive-p + (setq helm-el-package--show-only 'all) + (helm-update))) + +(defun helm-el-package-show-uninstalled () + (interactive) + (with-helm-alive-p + (setq helm-el-package--show-only 'uninstalled) + (helm-update))) + +(defvar helm-el-package-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-I") 'helm-el-package-show-installed) + (define-key map (kbd "M-U") 'helm-el-package-show-upgrade) + (define-key map (kbd "M-A") 'helm-el-package-show-all) + (define-key map (kbd "C-c ?") 'helm-el-package-help) + map)) + +(defvar helm-source-list-el-package nil) +(defclass helm-list-el-package-source (helm-source-in-buffer) + ((init :initform 'helm-el-package--init) + (get-line :initform 'buffer-substring) + (filtered-candidate-transformer :initform 'helm-el-package--transformer) + (action-transformer + :initform + (lambda (actions candidate) + (let ((pkg-desc (get-text-property + 0 'tabulated-list-id candidate)) + (acts (if helm-el-package--upgrades + (append actions '(("Upgrade all packages" + . helm-el-package-upgrade-all-action))) + actions))) + (cond ((cdr (assq (package-desc-name pkg-desc) + helm-el-package--upgrades)) + (append '(("Upgrade package" . helm-el-package-upgrade)) acts)) + ((package-installed-p (package-desc-name pkg-desc)) + (append acts '(("Reinstall package" . helm-el-package-reinstall) + ("Uninstall" . helm-el-package-uninstall)))) + (t (append acts '(("Install" . helm-el-package-install)))))))) + (mode-line :initform helm-el-package-mode-line) + (keymap :initform helm-el-package-map) + (update :initform 'helm-el-package--update) + (candidate-number-limit :initform 9999) + (action :initform '(("Describe" . helm-el-package-describe))))) + +(defun helm-el-package--update () + (setq helm-el-package--initialized-p nil)) + +(defun helm-el-package-reinstall (_pkg) + (cl-loop for p in (helm-marked-candidates) + for pkg-desc = (get-text-property 0 'tabulated-list-id p) + for name = (package-desc-name pkg-desc) + do (if (fboundp 'package-reinstall) + (package-reinstall name) + (package-delete pkg-desc) + (package-install name)))) + +;;;###autoload +(defun helm-list-elisp-packages (arg) + (interactive "P") + (when arg (setq helm-el-package--initialized-p nil)) + (unless helm-source-list-el-package + (setq helm-source-list-el-package + (helm-make-source "list packages" 'helm-list-el-package-source))) + (helm :sources 'helm-source-list-el-package + :buffer "*helm list packages*")) + +;;;###autoload +(defun helm-list-elisp-packages-no-fetch () + (interactive) + (let ((helm-el-package--initialized-p t)) + (helm-list-elisp-packages nil))) + +(provide 'helm-elisp-package) + +;;; helm-elisp-package.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-elisp.el b/emacs.d/elpa/helm-20150507.2215/helm-elisp.el new file mode 100644 index 0000000..7961be7 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-elisp.el @@ -0,0 +1,832 @@ +;;; helm-elisp.el --- Elisp symbols completion for helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) +(require 'helm-info) +(require 'helm-eval) +(require 'helm-files) +(require 'advice) + + +(defgroup helm-elisp nil + "Elisp related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-turn-on-show-completion t + "Display candidate in buffer while moving selection when non--nil." + :group 'helm-elisp + :type 'boolean) + +(defcustom helm-show-completion-use-special-display t + "A special display will be used in lisp completion if non--nil. +All functions that are wrapped in macro `with-helm-show-completion' +will be affected." + :group 'helm-elisp + :type 'boolean) + +(defcustom helm-show-completion-min-window-height 7 + "Minimum completion window height used in show completion. +This is used in macro `with-helm-show-completion'." + :group 'helm-elisp + :type 'integer) + +(defcustom helm-lisp-quoted-function-list + '(funcall apply mapc cl-mapc mapcar cl-mapcar + callf callf2 cl-callf cl-callf2 fset + fboundp fmakunbound symbol-function) + "List of function where quoted function completion happen. +e.g give only function names after \(funcall '." + :group 'helm-elisp + :type '(repeat (choice symbol))) + +(defcustom helm-lisp-unquoted-function-list + '(function defadvice) + "List of function where unquoted function completion happen. +e.g give only function names after \(function ." + :group 'helm-elisp + :type '(repeat (choice symbol))) + +(defcustom helm-apropos-fuzzy-match nil + "Enable fuzzy matching for `helm-apropos' when non-nil." + :group 'helm-elisp + :type 'boolean) + +(defcustom helm-lisp-fuzzy-completion nil + "Enable fuzzy matching in emacs-lisp completion when non-nil. +NOTE: This enable fuzzy matching in helm native implementation of +elisp completion, but not on helmized elisp completion, i.e +fuzzy completion is not available in `completion-at-point'." + :group 'helm-elisp + :type 'boolean) + +(defcustom helm-apropos-function-list '(helm-def-source--emacs-commands + helm-def-source--emacs-functions + helm-def-source--eieio-classes + helm-def-source--eieio-generic + helm-def-source--emacs-variables + helm-def-source--emacs-faces + helm-def-source--helm-attributes) + "A list of functions that build helm sources to use in `helm-apropos'." + :group 'helm-elisp + :type '(repeat (choice symbol))) + + +;;; Faces +;; +;; +(defgroup helm-elisp-faces nil + "Customize the appearance of helm-elisp." + :prefix "helm-" + :group 'helm-elisp + :group 'helm-faces) + +(defface helm-lisp-show-completion + '((t (:background "DarkSlateGray"))) + "Face used for showing candidates in `helm-lisp-completion'." + :group 'helm-elisp-faces) + +(defface helm-lisp-completion-info + '((t (:foreground "red"))) + "Face used for showing info in `helm-lisp-completion'." + :group 'helm-elisp-faces) + + +;;; Show completion. +;; +;; Provide show completion with macro `with-helm-show-completion'. + +(defvar helm-show-completion-overlay nil) + +;; Called each time cursor move in helm-buffer. +(defun helm-show-completion () + (with-helm-current-buffer + (overlay-put helm-show-completion-overlay + 'display (substring-no-properties + (helm-get-selection))))) + +(defun helm-show-completion-init-overlay (beg end) + (when (and helm-turn-on-show-completion beg end) + (setq helm-show-completion-overlay (make-overlay beg end)) + (overlay-put helm-show-completion-overlay + 'face 'helm-lisp-show-completion))) + +(defun helm-show-completion-display-function (buffer &rest _args) + "A special resized helm window is used depending on position in BUFFER." + (with-selected-window (selected-window) + (if (window-dedicated-p) + (helm-default-display-buffer buffer) + (let* ((screen-size (+ (count-screen-lines (window-start) (point) t) + 1 ; mode-line + (if header-line-format 1 0))) ; header-line + (def-size (- (window-height) + helm-show-completion-min-window-height)) + (upper-height (max window-min-height (min screen-size def-size))) + split-window-keep-point) + (recenter -1) + (set-window-buffer (if (active-minibuffer-window) + (minibuffer-selected-window) + (split-window nil upper-height)) + buffer))))) + +(defmacro with-helm-show-completion (beg end &rest body) + "Show helm candidate in an overlay at point. +BEG and END are the beginning and end position of the current completion +in `helm-current-buffer'. +BODY is an helm call where we want to enable show completion. +If `helm-turn-on-show-completion' is nil just do nothing." + (declare (indent 2) (debug t)) + `(let ((helm-move-selection-after-hook + (and helm-turn-on-show-completion + (append (list 'helm-show-completion) + helm-move-selection-after-hook)))) + (with-helm-temp-hook 'helm-after-initialize-hook + (with-helm-buffer + (set (make-local-variable 'helm-display-function) + (if helm-show-completion-use-special-display + 'helm-show-completion-display-function + 'helm-default-display-buffer)))) + (unwind-protect + (progn + (helm-show-completion-init-overlay ,beg ,end) + ,@body) + (when (and helm-turn-on-show-completion + helm-show-completion-overlay + (overlayp helm-show-completion-overlay)) + (delete-overlay helm-show-completion-overlay))))) + + +;;; Lisp symbol completion. +;; +;; +(defun helm-lisp-completion--predicate-at-point (beg) + ;; Return a predicate for `all-completions'. + (let ((fn-sym-p (lambda () + (or + (and (eq (char-before) ?\ ) + (save-excursion + (skip-syntax-backward " " (point-at-bol)) + (memq (symbol-at-point) + helm-lisp-unquoted-function-list))) + (and (eq (char-before) ?\') + (save-excursion + (forward-char -1) + (eq (char-before) ?\#))))))) + (save-excursion + (goto-char beg) + (if (or + ;; Complete on all symbols in non--lisp modes (logs mail etc..) + (not (memq major-mode '(emacs-lisp-mode + lisp-interaction-mode + inferior-emacs-lisp-mode))) + (not (or (funcall fn-sym-p) + (and (eq (char-before) ?\') + (save-excursion + (forward-char (if (funcall fn-sym-p) -2 -1)) + (skip-syntax-backward " " (point-at-bol)) + (memq (symbol-at-point) + helm-lisp-quoted-function-list))) + (eq (char-before) ?\())) ; no paren before str. + ;; Looks like we are in a let statement. + (condition-case nil + (progn (up-list -2) (forward-char 1) + (eq (char-after) ?\()) + (error nil))) + (lambda (sym) + (or (boundp sym) (fboundp sym) (symbol-plist sym))) + #'fboundp)))) + +(defun helm-thing-before-point (&optional limits regexp) + "Return symbol name before point. +If REGEXP is specified return what REGEXP find before point. +By default match the beginning of symbol before point. +With LIMITS arg specified return the beginning and end position +of symbol before point." + (save-excursion + (let (beg + (end (point)) + (boundary (field-beginning nil nil (point-at-bol)))) + (if (re-search-backward (or regexp "\\_<") boundary t) + (setq beg (match-end 0)) + (setq beg boundary)) + (unless (= beg end) + (if limits + (cons beg end) + (buffer-substring-no-properties beg end)))))) + +(defun helm-bounds-of-thing-before-point (&optional regexp) + "Get the beginning and end position of `helm-thing-before-point'. +Return a cons \(beg . end\)." + (helm-thing-before-point 'limits regexp)) + +(defun helm-insert-completion-at-point (beg end str) + ;; When there is no space after point + ;; we are completing inside a symbol or + ;; after a partial symbol with the next arg aside + ;; without space, in this case mark the region. + ;; deleting it would remove the + ;; next arg which is unwanted. + (delete-region beg end) + (insert str) + (let ((pos (cdr (or (bounds-of-thing-at-point 'symbol) + ;; needed for helm-dabbrev. + (bounds-of-thing-at-point 'filename))))) + (when (and pos (< (point) pos)) + (push-mark pos t t)))) + +(defvar helm-lisp-completion--cache nil) +(defvar helm-lgst-len nil) +;;;###autoload +(defun helm-lisp-completion-at-point () + "Helm lisp symbol completion at point." + (interactive) + (setq helm-lgst-len 0) + (let* ((target (helm-thing-before-point)) + (beg (car (helm-bounds-of-thing-before-point))) + (end (point)) + (pred (and beg (helm-lisp-completion--predicate-at-point beg))) + (loc-vars (and (fboundp 'elisp--local-variables) + (ignore-errors + (mapcar #'symbol-name (elisp--local-variables))))) + (glob-syms (and target pred (all-completions target obarray pred))) + (candidates (append loc-vars glob-syms)) + (helm-quit-if-no-candidate t) + (helm-execute-action-at-once-if-one t) + (enable-recursive-minibuffers t)) + (setq helm-lisp-completion--cache (cl-loop for sym in candidates + for len = (length sym) + when (> len helm-lgst-len) + do (setq helm-lgst-len len) + collect sym)) + (if candidates + (with-helm-show-completion beg end + ;; Overlay is initialized now in helm-current-buffer. + (helm + :sources (helm-build-in-buffer-source "Lisp completion" + :data helm-lisp-completion--cache + :persistent-action 'helm-lisp-completion-persistent-action + :nomark t + :fuzzy-match helm-lisp-fuzzy-completion + :persistent-help "Show brief doc in mode-line" + :filtered-candidate-transformer 'helm-lisp-completion-transformer + :action `(lambda (candidate) + (with-helm-current-buffer + (run-with-timer + 0.01 nil + 'helm-insert-completion-at-point + ,beg ,end candidate)))) + :input (if helm-lisp-fuzzy-completion + target (concat target " ")) + :resume 'noresume + :buffer "*helm lisp completion*" + :allow-nest t)) + (message "[No Match]")))) + +(defun helm-lisp-completion-persistent-action (candidate) + (let ((cursor-in-echo-area t) + mode-line-in-non-selected-windows) + (helm-show-info-in-mode-line + (propertize + (helm-get-first-line-documentation + (intern candidate)) + 'face 'helm-lisp-completion-info)))) + +(defun helm-lisp-completion-transformer (candidates _source) + "Helm candidates transformer for lisp completion." + (cl-loop for c in candidates + for sym = (intern c) + for annot = (cl-typecase sym + (command " (Com)") + (class " (Class)") + (generic " (Gen)") + (fbound " (Fun)") + (bound " (Var)") + (face " (Face)")) + for spaces = (make-string (- helm-lgst-len (length c)) ? ) + collect (cons (concat c spaces annot) c) into lst + finally return (sort lst #'helm-generic-sort-fn))) + +(defun helm-get-first-line-documentation (sym) + "Return first line documentation of symbol SYM. +If SYM is not documented, return \"Not documented\"." + (let ((doc (cond ((fboundp sym) + (documentation sym t)) + ((boundp sym) + (documentation-property sym 'variable-documentation t)) + ((facep sym) + (face-documentation sym)) + (t nil)))) + (if (and doc (not (string= doc "")) + ;; `documentation' return "\n\n(args...)" + ;; for CL-style functions. + (not (string-match-p "^\n\n" doc))) + (car (split-string doc "\n")) + "Not documented"))) + +;;; File completion. +;; +;; Complete file name at point. + +;;;###autoload +(defun helm-complete-file-name-at-point (&optional force) + "Complete file name at point." + (interactive) + (require 'helm-mode) + (let* ((tap (thing-at-point 'filename)) + beg + (init (and tap + (or force + (save-excursion + (end-of-line) + (search-backward tap (point-at-bol) t) + (setq beg (point)) + (looking-back "[^'`( ]" 1))) + (expand-file-name + (substring-no-properties tap)))) + (end (point)) + (helm-quit-if-no-candidate t) + (helm-execute-action-at-once-if-one t) + completion) + (with-helm-show-completion beg end + (setq completion (helm-read-file-name "FileName: " + :initial-input init))) + (when (and completion (not (string= completion ""))) + (delete-region beg end) (insert (if (string-match "^~" tap) + (abbreviate-file-name completion) + completion))))) + +;;;###autoload +(defun helm-lisp-indent () + ;; It is meant to use with `helm-define-multi-key' which + ;; does not support args for functions yet, so use `current-prefix-arg' + ;; for now instead of (interactive "P"). + (interactive) + (let ((tab-always-indent (or (eq tab-always-indent 'complete) + tab-always-indent))) + (indent-for-tab-command current-prefix-arg))) + +;;;###autoload +(defun helm-lisp-completion-or-file-name-at-point () + "Complete lisp symbol or filename at point. +Filename completion happen if string start after or between a double quote." + (interactive) + (let* ((tap (thing-at-point 'filename))) + (if (and tap (save-excursion + (end-of-line) + (search-backward tap (point-at-bol) t) + (looking-back "[^'`( ]" 1))) + (helm-complete-file-name-at-point) + (helm-lisp-completion-at-point)))) + + +;;; Apropos +;; +;; +(defun helm-apropos-init (test default) + "Init candidates buffer for `helm-apropos' sources." + (require 'helm-help) + (helm-init-candidates-in-buffer 'global + (let ((default-symbol (and (stringp default) + (intern-soft default))) + (symbols (all-completions "" obarray test))) + (if (and default-symbol (funcall test default-symbol)) + (cons default-symbol symbols) + symbols)))) + +(defun helm-apropos-init-faces (default) + "Init candidates buffer for faces for `helm-apropos'." + (require 'helm-help) + (with-current-buffer (helm-candidate-buffer 'global) + (goto-char (point-min)) + (let ((default-symbol (and (stringp default) + (intern-soft default))) + (faces (face-list))) + (when (and default-symbol (facep default-symbol)) + (insert (concat default "\n"))) + (insert + (mapconcat #'prin1-to-string + (if default + (cl-remove-if (lambda (sym) (string= sym default)) faces) + faces) + "\n"))))) + +(defun helm-apropos-default-sort-fn (candidates _source) + (if (string= helm-pattern "") + candidates + (sort candidates #'helm-generic-sort-fn))) + +(defun helm-def-source--emacs-variables (&optional default) + (helm-build-in-buffer-source "Variables" + :init `(lambda () + (helm-apropos-init + (lambda (x) (and (boundp x) (not (keywordp x)))) ,default)) + :fuzzy-match helm-apropos-fuzzy-match + :filtered-candidate-transformer (and (null helm-apropos-fuzzy-match) + 'helm-apropos-default-sort-fn) + :nomark t + :action '(("Describe Variable" . helm-describe-variable) + ("Find Variable" . helm-find-variable) + ("Info lookup" . helm-info-lookup-symbol) + ("Set variable" . helm-set-variable)))) + +(defun helm-def-source--emacs-faces (&optional default) + (helm-build-in-buffer-source "Faces" + :init (lambda () (helm-apropos-init-faces default)) + :fuzzy-match helm-apropos-fuzzy-match + :filtered-candidate-transformer + (append (and (null helm-apropos-fuzzy-match) + '(helm-apropos-default-sort-fn)) + (list + (lambda (candidates _source) + (cl-loop for c in candidates + collect (propertize c 'face (intern c)))))) + :nomark t + :action (lambda (candidate) + (describe-face (intern candidate))))) + +(defun helm-def-source--helm-attributes (&optional _default) + (helm-build-sync-source "Helm attributes" + :candidates (lambda () + (mapcar 'symbol-name helm-attributes)) + :fuzzy-match helm-apropos-fuzzy-match + :nomark t + :action (lambda (candidate) + (let (special-display-buffer-names + special-display-regexps + helm-persistent-action-use-special-display) + (with-output-to-temp-buffer "*Help*" + (princ (get (intern candidate) 'helm-attrdoc))))))) + +(defun helm-def-source--emacs-commands (&optional default) + (helm-build-in-buffer-source "Commands" + :init `(lambda () + (helm-apropos-init 'commandp ,default)) + :fuzzy-match helm-apropos-fuzzy-match + :filtered-candidate-transformer (and (null helm-apropos-fuzzy-match) + 'helm-apropos-default-sort-fn) + :nomark t + :action '(("Describe Function" . helm-describe-function) + ("Find Function" . helm-find-function) + ("Info lookup" . helm-info-lookup-symbol)))) + +(defun helm-def-source--emacs-functions (&optional default) + (helm-build-in-buffer-source "Functions" + :init `(lambda () + (helm-apropos-init #'(lambda (x) + (and (fboundp x) + (not (commandp x)) + (not (generic-p x)) + (not (class-p x)))) + ,default)) + :fuzzy-match helm-apropos-fuzzy-match + :filtered-candidate-transformer (and (null helm-apropos-fuzzy-match) + 'helm-apropos-default-sort-fn) + :nomark t + :action '(("Describe Function" . helm-describe-function) + ("Find Function" . helm-find-function) + ("Info lookup" . helm-info-lookup-symbol)))) + +(defun helm-def-source--eieio-classes (&optional default) + (helm-build-in-buffer-source "Classes" + :init `(lambda () + (helm-apropos-init #'(lambda (x) + (class-p x)) + ,default)) + :fuzzy-match helm-apropos-fuzzy-match + :filtered-candidate-transformer (and (null helm-apropos-fuzzy-match) + 'helm-apropos-default-sort-fn) + :nomark t + :action '(("Describe Function" . helm-describe-function) + ("Find Function" . helm-find-function) + ("Info lookup" . helm-info-lookup-symbol)))) + +(defun helm-def-source--eieio-generic (&optional default) + (helm-build-in-buffer-source "Generic functions" + :init `(lambda () + (helm-apropos-init #'(lambda (x) + (generic-p x)) + ,default)) + :fuzzy-match helm-apropos-fuzzy-match + :filtered-candidate-transformer (and (null helm-apropos-fuzzy-match) + 'helm-apropos-default-sort-fn) + :nomark t + :action '(("Describe Function" . helm-describe-function) + ("Find Function" . helm-find-function) + ("Info lookup" . helm-info-lookup-symbol)))) + +(defun helm-info-lookup-symbol-1 (c) + (let ((helm-execute-action-at-once-if-one t) + (helm-quit-if-no-candidate + `(lambda () + (message "`%s' Not Documented as a symbol" ,c)))) + (helm :sources '(helm-source-info-elisp + helm-source-info-cl + helm-source-info-eieio) + :resume 'noresume + :buffer "*helm lookup*" + :input c))) + +(defun helm-info-lookup-symbol (candidate) + (run-with-timer 0.01 nil #'helm-info-lookup-symbol-1 candidate)) + +;;;###autoload +(defun helm-apropos () + "Preconfigured helm to describe commands, functions, variables and faces." + (interactive) + (let ((default (thing-at-point 'symbol))) + (helm :sources + (mapcar (lambda (func) + (funcall func default)) + helm-apropos-function-list) + :buffer "*helm apropos*" + :preselect (and default (concat "\\_<" (regexp-quote default) "\\_>"))))) + + +;;; Advices +;; +;; +(defvar helm-source-advice + '((name . "Function Advice") + (candidates . helm-advice-candidates) + (action ("Toggle Enable/Disable" . helm-advice-toggle)) + (persistent-action . helm-advice-persistent-action) + (nomark) + (multiline) + (persistent-help . "Describe function / C-u C-j: Toggle advice"))) + +(defun helm-advice-candidates () + (cl-loop for (fname) in ad-advised-functions + for function = (intern fname) + append + (cl-loop for class in ad-advice-classes append + (cl-loop for advice in (ad-get-advice-info-field function class) + for enabled = (ad-advice-enabled advice) + collect + (cons (format + "%s %s %s" + (if enabled "Enabled " "Disabled") + (propertize fname 'face 'font-lock-function-name-face) + (ad-make-single-advice-docstring advice class nil)) + (list function class advice)))))) + +(defun helm-advice-persistent-action (func-class-advice) + (if current-prefix-arg + (helm-advice-toggle func-class-advice) + (describe-function (car func-class-advice)))) + +(defun helm-advice-toggle (func-class-advice) + (cl-destructuring-bind (function _class advice) func-class-advice + (cond ((ad-advice-enabled advice) + (ad-advice-set-enabled advice nil) + (message "Disabled")) + (t + (ad-advice-set-enabled advice t) + (message "Enabled"))) + (ad-activate function) + (and helm-in-persistent-action + (helm-advice-update-current-display-string)))) + +(defun helm-advice-update-current-display-string () + (helm-edit-current-selection + (let ((newword (cond ((looking-at "Disabled") "Enabled") + ((looking-at "Enabled") "Disabled")))) + (when newword + (delete-region (point) (progn (forward-word 1) (point))) + (insert newword))))) + +;;;###autoload +(defun helm-manage-advice () + "Preconfigured `helm' to disable/enable function advices." + (interactive) + (helm-other-buffer 'helm-source-advice "*helm advice*")) + + +;;; Locate elisp library +;; +;; +(defun helm-locate-library-scan-list () + (cl-loop for dir in load-path + when (file-directory-p dir) + append (directory-files dir t (concat (regexp-opt (get-load-suffixes)) + "\\'")) + into lst + finally return (helm-fast-remove-dups lst :test 'equal))) + +;;;###autoload +(defun helm-locate-library () + (interactive) + (helm :sources (helm-build-in-buffer-source "Elisp libraries (Scan)" + :data (lambda () (helm-locate-library-scan-list)) + :fuzzy-match t + :keymap helm-generic-files-map + :match-part (lambda (candidate) + (if helm-ff-transformer-show-only-basename + (helm-basename candidate) candidate)) + :filter-one-by-one (lambda (c) + (if helm-ff-transformer-show-only-basename + (cons (helm-basename c) c) c)) + :action (helm-actions-from-type-file)) + :buffer "*helm locate library*")) + +(defun helm-set-variable (var) + "Set value to VAR interactively." + (let* ((sym (helm-symbolify var)) + (val (default-value sym))) + (set-default sym (eval-minibuffer (format "Set `%s': " var) + (if (or (stringp val) (memq val '(nil t))) + (prin1-to-string val) + (format "'%s" (prin1-to-string val))))))) + + +;;; Type attributes +;; +;; +(let ((actions '(("Describe command" . describe-function) + ("Add command to kill ring" . helm-kill-new) + ("Go to command's definition" . find-function) + ("Debug on entry" . debug-on-entry) + ("Cancel debug on entry" . cancel-debug-on-entry) + ("Trace function" . trace-function) + ("Trace function (background)" . trace-function-background) + ("Untrace function" . untrace-function)))) + (define-helm-type-attribute 'command + `((action ("Call interactively" . helm-call-interactively) + ,@actions) + (coerce . helm-symbolify) + (persistent-action . describe-function)) + "Command. (string or symbol)") + + (define-helm-type-attribute 'function + `((action . ,actions) + (action-transformer helm-transform-function-call-interactively) + (candidate-transformer helm-mark-interactive-functions) + (coerce . helm-symbolify)) + "Function. (string or symbol)")) + +(define-helm-type-attribute 'variable + '((action + ("Describe variable" . describe-variable) + ("Add variable to kill ring" . helm-kill-new) + ("Go to variable's definition" . find-variable) + ("Set variable" . helm-set-variable)) + (coerce . helm-symbolify)) + "Variable.") + +(define-helm-type-attribute 'timer + '((action + ("Cancel Timer" . (lambda (_timer) + (let ((mkd (helm-marked-candidates))) + (cl-loop for timer in mkd + do (cancel-timer timer))))) + ("Describe Function" . (lambda (tm) (describe-function (timer--function tm)))) + ("Find Function" . (lambda (tm) (find-function (timer--function tm))))) + (persistent-action . (lambda (tm) (describe-function (timer--function tm)))) + (persistent-help . "Describe Function")) + "Timer.") + + +;;; Elisp Timers. +;; +;; +(defclass helm-absolute-time-timers-class (helm-source-sync helm-type-timers) + ((candidates :initform timer-list) + (filtered-candidate-transformer + :initform + (lambda (candidates _source) + (cl-loop for timer in candidates + collect (cons (helm-elisp--format-timer timer) timer)))) + (allow-dups :initform t) + (volatile :initform t))) + +(defvar helm-source-absolute-time-timers + (helm-make-source "Absolute Time Timers" 'helm-absolute-time-timers-class)) + +(defclass helm-idle-time-timers-class (helm-source-sync helm-type-timers) + ((candidates :initform timer-idle-list) + (allow-dups :initform t) + (volatile :initform t) + (filtered-candidate-transformer + :initform + (lambda (candidates _source) + (cl-loop for timer in candidates + collect (cons (helm-elisp--format-timer timer) timer)))))) + +(defvar helm-source-idle-time-timers + (helm-make-source "Idle Time Timers" 'helm-idle-time-timers-class)) + +(defun helm-elisp--format-timer (timer) + (format "%s repeat=%s %s(%s)" + (let ((time (timer--time timer))) + (if (timer--idle-delay timer) + (format-time-string "idle-for=%5s" time) + (format-time-string "%m/%d %T" time))) + (or (timer--repeat-delay timer) "nil") + (mapconcat 'identity (split-string + (prin1-to-string (timer--function timer)) + "\n") " ") + (mapconcat 'prin1-to-string (timer--args timer) " "))) + +;;;###autoload +(defun helm-timers () + "Preconfigured `helm' for timers." + (interactive) + (helm :sources '(helm-source-absolute-time-timers + helm-source-idle-time-timers) + :buffer "*helm timers*")) + + +;;; Complex command history +;; +;; +(defun helm-btf--usable-p () + "Return t if current version of `backtrace-frame' accept 2 arguments." + (condition-case nil + (and (backtrace-frame 1 'condition-case) t) + (wrong-number-of-arguments nil))) + +(if (helm-btf--usable-p) ; Check if BTF accept more than one arg. + ;; Emacs 24.4. + (dont-compile + (defvar helm-sexp--last-sexp nil) + ;; This wont work compiled. + (defun helm-sexp-eval-1 () + (interactive) + (unwind-protect + (progn + ;; Trick called-interactively-p into thinking that `cand' is + ;; an interactive call, See `repeat-complex-command'. + (add-hook 'called-interactively-p-functions + #'helm-complex-command-history--called-interactively-skip) + (eval (read helm-sexp--last-sexp))) + (remove-hook 'called-interactively-p-functions + #'helm-complex-command-history--called-interactively-skip))) + + (defun helm-complex-command-history--called-interactively-skip (i _frame1 frame2) + (and (eq 'eval (cadr frame2)) + (eq 'helm-sexp-eval-1 + (cadr (backtrace-frame (+ i 2) #'called-interactively-p))) + 1)) + + (defun helm-sexp-eval (_candidate) + (call-interactively #'helm-sexp-eval-1))) + ;; Emacs 24.3 + (defun helm-sexp-eval (cand) + (let ((sexp (read cand))) + (condition-case err + (if (> (length (remove nil sexp)) 1) + (eval sexp) + (apply 'call-interactively sexp)) + (error (message "Evaluating gave an error: %S" err) + nil))))) + +(defvar helm-source-complex-command-history + (helm-build-sync-source "Complex Command History" + :candidates (lambda () + ;; Use cdr to avoid adding + ;; `helm-complex-command-history' here. + (cl-loop for i in command-history + unless (equal i '(helm-complex-command-history)) + collect (prin1-to-string i))) + :action (helm-make-actions + "Eval" (lambda (candidate) + (and (boundp 'helm-sexp--last-sexp) + (setq helm-sexp--last-sexp candidate)) + (run-with-timer 0.1 nil #'helm-sexp-eval candidate)) + "Edit and eval" + (lambda (cand) + (minibuffer-with-setup-hook + (lambda () (insert cand)) + (call-interactively #'eval-expression)))) + :persistent-action #'helm-sexp-eval)) + +;;;###autoload +(defun helm-complex-command-history () + (interactive) + (helm :sources 'helm-source-complex-command-history + :buffer "*helm complex commands*")) + +(provide 'helm-elisp) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-elisp.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-elscreen.el b/emacs.d/elpa/helm-20150507.2215/helm-elscreen.el new file mode 100644 index 0000000..178d37f --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-elscreen.el @@ -0,0 +1,79 @@ +;;; helm-elscreen.el -- Elscreen support -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) + +(declare-function elscreen-find-screen-by-buffer "ext:elscreen.el" (buffer &optional create)) +(declare-function elscreen-find-file "ext:elscreen.el" (filename)) +(declare-function elscreen-goto "ext:elscreen.el" (screen)) + +(defun helm-find-buffer-on-elscreen (candidate) + "Open buffer in new screen, if marked buffers open all in elscreens." + (helm-require-or-error 'elscreen 'helm-find-buffer-on-elscreen) + (helm-aif (helm-marked-candidates) + (cl-dolist (i it) + (let ((target-screen (elscreen-find-screen-by-buffer + (get-buffer i) 'create))) + (elscreen-goto target-screen))) + (let ((target-screen (elscreen-find-screen-by-buffer + (get-buffer candidate) 'create))) + (elscreen-goto target-screen)))) + +(defun helm-elscreen-find-file (file) + (helm-require-or-error 'elscreen 'helm-elscreen-find-file) + (elscreen-find-file file)) + +(defvar helm-source-elscreen + '((name . "Elscreen") + (candidates + . (lambda () + (if (cdr (elscreen-get-screen-to-name-alist)) + (sort + (cl-loop for sname in (elscreen-get-screen-to-name-alist) + append (list (format "[%d] %s" (car sname) (cdr sname)))) + #'(lambda (a b) (compare-strings a nil nil b nil nil)))))) + (action + . (("Change Screen" . + (lambda (candidate) + (elscreen-goto (- (aref candidate 1) (aref "0" 0))))) + ("Kill Screen(s)" . + (lambda (candidate) + (cl-dolist (i (helm-marked-candidates)) + (elscreen-goto (- (aref i 1) (aref "0" 0))) + (elscreen-kill)))) + ("Only Screen" . + (lambda (candidate) + (elscreen-goto (- (aref candidate 1) (aref "0" 0))) + (elscreen-kill-others))))))) + +;;;###autoload +(defun helm-elscreen () + "Preconfigured helm to list elscreen." + (interactive) + (helm-other-buffer 'helm-source-elscreen "*Helm Elscreen*")) + +(provide 'helm-elscreen) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-elscreen.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-eshell.el b/emacs.d/elpa/helm-20150507.2215/helm-eshell.el new file mode 100644 index 0000000..7b164a0 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-eshell.el @@ -0,0 +1,246 @@ +;;; helm-eshell.el --- pcomplete and eshell completion for helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;; Enable like this in .emacs: +;; +;; (add-hook 'eshell-mode-hook +;; #'(lambda () +;; (define-key eshell-mode-map [remap pcomplete] 'helm-esh-pcomplete))) +;; + +;;; Code: +(require 'cl-lib) +(require 'helm) +(require 'helm-elisp) +(require 'helm-regexp) + +(declare-function eshell-read-aliases-list "em-alias") +(declare-function eshell-send-input "esh-mode" (&optional use-region queue-p no-newline)) +(declare-function eshell-bol "esh-mode") +(declare-function eshell-parse-arguments "esh-arg" (beg end)) +(declare-function eshell-backward-argument "esh-mode" (&optional arg)) + +(defvar helm-eshell-history-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-p") 'helm-next-line) + map) + "Keymap for `helm-eshell-history'.") + +(defvar helm-esh-completion-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "TAB") 'helm-next-line) + map) + "Keymap for `helm-esh-pcomplete'.") + +(defclass helm-esh-source (helm-source-sync) + ((init :initform (lambda () + (setq pcomplete-current-completions nil + pcomplete-last-completion-raw nil) + ;; Eshell-command add this hook in all minibuffers + ;; Remove it for the helm one. (Fixed in Emacs24) + (remove-hook 'minibuffer-setup-hook 'eshell-mode))) + (candidates :initform 'helm-esh-get-candidates) + (nomark :initform t) + (persistent-action :initform 'ignore) + (filtered-candidate-transformer + :initform + (lambda (candidates _sources) + (cl-loop + for i in candidates + collect + (cond ((string-match "\\`~/?" helm-ec-target) + (abbreviate-file-name i)) + ((string-match "\\`/" helm-ec-target) i) + (t + (file-relative-name i))) + into lst + finally return (sort lst 'helm-generic-sort-fn)))) + (action :initform 'helm-ec-insert)) + "Helm class to define source for Eshell completion.") + +;; Internal. +(defvar helm-ec-target "") +(defun helm-ec-insert (candidate) + "Replace text at point with CANDIDATE. +The function that call this should set `helm-ec-target' to thing at point." + (let ((pt (point))) + (when (and helm-ec-target + (search-backward helm-ec-target nil t) + (string= (buffer-substring (point) pt) helm-ec-target)) + (delete-region (point) pt))) + (when (string-match "\\`\\*" helm-ec-target) (insert "*")) + (cond ((string-match "\\`~/?" helm-ec-target) + (insert (helm-quote-whitespace (abbreviate-file-name candidate)))) + ((string-match "\\`/" helm-ec-target) + (insert (helm-quote-whitespace candidate))) + (t + (insert (concat (and (string-match "\\`[.]/" helm-ec-target) "./") + (helm-quote-whitespace + (file-relative-name candidate))))))) + +(defun helm-esh-get-candidates () + "Get candidates for eshell completion using `pcomplete'." + (catch 'pcompleted + (with-helm-current-buffer + (let* ((pcomplete-stub) + pcomplete-seen pcomplete-norm-func + pcomplete-args pcomplete-last pcomplete-index + (pcomplete-autolist pcomplete-autolist) + (pcomplete-suffix-list pcomplete-suffix-list) + (table (pcomplete-completions)) + (entry (or (try-completion helm-pattern + (pcomplete-entries)) + helm-pattern))) + (cl-loop ;; expand entry too to be able to compare it with file-cand. + with exp-entry = (and (stringp entry) + (not (string= entry "")) + (file-name-as-directory + (expand-file-name entry default-directory))) + for i in (all-completions pcomplete-stub table) + ;; Transform the related names to abs names. + for file-cand = (and exp-entry + (if (file-remote-p i) i + (expand-file-name + i (file-name-directory entry)))) + ;; Compare them to avoid dups. + for file-entry-p = (and (stringp exp-entry) + (stringp file-cand) + ;; Fix :/tmp/foo/ $ cd foo + (not (file-directory-p file-cand)) + (file-equal-p exp-entry file-cand)) + if (and file-cand (or (file-remote-p file-cand) + (file-exists-p file-cand)) + (not file-entry-p)) + collect file-cand into ls + else + ;; Avoid adding entry here. + unless file-entry-p collect i into ls + finally return + (if (and exp-entry + (file-directory-p exp-entry) + ;; If the car of completion list is + ;; an executable, probably we are in + ;; command completion, so don't add a + ;; possible file related entry here. + (and ls (not (executable-find (car ls)))) + ;; Don't add entry if already in prompt. + (not (file-equal-p exp-entry pcomplete-stub))) + (append (list exp-entry) + ;; Entry should not be here now but double check. + (remove entry ls)) + ls)))))) + +;;; Eshell history. +;; +;; +(defclass helm-eshell-history-source (helm-source-in-buffer) + ((init :initform (lambda () + (let (eshell-hist-ignoredups) + (eshell-write-history eshell-history-file-name t) + (with-current-buffer (helm-candidate-buffer 'global) + (insert-file-contents eshell-history-file-name))) + ;; Same comment as in `helm-source-esh' + (remove-hook 'minibuffer-setup-hook 'eshell-mode))) + (nomark :initform t) + (keymap :initform helm-eshell-history-map) + (filtered-candidate-transformer :initform (lambda (candidates sources) + (reverse candidates))) + (candidate-number-limit :initform 9999) + (action :initform (lambda (candidate) + (eshell-kill-input) + (insert candidate)))) + "Helm class to define source for Eshell history.") + +;;;###autoload +(defun helm-esh-pcomplete () + "Preconfigured helm to provide helm completion in eshell." + (interactive) + (let* ((helm-quit-if-no-candidate t) + (helm-execute-action-at-once-if-one t) + (end (point-marker)) + (beg (save-excursion (eshell-bol) (point))) + (args (catch 'eshell-incomplete + (eshell-parse-arguments beg end))) + (target + (or (and (looking-back " " 1) " ") + (buffer-substring-no-properties + (save-excursion + (eshell-backward-argument 1) (point)) + end))) + (first (car args)) ; Maybe lisp delimiter "(". + last) ; Will be the last but parsed by pcomplete. + (setq helm-ec-target (or target " ") + end (point) + ;; Reset beg for `with-helm-show-completion'. + beg (or (and target (not (string= target " ")) + (- end (length target))) + ;; Nothing at point. + (progn (insert " ") (point)))) + (cond ((eq first ?\() + (helm-lisp-completion-or-file-name-at-point)) + ;; In eshell `pcomplete-parse-arguments' is called + ;; with `pcomplete-parse-arguments-function' + ;; locally bound to `eshell-complete-parse-arguments' + ;; which is calling `lisp-complete-symbol', + ;; calling it before would popup the + ;; *completions* buffer. + (t (setq last (replace-regexp-in-string + "\\`\\*" "" + (car (last (ignore-errors + (pcomplete-parse-arguments)))))) + (with-helm-show-completion beg end + (helm :sources (helm-make-source "Eshell completions" 'helm-esh-source) + :buffer "*helm pcomplete*" + :keymap helm-esh-completion-map + :resume 'noresume + :input (and (stringp last) + (helm-ff-set-pattern last)))))))) + +;;;###autoload +(defun helm-eshell-history () + "Preconfigured helm for eshell history." + (interactive) + (let* ((end (point)) + (beg (save-excursion (eshell-bol) (point))) + (input (buffer-substring beg end)) + flag-empty) + (when (eq beg end) + (insert " ") + (setq flag-empty t) + (setq end (point))) + (unwind-protect + (with-helm-show-completion beg end + (helm :sources (helm-make-source "Eshell history" + 'helm-eshell-history-source) + :buffer "*helm eshell history*" + :resume 'noresume + :input input)) + (when (and flag-empty + (looking-back " " 1)) + (delete-char -1))))) + +(provide 'helm-eshell) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-eshell ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-eval.el b/emacs.d/elpa/helm-20150507.2215/helm-eval.el new file mode 100644 index 0000000..183c570 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-eval.el @@ -0,0 +1,193 @@ +;;; helm-eval.el --- eval expressions from helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) +(require 'eldoc) + + +(defgroup helm-eval nil + "Eval related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-eldoc-in-minibuffer-show-fn + 'helm-show-info-in-mode-line + "A function to display eldoc info. +Should take one arg: the string to display." + :group 'helm-eval + :type 'symbol) + +(defcustom helm-show-info-in-mode-line-delay 12 + "Eldoc will show info in mode-line during this delay if user is idle." + :type 'integer + :group 'helm-eval) + + +;;; Eldoc compatibility between emacs-24 and emacs-25 +;; +(if (require 'elisp-mode nil t) ; emacs-25 + ;; Maybe the eldoc functions have been + ;; already aliased by eldoc-eval. + (cl-loop for (f . a) in '((eldoc-current-symbol . + elisp--current-symbol) + (eldoc-fnsym-in-current-sexp . + elisp--fnsym-in-current-sexp) + (eldoc-get-fnsym-args-string . + elisp--get-fnsym-args-string) + (eldoc-get-var-docstring . + elisp--get-var-docstring)) + unless (fboundp f) + do (defalias f a)) + ;; Emacs-24. + (declare-function eldoc-current-symbol "eldoc") + (declare-function eldoc-get-fnsym-args-string "eldoc" (sym &optional index)) + (declare-function eldoc-get-var-docstring "eldoc" (sym)) + (declare-function eldoc-fnsym-in-current-sexp "eldoc")) + +;;; Evaluation Result +;; +;; +;; Internal +(defvar helm-eldoc-active-minibuffers-list nil) + +(defvar helm-eval-expression-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "") 'helm-eval-new-line-and-indent) + (define-key map (kbd "") 'lisp-indent-line) + (define-key map (kbd "") 'helm-lisp-completion-at-point) + (define-key map (kbd "C-p") 'previous-line) + (define-key map (kbd "C-n") 'next-line) + (define-key map (kbd "") 'previous-line) + (define-key map (kbd "") 'next-line) + (define-key map (kbd "") 'forward-char) + (define-key map (kbd "") 'backward-char) + map)) + +(defvar helm-source-evaluation-result + '((name . "Evaluation Result") + (init . (lambda () (require 'edebug))) + (dummy) + (multiline) + (mode-line . "C-RET: nl-and-indent, tab: reindent, C-tab:complete, C-p/n: next/prec-line.") + (filtered-candidate-transformer . (lambda (candidates _source) + (list + (condition-case nil + (with-helm-current-buffer + (pp-to-string + (if edebug-active + (edebug-eval-expression + (read helm-pattern)) + (eval (read helm-pattern))))) + (error "Error"))))) + (action . (("Copy result to kill-ring" . (lambda (candidate) + (kill-new + (replace-regexp-in-string + "\n" "" candidate)))) + ("copy sexp to kill-ring" . (lambda (candidate) + (kill-new helm-input))))))) + +(defun helm-eval-new-line-and-indent () + (interactive) + (newline) (lisp-indent-line)) + +(defun helm-eldoc-store-minibuffer () + "Store minibuffer buffer name in `helm-eldoc-active-minibuffers-list'." + (with-selected-window (minibuffer-window) + (push (current-buffer) helm-eldoc-active-minibuffers-list))) + +(defun helm-eldoc-show-in-eval () + "Return eldoc in mode-line for current minibuffer input." + (let ((buf (window-buffer (active-minibuffer-window)))) + (condition-case err + (when (member buf helm-eldoc-active-minibuffers-list) + (with-current-buffer buf + (let* ((sym (save-excursion + (unless (looking-back ")\\|\"" 1) + (forward-char -1)) + (eldoc-current-symbol))) + (info-fn (eldoc-fnsym-in-current-sexp)) + (doc (or (eldoc-get-var-docstring sym) + (eldoc-get-fnsym-args-string + (car info-fn) (cadr info-fn))))) + (when doc (funcall helm-eldoc-in-minibuffer-show-fn doc))))) + (error (message "Eldoc in minibuffer error: %S" err) nil)))) + +(defun helm-show-info-in-mode-line (str) + "Display string STR in mode-line." + (save-selected-window + (with-current-buffer helm-buffer + (let ((mode-line-format (concat " " str))) + (force-mode-line-update) + (sit-for helm-show-info-in-mode-line-delay)) + (force-mode-line-update)))) + +;;; Calculation Result +;; +;; +(defvar helm-source-calculation-result + '((name . "Calculation Result") + (dummy) + (filtered-candidate-transformer . (lambda (candidates _source) + (list + (condition-case nil + (calc-eval helm-pattern) + (error "error"))))) + (action ("Copy result to kill-ring" . kill-new)))) + +;;;###autoload +(defun helm-eval-expression (arg) + "Preconfigured helm for `helm-source-evaluation-result'." + (interactive "P") + (helm :sources 'helm-source-evaluation-result + :input (when arg (thing-at-point 'sexp)) + :buffer "*helm eval*" + :history 'read-expression-history + :keymap helm-eval-expression-map)) + +(defvar eldoc-idle-delay) +;;;###autoload +(defun helm-eval-expression-with-eldoc () + "Preconfigured helm for `helm-source-evaluation-result' with `eldoc' support. " + (interactive) + (let ((timer (run-with-idle-timer + eldoc-idle-delay 'repeat + 'helm-eldoc-show-in-eval))) + (unwind-protect + (minibuffer-with-setup-hook + 'helm-eldoc-store-minibuffer + (call-interactively 'helm-eval-expression)) + (and timer (cancel-timer timer)) + (setq helm-eldoc-active-minibuffers-list + (cdr helm-eldoc-active-minibuffers-list))))) + +;;;###autoload +(defun helm-calcul-expression () + "Preconfigured helm for `helm-source-calculation-result'." + (interactive) + (helm-other-buffer 'helm-source-calculation-result "*helm calcul*")) + +(provide 'helm-eval) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-eval.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-external.el b/emacs.d/elpa/helm-20150507.2215/helm-external.el new file mode 100644 index 0000000..28298e3 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-external.el @@ -0,0 +1,216 @@ +;;; helm-external.el --- Run Externals commands within Emacs with helm completion. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-net) + + +(defgroup helm-external nil + "External related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-raise-command nil + "A shell command to jump to a window running specific program. +Need external program wmctrl. +This will be use with `format', so use something like \"wmctrl -xa %s\"." + :type 'string + :group 'helm-external) + +(defcustom helm-external-programs-associations nil + "Alist to store externals programs associated with file extension. +This variable overhide setting in .mailcap file. +e.g : '\(\(\"jpg\" . \"gqview\"\) (\"pdf\" . \"xpdf\"\)\) " + :type '(alist :key-type string :value-type string) + :group 'helm-external) + +(defcustom helm-default-external-file-browser "nautilus" + "Default external file browser for your system. +Directories will be opened externally with it when +opening file externally in `helm-find-files'. +Set to nil if you do not have external file browser +or do not want to use it. +Windows users should set that to \"explorer.exe\"." + :group 'helm-external + :type 'string) + + +;;; Internals +(defvar helm-external-command-history nil) +(defvar helm-external-commands-list nil + "A list of all external commands the user can execute. +If this variable is not set by the user, it will be calculated +automatically.") + +(defun helm-external-commands-list-1 (&optional sort) + "Returns a list of all external commands the user can execute. +If `helm-external-commands-list' is non-nil it will +return its contents. Else it calculates all external commands +and sets `helm-external-commands-list'." + (helm-aif helm-external-commands-list + it + (setq helm-external-commands-list + (cl-loop + for dir in (split-string (getenv "PATH") path-separator) + when (and (file-exists-p dir) (file-accessible-directory-p dir)) + for lsdir = (cl-loop for i in (directory-files dir t) + for bn = (file-name-nondirectory i) + when (and (not (member bn completions)) + (not (file-directory-p i)) + (file-executable-p i)) + collect bn) + append lsdir into completions + finally return + (if sort (sort completions 'string-lessp) completions))))) + +(defun helm-run-or-raise (exe &optional file) + "Generic command that run asynchronously EXE. +If EXE is already running just jump to his window if `helm-raise-command' +is non--nil. +When FILE argument is provided run EXE with FILE. +In this case EXE must be provided as \"EXE %s\"." + (let* ((real-com (car (split-string (replace-regexp-in-string + "%s" "" exe)))) + (proc (if file (concat real-com " " file) real-com)) + process-connection-type) + (if (get-process proc) + (if helm-raise-command + (shell-command (format helm-raise-command real-com)) + (error "Error: %s is already running" real-com)) + (when (cl-loop for i in helm-external-commands-list thereis (string= real-com i)) + (message "Starting %s..." real-com) + (if file + (start-process-shell-command + proc nil (format exe (shell-quote-argument + (if (eq system-type 'windows-nt) + (helm-w32-prepare-filename file) + file)))) + (start-process-shell-command proc nil real-com)) + (set-process-sentinel + (get-process proc) + #'(lambda (process event) + (when (and (string= event "finished\n") + helm-raise-command + (not (helm-get-pid-from-process-name real-com))) + (shell-command (format helm-raise-command "emacs"))) + (message "%s process...Finished." process)))) + (setq helm-external-commands-list + (cons real-com + (delete real-com helm-external-commands-list)))))) + +(defun helm-get-mailcap-for-file (filename) + "Get the command to use for FILENAME from mailcap files. +The command is like and is meant to use with `format'." + (mailcap-parse-mailcaps) + (let* ((ext (file-name-extension filename)) + (mime (when ext (mailcap-extension-to-mime ext))) + (result (when mime (mailcap-mime-info mime)))) + ;; If elisp file have no associations in .mailcap + ;; `mailcap-maybe-eval' is returned, in this case just return nil. + (when (stringp result) result))) + +(defun helm-get-default-program-for-file (filename) + "Try to find a default program to open FILENAME. +Try first in `helm-external-programs-associations' and then in mailcap file +if nothing found return nil." + (let* ((ext (file-name-extension filename)) + (def-prog (assoc-default ext helm-external-programs-associations))) + (cond ((and def-prog (not (string= def-prog ""))) + (concat def-prog " %s")) + ((and helm-default-external-file-browser + (file-directory-p filename)) + (concat helm-default-external-file-browser " %s")) + (t (helm-get-mailcap-for-file filename))))) + +(defun helm-open-file-externally (file) + "Open FILE with an external program. +Try to guess which program to use with `helm-get-default-program-for-file'. +If not found or a prefix arg is given query the user which tool to use." + (let* ((fname (expand-file-name file)) + (collection (helm-external-commands-list-1 'sort)) + (def-prog (helm-get-default-program-for-file fname)) + (real-prog-name (if (or helm-current-prefix-arg (not def-prog)) + ;; Prefix arg or no default program. + (prog1 + (helm-comp-read + "Program: " collection + :must-match t + :name "Open file Externally" + :del-input nil + :history helm-external-command-history) + ;; Always prompt to set this program as default. + (setq def-prog nil)) + ;; No prefix arg or default program exists. + (replace-regexp-in-string " %s\\| '%s'" "" def-prog))) + (program (concat real-prog-name " %s"))) + (unless (or def-prog ; Association exists, no need to record it. + ;; Don't try to record non--filenames associations (e.g urls). + (not (file-exists-p fname))) + (when + (y-or-n-p + (format + "Do you want to make `%s' the default program for this kind of files? " + real-prog-name)) + (helm-aif (assoc (file-name-extension fname) + helm-external-programs-associations) + (setq helm-external-programs-associations + (delete it helm-external-programs-associations))) + (push (cons (file-name-extension fname) + (helm-read-string + "Program (Add args maybe and confirm): " real-prog-name)) + helm-external-programs-associations) + (customize-save-variable 'helm-external-programs-associations + helm-external-programs-associations))) + (helm-run-or-raise program file) + (setq helm-external-command-history + (cons real-prog-name + (delete real-prog-name + (cl-loop for i in helm-external-command-history + when (executable-find i) collect i)))))) + +;;;###autoload +(defun helm-run-external-command (program) + "Preconfigured `helm' to run External PROGRAM asyncronously from Emacs. +If program is already running exit with error. +You can set your own list of commands with +`helm-external-commands-list'." + (interactive (list + (helm-comp-read + "RunProgram: " + (helm-external-commands-list-1 'sort) + :must-match t + :del-input nil + :name "External Commands" + :history helm-external-command-history))) + (helm-run-or-raise program) + (setq helm-external-command-history + (cons program (delete program + (cl-loop for i in helm-external-command-history + when (executable-find i) collect i))))) + + +(provide 'helm-external) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-external ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-files.el b/emacs.d/elpa/helm-20150507.2215/helm-files.el new file mode 100644 index 0000000..d14f562 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-files.el @@ -0,0 +1,3254 @@ +;;; helm-files.el --- helm file browser and related. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) +(require 'helm-external) +(require 'helm-grep) +(require 'helm-match-plugin) +(require 'helm-help) +(require 'helm-locate) +(require 'helm-bookmark) +(require 'helm-tags) +(require 'helm-buffers) +(require 'thingatpt) +(require 'ffap) +(require 'dired-aux) +(require 'dired-x) +(require 'tramp) +(require 'image-dired) + +(declare-function find-library-name "find-func.el" (library)) +(declare-function w32-shell-execute "ext:w32fns.c" (operation document &optional parameters show-flag)) +(declare-function gnus-dired-attach "ext:gnus-dired.el" (files-to-attach)) +(declare-function image-dired-display-image "image-dired.el" (file &optional original-size)) +(declare-function image-dired-update-property "image-dired.el" (prop value)) +(declare-function eshell-read-aliases-list "em-alias") +(declare-function eshell-send-input "esh-mode" (&optional use-region queue-p no-newline)) +(declare-function eshell-kill-input "esh-mode") +(declare-function eshell-bol "esh-mode") +(declare-function helm-ls-git-ls "ext:helm-ls-git") +(declare-function helm-hg-find-files-in-project "ext:helm-ls-hg") + +(defvar recentf-list) + + +;;; Type attributes +;; +;; +(define-helm-type-attribute 'file + (helm-build-type-file) + "File name.") + + + +(defgroup helm-files nil + "Files applications and libraries for Helm." + :group 'helm) + +(defcustom helm-boring-file-regexp-list + (mapcar (lambda (f) + (concat + (rx-to-string + (replace-regexp-in-string + "/$" "" f) t) "$")) + completion-ignored-extensions) + "The regexp list matching boring files." + :group 'helm-files + :type '(repeat (choice regexp))) + +(defcustom helm-for-files-preferred-list + '(helm-source-buffers-list + helm-source-recentf + helm-source-bookmarks + helm-source-file-cache + helm-source-files-in-current-dir + helm-source-locate) + "Your preferred sources to find files." + :type '(repeat (choice symbol)) + :group 'helm-files) + +(defcustom helm-tramp-verbose 0 + "Just like `tramp-verbose' but specific to helm. +When set to 0 don't show tramp messages in helm. +If you want to have the default tramp messages set it to 3." + :type 'integer + :group 'helm-files) + +(defcustom helm-ff-auto-update-initial-value nil + "Auto update when only one candidate directory is matched. +Default value when starting `helm-find-files' is nil because +it prevent using to delete char backward and by the way +confuse beginners. +For a better experience with `helm-find-files' set this to non--nil +and use C- to toggle it." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-lynx-style-map t + "Use arrow keys to navigate with `helm-find-files'. +You will have to restart Emacs or reeval `helm-find-files-map' +and `helm-read-file-map' for this take effect." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-history-max-length 100 + "Number of elements shown in `helm-find-files' history." + :group 'helm-files + :type 'integer) + +(defcustom helm-ff-smart-completion t + "Try to complete filenames smarter when non--nil. +See `helm-ff--transform-pattern-for-completion' for more info." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-tramp-not-fancy t + "No colors when listing remote files when set to non--nil. +This make listing much faster, specially on slow machines." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-exif-data-program "exiftran" + "Program used to extract exif data of an image file." + :group 'helm-files + :type 'string) + +(defcustom helm-ff-exif-data-program-args "-d" + "Arguments used for `helm-ff-exif-data-program'." + :group 'helm-files + :type 'string) + +(defcustom helm-ff-newfile-prompt-p t + "Whether Prompt or not when creating new file. +This set `ffap-newfile-prompt'." + :type 'boolean + :group 'helm-files) + +(defcustom helm-ff-avfs-directory "~/.avfs" + "The default avfs directory, usually '~/.avfs'. +When this is set you will be able to expand archive filenames with `C-j' +inside an avfs directory mounted with mountavfs. +See ." + :type 'string + :group 'helm-files) + +(defcustom helm-ff-file-compressed-list '("gz" "bz2" "zip" "7z") + "Minimal list of compressed files extension." + :type '(repeat (choice string)) + :group 'helm-files) + +(defcustom helm-ff-printer-list nil + "A list of available printers on your system. +When non--nil let you choose a printer to print file. +Otherwise when nil the variable `printer-name' will be used. +On Unix based systems (lpstat command needed) you don't need to set this, +`helm-ff-find-printers' will find a list of available printers for you." + :type '(repeat (choice string)) + :group 'helm-files) + +(defcustom helm-ff-transformer-show-only-basename t + "Show only basename of candidates in `helm-find-files'. +This can be toggled at anytime from `helm-find-files' with \ +\\\\[helm-ff-run-toggle-basename]." + :type 'boolean + :group 'helm-files) + +(defcustom helm-ff-signal-error-on-dot-files t + "Signal error when file is `.' or `..' on file deletion when non--nil. +Default is non--nil. +WARNING: Setting this to nil is unsafe and can cause deletion of a whole tree." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-search-library-in-sexp nil + "Search for library in `require' and `declare-function' sexp." + :group 'helm-files + :type 'boolean) + +(defcustom helm-tooltip-hide-delay 25 + "Hide tooltips automatically after this many seconds." + :group 'helm-files + :type 'integer) + +(defcustom helm-ff-file-name-history-use-recentf nil + "Use `recentf-list' instead of `file-name-history' in `helm-find-files'." + :group 'helm-files + :type 'boolean) + +(defcustom helm-ff-skip-boring-files nil + "Non--nil to skip files matching regexps in `helm-boring-file-regexp-list'. +This take effect in `helm-find-files' and file completion used by `helm-mode' +i.e `helm-read-file-name'." + :group 'helm-files + :type 'boolean) + +(defcustom helm-findutils-skip-boring-files t + "Ignore files matching regexps in `completion-ignored-extensions'." + :group 'helm-files + :type 'boolean) + +(defcustom helm-findutils-search-full-path nil + "Search in full path with shell command find when non--nil. +I.e use the -path/ipath arguments of find instead of -name/iname." + :group 'helm-files + :type 'boolean) + +(defcustom helm-files-save-history-extra-sources + '("Find" "Locate" "Recentf" + "Files from Current Directory" "File Cache") + "Extras source that save candidate to `file-name-history'." + :group 'helm-files + :type '(repeat (choice string))) + +(defcustom helm-find-files-before-init-hook nil + "Hook that run before initialization of `helm-find-files'." + :group 'helm-files + :type 'hook) + +(defcustom helm-find-files-after-init-hook nil + "Hook that run after initialization of `helm-find-files'." + :group 'helm-files + :type 'hook) + +(defcustom helm-multi-files-toggle-locate-binding "C-c p" + "Default binding to switch back and forth locate in `helm-multi-files'." + :group 'helm-files + :type 'string) + +(defcustom helm-find-files-bookmark-prefix "Helm-find-files: " + "bookmark name prefix of `helm-find-files' sessions." + :group 'helm-files + :type 'string) + +;;; Faces +;; +;; +(defgroup helm-files-faces nil + "Customize the appearance of helm-files." + :prefix "helm-" + :group 'helm-files + :group 'helm-faces) + +(defface helm-ff-prefix + '((t (:background "yellow" :foreground "black"))) + "Face used to prefix new file or url paths in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-executable + '((t (:foreground "green"))) + "Face used for executable files in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-directory + '((t (:foreground "DarkRed" :background "LightGray"))) + "Face used for directories in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-dotted-directory + '((t (:foreground "black" :background "DimGray"))) + "Face used for dotted directories in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-symlink + '((t (:foreground "DarkOrange"))) + "Face used for symlinks in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-invalid-symlink + '((t (:foreground "black" :background "red"))) + "Face used for invalid symlinks in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-ff-file + '((t (:inherit font-lock-builtin-face))) + "Face used for file names in `helm-find-files'." + :group 'helm-files-faces) + +(defface helm-history-deleted + '((t (:inherit helm-ff-invalid-symlink))) + "Face used for deleted files in `file-name-history'." + :group 'helm-files-faces) + +(defface helm-history-remote + '((t (:foreground "Indianred1"))) + "Face used for remote files in `file-name-history'." + :group 'helm-files-faces) + + +;;; Helm-find-files - The helm file browser. +;; +;; Keymaps +(defvar helm-find-files-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) + (define-key map (kbd "C-x C-f") 'helm-ff-run-locate) + (define-key map (kbd "C-x C-d") 'helm-ff-run-browse-project) + (define-key map (kbd "C-x r m") 'helm-ff-bookmark-set) + (define-key map (kbd "C-x r b") 'helm-find-files-toggle-to-bookmark) + (define-key map (kbd "C-s") 'helm-ff-run-grep) + (define-key map (kbd "M-g s") 'helm-ff-run-grep) + (define-key map (kbd "M-g p") 'helm-ff-run-pdfgrep) + (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) + (define-key map (kbd "M-.") 'helm-ff-run-etags) + (define-key map (kbd "M-R") 'helm-ff-run-rename-file) + (define-key map (kbd "M-C") 'helm-ff-run-copy-file) + (define-key map (kbd "M-B") 'helm-ff-run-byte-compile-file) + (define-key map (kbd "M-L") 'helm-ff-run-load-file) + (define-key map (kbd "M-S") 'helm-ff-run-symlink-file) + (define-key map (kbd "M-H") 'helm-ff-run-hardlink-file) + (define-key map (kbd "M-D") 'helm-ff-run-delete-file) + (define-key map (kbd "M-K") 'helm-ff-run-kill-buffer-persistent) + (define-key map (kbd "C-c d") 'helm-ff-persistent-delete) + (define-key map (kbd "M-e") 'helm-ff-run-switch-to-eshell) + (define-key map (kbd "C-c i") 'helm-ff-run-complete-fn-at-point) + (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame) + (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) + (define-key map (kbd "C-c X") 'helm-ff-run-open-file-with-default-tool) + (define-key map (kbd "M-!") 'helm-ff-run-eshell-command-on-file) + (define-key map (kbd "M-%") 'helm-ff-run-query-replace-on-marked) + (define-key map (kbd "C-c =") 'helm-ff-run-ediff-file) + (define-key map (kbd "M-=") 'helm-ff-run-ediff-merge-file) + (define-key map (kbd "M-p") 'helm-ff-run-switch-to-history) + (define-key map (kbd "C-c h") 'helm-ff-file-name-history) + (define-key map (kbd "M-i") 'helm-ff-properties-persistent) + (define-key map (kbd "C-c ?") 'helm-ff-help) + (define-key map (kbd "C-}") 'helm-narrow-window) + (define-key map (kbd "C-{") 'helm-enlarge-window) + (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "C-c ") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "C-c C-a") 'helm-ff-run-gnus-attach-files) + (define-key map (kbd "C-c p") 'helm-ff-run-print-file) + (define-key map (kbd "C-c /") 'helm-ff-run-find-sh-command) + ;; Next 2 have no effect if candidate is not an image file. + (define-key map (kbd "M-l") 'helm-ff-rotate-left-persistent) + (define-key map (kbd "M-r") 'helm-ff-rotate-right-persistent) + (define-key map (kbd "C-.") 'helm-find-files-up-one-level) + (define-key map (kbd "C-l") 'helm-find-files-up-one-level) + (define-key map (kbd "C-h C-b") 'helm-send-bug-report-from-helm) + (define-key map (kbd "C-c r") 'helm-ff-run-find-file-as-root) + (define-key map (kbd "C-c @") 'helm-ff-run-insert-org-link) + (helm-define-key-with-subkeys map (kbd "DEL") ?\d 'helm-ff-delete-char-backward + nil nil 'helm-ff-delete-char-backward--exit-fn) + (when helm-ff-lynx-style-map + (define-key map (kbd "") 'helm-find-files-up-one-level) + (define-key map (kbd "") 'helm-execute-persistent-action)) + (delq nil map)) + "Keymap for `helm-find-files'.") + +(defvar helm-read-file-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "") 'helm-cr-empty-string) + (define-key map (kbd "") 'helm-cr-empty-string) + (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) + (define-key map (kbd "C-.") 'helm-find-files-up-one-level) + (define-key map (kbd "C-l") 'helm-find-files-up-one-level) + (define-key map (kbd "C-c h") 'helm-ff-file-name-history) + (define-key map (kbd "C-") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "C-c ") 'helm-ff-run-toggle-auto-update) + (define-key map (kbd "C-c ?") 'helm-read-file-name-help) + (helm-define-key-with-subkeys map (kbd "DEL") ?\d 'helm-ff-delete-char-backward + nil nil 'helm-ff-delete-char-backward--exit-fn) + (when helm-ff-lynx-style-map + (define-key map (kbd "") 'helm-find-files-up-one-level) + (define-key map (kbd "") 'helm-execute-persistent-action) + (define-key map (kbd "") 'helm-previous-source) + (define-key map (kbd "") 'helm-next-source)) + (delq nil map)) + "Keymap for `helm-read-file-name'.") + +(defvar helm-esh-on-file-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-esh-help) + map) + "Keymap for `helm-find-files-eshell-command-on-file'.") + + +;; Internal. +(defvar helm-find-files-doc-header " (`C-l': Go up one level)" + "*The doc that is inserted in the Name header of a find-files or dired source.") +(defvar helm-ff-auto-update-flag nil + "Internal, flag to turn on/off auto-update in `helm-find-files'. +Don't set it directly, use instead `helm-ff-auto-update-initial-value'.") +(defvar helm-ff-last-expanded nil + "Store last expanded directory or file.") +(defvar helm-ff-default-directory nil) +(defvar helm-ff-history nil) +(defvar helm-ff-cand-to-mark nil) +(defvar helm-ff-url-regexp + "\\`\\(news\\(post\\)?:\\|nntp:\\|mailto:\\|file:\\|\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\):/?/?\\).*" + "Same as `ffap-url-regexp' but match earlier possible url.") +(defvar helm-tramp-file-name-regexp "\\`/\\([^[/:]+\\|[^/]+]\\):") +(defvar helm-marked-buffer-name "*helm marked*") +(defvar helm-ff--auto-update-state nil) +(defvar helm-ff--deleting-char-backward nil) +(defvar helm-multi-files--toggle-locate nil) +(defvar helm-ff--move-to-first-real-candidate t) +(defvar helm-find-files--toggle-bookmark nil) + + +;;; Helm-find-files +;; +;; +(defvar helm-source-find-files nil + "The main source to browse files. +Should not be used among other sources.") + +(defclass helm-source-ffiles (helm-source-sync) + ((header-name + :initform (lambda (name) + (concat name helm-find-files-doc-header))) + (init + :initform (lambda () + (setq helm-ff-auto-update-flag + helm-ff-auto-update-initial-value) + (setq helm-ff--auto-update-state + helm-ff-auto-update-flag) + (helm-set-local-variable 'bookmark-make-record-function + #'helm-ff-make-bookmark-record))) + (candidates :initform 'helm-find-files-get-candidates) + (filtered-candidate-transformer :initform 'helm-ff-sort-candidates) + (filter-one-by-one :initform 'helm-ff-filter-candidate-one-by-one) + (persistent-action :initform 'helm-find-files-persistent-action) + (persistent-help :initform "Hit1 Expand Candidate, Hit2 or (C-u) Find file") + (mode-line :initform helm-ff-mode-line-string) + (volatile :initform t) + (nohighlight :initform t) + (keymap :initform helm-find-files-map) + (candidate-number-limit + :initform 9999) + (action-transformer + :initform 'helm-find-files-action-transformer) + (action + :initform + (helm-make-actions + "Find File" 'helm-find-file-or-marked + "Find file in Dired" 'helm-point-file-in-dired + (lambda () (and (locate-library "elscreen") "Find file in Elscreen")) + 'helm-elscreen-find-file + "View file" 'view-file + "Checksum File" 'helm-ff-checksum + "Query replace fnames on marked" 'helm-ff-query-replace-on-marked + "Query replace contents on marked" 'helm-ff-query-replace + "Query replace regexp contents on marked" 'helm-ff-query-replace-regexp + "Serial rename files" 'helm-ff-serial-rename + "Serial rename by symlinking files" 'helm-ff-serial-rename-by-symlink + "Serial rename by copying files" 'helm-ff-serial-rename-by-copying + "Open file with default tool" 'helm-open-file-with-default-tool + "Find file in hex dump" 'hexl-find-file + "Browse project" 'helm-ff-browse-project + "Complete at point `C-c i'" 'helm-insert-file-name-completion-at-point + "Insert as org link `C-c @'" 'helm-files-insert-as-org-link + "Find shell command `C-c /'" 'helm-ff-find-sh-command + "Add marked files to file-cache" 'helm-ff-cache-add-file + "Open file externally `C-c C-x, C-u to choose'" 'helm-open-file-externally + "Grep File(s) `C-s, C-u Recurse'" 'helm-find-files-grep + "Zgrep File(s) `M-g z, C-u Recurse'" 'helm-ff-zgrep + "Switch to Eshell `M-e'" 'helm-ff-switch-to-eshell + "Etags `M-., C-u reload tag file'" 'helm-ff-etags-select + "Eshell command on file(s) `M-!, C-u take all marked as arguments.'" + 'helm-find-files-eshell-command-on-file + "Find file as root `C-c r'" 'helm-find-file-as-root + "Ediff File `C-='" 'helm-find-files-ediff-files + "Ediff Merge File `C-c ='" 'helm-find-files-ediff-merge-files + "Delete File(s) `M-D'" 'helm-delete-marked-files + "Copy file(s) `M-C, C-u to follow'" 'helm-find-files-copy + "Rename file(s) `M-R, C-u to follow'" 'helm-find-files-rename + "Symlink files(s) `M-S, C-u to follow'" 'helm-find-files-symlink + "Relsymlink file(s) `C-u to follow'" 'helm-find-files-relsymlink + "Hardlink file(s) `M-H, C-u to follow'" 'helm-find-files-hardlink + "Find file other window `C-c o'" 'find-file-other-window + "Switch to history `M-p'" 'helm-find-files-switch-to-hist + "Find file other frame `C-c C-o'" 'find-file-other-frame + "Print File `C-c p, C-u to refresh'" 'helm-ff-print + "Locate `C-x C-f, C-u to specify locate db'" 'helm-ff-locate)) + (before-init-hook :initform 'helm-find-files-before-init-hook) + (after-init-hook :initform 'helm-find-files-after-init-hook))) + +;; Bookmark handlers. +;; +(defun helm-ff-make-bookmark-record () + "The `bookmark-make-record-function' for `helm-find-files'." + (with-helm-buffer + `((filename . ,helm-ff-default-directory) + (presel . ,(helm-get-selection)) + (handler . helm-ff-bookmark-jump)))) + +(defun helm-ff-bookmark-jump (bookmark) + "bookmark handler for `helm-find-files'." + (let ((fname (bookmark-prop-get bookmark 'filename)) + (presel (bookmark-prop-get bookmark 'presel))) + (helm-find-files-1 fname (if helm-ff-transformer-show-only-basename + (helm-basename presel) + presel)))) + +(defun helm-ff-bookmark-set () + "Record `helm-find-files' session in bookmarks." + (interactive) + (with-helm-buffer + (bookmark-set + (concat helm-find-files-bookmark-prefix + (abbreviate-file-name helm-ff-default-directory)))) + (message "Helm find files session bookmarked! ")) + +(defun helm-dwim-target-directory () + "Return value of `default-directory' of buffer in other window. +If there is only one window return the value ot `default-directory' +for current buffer." + (with-helm-current-buffer + (let ((num-windows (length (remove (get-buffer-window helm-marked-buffer-name) + (window-list))))) + (expand-file-name + (if (> num-windows 1) + (save-selected-window + (other-window 1) + default-directory) + (or (car-safe helm-ff-history) default-directory)))))) + +(defun helm-find-files-do-action (action) + "Generic function for creating actions from `helm-source-find-files'. +ACTION must be an action supported by `helm-dired-action'." + (let* ((ifiles (mapcar 'expand-file-name ; Allow modify '/foo/.' -> '/foo' + (helm-marked-candidates :with-wildcard t))) + (cand (helm-get-selection)) ; Target + (prompt (format "%s %s file(s) to: " + (capitalize (symbol-name action)) + (length ifiles))) + helm-ff--move-to-first-real-candidate + (helm-always-two-windows t) + (helm-reuse-last-window-split-state t) + (helm-split-window-default-side + (eq helm-split-window-default-side 'same)) + helm-split-window-in-side-p + (parg helm-current-prefix-arg) + helm-display-source-at-screen-top ; prevent setting window-start. + helm-ff-auto-update-initial-value + (dest (with-helm-display-marked-candidates + helm-marked-buffer-name + (mapcar #'(lambda (f) + (if (file-directory-p f) + (concat (helm-basename f) "/") + (helm-basename f))) + ifiles) + (with-helm-current-buffer + (helm-read-file-name + prompt + :preselect (if helm-ff-transformer-show-only-basename + (helm-basename cand) cand) + :initial-input (helm-dwim-target-directory) + :history (helm-find-files-history :comp-read nil)))))) + (helm-dired-action + dest :files ifiles :action action :follow parg))) + +(defun helm-find-files-copy (_candidate) + "Copy files from `helm-find-files'." + (helm-find-files-do-action 'copy)) + +(defun helm-find-files-rename (_candidate) + "Rename files from `helm-find-files'." + (helm-find-files-do-action 'rename)) + +(defun helm-find-files-symlink (_candidate) + "Symlink files from `helm-find-files'." + (helm-find-files-do-action 'symlink)) + +(defun helm-find-files-relsymlink (_candidate) + "Relsymlink files from `helm-find-files'." + (helm-find-files-do-action 'relsymlink)) + +(defun helm-find-files-hardlink (_candidate) + "Hardlink files from `helm-find-files'." + (helm-find-files-do-action 'hardlink)) + +(defun helm-find-files-byte-compile (_candidate) + "Byte compile elisp files from `helm-find-files'." + (let ((files (helm-marked-candidates :with-wildcard t)) + (parg helm-current-prefix-arg)) + (cl-loop for fname in files + do (byte-compile-file fname parg)))) + +(defun helm-find-files-load-files (_candidate) + "Load elisp files from `helm-find-files'." + (let ((files (helm-marked-candidates :with-wildcard t))) + (cl-loop for fname in files + do (load fname)))) + +(defun helm-find-files-ediff-files-1 (candidate &optional merge) + "Generic function to ediff/merge files in `helm-find-files'." + (let* ((bname (helm-basename candidate)) + (marked (helm-marked-candidates :with-wildcard t)) + (prompt (if merge "Ediff Merge `%s' With File: " + "Ediff `%s' With File: ")) + (fun (if merge 'ediff-merge-files 'ediff-files)) + (input (helm-dwim-target-directory)) + (presel (if helm-ff-transformer-show-only-basename + (helm-basename candidate) + (expand-file-name + (helm-basename candidate) + input)))) + (if (= (length marked) 2) + (funcall fun (car marked) (cadr marked)) + (funcall fun candidate (helm-read-file-name + (format prompt bname) + :initial-input input + :preselect presel))))) + +(defun helm-find-files-ediff-files (candidate) + (helm-find-files-ediff-files-1 candidate)) + +(defun helm-find-files-ediff-merge-files (candidate) + (helm-find-files-ediff-files-1 candidate 'merge)) + +(defun helm-find-files-grep (_candidate) + "Default action to grep files from `helm-find-files'." + (apply 'run-with-timer 0.01 nil + #'helm-do-grep-1 + (helm-marked-candidates :with-wildcard t) + helm-current-prefix-arg)) + +(defun helm-ff-zgrep (_candidate) + "Default action to zgrep files from `helm-find-files'." + (helm-ff-zgrep-1 (helm-marked-candidates :with-wildcard t) helm-current-prefix-arg)) + +(defun helm-ff-pdfgrep (_candidate) + "Default action to pdfgrep files from `helm-find-files'." + (let ((cands (cl-loop for file in (helm-marked-candidates :with-wildcard t) + if (or (string= (file-name-extension file) "pdf") + (string= (file-name-extension file) "PDF")) + collect file)) + (helm-pdfgrep-default-function 'helm-pdfgrep-init)) + (when cands + (helm-do-pdfgrep-1 cands)))) + +(defun helm-ff-etags-select (candidate) + "Default action to jump to etags from `helm-find-files'." + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (let* ((source-name (assoc-default 'name (helm-get-current-source))) + (default-directory (if (string= source-name "Find Files") + helm-ff-default-directory + (file-name-directory candidate)))) + (helm-etags-select helm-current-prefix-arg))) + +(defun helm-find-files-switch-to-hist (_candidate) + "Switch to helm-find-files history." + (helm-find-files t)) + +(defvar eshell-command-aliases-list nil) +(defvar helm-eshell-command-on-file-input-history nil) +(defun helm-find-files-eshell-command-on-file-1 (&optional map) + "Run `eshell-command' on CANDIDATE or marked candidates. +This is done possibly with an eshell alias, if no alias found, you can type in +an eshell command. + +Basename of CANDIDATE can be a wild-card. +e.g you can do \"eshell-command command *.el\" +Where \"*.el\" is the CANDIDATE. + +It is possible to do eshell-command command +like this: \"command %s some more args\". + +If MAP is given run `eshell-command' on all marked files at once, +Otherwise, run `eshell-command' on each marked files. +In other terms, with a prefix arg do on the three marked files +\"foo\" \"bar\" \"baz\": + +\"eshell-command command foo bar baz\" + +otherwise do + +\"eshell-command command foo\" +\"eshell-command command bar\" +\"eshell-command command baz\" + +Note: +If `eshell' or `eshell-command' have not been run once, +or if you have no eshell aliases `eshell-command-aliases-list' +will not be loaded first time you use this." + (when (or eshell-command-aliases-list + (y-or-n-p "Eshell is not loaded, run eshell-command without alias anyway? ")) + (and eshell-command-aliases-list (eshell-read-aliases-list)) + (let* ((cand-list (helm-marked-candidates :with-wildcard t)) + (default-directory (or helm-ff-default-directory + ;; If candidate is an url *-ff-default-directory is nil + ;; so keep value of default-directory. + default-directory)) + (command (helm-comp-read + "Command: " + (cl-loop for (a . c) in eshell-command-aliases-list + when (string-match "\\(\\$1\\|\\$\\*\\)$" (car c)) + collect (propertize a 'help-echo (car c)) into ls + finally return (sort ls 'string<)) + :buffer "*helm eshell on file*" + :name "Eshell command" + :keymap helm-esh-on-file-map + :mode-line + '("Eshell alias" + "C-c ?: Help, \\[universal-argument]: Insert output at point") + :input-history + 'helm-eshell-command-on-file-input-history)) + (alias-value (car (assoc-default command eshell-command-aliases-list)))) + (if (or (equal helm-current-prefix-arg '(16)) + (equal map '(16))) + ;; Two time C-u from `helm-comp-read' mean print to current-buffer. + ;; i.e `eshell-command' will use this value. + (setq current-prefix-arg '(16)) + ;; Else reset the value of `current-prefix-arg' + ;; to avoid printing in current-buffer. + (setq current-prefix-arg nil)) + (if (and (or + ;; One prefix-arg have been passed before `helm-comp-read'. + ;; If map have been set with C-u C-u (value == '(16)) + ;; ignore it. + (and map (equal map '(4))) + ;; One C-u from `helm-comp-read'. + (equal helm-current-prefix-arg '(4)) + ;; An alias that finish with $* + (and alias-value + ;; If command is an alias be sure it accept + ;; more than one arg i.e $*. + (string-match "\\$\\*$" alias-value))) + (cdr cand-list)) + + ;; Run eshell-command with ALL marked files as arguments. + ;; This wont work on remote files, because tramp handlers depends + ;; on `default-directory' (limitation). + (let ((mapfiles (mapconcat 'shell-quote-argument cand-list " "))) + (if (string-match "'%s'\\|\"%s\"\\|%s" command) + (eshell-command (format command mapfiles)) ; See [1] + (eshell-command (format "%s %s" command mapfiles)))) + + ;; Run eshell-command on EACH marked files. + ;; To work with tramp handler we have to call + ;; COMMAND on basename of each file, using + ;; its basedir as `default-directory'. + (cl-loop for f in cand-list + for dir = (and (not (string-match ffap-url-regexp f)) + (helm-basedir f)) + for file = (format "'%s'" (if (and dir (file-remote-p dir)) + (helm-basename f) f)) + for com = (if (string-match "'%s'\\|\"%s\"\\|%s" command) + ;; [1] This allow to enter other args AFTER filename + ;; i.e + (format command file) + (format "%s %s" command file)) + do (let ((default-directory (or dir default-directory))) + (eshell-command com))))))) + +(defun helm-find-files-eshell-command-on-file (_candidate) + "Run `eshell-command' on CANDIDATE or marked candidates. +See `helm-find-files-eshell-command-on-file-1' for more info." + (helm-find-files-eshell-command-on-file-1 helm-current-prefix-arg)) + +(defun helm-ff-switch-to-eshell (_candidate) + "Switch to eshell and cd to `helm-ff-default-directory'." + (let ((cd-eshell #'(lambda () + (eshell-kill-input) + (goto-char (point-max)) + (insert + (format "cd '%s'" helm-ff-default-directory)) + (eshell-send-input)))) + (if (get-buffer "*eshell*") + (switch-to-buffer "*eshell*") + (call-interactively 'eshell)) + (unless (get-buffer-process (current-buffer)) + (funcall cd-eshell)))) + +(defun helm-ff-serial-rename-action (method) + "Rename all marked files in `helm-ff-default-directory' with METHOD. +See `helm-ff-serial-rename-1'." + (let* ((helm--reading-passwd-or-string t) + (cands (helm-marked-candidates :with-wildcard t)) + (def-name (car cands)) + (name (helm-read-string "NewName: " + (replace-regexp-in-string + "[0-9]+$" "" + (helm-basename + def-name + (file-name-extension def-name))))) + (start (read-number "StartAtNumber: ")) + (extension (helm-read-string "Extension: " + (file-name-extension (car cands)))) + (dir (expand-file-name + (helm-read-file-name + "Serial Rename to directory: " + :initial-input + (expand-file-name helm-ff-default-directory) + :test 'file-directory-p + :must-match t))) + done) + (with-helm-display-marked-candidates + helm-marked-buffer-name (mapcar 'helm-basename cands) + (if (y-or-n-p + (format "Rename %s file(s) to <%s> like this ?\n%s " + (length cands) dir (format "%s <-> %s%s.%s" + (helm-basename (car cands)) + name start extension))) + (progn + (helm-ff-serial-rename-1 + dir cands name start extension :method method) + (setq done t) + (message nil)))) + (if done + (with-helm-current-buffer (helm-find-files-1 dir)) + (message "Operation aborted")))) + +(defun helm-ff-member-directory-p (file directory) + (let ((dir-file (expand-file-name + (file-name-as-directory (file-name-directory file)))) + (cur-dir (expand-file-name (file-name-as-directory directory)))) + (string= dir-file cur-dir))) + +(cl-defun helm-ff-serial-rename-1 + (directory collection new-name start-at-num extension &key (method 'rename)) + "rename files in COLLECTION to DIRECTORY with the prefix name NEW-NAME. +Rename start at number START-AT-NUM - ex: prefixname-01.jpg. +EXTENSION is the file extension to use, in empty prompt, +reuse the original extension of file. +METHOD can be one of rename, copy or symlink. +Files will be renamed if they are files of current directory, otherwise they +will be treated with METHOD. +Default METHOD is rename." + ;; Maybe remove directories selected by error in collection. + (setq collection (cl-remove-if 'file-directory-p collection)) + (let* ((tmp-dir (file-name-as-directory + (concat (file-name-as-directory directory) + (symbol-name (cl-gensym "tmp"))))) + (fn (cl-case method + (copy 'copy-file) + (symlink 'make-symbolic-link) + (rename 'rename-file) + (t (error "Error: Unknown method %s" method))))) + (make-directory tmp-dir) + (unwind-protect + (progn + ;; Rename all files to tmp-dir with new-name. + ;; If files are not from start directory, use method + ;; to move files to tmp-dir. + (cl-loop for i in collection + for count from start-at-num + for fnum = (if (< count 10) "0%s" "%s") + for nname = (concat tmp-dir new-name (format fnum count) + (if (not (string= extension "")) + (format ".%s" (replace-regexp-in-string + "[.]" "" extension)) + (file-name-extension i 'dot))) + do (if (helm-ff-member-directory-p i directory) + (rename-file i nname) + (funcall fn i nname))) + ;; Now move all from tmp-dir to destination. + (cl-loop with dirlist = (directory-files + tmp-dir t directory-files-no-dot-files-regexp) + for f in dirlist do + (if (file-symlink-p f) + (make-symbolic-link (file-truename f) + (concat (file-name-as-directory directory) + (helm-basename f))) + (rename-file f directory)))) + (delete-directory tmp-dir t)))) + +(defun helm-ff-serial-rename (_candidate) + "Serial rename all marked files to `helm-ff-default-directory'. +Rename only file of current directory, and symlink files coming from +other directories. +See `helm-ff-serial-rename-1'." + (helm-ff-serial-rename-action 'rename)) + +(defun helm-ff-serial-rename-by-symlink (_candidate) + "Serial rename all marked files to `helm-ff-default-directory'. +Rename only file of current directory, and symlink files coming from +other directories. +See `helm-ff-serial-rename-1'." + (helm-ff-serial-rename-action 'symlink)) + +(defun helm-ff-serial-rename-by-copying (_candidate) + "Serial rename all marked files to `helm-ff-default-directory'. +Rename only file of current directory, and copy files coming from +other directories. +See `helm-ff-serial-rename-1'." + (helm-ff-serial-rename-action 'copy)) + +(defun helm-ff-query-replace-on-marked-1 (candidates) + (with-helm-display-marked-candidates + helm-marked-buffer-name + (mapcar 'helm-basename candidates) + (let* ((regexp (read-string "Replace regexp on filename(s): ")) + (str (read-string (format "Replace regexp `%s' with: " regexp)))) + (cl-loop with query = "y" + with count = 0 + for old in candidates + for new = (concat (helm-basedir old) + (replace-regexp-in-string + regexp str + (helm-basename old))) + ;; If `regexp' is not matched in `old' + ;; `replace-regexp-in-string' will + ;; return `old' unmodified. + unless (string= old new) + do (progn + (unless (string= query "!") + (while (not (member + (setq query + (string + (read-key + (propertize + (format + "Replace `%s' by `%s' [!,y,n,q]" + old new) + 'face 'minibuffer-prompt)))) + '("y" "!" "n" "q"))) + (message "Please answer by y,n,! or q") (sit-for 1))) + (when (string= query "q") + (cl-return (message "Operation aborted"))) + (unless (string= query "n") + (rename-file old new) + (cl-incf count))) + finally (message "%d Files renamed" count)))) + ;; This fix the emacs bug where "Emacs-Lisp:" is sent + ;; in minibuffer (not the echo area). + (sit-for 0.1) + (with-current-buffer (window-buffer (minibuffer-window)) + (delete-minibuffer-contents))) + +;; The action. +(defun helm-ff-query-replace-on-marked (_candidate) + (let ((marked (helm-marked-candidates))) + (helm-run-after-quit #'helm-ff-query-replace-on-marked-1 marked))) + +;; The command for `helm-find-files-map'. +(defun helm-ff-run-query-replace-on-marked () + (interactive) + (helm-ff-query-replace-on-marked nil)) + +(defun helm-ff-query-replace (_candidate) + (let ((bufs (cl-loop for f in (helm-marked-candidates) + collect (buffer-name (find-file-noselect f))))) + (helm-run-after-quit #'helm-buffer-query-replace-1 nil bufs))) + +(defun helm-ff-query-replace-regexp (_candidate) + (let ((bufs (cl-loop for f in (helm-marked-candidates) + collect (buffer-name (find-file-noselect f))))) + (helm-run-after-quit #'helm-buffer-query-replace-1 'regexp bufs))) + +(defun helm-ff-run-query-replace () + (interactive) + (helm-ff-query-replace nil)) + +(defun helm-ff-run-query-replace-regexp () + (interactive) + (helm-ff-query-replace-regexp nil)) + +(defun helm-ff-toggle-auto-update (_candidate) + (setq helm-ff-auto-update-flag (not helm-ff-auto-update-flag)) + (setq helm-ff--auto-update-state helm-ff-auto-update-flag) + (message "[Auto expansion %s]" + (if helm-ff-auto-update-flag "enabled" "disabled"))) + +(defun helm-ff-run-toggle-auto-update () + (interactive) + (with-helm-alive-p + (helm-attrset 'toggle-auto-update '(helm-ff-toggle-auto-update . never-split)) + (helm-execute-persistent-action 'toggle-auto-update))) + +(defun helm-ff-delete-char-backward () + "Disable helm find files auto update and delete char backward." + (interactive) + (setq helm-ff-auto-update-flag nil) + (setq helm-ff--deleting-char-backward t) + (call-interactively + (lookup-key (current-global-map) + (read-kbd-macro "DEL")))) + +(defun helm-ff-delete-char-backward--exit-fn () + (setq helm-ff-auto-update-flag helm-ff--auto-update-state) + (setq helm-ff--deleting-char-backward nil)) + +(defun helm-ff-run-switch-to-history () + "Run Switch to history action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (when (helm-file-completion-source-p) + (helm-quit-and-execute-action 'helm-find-files-switch-to-hist)))) + +(defun helm-ff-run-grep () + "Run Grep action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-grep))) + +(defun helm-ff-run-pdfgrep () + "Run Pdfgrep action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-pdfgrep))) + +(defun helm-ff-run-zgrep () + "Run Grep action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-zgrep))) + +(defun helm-ff-run-copy-file () + "Run Copy file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-copy))) + +(defun helm-ff-run-rename-file () + "Run Rename file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-rename))) + +(defun helm-ff-run-byte-compile-file () + "Run Byte compile file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-byte-compile))) + +(defun helm-ff-run-load-file () + "Run Load file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-load-files))) + +(defun helm-ff-run-eshell-command-on-file () + "Run eshell command on file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action + 'helm-find-files-eshell-command-on-file))) + +(defun helm-ff-run-ediff-file () + "Run Ediff file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-ediff-files))) + +(defun helm-ff-run-ediff-merge-file () + "Run Ediff merge file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action + 'helm-find-files-ediff-merge-files))) + +(defun helm-ff-run-symlink-file () + "Run Symlink file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-symlink))) + +(defun helm-ff-run-hardlink-file () + "Run Hardlink file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-files-hardlink))) + +(defun helm-ff-run-delete-file () + "Run Delete file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-delete-marked-files))) + +(defun helm-ff-run-complete-fn-at-point () + "Run complete file name action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action + 'helm-insert-file-name-completion-at-point))) + +(defun helm-ff-run-switch-to-eshell () + "Run switch to eshell action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-switch-to-eshell))) + +(defun helm-ff-run-switch-other-window () + "Run switch to other window action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'find-file-other-window))) + +(defun helm-ff-run-switch-other-frame () + "Run switch to other frame action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'find-file-other-frame))) + +(defun helm-ff-run-open-file-externally () + "Run open file externally command action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-open-file-externally))) + +(defun helm-ff-run-open-file-with-default-tool () + "Run open file externally command action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-open-file-with-default-tool))) + +(defun helm-ff-locate (candidate) + "Locate action function for `helm-find-files'." + (helm-locate-set-command) + (let ((input (concat (helm-basename + (expand-file-name + candidate + helm-ff-default-directory)) + ;; The locate '-b' option doesn't exists + ;; in everything (es). + (unless (and (eq system-type 'windows-nt) + (string-match "^es" helm-locate-command)) + " -b")))) + (helm-locate-1 helm-current-prefix-arg nil 'from-ff input))) + +(defun helm-ff-run-locate () + "Run locate action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-locate))) + +(defun helm-files-insert-as-org-link (candidate) + (insert (format "[[%s][]]" candidate)) + (goto-char (- (point) 2))) + +(defun helm-ff-run-insert-org-link () + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-files-insert-as-org-link))) + +(defun helm-ff-run-find-file-as-root () + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-find-file-as-root))) + +(defun helm-ff-run-gnus-attach-files () + "Run gnus attach files command action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-gnus-attach-files))) + +(defun helm-ff-run-etags () + "Run Etags command action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-etags-select))) + +(defvar lpr-printer-switch) +(defun helm-ff-print (_candidate) + "Print marked files. + +You may to set in order +variables `lpr-command',`lpr-switches' and/or `printer-name', +but with no settings helm should detect your printer(s) and +print with the default `lpr' settings. + +NOTE: DO NOT set the \"-P\" flag in `lpr-switches', if you really +have to modify this, do it in `lpr-printer-switch'. + +Same as `dired-do-print' but for helm." + (require 'lpr) + (when (or helm-current-prefix-arg + (not helm-ff-printer-list)) + (setq helm-ff-printer-list + (helm-ff-find-printers))) + (let* ((file-list (helm-marked-candidates :with-wildcard t)) + (len (length file-list)) + (printer-name (if helm-ff-printer-list + (helm-comp-read + "Printer: " helm-ff-printer-list) + printer-name)) + (lpr-switches + (if (and (stringp printer-name) + (string< "" printer-name)) + (cons (concat lpr-printer-switch printer-name) + lpr-switches) + lpr-switches)) + (command (helm-read-string + (format "Print *%s File(s):\n%s with: " + len + (mapconcat + (lambda (f) (format "- %s\n" f)) + file-list "")) + (when (and lpr-command lpr-switches) + (mapconcat 'identity + (cons lpr-command + (if (stringp lpr-switches) + (list lpr-switches) + lpr-switches)) + " ")))) + (file-args (mapconcat #'(lambda (x) + (format "'%s'" x)) + file-list " ")) + (cmd-line (concat command " " file-args))) + (if command + (start-process-shell-command "helm-print" nil cmd-line) + (error "Error: Please verify your printer settings in Emacs.")))) + +(defun helm-ff-run-print-file () + "Run Print file action from `helm-source-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-print))) + +(defun helm-ff-checksum (file) + "Calculate the checksum of FILE. +The checksum is copied to kill-ring." + (let ((algo (intern (helm-comp-read + "Algorithm: " + '(md5 sha1 sha224 sha256 sha384 sha512))))) + (kill-new (with-temp-buffer + (insert-file-contents-literally file) + (secure-hash algo (current-buffer)))) + (message "Checksum copied to kill-ring."))) + +(defun helm-ff-toggle-basename (_candidate) + (setq helm-ff-transformer-show-only-basename + (not helm-ff-transformer-show-only-basename)) + (let* ((cand (helm-get-selection nil t)) + (target (if helm-ff-transformer-show-only-basename + (helm-basename cand) cand))) + (helm-force-update (regexp-quote target)))) + +(defun helm-ff-run-toggle-basename () + (interactive) + (with-helm-alive-p + (unless (helm-empty-source-p) + (helm-attrset 'toggle-basename '(helm-ff-toggle-basename . never-split)) + (helm-execute-persistent-action 'toggle-basename)))) + +(cl-defun helm-reduce-file-name (fname level &key unix-close expand) + "Reduce FNAME by LEVEL from end or beginning depending LEVEL value. +If LEVEL is positive reduce from end else from beginning. +If UNIX-CLOSE is non--nil close filename with /. +If EXPAND is non--nil expand-file-name." + (let* ((exp-fname (expand-file-name fname)) + (fname-list (split-string (if (or (string= fname "~/") expand) + exp-fname fname) "/" t)) + (len (length fname-list)) + (pop-list (if (< level 0) + (cl-subseq fname-list (* level -1)) + (cl-subseq fname-list 0 (- len level)))) + (result (mapconcat 'identity pop-list "/")) + (empty (string= result ""))) + (when unix-close (setq result (concat result "/"))) + (if (string-match "^~" result) + (if (string= result "~/") "~/" result) + (if (< level 0) + (if empty "../" (concat "../" result)) + (cond ((eq system-type 'windows-nt) + (if empty (expand-file-name "/") ; Expand to "/" or "c:/". + result)) + (empty "/") + (t + (concat "/" result))))))) + +;; Internal +(defvar helm--file-completion-sources + '("Find Files" "Read File Name" "Read File Name History") + "Sources that use the *find-files mechanism can be added here. +Sources generated by `helm-mode' don't need to be added here, it will +be done automatically. +You should not modify this yourself unless you know what you do.") + +(defun helm-file-completion-source-p () + "Return non--nil if current source is a file completion source." + (or minibuffer-completing-file-name + (let ((cur-source (cdr (assoc 'name (helm-get-current-source))))) + (cl-loop for i in helm--file-completion-sources + thereis (string= cur-source i))))) + +(defun helm-find-files-up-one-level (arg) + "Go up one level like unix command `cd ..'. +If prefix numeric arg is given go ARG level up." + (interactive "p") + (with-helm-alive-p + (when (and (helm-file-completion-source-p) + (not (helm-ff-invalid-tramp-name-p))) + (with-helm-window + (when helm-follow-mode + (helm-follow-mode -1) (message nil))) + ;; When going up one level we want to be at the line + ;; corresponding to actual directory, so store this info + ;; in `helm-ff-last-expanded'. + (let ((cur-cand (helm-get-selection)) + (new-pattern (helm-reduce-file-name + helm-pattern arg :unix-close t :expand t))) + (cond ((file-directory-p helm-pattern) + (setq helm-ff-last-expanded helm-ff-default-directory)) + ((file-exists-p helm-pattern) + (setq helm-ff-last-expanded helm-pattern)) + ((and cur-cand (file-exists-p cur-cand)) + (setq helm-ff-last-expanded cur-cand))) + (helm-set-pattern new-pattern helm-suspend-update-flag) + (with-helm-after-update-hook (helm-ff-retrieve-last-expanded)))))) + +(defun helm-ff-retrieve-last-expanded () + "Move overlay to last visited directory `helm-ff-last-expanded'. +This happen after using `helm-find-files-up-one-level', +or hitting C-j on \"..\"." + (when helm-ff-last-expanded + (let ((presel (if helm-ff-transformer-show-only-basename + (helm-basename + (directory-file-name helm-ff-last-expanded)) + (directory-file-name helm-ff-last-expanded)))) + (with-helm-window + (when (re-search-forward (concat "^" (regexp-quote presel) "$") nil t) + (forward-line 0) + (helm-mark-current-line))) + (setq helm-ff-last-expanded nil)))) + +(defun helm-ff-move-to-first-real-candidate () + "When candidate is an incomplete file name move to first real candidate." + (helm-aif (and (helm-file-completion-source-p) + (not (helm-empty-source-p)) + (not (string-match + "\\`[Dd]ired" + (assoc-default 'name (helm-get-current-source)))) + helm-ff--move-to-first-real-candidate + (helm-get-selection)) + (unless (or (not (stringp it)) + (and (string-match helm-tramp-file-name-regexp it) + (not (file-remote-p it nil t))) + (file-exists-p it)) + (helm-next-line)))) +(add-hook 'helm-after-update-hook 'helm-ff-move-to-first-real-candidate) + +;;; Auto-update - helm-find-files auto expansion of directories. +;; +;; +(defun helm-ff-update-when-only-one-matched () + "Expand to directory when sole completion. +When only one candidate is remaining and it is a directory, +expand to this directory. +This happen only when `helm-ff-auto-update-flag' is non--nil +or when `helm-pattern' is equal to \"~/\"." + (when (or (and helm-ff-auto-update-flag + (null helm-ff--deleting-char-backward) + (helm-file-completion-source-p) + ;; Issue #295 + ;; File predicates are returning t + ;; with paths like //home/foo. + ;; So check it is not the case by regexp + ;; to allow user to do C-a / to start e.g + ;; entering a tramp method e.g /sudo::. + (not (string-match "\\`//" helm-pattern)) + (not (helm-ff-invalid-tramp-name-p)) + (not (eq last-command 'helm-yank-text-at-point))) + ;; Fix issue #542. + (string= helm-pattern "~/")) + (let* ((history-p (string= (assoc-default + 'name (helm-get-current-source)) + "Read File Name History")) + (pat (if (string-match helm-tramp-file-name-regexp + helm-pattern) + (helm-create-tramp-name helm-pattern) + helm-pattern)) + (completed-p (string= (file-name-as-directory + (expand-file-name pat)) + helm-ff-default-directory)) + (candnum (helm-get-candidate-number))) + (when (and (or + ;; Only one candidate remaining + ;; and at least 2 char in basename. + (and (<= candnum 2) + (>= (string-width (helm-basename helm-pattern)) 2)) + ;; Already completed. + completed-p) + (not history-p)) ; Don't try to auto complete in history. + (with-helm-window + (let ((cur-cand (prog2 + (unless (or completed-p (file-exists-p pat)) + ;; Only one non--existing candidate + ;; and one directory candidate, move to it. + (helm-next-line)) + (helm-get-selection)))) + (when (and (stringp cur-cand) + (file-accessible-directory-p cur-cand)) + (if (and (not (helm-dir-is-dot cur-cand)) ; [1] + ;; Maybe we are here because completed-p is true + ;; but check this again to be sure. (Windows fix) + (<= candnum 2)) ; [2] + ;; If after going to next line the candidate + ;; is not one of "." or ".." [1] + ;; and only one candidate is remaining [2], + ;; assume candidate is a new directory to expand, and do it. + (helm-set-pattern (file-name-as-directory cur-cand)) + ;; The candidate is one of "." or ".." + ;; that mean we have entered the last letter of the directory name + ;; in prompt, so expansion is already done, just add the "/" at end + ;; of name unless helm-pattern ends with "." + ;; (i.e we are writing something starting with ".") + (unless (string-match "\\`.*[.]\\{1\\}\\'" helm-pattern) + (helm-set-pattern + ;; Need to expand-file-name to avoid e.g /ssh:host:./ in prompt. + (expand-file-name (file-name-as-directory helm-pattern))))) + (helm-check-minibuffer-input)))))))) + +(defun helm-ff-auto-expand-to-home-or-root () + "Allow expanding to home/user directory or root or text yanked after pattern." + (when (and (helm-file-completion-source-p) + (string-match + "/\\$.*/\\|/\\./\\|/\\.\\./\\|/~.*/\\|//\\|\\(/[[:alpha:]]:/\\|\\s\\+\\)" + helm-pattern) + (with-current-buffer (window-buffer (minibuffer-window)) (eolp)) + (not (string-match helm-ff-url-regexp helm-pattern))) + (let* ((match (match-string 0 helm-pattern)) + (input (cond ((string= match "/./") + (expand-file-name default-directory)) + ((string= helm-pattern "/../") "/") + ((string-match-p "\\`/\\$" match) + (let ((sub (substitute-in-file-name match))) + (if (file-directory-p sub) + sub (replace-regexp-in-string "/\\'" "" sub)))) + (t (expand-file-name + (helm-substitute-in-filename helm-pattern) + ;; [Windows] On UNC paths "/" expand to current machine, + ;; so use the root of current Drive. (i.e "C:/") + (and (memq system-type '(windows-nt ms-dos)) + (getenv "SystemDrive")) ; nil on Unix. + ))))) + (if (file-directory-p input) + (setq helm-ff-default-directory + (setq input (file-name-as-directory input))) + (setq helm-ff-default-directory (file-name-as-directory + (file-name-directory input)))) + (with-helm-window + (helm-set-pattern input) + (helm-check-minibuffer-input))))) + +(defun helm-substitute-in-filename (fname) + "Substitute all parts of FNAME from start up to \"~/\" or \"/\". +On windows system substitute from start up to \"/[[:lower:]]:/\". +This function is needed for `helm-ff-auto-expand-to-home-or-root' +and should be used carefully elsewhere, or not at all, using +`substitute-in-file-name' instead." + (if (and ffap-url-regexp + (string-match-p ffap-url-regexp fname)) + fname + (with-temp-buffer + (insert fname) + (goto-char (point-min)) + (skip-chars-forward "/") ;; Avoid infloop in UNC paths Issue #424 + (if (re-search-forward "~.*/?\\|//\\|/[[:alpha:]]:/" nil t) + (let ((match (match-string 0))) + (goto-char (if (or (string= match "//") + (string-match-p "/[[:alpha:]]:/" match)) + (1+ (match-beginning 0)) + (match-beginning 0))) + (buffer-substring-no-properties (point) (point-at-eol))) + fname)))) + +(add-hook 'helm-after-update-hook 'helm-ff-update-when-only-one-matched) +(add-hook 'helm-after-update-hook 'helm-ff-auto-expand-to-home-or-root) + +(defun helm-point-file-in-dired (file) + "Put point on filename FILE in dired buffer." + (unless (and ffap-url-regexp + (string-match-p ffap-url-regexp file)) + (let ((target (expand-file-name (helm-substitute-in-filename file)))) + (dired (file-name-directory target)) + (dired-goto-file target)))) + +(defun helm-create-tramp-name (fname) + "Build filename for `helm-pattern' like /su:: or /sudo::." + (apply #'tramp-make-tramp-file-name + (cl-loop with v = (tramp-dissect-file-name fname) + for i across v collect i))) + +(cl-defun helm-ff-tramp-hostnames (&optional (pattern helm-pattern)) + "Get a list of hosts for tramp method found in `helm-pattern'. +Argument PATTERN default to `helm-pattern', it is here only for debugging +purpose." + (when (string-match helm-tramp-file-name-regexp pattern) + (let ((method (match-string 1 pattern)) + (tn (match-string 0 pattern)) + (all-methods (mapcar 'car tramp-methods))) + (helm-fast-remove-dups + (cl-loop for (f . h) in (tramp-get-completion-function method) + append (cl-loop for e in (funcall f (car h)) + for host = (and (consp e) (cadr e)) + when (and host (not (member host all-methods))) + collect (concat tn host))) + :test 'equal)))) + +(defun helm-ff-before-action-hook-fn () + "Exit helm when user try to execute action on an invalid tramp fname." + (let ((cand (helm-get-selection))) + (when (and (helm-file-completion-source-p) + (stringp cand) + (helm-ff-invalid-tramp-name-p cand) ; Check candidate. + (helm-ff-invalid-tramp-name-p)) ; check helm-pattern. + (error "Error: Unknown file or directory `%s'" cand)))) +(add-hook 'helm-before-action-hook 'helm-ff-before-action-hook-fn) + +(cl-defun helm-ff-invalid-tramp-name-p (&optional (pattern helm-pattern)) + "Return non--nil when PATTERN is an invalid tramp filename." + (string= (helm-ff-set-pattern pattern) + "Invalid tramp file name")) + +(defun helm-ff-set-pattern (pattern) + "Handle tramp filenames in `helm-pattern'." + (let ((methods (mapcar 'car tramp-methods)) + (reg "\\`/\\([^[/:]+\\|[^/]+]\\):.*:") + cur-method tramp-name) + ;; In some rare cases tramp can return a nil input, + ;; so be sure pattern is a string for safety (Issue #476). + (unless pattern (setq pattern "")) + (cond ((string-match "\\`\\$" pattern) + (substitute-in-file-name pattern)) + ((string= pattern "") "") + ((string-match "\\`[.]\\{1,2\\}/\\'" pattern) + (expand-file-name pattern)) + ((string-match ".*\\(~?/?[.]\\{1\\}/\\)\\'" pattern) + (expand-file-name default-directory)) + ((and (string-match ".*\\(~//\\|//\\)\\'" pattern) + (not (string-match helm-ff-url-regexp helm-pattern))) + (expand-file-name "/")) ; Expand to "/" or "c:/" + ((string-match "\\`\\(~/\\|.*/~/\\)\\'" pattern) + (expand-file-name "~/")) + ;; Match "/method:maybe_hostname:~" + ((and (string-match (concat reg "~") pattern) + (setq cur-method (match-string 1 pattern)) + (member cur-method methods)) + (setq tramp-name (expand-file-name + (helm-create-tramp-name + (match-string 0 pattern)))) + (replace-match tramp-name nil t pattern)) + ;; Match "/method:maybe_hostname:" + ((and (string-match reg pattern) + (setq cur-method (match-string 1 pattern)) + (member cur-method methods)) + (setq tramp-name (helm-create-tramp-name + (match-string 0 pattern))) + (replace-match tramp-name nil t pattern)) + ;; Match "/hostname:" + ((and (string-match helm-tramp-file-name-regexp pattern) + (setq cur-method (match-string 1 pattern)) + (and cur-method (not (member cur-method methods)))) + (setq tramp-name (helm-create-tramp-name + (match-string 0 pattern))) + (replace-match tramp-name nil t pattern)) + ;; Match "/method:" in this case don't try to connect. + ((and (not (string-match reg pattern)) + (string-match helm-tramp-file-name-regexp pattern) + (member (match-string 1 pattern) methods)) + "Invalid tramp file name") ; Write in helm-buffer. + ;; PATTERN is a directory, end it with "/". + ;; This will make PATTERN not ending yet with "/" + ;; candidate for `helm-ff-default-directory', + ;; allowing `helm-ff-retrieve-last-expanded' to retrieve it + ;; when descending level. + ;; However, we don't add automatically the "/" when + ;; `helm-ff-auto-update-flag' is enabled to avoid quick expansion. + ((and (file-accessible-directory-p pattern) + helm-ff-auto-update-flag) + (file-name-as-directory (expand-file-name pattern))) + ;; Return PATTERN unchanged. + (t pattern)))) + +(defun helm-find-files-get-candidates (&optional require-match) + "Create candidate list for `helm-source-find-files'." + (let* ((path (helm-ff-set-pattern helm-pattern)) + (dir-p (file-accessible-directory-p path)) + basedir + invalid-basedir + non-essential + (tramp-verbose helm-tramp-verbose)) ; No tramp message when 0. + (set-text-properties 0 (length path) nil path) + ;; Issue #118 allow creation of newdir+newfile. + (unless (or + ;; A tramp file name not completed. + (string= path "Invalid tramp file name") + ;; An empty pattern + (string= path "") + ;; Check if base directory of PATH is valid. + (helm-aif (file-name-directory path) + ;; If PATH is a valid directory IT=PATH, + ;; else IT=basedir of PATH. + (file-directory-p it))) + ;; BASEDIR is invalid, that's mean user is starting + ;; to write a non--existing path in minibuffer + ;; probably to create a 'new_dir' or a 'new_dir+new_file'. + (setq invalid-basedir t)) + ;; Don't set now `helm-pattern' if `path' == "Invalid tramp file name" + ;; like that the actual value (e.g /ssh:) is passed to + ;; `helm-ff-tramp-hostnames'. + (unless (or (string= path "Invalid tramp file name") + invalid-basedir) ; Leave helm-pattern unchanged. + (setq helm-ff-auto-update-flag ; [1] + ;; Unless auto update is disabled at startup or + ;; interactively, start auto updating only at third char. + (unless (or (null helm-ff-auto-update-initial-value) + (null helm-ff--auto-update-state) + ;; But don't enable auto update when + ;; deleting backward. + helm-ff--deleting-char-backward) + (or (>= (length (helm-basename path)) 3) dir-p))) + (setq helm-pattern (helm-ff--transform-pattern-for-completion path)) + ;; This have to be set after [1] to allow deleting char backward. + (setq basedir (expand-file-name + (if (and dir-p helm-ff-auto-update-flag) + ;; Add the final "/" to path + ;; when `helm-ff-auto-update-flag' is enabled. + (file-name-as-directory path) + (if (string= path "") "/" + (file-name-directory path))))) + (setq helm-ff-default-directory + (if (string= helm-pattern "") + (expand-file-name "/") ; Expand to "/" or "c:/" + ;; If path is an url *default-directory have to be nil. + (unless (or (string-match helm-ff-url-regexp path) + (and ffap-url-regexp + (string-match ffap-url-regexp path))) + basedir)))) + (cond ((string= path "Invalid tramp file name") + (or (helm-ff-tramp-hostnames) ; Hostnames completion. + (prog2 + ;; `helm-pattern' have not been modified yet. + ;; Set it here to the value of `path' that should be now + ;; "Invalid tramp file name" and set the candidates list + ;; to ("Invalid tramp file name") to make `helm-pattern' + ;; match single candidate "Invalid tramp file name". + (setq helm-pattern path) + ;; "Invalid tramp file name" is now printed + ;; in `helm-buffer'. + (list path)))) + ((or (and (file-regular-p path) + (eq last-repeatable-command 'helm-execute-persistent-action)) + ;; `ffap-url-regexp' don't match until url is complete. + (string-match helm-ff-url-regexp path) + invalid-basedir + (and (not (file-exists-p path)) (string-match "/$" path)) + (and ffap-url-regexp (string-match ffap-url-regexp path))) + (list path)) + ((string= path "") (helm-ff-directory-files "/" t)) + ((and (file-directory-p path) (not (file-readable-p path))) + (list (format "Opening directory: access denied, `%s'" path))) + ;; A fast expansion of PATH is made only if `helm-ff-auto-update-flag' + ;; is enabled. + ((and dir-p helm-ff-auto-update-flag) + (helm-ff-directory-files path t)) + (t (append (unless (or require-match + ;; When `helm-ff-auto-update-flag' has been + ;; disabled, whe don't want PATH to be added on top + ;; if it is a directory. + dir-p) + (list path)) + (helm-ff-directory-files basedir t)))))) + +(defsubst helm-ff-directory-files (directory &optional full) + "List contents of DIRECTORY. +Argument FULL mean absolute path. +It is same as `directory-files' but always returns the +dotted filename '.' and '..' even on root directories in Windows +systems." + (setq directory (file-name-as-directory + (expand-file-name directory))) + (let ((ls (directory-files + directory full directory-files-no-dot-files-regexp)) + (dot (concat directory ".")) + (dot2 (concat directory ".."))) + (append (list dot dot2) ls))) + +(defun helm-ff-handle-backslash (fname) + ;; Allow creation of filenames containing a backslash. + (cl-loop with bad = '((92 . "")) + for i across fname + for isbad = (assq i bad) + if isbad concat (cdr isbad) + else concat (string i))) + +(defun helm-ff-smart-completion-p () + (and helm-ff-smart-completion + (not (memq helm-mp-matching-method '(multi1 multi3p))))) + +(defun helm-ff--transform-pattern-for-completion (pattern) + "Maybe return PATTERN with it's basename modified as a regexp. +This happen only when `helm-ff-smart-completion' is enabled. +This provide a similar behavior as `ido-enable-flex-matching'. +See also `helm--mapconcat-pattern'. +If PATTERN is an url returns it unmodified. +When PATTERN contain a space fallback to match-plugin. +If basename contain one or more space fallback to match-plugin. +If PATTERN is a valid directory name,return PATTERN unchanged." + ;; handle bad filenames containing a backslash. + (setq pattern (helm-ff-handle-backslash pattern)) + (let ((bn (helm-basename pattern)) + (bd (or (helm-basedir pattern) "")) + (dir-p (file-directory-p pattern)) + (tramp-p (cl-loop for (m . f) in tramp-methods + thereis (string-match m pattern)))) + ;; Always regexp-quote base directory name to handle + ;; crap dirnames such e.g bookmark+ + (cond + ((or (and dir-p tramp-p (string-match ":\\'" pattern)) + (string= pattern "") + (and dir-p (<= (length bn) 2)) + ;; Fix Issue #541 when BD have a subdir similar + ;; to BN, don't switch to match plugin + ;; which will match both. + (and dir-p (string-match (regexp-quote bn) bd))) + ;; Use full PATTERN on e.g "/ssh:host:". + (regexp-quote pattern)) + ;; Prefixing BN with a space call match-plugin completion. + ;; This allow showing all files/dirs matching BN (Issue #518). + ;; FIXME: some match-plugin methods may not work here. + (dir-p (concat (regexp-quote bd) " " (regexp-quote bn))) + ((or (not (helm-ff-smart-completion-p)) + (string-match "\\s-" bn)) ; Fall back to match-plugin. + (concat (regexp-quote bd) bn)) + ((or (string-match "[*][.]?.*" bn) ; Allow entering wilcard. + (string-match "/$" pattern) ; Allow mkdir. + (string-match helm-ff-url-regexp pattern) + (and (string= helm-ff-default-directory "/") tramp-p)) + ;; Don't treat wildcards ("*") as regexp char. + ;; (e.g ./foo/*.el => ./foo/[*].el) + (concat (regexp-quote bd) + (replace-regexp-in-string "[*]" "[*]" bn))) + (t + (setq bn (if (>= (length bn) 2) ; wait 2nd char before concating. + (helm--mapconcat-pattern bn) + (concat ".*" (regexp-quote bn)))) + (concat (regexp-quote bd) bn))))) + +(defun helm-dir-is-dot (dir) + (string-match "\\(?:/\\|\\`\\)\\.\\{1,2\\}\\'" dir)) + +(defun helm-ff-save-history () + "Store the last value of `helm-ff-default-directory' in `helm-ff-history'. +Note that only existing directories are saved here." + (when (and helm-ff-default-directory + (helm-file-completion-source-p) + (file-directory-p helm-ff-default-directory)) + (set-text-properties 0 (length helm-ff-default-directory) + nil helm-ff-default-directory) + (push helm-ff-default-directory helm-ff-history))) +(add-hook 'helm-cleanup-hook 'helm-ff-save-history) + +(defun helm-files-save-file-name-history (&optional force) + "Save selected file to `file-name-history'." + (let ((src-name (assoc-default 'name (helm-get-current-source)))) + (when (or force (helm-file-completion-source-p) + (member src-name helm-files-save-history-extra-sources)) + (let ((mkd (helm-marked-candidates)) + (history-delete-duplicates t)) + (cl-loop for sel in mkd + when (and sel + (stringp sel) + (file-exists-p sel) + (not (file-directory-p sel))) + do + ;; we use `abbreviate-file-name' here because + ;; other parts of Emacs seems to, + ;; and we don't want to introduce duplicates. + (add-to-history 'file-name-history + (abbreviate-file-name sel))))))) +(add-hook 'helm-exit-minibuffer-hook 'helm-files-save-file-name-history) + +(defun helm-ff-valid-symlink-p (file) + (helm-aif (condition-case-unless-debug nil + ;; `file-truename' send error + ;; on cyclic symlinks (Issue #692). + (file-truename file) + (error nil)) + (file-exists-p it))) + +(defun helm-get-default-mode-for-file (filename) + "Return the default mode to open FILENAME." + (let ((mode (cl-loop for (r . m) in auto-mode-alist + thereis (and (string-match r filename) m)))) + (or (and (symbolp mode) mode) "Fundamental"))) + +(defun helm-ff-properties (candidate) + "Show file properties of CANDIDATE in a tooltip or message." + (let* ((all (helm-file-attributes candidate)) + (dired-line (helm-file-attributes + candidate :dired t :human-size t)) + (type (cl-getf all :type)) + (mode-type (cl-getf all :mode-type)) + (owner (cl-getf all :uid)) + (owner-right (cl-getf all :user t)) + (group (cl-getf all :gid)) + (group-right (cl-getf all :group)) + (other-right (cl-getf all :other)) + (size (helm-file-human-size (cl-getf all :size))) + (modif (cl-getf all :modif-time)) + (access (cl-getf all :access-time)) + (ext (helm-get-default-program-for-file candidate)) + (tooltip-hide-delay (or helm-tooltip-hide-delay tooltip-hide-delay))) + (if (and (window-system) tooltip-mode) + (tooltip-show + (concat + (helm-basename candidate) "\n" + dired-line "\n" + (format "Mode: %s\n" (helm-get-default-mode-for-file candidate)) + (format "Ext prog: %s\n" (or (and ext (replace-regexp-in-string + " %s" "" ext)) + "Not defined")) + (format "Type: %s: %s\n" type mode-type) + (when (string= type "symlink") + (format "True name: '%s'\n" + (cond ((string-match "^\.#" (helm-basename candidate)) + "Autosave symlink") + ((helm-ff-valid-symlink-p candidate) + (file-truename candidate)) + (t "Invalid Symlink")))) + (format "Owner: %s: %s\n" owner owner-right) + (format "Group: %s: %s\n" group group-right) + (format "Others: %s\n" other-right) + (format "Size: %s\n" size) + (format "Modified: %s\n" modif) + (format "Accessed: %s\n" access))) + (message dired-line) (sit-for 5)))) + +(defun helm-ff-properties-persistent () + "Show properties without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'properties-action '(helm-ff-properties . never-split)) + (helm-execute-persistent-action 'properties-action))) + +(defun helm-ff-persistent-delete () + "Delete current candidate without quitting." + (interactive) + (with-helm-alive-p + (helm-attrset 'quick-delete '(helm-ff-quick-delete . never-split)) + (helm-execute-persistent-action 'quick-delete))) + +(defun helm-ff-dot-file-p (file) + "Check if FILE is `.' or `..'." + (member (helm-basename file) '("." ".."))) + +(defun helm-ff-quick-delete (_candidate) + "Delete file CANDIDATE without quitting." + (let ((marked (helm-marked-candidates))) + (unwind-protect + (save-selected-window + (cl-loop for c in marked do + (progn (helm-preselect (if (and helm-ff-transformer-show-only-basename + (not (helm-ff-dot-file-p c))) + (helm-basename c) c)) + (when (y-or-n-p (format "Really Delete file `%s'? " c)) + (helm-delete-file c helm-ff-signal-error-on-dot-files + 'synchro) + (helm-delete-current-selection) + (message nil))))) + (with-helm-buffer + (setq helm-marked-candidates nil + helm-visible-mark-overlays nil)) + (helm-force-update)))) + +(defun helm-ff-kill-buffer-fname (candidate) + (let ((buf (get-file-buffer candidate))) + (if buf + (progn + (kill-buffer buf) (message "Buffer `%s' killed" buf)) + (message "No buffer to kill")))) + +(defun helm-ff-kill-or-find-buffer-fname (candidate) + "Find file CANDIDATE or kill it's buffer if it is visible. +Never kill `helm-current-buffer'. +Never kill buffer modified. +This is called normally on third hit of \ +\\\\[helm-execute-persistent-action] +in `helm-find-files-persistent-action'." + (let* ((buf (get-file-buffer candidate)) + (buf-name (buffer-name buf)) + (win (get-buffer-window buf)) + (helm--reading-passwd-or-string t)) + (if (and buf win + (not (eq buf (get-buffer helm-current-buffer))) + (not (buffer-modified-p buf))) + (progn + (kill-buffer buf) + (set-window-buffer win helm-current-buffer) + (message "Buffer `%s' killed" buf-name)) + (find-file candidate)))) + +(defun helm-ff-run-kill-buffer-persistent () + "Execute `helm-ff-kill-buffer-fname' whitout quitting." + (interactive) + (with-helm-alive-p + (helm-attrset 'kill-buffer-fname 'helm-ff-kill-buffer-fname) + (helm-execute-persistent-action 'kill-buffer-fname))) + +(defun helm-ff-prefix-filename (fname &optional file-or-symlinkp new-file) + "Return filename FNAME maybe prefixed with [?] or [@]. +If FILE-OR-SYMLINKP is non--nil this mean we assume FNAME is an +existing filename or valid symlink and there is no need to test it. +NEW-FILE when non--nil mean FNAME is a non existing file and +return FNAME prefixed with [?]." + (let* ((prefix-new (propertize + " " 'display + (propertize "[?]" 'face 'helm-ff-prefix))) + (prefix-url (propertize + " " 'display + (propertize "[@]" 'face 'helm-ff-prefix)))) + (cond ((or file-or-symlinkp (file-exists-p fname)) fname) + ((or (string-match helm-ff-url-regexp fname) + (and ffap-url-regexp (string-match ffap-url-regexp fname))) + (concat prefix-url " " fname)) + ((or new-file (not (file-exists-p fname))) + (concat prefix-new " " fname))))) + +(defun helm-ff-score-candidate-for-pattern (str pattern) + (if (member str '("." "..")) + 200 + (helm-score-candidate-for-pattern str pattern))) + +(defun helm-ff-sort-candidates (candidates _source) + "Sort function for `helm-source-find-files'. +Return candidates prefixed with basename of `helm-input' first." + (if (or (and (file-directory-p helm-input) + (string-match "/\\'" helm-input)) + (string-match "\\`\\$" helm-input) + (null candidates)) + candidates + (let* ((c1 (car candidates)) + (cand1real (if (consp c1) (cdr c1) c1)) + (cand1 (unless (file-exists-p cand1real) c1)) + (rest-cand (if cand1 (cdr candidates) candidates)) + (memo-src (make-hash-table :test 'equal)) + (all (sort rest-cand + #'(lambda (s1 s2) + (let* ((score (lambda (str) + (helm-ff-score-candidate-for-pattern + str (helm-basename helm-input)))) + (bn1 (helm-basename (if (consp s1) (cdr s1) s1))) + (bn2 (helm-basename (if (consp s2) (cdr s2) s2))) + (sc1 (or (gethash bn1 memo-src) + (puthash bn1 (funcall score bn1) memo-src))) + (sc2 (or (gethash bn2 memo-src) + (puthash bn2 (funcall score bn2) memo-src)))) + (cond ((= sc1 sc2) + (< (string-width bn1) + (string-width bn2))) + ((> sc1 sc2)))))))) + (if cand1 (cons cand1 all) all)))) + +(defun helm-ff-filter-candidate-one-by-one (file) + "`filter-one-by-one' Transformer function for `helm-source-find-files'." + ;; Handle boring files + (unless (and helm-ff-skip-boring-files + (cl-loop for r in helm-boring-file-regexp-list + ;; Prevent user doing silly thing like + ;; adding the dotted files to boring regexps (#924). + thereis (and (not (string-match "\\.$" file)) + (string-match r file)))) + ;; Handle tramp files. + (if (and (string-match helm-tramp-file-name-regexp helm-pattern) + helm-ff-tramp-not-fancy) + (if helm-ff-transformer-show-only-basename + (if (helm-dir-is-dot file) + file + (cons (or (helm-ff-get-host-from-tramp-invalid-fname file) + (helm-basename file)) + file)) + file) + ;; Now highlight. + (let* ((disp (if (and helm-ff-transformer-show-only-basename + (not (helm-dir-is-dot file)) + (not (and ffap-url-regexp + (string-match ffap-url-regexp file))) + (not (string-match helm-ff-url-regexp file))) + (or (helm-ff-get-host-from-tramp-invalid-fname file) + (helm-basename file)) file)) + (attr (file-attributes file)) + (type (car attr))) + + (cond ((string-match "access denied" file) file) + ( ;; A not already saved file. + (and (stringp type) + (not (helm-ff-valid-symlink-p file)) + (not (string-match "^\.#" (helm-basename file)))) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-invalid-symlink) t) + file)) + ;; A symlink. + ((stringp type) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-symlink) t) + file)) + ;; A dotted directory. + ((and (eq t type) (helm-ff-dot-file-p file)) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-dotted-directory) t) + file)) + ;; A directory. + ((eq t type) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-directory) t) + file)) + ;; An executable file. + ((and attr (string-match "x" (nth 8 attr))) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-executable) t) + file)) + ;; A file. + ((and attr (null type)) + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-file) t) + file)) + ;; A non--existing file. + (t + (cons (helm-ff-prefix-filename + (propertize disp 'face 'helm-ff-file) nil 'new-file) + file))))))) + +(defun helm-find-files-action-transformer (actions candidate) + "Action transformer for `helm-source-find-files'." + (let ((str-at-point (with-helm-current-buffer + (buffer-substring-no-properties + (point-at-bol) (point-at-eol))))) + (cond ((with-helm-current-buffer + (eq major-mode 'message-mode)) + (append actions + '(("Gnus attach file(s)" . helm-ff-gnus-attach-files)))) + ((save-match-data + (and (not (string-match-p ffap-url-regexp str-at-point)) + (string-match "\\(.*\\):\\([0-9]+\\)\\'" str-at-point) + (file-equal-p (match-string 1 str-at-point) candidate))) + (append '(("Find file to line number" . helm-ff-goto-line)) + actions)) + ((string-match (image-file-name-regexp) candidate) + (append actions + '(("Rotate image right `M-r'" . helm-ff-rotate-image-right) + ("Rotate image left `M-l'" . helm-ff-rotate-image-left)))) + ((string-match "\.el$" (helm-aif (helm-marked-candidates) + (car it) candidate)) + (append actions + '(("Byte compile lisp file(s) `M-B, C-u to load'" + . helm-find-files-byte-compile) + ("Load File(s) `M-L'" . helm-find-files-load-files)))) + ((and (string-match "\.html?$" candidate) + (file-exists-p candidate)) + (append actions + '(("Browse url file" . browse-url-of-file)))) + ((or (string= (file-name-extension candidate) "pdf") + (string= (file-name-extension candidate) "PDF")) + (append actions + '(("Pdfgrep File(s)" . helm-ff-pdfgrep)))) + (t actions)))) + +(defun helm-ff-goto-line (candidate) + "Find file CANDIDATE and maybe jump to line number found in fname at point. +line number should be added at end of fname preceded with \":\". +e.g \"foo:12\"." + (let ((linum (let ((str (with-helm-current-buffer + (buffer-substring-no-properties + (point-at-bol) (point-at-eol))))) + (when (string-match ":\\([0-9]+\\)\\'" str) + (match-string 1 str))))) + (find-file candidate) + (and linum (not (string= linum "")) + (helm-goto-line (string-to-number linum) t)))) + +(defun helm-ff-gnus-attach-files (_candidate) + "Run `gnus-dired-attach' on `helm-marked-candidates' or CANDIDATE." + (require 'gnus-dired) + (let ((flist (helm-marked-candidates :with-wildcard t))) + (gnus-dired-attach flist))) + +(defvar image-dired-display-image-buffer) +(defun helm-ff-rotate-current-image-1 (file &optional num-arg) + "Rotate current image at NUM-ARG degrees. +This is a destructive operation on FILE made by external tool mogrify." + (setq file (file-truename file)) ; For symlinked images. + ;; When FILE is not an image-file, do nothing. + (when (string-match (image-file-name-regexp) file) + (if (executable-find "mogrify") + (progn + (shell-command (format "mogrify -rotate %s %s" + (or num-arg 90) + (shell-quote-argument file))) + (when (buffer-live-p image-dired-display-image-buffer) + (kill-buffer image-dired-display-image-buffer)) + (image-dired-display-image file) + (message nil) + (display-buffer (get-buffer image-dired-display-image-buffer))) + (error "mogrify not found")))) + +(defun helm-ff-rotate-image-left (candidate) + "Rotate image file CANDIDATE left. +This affect directly file CANDIDATE." + (helm-ff-rotate-current-image-1 candidate -90)) + +(defun helm-ff-rotate-image-right (candidate) + "Rotate image file CANDIDATE right. +This affect directly file CANDIDATE." + (helm-ff-rotate-current-image-1 candidate)) + +(defun helm-ff-rotate-left-persistent () + "Rotate image left without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'image-action1 'helm-ff-rotate-image-left) + (helm-execute-persistent-action 'image-action1))) + +(defun helm-ff-rotate-right-persistent () + "Rotate image right without quitting helm." + (interactive) + (with-helm-alive-p + (helm-attrset 'image-action2 'helm-ff-rotate-image-right) + (helm-execute-persistent-action 'image-action2))) + +(defun helm-ff-exif-data (candidate) + "Extract exif data from file CANDIDATE using `helm-ff-exif-data-program'." + (if (and helm-ff-exif-data-program + (executable-find helm-ff-exif-data-program)) + (shell-command-to-string (format "%s %s %s" + helm-ff-exif-data-program + helm-ff-exif-data-program-args + candidate)) + (format "No program %s found to extract exif" + helm-ff-exif-data-program))) + +(defun helm-find-files-persistent-action (candidate) + "Open subtree CANDIDATE without quitting helm. +If CANDIDATE is not a directory expand CANDIDATE filename. +If CANDIDATE is alone, open file CANDIDATE filename. +That's mean: +First hit on C-j expand CANDIDATE second hit open file. +If a prefix arg is given or `helm-follow-mode' is on open file." + (let* ((follow (or (buffer-local-value + 'helm-follow-mode + (get-buffer-create helm-buffer)) + helm--temp-follow-flag)) + (new-pattern (helm-get-selection)) + (num-lines-buf (with-current-buffer helm-buffer + (count-lines (point-min) (point-max)))) + (insert-in-minibuffer #'(lambda (fname) + (with-selected-window (minibuffer-window) + (unless follow + (delete-minibuffer-contents) + (set-text-properties 0 (length fname) + nil fname) + (insert fname)))))) + (cond ((and (helm-ff-invalid-tramp-name-p) + (string-match helm-tramp-file-name-regexp candidate)) + ;; First hit insert hostname and + ;; second hit insert ":" and expand. + (if (string= candidate helm-pattern) + (funcall insert-in-minibuffer (concat candidate ":")) + (funcall insert-in-minibuffer candidate))) + ( ;; A symlink directory, expand it's truename. + (and (file-directory-p candidate) (file-symlink-p candidate)) + (funcall insert-in-minibuffer (file-name-as-directory + (file-truename + (expand-file-name candidate))))) + ;; A directory, open it. + ((file-directory-p candidate) + (when (string= (helm-basename candidate) "..") + (setq helm-ff-last-expanded helm-ff-default-directory)) + (funcall insert-in-minibuffer (file-name-as-directory + (expand-file-name candidate)))) + ;; A symlink file, expand to it's true name. (first hit) + ((and (file-symlink-p candidate) (not current-prefix-arg) (not follow)) + (funcall insert-in-minibuffer (file-truename candidate))) + ;; A regular file, expand it, (first hit) + ((and (>= num-lines-buf 3) (not current-prefix-arg) (not follow)) + (setq helm-pattern "") ; Force update. + (funcall insert-in-minibuffer new-pattern)) + ;; An image file and it is the second hit on C-j, + ;; show the file in `image-dired'. + ((string-match (image-file-name-regexp) candidate) + (when (buffer-live-p (get-buffer image-dired-display-image-buffer)) + (kill-buffer image-dired-display-image-buffer)) + ;; Fix emacs bug never fixed upstream. + (unless (file-directory-p image-dired-dir) + (make-directory image-dired-dir)) + (image-dired-display-image candidate) + (message nil) + (switch-to-buffer image-dired-display-image-buffer) + (with-current-buffer image-dired-display-image-buffer + (let ((exif-data (helm-ff-exif-data candidate))) + (setq default-directory helm-ff-default-directory) + (image-dired-update-property 'help-echo exif-data)))) + ;; Allow browsing archive on avfs fs. + ;; Assume volume is already mounted with mountavfs. + ((and helm-ff-avfs-directory + (string-match + (regexp-quote (expand-file-name helm-ff-avfs-directory)) + (file-name-directory candidate)) + (helm-ff-file-compressed-p candidate)) + (funcall insert-in-minibuffer (concat candidate "#"))) + ;; On second hit we open file. + ;; On Third hit we kill it's buffer maybe. + (t + (helm-ff-kill-or-find-buffer-fname candidate))))) + +(defun helm-ff-file-compressed-p (candidate) + "Whether CANDIDATE is a compressed file or not." + (member (file-name-extension candidate) + helm-ff-file-compressed-list)) + +(defun helm-insert-file-name-completion-at-point (candidate) + "Insert file name completion at point." + (with-helm-current-buffer + (if buffer-read-only + (error "Error: Buffer `%s' is read-only" (buffer-name)) + (let* ((end (point)) + (tap (thing-at-point 'filename)) + (guess (and (stringp tap) (substring-no-properties tap))) + (beg (- (point) (length guess))) + (full-path-p (and (stringp guess) + (or (string-match-p + (concat "^" (getenv "HOME")) + guess) + (string-match-p + "\\`\\(/\\|[[:lower:][:upper:]]:/\\)" + guess))))) + (set-text-properties 0 (length candidate) nil candidate) + (if (and guess (not (string= guess "")) + (or (string-match "^\\(~/\\|/\\|[[:lower:][:upper:]]:/\\)" + guess) + (file-exists-p candidate))) + (progn + (delete-region beg end) + (insert (cond (full-path-p + (expand-file-name candidate)) + ((string= (match-string 1 guess) "~/") + (abbreviate-file-name candidate)) + (t (file-relative-name candidate))))) + (insert (cond ((equal helm-current-prefix-arg '(4)) + (abbreviate-file-name candidate)) + ((equal helm-current-prefix-arg '(16)) + (file-relative-name candidate)) + (t candidate)))))))) + +(cl-defun helm-find-files-history (&key (comp-read t)) + "The `helm-find-files' history. +Show the first `helm-ff-history-max-length' elements of +`helm-ff-history' in an `helm-comp-read'." + (let ((history (when helm-ff-history + (helm-fast-remove-dups helm-ff-history + :test 'equal)))) + (when history + (setq helm-ff-history + (if (>= (length history) helm-ff-history-max-length) + (cl-subseq history 0 helm-ff-history-max-length) + history)) + (if comp-read + (helm-comp-read + "Switch to Directory: " + helm-ff-history + :name "Helm Find Files History" + :must-match t) + helm-ff-history)))) + +(defun helm-find-files-1 (fname &optional preselect) + "Find FNAME with `helm' completion. +Like `find-file' but with `helm' support. +Use it for non--interactive calls of `helm-find-files'." + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (setq helm-find-files--toggle-bookmark nil) + (let* ( ;; Be sure we don't erase the precedent minibuffer if some. + (helm-ff-auto-update-initial-value + (and helm-ff-auto-update-initial-value + (not (minibuffer-window-active-p (minibuffer-window))))) + (tap (thing-at-point 'filename)) + (def (and tap (or (file-remote-p tap) + (expand-file-name tap))))) + (unless helm-source-find-files + (setq helm-source-find-files (helm-make-source + "Find Files" 'helm-source-ffiles))) + (helm :sources 'helm-source-find-files + :input fname + :case-fold-search helm-file-name-case-fold-search + :preselect preselect + :default def + :prompt "Find Files or Url: " + :buffer "*Helm Find Files*"))) + +(defun helm-find-files-toggle-to-bookmark () + "Toggle helm-bookmark for `helm-find-files' and `helm-find-files.'" + (interactive) + (with-helm-buffer + (if (setq helm-find-files--toggle-bookmark + (not helm-find-files--toggle-bookmark)) + (progn + (helm-set-pattern "" t) + (helm-set-sources '(helm-source-bookmark-helm-find-files))) + ;; Switch back to helm-find-files. + (helm-set-pattern "./" t) ; Back to initial directory of hff session. + (helm-set-sources '(helm-source-find-files)) + (helm--maybe-update-keymap)))) + +(defun helm-find-files-initial-input (&optional input) + "Return INPUT if present, otherwise try to guess it." + (let ((ffap-machine-p-known 'reject)) + (unless (eq major-mode 'image-mode) + (or (and input (or (and (file-remote-p input) input) + (expand-file-name input))) + (helm-find-files-input + (ffap-guesser) + (thing-at-point 'filename)))))) + +(defun helm-find-files-input (file-at-pt thing-at-pt) + "Try to guess a default input for `helm-find-files'." + (let* ((non-essential t) + (remp (or (and file-at-pt (file-remote-p file-at-pt)) + (and thing-at-pt (file-remote-p thing-at-pt)))) + (def-dir (helm-current-directory)) + (urlp (and file-at-pt ffap-url-regexp + (string-match ffap-url-regexp file-at-pt))) + (lib (when helm-ff-search-library-in-sexp + (helm-find-library-at-point))) + (hlink (helm-ff-find-url-at-point)) + (file-p (and file-at-pt + (not (string= file-at-pt "")) + (not remp) + (file-exists-p file-at-pt) + thing-at-pt + (not (string= thing-at-pt "")) + (file-exists-p + (file-name-directory + (expand-file-name thing-at-pt def-dir)))))) + (cond (lib) ; e.g we are inside a require sexp. + (hlink) ; String at point is an hyperlink. + (file-p ; a regular file + (helm-aif (ffap-file-at-point) (expand-file-name it))) + (urlp file-at-pt) ; possibly an url or email. + ((and file-at-pt + (not remp) + (file-exists-p file-at-pt)) + file-at-pt)))) + +(defun helm-ff-find-url-at-point () + "Try to find link to an url in text-property at point." + (let* ((he (get-text-property (point) 'help-echo)) + (ov (overlays-at (point))) + (ov-he (and ov (overlay-get + (car (overlays-at (point))) 'help-echo))) + (w3m-l (get-text-property (point) 'w3m-href-anchor)) + (nt-prop (get-text-property (point) 'nt-link))) + ;; Org link. + (when (and (stringp he) (string-match "^LINK: " he)) + (setq he (replace-match "" t t he))) + (cl-loop for i in (list he ov-he w3m-l nt-prop) + thereis (and (stringp i) ffap-url-regexp (string-match ffap-url-regexp i) i)))) + +(defun helm-find-library-at-point () + "Try to find library path at point. +Find inside `require' and `declare-function' sexp." + (require 'find-func) + (let* ((beg-sexp (save-excursion (search-backward "(" (point-at-bol) t))) + (end-sexp (save-excursion (search-forward ")" (point-at-eol) t))) + (sexp (and beg-sexp end-sexp + (buffer-substring-no-properties + (1+ beg-sexp) (1- end-sexp))))) + (ignore-errors + (cond ((and sexp (string-match "require \'.+[^)]" sexp)) + (find-library-name + (replace-regexp-in-string + "'\\|\)\\|\(" "" + ;; If require use third arg, ignore it, + ;; always use library path found in `load-path'. + (cl-second (split-string (match-string 0 sexp)))))) + ((and sexp (string-match-p "^declare-function" sexp)) + (find-library-name + (replace-regexp-in-string + "\"\\|ext:" "" + (cl-third (split-string sexp))))) + (t nil))))) + + +;;; Handle copy, rename, symlink, relsymlink and hardlink from helm. +;; +;; +(defvar dired-async-be-async) +(cl-defun helm-dired-action (candidate + &key action follow (files (dired-get-marked-files))) + "Execute ACTION on FILES to CANDIDATE. +Where ACTION is a symbol that can be one of: +'copy, 'rename, 'symlink,'relsymlink, 'hardlink. +Argument FOLLOW when non--nil specify to follow FILES to destination for the actions +copy and rename." + (when (get-buffer dired-log-buffer) (kill-buffer dired-log-buffer)) + (let ((fn (cl-case action + (copy 'dired-copy-file) + (rename 'dired-rename-file) + (symlink 'make-symbolic-link) + (relsymlink 'dired-make-relative-symlink) + (hardlink 'dired-hardlink))) + (marker (cl-case action + ((copy rename) dired-keep-marker-copy) + (symlink dired-keep-marker-symlink) + (relsymlink dired-keep-marker-relsymlink) + (hardlink dired-keep-marker-hardlink))) + (dirflag (and (= (length files) 1) + (file-directory-p (car files)) + (not (file-directory-p candidate)))) + ;; When FOLLOW is enabled, disable helm-async. + ;; If it is globally disabled use this nil value. + (dired-async-be-async (and (boundp 'dired-async-be-async) + dired-async-be-async + (not follow)))) + (dired-create-files + fn (symbol-name action) files + ;; CANDIDATE is the destination. + (if (file-directory-p candidate) + ;; When CANDIDATE is a directory, build file-name in this directory. + ;; Else we use CANDIDATE. + #'(lambda (from) + (expand-file-name (file-name-nondirectory from) candidate)) + #'(lambda (_from) candidate)) + marker) + (push (file-name-as-directory + (if (file-directory-p candidate) + (expand-file-name candidate) + (file-name-directory candidate))) + helm-ff-history) + ;; If follow is non--nil we should not be in async mode. + (when (and follow + (not (memq action '(symlink relsymlink hardlink))) + (not (get-buffer dired-log-buffer))) + (let ((target (directory-file-name candidate))) + (unwind-protect + (progn + (setq helm-ff-cand-to-mark + (helm-get-dest-fnames-from-list files candidate dirflag)) + (with-helm-after-update-hook (helm-ff-maybe-mark-candidates)) + (if (and dirflag (eq action 'rename)) + (helm-find-files-1 (file-name-directory target) + (if helm-ff-transformer-show-only-basename + (helm-basename target) target)) + (helm-find-files-1 (file-name-as-directory + (expand-file-name candidate))))) + (setq helm-ff-cand-to-mark nil)))))) + +(defun helm-get-dest-fnames-from-list (flist dest-cand rename-dir-flag) + "Transform filenames of FLIST to abs of DEST-CAND. +If RENAME-DIR-FLAG is non--nil collect the `directory-file-name' of transformed +members of FLIST." + ;; At this point files have been renamed/copied at destination. + ;; That's mean DEST-CAND exists. + (cl-loop + with dest = (expand-file-name dest-cand) + for src in flist + for basename-src = (helm-basename src) + for fname = (cond (rename-dir-flag (directory-file-name dest)) + ((file-directory-p dest) + (concat (file-name-as-directory dest) basename-src)) + (t dest)) + when (file-exists-p fname) + collect fname into tmp-list + finally return (sort tmp-list 'string<))) + +(defun helm-ff-maybe-mark-candidates () + "Mark all candidates of list `helm-ff-cand-to-mark'. +This is used when copying/renaming/symlinking etc... and +following files to destination." + (when (and (string= (assoc-default 'name (helm-get-current-source)) + (assoc-default 'name helm-source-find-files)) + helm-ff-cand-to-mark) + (with-helm-window + (while helm-ff-cand-to-mark + (if (string= (car helm-ff-cand-to-mark) (helm-get-selection)) + (progn + (helm-make-visible-mark) + (helm-next-line) + (setq helm-ff-cand-to-mark (cdr helm-ff-cand-to-mark))) + (helm-next-line))) + (unless (helm-this-visible-mark) + (helm-prev-visible-mark))))) + + +;;; Routines for files +;; +;; +(defun helm-file-buffers (filename) + "Returns a list of buffer names corresponding to FILENAME." + (cl-loop with name = (expand-file-name filename) + for buf in (buffer-list) + for bfn = (buffer-file-name buf) + when (and bfn (string= name bfn)) + collect (buffer-name buf))) + +(defun helm-delete-file (file &optional error-if-dot-file-p synchro) + "Delete the given file after querying the user. +Ask to kill buffers associated with that file, too." + (when (and error-if-dot-file-p + (helm-ff-dot-file-p file)) + (error "Error: Cannot operate on `.' or `..'")) + (let ((buffers (helm-file-buffers file)) + (helm--reading-passwd-or-string t)) + (if (or (< emacs-major-version 24) synchro) + ;; `dired-delete-file' in Emacs versions < 24 + ;; doesn't support delete-by-moving-to-trash + ;; so use `delete-directory' and `delete-file' + ;; that handle it. + (cond ((and (not (file-symlink-p file)) + (file-directory-p file) + (directory-files file t dired-re-no-dot)) + (when (y-or-n-p (format "Recursive delete of `%s'? " file)) + (delete-directory file 'recursive))) + ((and (not (file-symlink-p file)) + (file-directory-p file)) + (delete-directory file)) + (t (delete-file file))) + (dired-delete-file + file dired-recursive-deletes delete-by-moving-to-trash)) + (when buffers + (cl-dolist (buf buffers) + (when (y-or-n-p (format "Kill buffer %s, too? " buf)) + (kill-buffer buf)))))) + +(defun helm-delete-marked-files (_ignore) + (let* ((files (helm-marked-candidates :with-wildcard t)) + (len (length files))) + (with-helm-display-marked-candidates + helm-marked-buffer-name + (mapcar #'(lambda (f) + (if (file-directory-p f) + (concat (helm-basename f) "/") + (helm-basename f))) + files) + (if (not (y-or-n-p (format "Delete *%s File(s)" len))) + (message "(No deletions performed)") + (cl-dolist (i files) + (set-text-properties 0 (length i) nil i) + (helm-delete-file i helm-ff-signal-error-on-dot-files)) + (message "%s File(s) deleted" len))))) + +(defun helm-find-file-or-marked (candidate) + "Open file CANDIDATE or open helm marked files in separate windows. +Called with a prefix arg open files in background without selecting them." + (let ((marked (helm-marked-candidates :with-wildcard t)) + (url-p (and ffap-url-regexp ; we should have only one candidate. + (string-match ffap-url-regexp candidate))) + (ffap-newfile-prompt helm-ff-newfile-prompt-p) + (find-file-wildcards nil) + (make-dir-fn + #'(lambda (dir &optional helm-ff) + (when (y-or-n-p (format "Create directory `%s'? " dir)) + (let ((dirfname (directory-file-name dir))) + (if (file-exists-p dirfname) + (error + "Mkdir: Unable to create directory `%s': file exists." + (helm-basename dirfname)) + (make-directory dir 'parent))) + (when helm-ff + ;; Allow having this new dir in history + ;; to be able to retrieve it immediately + ;; if we want to e.g copy a file from somewhere in it. + (setq helm-ff-default-directory + (file-name-as-directory dir)) + (push helm-ff-default-directory helm-ff-history)) + (or (and helm-ff (helm-find-files-1 dir)) t)))) + (helm--reading-passwd-or-string t)) + (if (cdr marked) + (if helm-current-prefix-arg + (dired-simultaneous-find-file marked nil) + (mapc 'find-file-noselect (cdr marked)) + (find-file (car marked))) + (if (and (not (file-exists-p candidate)) + (not url-p) + (string-match "/$" candidate)) + ;; A a non--existing filename ending with / + ;; Create a directory and jump to it. + (funcall make-dir-fn candidate 'helm-ff) + ;; A non--existing filename NOT ending with / or + ;; an existing filename, create or jump to it. + ;; If the basedir of candidate doesn't exists, + ;; ask for creating it. + (let ((dir (file-name-directory candidate))) + (find-file-at-point + (cond ((and dir (file-directory-p dir)) + (substitute-in-file-name (car marked))) + ;; FIXME Why do we use this on urls ? + (url-p (helm-substitute-in-filename (car marked))) + ((funcall make-dir-fn dir) candidate)))))))) + +(defun helm-shadow-boring-files (files) + "Files matching `helm-boring-file-regexp' will be +displayed with the `file-name-shadow' face if available." + (helm-shadow-entries files helm-boring-file-regexp-list)) + +(defun helm-skip-boring-files (files) + "Files matching `helm-boring-file-regexp' will be skipped." + (helm-skip-entries files helm-boring-file-regexp-list)) + +(defun helm-skip-current-file (files) + "Current file will be skipped." + (remove (buffer-file-name helm-current-buffer) files)) + +(defun helm-w32-pathname-transformer (args) + "Change undesirable features of windows pathnames to ones more acceptable to +other candidate transformers." + (if (eq system-type 'windows-nt) + (helm-transform-mapcar + (lambda (x) + (replace-regexp-in-string + "/cygdrive/\\(.\\)" "\\1:" + (replace-regexp-in-string "\\\\" "/" x))) + args) + args)) + +(defun helm-transform-file-load-el (actions candidate) + "Add action to load the file CANDIDATE if it is an emacs lisp +file. Else return ACTIONS unmodified." + (if (member (file-name-extension candidate) '("el" "elc")) + (append actions '(("Load Emacs Lisp File" . load-file))) + actions)) + +(defun helm-transform-file-browse-url (actions candidate) + "Add an action to browse the file CANDIDATE if it is a html file or URL. +Else return ACTIONS unmodified." + (let ((browse-action '("Browse with Browser" . browse-url))) + (cond ((string-match "^http\\|^ftp" candidate) + (cons browse-action actions)) + ((string-match "\\.html?$" candidate) + (append actions (list browse-action))) + (t actions)))) + +(defun helm-multi-files-toggle-to-locate () + (interactive) + (with-helm-buffer + (if (setq helm-multi-files--toggle-locate + (not helm-multi-files--toggle-locate)) + (progn + (helm-set-sources (unless (memq 'helm-source-locate + helm-sources) + (cons 'helm-source-locate helm-sources))) + (helm-set-source-filter '(helm-source-locate))) + (helm-kill-async-processes) + (helm-set-sources (remove 'helm-source-locate + helm-for-files-preferred-list)) + (helm-set-source-filter nil)))) + + +;;; List of files gleaned from every dired buffer +;; +;; +(defun helm-files-in-all-dired-candidates () + (save-excursion + (cl-loop for (f . b) in dired-buffers + when (buffer-live-p b) + append (let ((dir (with-current-buffer b dired-directory))) + (if (listp dir) (cdr dir) + (directory-files f t dired-re-no-dot)))))) + +;; (dired '("~/" "~/.emacs.d/.emacs-custom.el" "~/.emacs.d/.emacs.bmk")) + +(defvar helm-source-files-in-all-dired + '((name . "Files in all dired buffer.") + (candidates . helm-files-in-all-dired-candidates) + (type . file))) + + +;;; File Cache +;; +;; +(defvar file-cache-alist) + +(defclass helm-file-cache (helm-source-in-buffer helm-type-file) + ((init :initform (lambda () (require 'filecache))) + (keymap :initform helm-generic-files-map) + (help-message :initform helm-generic-file-help-message) + (mode-line :initform helm-generic-file-mode-line-string))) + +(defun helm-file-cache-get-candidates () + (cl-loop for item in file-cache-alist append + (cl-destructuring-bind (base &rest dirs) item + (cl-loop for dir in dirs collect + (concat dir base))))) + +(defvar helm-source-file-cache nil) + +(defcustom helm-file-cache-fuzzy-match nil + "Enable fuzzy matching in `helm-source-file-cache' when non--nil." + :group 'helm-files + :type 'boolean + :set (lambda (var val) + (set var val) + (setq helm-source-file-cache + (helm-make-source "File Cache" 'helm-file-cache + :fuzzy-match helm-file-cache-fuzzy-match + :data 'helm-file-cache-get-candidates)))) + +(cl-defun helm-file-cache-add-directory-recursively + (dir &optional match (ignore-dirs t)) + (require 'filecache) + (cl-loop for f in (helm-walk-directory + dir + :path 'full + :directories nil + :match match + :skip-subdirs ignore-dirs) + do (file-cache-add-file f))) + +(defun helm-ff-cache-add-file (_candidate) + (require 'filecache) + (let ((mkd (helm-marked-candidates :with-wildcard t))) + (mapc 'file-cache-add-file mkd))) + +(defun helm-ff-file-cache-remove-file-1 (file) + "Remove FILE from `file-cache-alist'." + (let ((entry (assoc (helm-basename file) file-cache-alist)) + (dir (helm-basedir file)) + new-entry) + (setq new-entry (remove dir entry)) + (when (= (length entry) 1) + (setq new-entry nil)) + (setq file-cache-alist + (cons new-entry (remove entry file-cache-alist))))) + +(defun helm-ff-file-cache-remove-file (_file) + "Remove marked files from `file-cache-alist.'" + (let ((mkd (helm-marked-candidates))) + (mapc 'helm-ff-file-cache-remove-file-1 mkd))) + +(defun helm-transform-file-cache (actions _candidate) + (let ((source (helm-get-current-source))) + (if (string= (assoc-default 'name source) "File Cache") + (append actions + '(("Remove marked files from file-cache" + . helm-ff-file-cache-remove-file))) + actions))) + + +;;; File name history +;; +;; +(defvar helm-source-file-name-history + `((name . "File Name History") + (candidates . file-name-history) + (persistent-action . ignore) + (filtered-candidate-transformer . helm-file-name-history-transformer) + (action . ,(helm-actions-from-type-file)))) + +(defvar helm-source--ff-file-name-history nil + "[Internal] This source is build to be used with `helm-find-files'. +Don't use it in your own code unless you know what you are doing.") + +(defun helm-file-name-history-transformer (candidates _source) + (cl-loop for c in candidates collect + (cond ((file-remote-p c) + (cons (propertize c 'face 'helm-history-remote) c)) + ((file-exists-p c) + (cons (propertize c 'face 'helm-ff-file) c)) + (t (cons (propertize c 'face 'helm-history-deleted) c))))) + +(defun helm-ff-file-name-history () + "Switch to `file-name-history' without quitting `helm-find-files'." + (interactive) + (unless helm-source--ff-file-name-history + (setq helm-source--ff-file-name-history + (helm-build-sync-source "File name history" + :init (lambda () + (with-helm-alive-p + (when helm-ff-file-name-history-use-recentf + (require 'recentf) + (or recentf-mode (recentf-mode 1))))) + :candidates (lambda () + (if helm-ff-file-name-history-use-recentf + recentf-list + file-name-history)) + :fuzzy-match t + :persistent-action 'ignore + :filtered-candidate-transformer 'helm-file-name-history-transformer + :action (helm-make-actions + "Find file" (lambda (candidate) + (helm-set-pattern + (expand-file-name candidate)) + (with-helm-after-update-hook (helm-exit-minibuffer))) + "Find file in helm" (lambda (candidate) + (helm-set-pattern + (expand-file-name candidate))))))) + (with-helm-alive-p + (helm :sources 'helm-source--ff-file-name-history + :buffer "*helm-file-name-history*" + :allow-nest t + :resume 'noresume))) + +;;; Recentf files +;; +;; +(defvar helm-recentf--basename-flag nil) + +(defun helm-recentf-pattern-transformer (pattern) + (let ((pattern-no-flag (replace-regexp-in-string " -b" "" pattern))) + (cond ((and (string-match " " pattern-no-flag) + (string-match " -b\\'" pattern)) + (setq helm-recentf--basename-flag t) + pattern-no-flag) + ((string-match "\\([^ ]*\\) -b\\'" pattern) + (prog1 (match-string 1 pattern) + (setq helm-recentf--basename-flag t))) + (t (setq helm-recentf--basename-flag nil) + pattern)))) + +(defclass helm-recentf-source (helm-source-sync) + ((init :initform (lambda () + (require 'recentf) + (recentf-mode 1))) + (candidates :initform (lambda () recentf-list)) + (pattern-transformer :initform 'helm-recentf-pattern-transformer) + (match-part :initform (lambda (candidate) + (if (or helm-ff-transformer-show-only-basename + helm-recentf--basename-flag) + (helm-basename candidate) candidate))) + (filter-one-by-one :initform (lambda (c) + (if (and helm-ff-transformer-show-only-basename + (not (consp c))) + (cons (helm-basename c) c) + c))) + (keymap :initform helm-generic-files-map) + (help-message :initform helm-generic-file-help-message) + (mode-line :initform helm-generic-file-mode-line-string) + (action :initform (helm-actions-from-type-file)))) + +(defvar helm-source-recentf nil + "See (info \"(emacs)File Conveniences\"). +Set `recentf-max-saved-items' to a bigger value if default is too small.") + +(defcustom helm-recentf-fuzzy-match nil + "Enable fuzzy matching in `helm-source-recentf' when non--nil." + :group 'helm-files + :type 'boolean + :set (lambda (var val) + (set var val) + (setq helm-source-recentf + (helm-make-source "Recentf" 'helm-recentf-source + :fuzzy-match helm-recentf-fuzzy-match)))) + +;;; Browse project +;; Need dependencies: +;; +;; +;; Only hg and git are supported for now. +(defvar helm--browse-project-cache (make-hash-table :test 'equal)) + +(defun helm-browse-project-get-buffers (root-directory) + (cl-loop for b in (helm-buffer-list) + for bf = (buffer-file-name (get-buffer b)) + when (and bf (file-in-directory-p bf root-directory)) + collect b)) + +(defun helm-browse-project-build-buffers-source (directory) + (helm-make-source "Buffers in project" 'helm-source-buffers + :header-name (lambda (name) + (format + "%s (%s)" + name (abbreviate-file-name directory))) + :buffer-list (lambda () (helm-browse-project-get-buffers directory)))) + +(defun helm-browse-project-find-files (directory &optional refresh) + (when refresh (remhash directory helm--browse-project-cache)) + (unless (gethash directory helm--browse-project-cache) + (puthash directory (helm-walk-directory + directory + :directories nil :path 'full :skip-subdirs t) + helm--browse-project-cache)) + (helm :sources `(,(helm-browse-project-build-buffers-source directory) + ,(helm-build-in-buffer-source "Browse project" + :data (gethash directory helm--browse-project-cache) + :header-name (lambda (name) + (format + "%s (%s)" + name (abbreviate-file-name directory))) + :match-part (lambda (c) + (if helm-ff-transformer-show-only-basename + (helm-basename c) c)) + :filter-one-by-one + (lambda (c) + (if helm-ff-transformer-show-only-basename + (cons (propertize (helm-basename c) + 'face 'helm-ff-file) + c) + (propertize c 'face 'helm-ff-file))) + :mode-line helm-generic-file-mode-line-string + :keymap helm-generic-files-map + :action (helm-actions-from-type-file))) + :buffer "*helm browse project*")) + +;;;###autoload +(defun helm-browse-project (arg) + "Browse files and see status of project with its vcs. +Only HG and GIT are supported for now. +Fall back to `helm-find-files' or `helm-browse-project-find-files' +if current directory is not under control of one of those vcs. +With a prefix ARG browse files recursively, with two prefix ARG +rebuild the cache. +If the current directory is found in the cache, start +`helm-browse-project-find-files' even with no prefix ARG. +NOTE: The prefix ARG have no effect on the VCS controlled directories. + +Needed dependencies for VCS: + +and +." + (interactive "P") + (cond ((and (require 'helm-ls-git nil t) + (fboundp 'helm-ls-git-root-dir) + (helm-ls-git-root-dir)) + (helm-ls-git-ls)) + ((and (require 'helm-ls-hg nil t) + (fboundp 'helm-hg-root) + (helm-hg-root)) + (helm-hg-find-files-in-project)) + (t (let ((cur-dir (helm-current-directory))) + (if (or arg (gethash cur-dir helm--browse-project-cache)) + (helm-browse-project-find-files cur-dir (equal arg '(16))) + (helm :sources (helm-browse-project-build-buffers-source cur-dir) + :buffer "*helm browse project*")))))) + +(defun helm-ff-browse-project (_candidate) + "Browse project in current directory. +See `helm-browse-project'." + (with-helm-default-directory helm-ff-default-directory + (helm-browse-project helm-current-prefix-arg))) + +(defun helm-ff-run-browse-project () + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-browse-project))) + +;;; session.el files +;; +;; session (http://emacs-session.sourceforge.net/) is an alternative to +;; recentf that saves recent file history and much more. +(defvar helm-source-session + `((name . "Session") + (candidates . (lambda () + (cl-delete-if-not #'(lambda (f) + (or (string-match helm-tramp-file-name-regexp f) + (file-exists-p f))) + (mapcar 'car session-file-alist)))) + (keymap . ,helm-generic-files-map) + (help-message . helm-generic-file-help-message) + (mode-line . helm-generic-file-mode-line-string) + (action . ,(helm-actions-from-type-file))) + "File list from emacs-session.") + + +;;; Files in current dir +;; +;; +(defun helm-highlight-files (files) + "A basic transformer for helm files sources. +Colorize only symlinks, directories and files." + (cl-loop for i in files + for disp = (if (and helm-ff-transformer-show-only-basename + (not (helm-dir-is-dot i)) + (not (and ffap-url-regexp + (string-match ffap-url-regexp i))) + (not (string-match helm-ff-url-regexp i))) + (helm-basename i) i) + for type = (car (file-attributes i)) + collect + (cond ((and helm-ff-tramp-not-fancy + (string-match helm-tramp-file-name-regexp i)) + (cons disp i)) + ((stringp type) + (cons (propertize disp + 'face 'helm-ff-symlink + 'help-echo (expand-file-name i)) + i)) + ((eq type t) + (cons (propertize disp + 'face 'helm-ff-directory + 'help-echo (expand-file-name i)) + i)) + (t (cons (propertize disp + 'face 'helm-ff-file + 'help-echo (expand-file-name i)) + i))))) + +(defclass helm-files-in-current-dir-source (helm-source-sync helm-type-file) + ((candidates :initform (lambda () + (with-helm-current-buffer + (let ((dir (helm-current-directory))) + (when (file-accessible-directory-p dir) + (directory-files dir t)))))) + (pattern-transformer :initform 'helm-recentf-pattern-transformer) + (match-part :initform (lambda (candidate) + (if (or helm-ff-transformer-show-only-basename + helm-recentf--basename-flag) + (helm-basename candidate) candidate))) + (fuzzy-match :initform t) + (keymap :initform helm-generic-files-map) + (help-message :initform helm-generic-file-help-message) + (mode-line :initform helm-generic-file-mode-line-string))) + +(defvar helm-source-files-in-current-dir + (helm-make-source "Files from Current Directory" + helm-files-in-current-dir-source)) + + +;;; External searching file tools. +;; +;; Tracker desktop search +(defvar helm-source-tracker-cand-incomplete nil "Contains incomplete candidate") +(defun helm-source-tracker-transformer (candidates _source) + (helm-log "received: %S" candidates) + (cl-loop for cand in candidates + for path = (when (stringp helm-source-tracker-cand-incomplete) + (caar (helm-highlight-files + (list helm-source-tracker-cand-incomplete)))) + for built = (if (not (stringp cand)) cand + (let ((snippet cand)) + (unless (or (null path) + (string= "" path) + (not (string-match-p + "\\`[[:space:]]*\\.\\.\\." + snippet))) + (let ((complete-candidate + (cons (concat path "\n" snippet) path))) + (setq helm-source-tracker-cand-incomplete nil) + (helm-log "built: %S" complete-candidate) + complete-candidate)))) + when (and (stringp cand) + (string-match "\\`[[:space:]]*file://" cand)) + do (setq helm-source-tracker-cand-incomplete ; save path + (replace-match "" t t cand)) end + collect built)) + +(defvar helm-source-tracker-search + `((name . "Tracker Search") + (candidates-process + . (lambda () + (start-process "tracker-search-process" nil + "tracker-search" + "--disable-color" + "--limit=512" + helm-pattern))) + (filtered-candidate-transformer . helm-source-tracker-transformer) + ;;(multiline) ; https://github.com/emacs-helm/helm/issues/529 + (keymap . ,helm-generic-files-map) + (action . ,(cdr (helm-get-attribute-from-type 'action 'file))) + (action-transformer + helm-transform-file-load-el + helm-transform-file-browse-url) + (requires-pattern . 3)) + "Source for retrieving files matching the current input pattern +with the tracker desktop search.") + +;; Spotlight (MacOS X desktop search) +(defvar helm-source-mac-spotlight + '((name . "mdfind") + (candidates-process + . (lambda () (start-process "mdfind-process" nil "mdfind" helm-pattern))) + (type . file) + (requires-pattern . 3)) + "Source for retrieving files via Spotlight's command line +utility mdfind.") + + +;;; Findutils +;; +;; +(defvar helm-source-findutils + (helm-build-async-source "Find" + :header-name (lambda (name) + (concat name " in [" (helm-default-directory) "]")) + :candidates-process 'helm-find-shell-command-fn + :filtered-candidate-transformer 'helm-findutils-transformer + :action-transformer 'helm-transform-file-load-el + :action (helm-actions-from-type-file) + :mode-line helm-generic-file-mode-line-string + :keymap helm-generic-files-map + :candidate-number-limit 9999 + :requires-pattern 3)) + +(defun helm-findutils-transformer (candidates _source) + (cl-loop for i in candidates + for type = (car (file-attributes i)) + for abs = (expand-file-name i (helm-default-directory)) + for disp = (if (and helm-ff-transformer-show-only-basename + (not (string-match "[.]\\{1,2\\}$" i))) + (helm-basename i) abs) + collect (cond ((eq t type) + (cons (propertize disp 'face 'helm-ff-directory) abs)) + ((stringp type) + (cons (propertize disp 'face 'helm-ff-symlink) abs)) + (t (cons (propertize disp 'face 'helm-ff-file) abs))))) + +(defun helm-find-shell-command-fn () + "Asynchronously fetch candidates for `helm-find'. +Additional find options can be sepcified after a \"*\" +separator." + (require 'find-cmd) + (with-helm-default-directory (helm-default-directory) + (let* (process-connection-type + (patterns+options (split-string helm-pattern "\\(\\`\\| +\\)\\* +")) + (fold-case (helm-set-case-fold-search (car patterns+options))) + (patterns (split-string (car patterns+options))) + (additional-options (and (cdr patterns+options) + (list (concat (cadr patterns+options) " ")))) + (ignored-dirs ()) + (ignored-files (when helm-findutils-skip-boring-files + (cl-loop for f in completion-ignored-extensions + if (string-match "/$" f) + do (push (replace-match "" nil t f) + ignored-dirs) + else collect (concat "*" f)))) + (path-or-name (if helm-findutils-search-full-path + '(ipath path) '(iname name))) + (name-or-iname (if fold-case + (car path-or-name) (cadr path-or-name))) + (cmd (find-cmd (and ignored-dirs + `(prune (name ,@ignored-dirs))) + (and ignored-files + `(not (name ,@ignored-files))) + `(and ,@(mapcar + (lambda (pattern) + `(,name-or-iname ,(concat "*" pattern "*"))) + patterns) + ,@additional-options))) + (proc (start-file-process-shell-command "hfind" helm-buffer cmd))) + (helm-log "Find command:\n%s" cmd) + (prog1 proc + (set-process-sentinel + proc + #'(lambda (process event) + (helm-process-deferred-sentinel-hook + process event (helm-default-directory)) + (if (string= event "finished\n") + (with-helm-window + (setq mode-line-format + '(" " mode-line-buffer-identification " " + (:eval (format "L%s" (helm-candidate-number-at-point))) " " + (:eval (propertize + (format "[Find process finished - (%s results)]" + (max (1- (count-lines + (point-min) (point-max))) + 0)) + 'face 'helm-locate-finish)))) + (force-mode-line-update)) + (helm-log "Error: Find %s" + (replace-regexp-in-string "\n" "" event))))))))) + +(defun helm-find-1 (dir) + (let ((default-directory (file-name-as-directory dir))) + (helm :sources 'helm-source-findutils + :buffer "*helm find*" + :ff-transformer-show-only-basename nil + :case-fold-search helm-file-name-case-fold-search))) + +;; helm-find-files integration. +(defun helm-ff-find-sh-command (_candidate) + "Run `helm-find' from `helm-find-files'." + (helm-find-1 helm-ff-default-directory)) + +(defun helm-ff-run-find-sh-command () + "Run find shell command action with key from `helm-find-files'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-ff-find-sh-command))) + + +;;; Preconfigured commands +;; +;; +;;;###autoload +(defun helm-find (arg) + "Preconfigured `helm' for the find shell command." + (interactive "P") + (let ((directory + (if arg + (file-name-as-directory + (read-directory-name "DefaultDirectory: ")) + default-directory))) + (helm-find-1 directory))) + +(defvar org-directory) +;;;###autoload +(defun helm-find-files (arg) + "Preconfigured `helm' for helm implementation of `find-file'. +Called with a prefix arg show history if some. +Don't call it from programs, use `helm-find-files-1' instead. +This is the starting point for nearly all actions you can do on files." + (interactive "P") + (let* ((hist (and arg helm-ff-history (helm-find-files-history))) + (default-input (or hist (helm-find-files-initial-input))) + (input (cond ((and (eq major-mode 'org-agenda-mode) + org-directory + (not default-input)) + (expand-file-name org-directory)) + ((and (eq major-mode 'dired-mode) default-input) + (file-name-directory default-input)) + ((and (not (string= default-input "")) + default-input)) + (t (expand-file-name (helm-current-directory))))) + (presel (helm-aif (or hist + (buffer-file-name (current-buffer)) + (and (eq major-mode 'dired-mode) + default-input)) + (if helm-ff-transformer-show-only-basename + (helm-basename it) it)))) + (set-text-properties 0 (length input) nil input) + (helm-find-files-1 input (and presel (concat "^" (regexp-quote presel)))))) + +;;;###autoload +(defun helm-for-files () + "Preconfigured `helm' for opening files. +Run all sources defined in `helm-for-files-preferred-list'." + (interactive) + (unless helm-source-buffers-list + (setq helm-source-buffers-list + (helm-make-source "Buffers" 'helm-source-buffers))) + (let ((helm-ff-transformer-show-only-basename nil)) + (helm :sources helm-for-files-preferred-list :buffer "*helm for files*"))) + +;;;###autoload +(defun helm-multi-files () + "Same as `helm-for-files' but allow toggling from locate to others sources." + (interactive) + (unless helm-source-buffers-list + (setq helm-source-buffers-list + (helm-make-source "Buffers" 'helm-source-buffers))) + (setq helm-multi-files--toggle-locate nil) + (let ((sources (remove 'helm-source-locate helm-for-files-preferred-list)) + (helm-ff-transformer-show-only-basename nil) + (old-key (lookup-key + helm-map + (read-kbd-macro helm-multi-files-toggle-locate-binding)))) + (with-helm-temp-hook 'helm-after-initialize-hook + (define-key helm-map (kbd helm-multi-files-toggle-locate-binding) + 'helm-multi-files-toggle-to-locate)) + (unwind-protect + (helm :sources sources + :buffer "*helm multi files*") + (define-key helm-map (kbd helm-multi-files-toggle-locate-binding) + old-key)))) + +;;;###autoload +(defun helm-recentf () + "Preconfigured `helm' for `recentf'." + (interactive) + (let ((helm-ff-transformer-show-only-basename nil)) + (helm-other-buffer 'helm-source-recentf "*helm recentf*"))) + +(provide 'helm-files) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-files.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-font.el b/emacs.d/elpa/helm-20150507.2215/helm-font.el new file mode 100644 index 0000000..e7a7d24 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-font.el @@ -0,0 +1,187 @@ +;;; helm-font --- Font and ucs selection for Helm -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) + +(defvar helm-ucs-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "") 'helm-ucs-persistent-delete) + (define-key map (kbd "") 'helm-ucs-persistent-backward) + (define-key map (kbd "") 'helm-ucs-persistent-forward) + (define-key map (kbd "") 'helm-ucs-persistent-insert) + (define-key map (kbd "C-c ?") 'helm-ucs-help) + map) + "Keymap for `helm-ucs'.") + + +;;; Xfont selection +;; +;; +(defun helm-persistent-xfont-action (elm) + "Show current font temporarily" + (let ((current-font (cdr (assoc 'font (frame-parameters)))) + (default-font elm)) + (unwind-protect + (progn (set-frame-font default-font 'keep-size) (sit-for 2)) + (set-frame-font current-font)))) + +(defvar helm-xfonts-cache nil) +(defvar helm-source-xfonts + '((name . "X Fonts") + (init . (lambda () + (unless helm-xfonts-cache + (setq helm-xfonts-cache + (x-list-fonts "*"))))) + (candidates . helm-xfonts-cache) + (action . (("Copy to kill ring" . (lambda (elm) + (kill-new elm))) + ("Set Font" . (lambda (elm) + (kill-new elm) + (set-frame-font elm 'keep-size) + (message "New font have been copied to kill ring"))))) + (persistent-action . helm-persistent-xfont-action) + (persistent-help . "Switch to this font temporarily"))) + +;;; ð•Œð•”𕤠ð•Šð•ªð•žð•“ð• ð• ð•”ð• ð•žð•¡ð•ð•–ð•¥ð•šð• ð•Ÿ +;; +;; +(defvar helm-ucs-max-len 0) +(defun helm-calculate-ucs-max-len () + "Calculate the length of longest `ucs-names' candidate." + (cl-loop with count = 0 + for (n . v) in (ucs-names) + for len = (length n) + if (> len count) + do (setq count len) + finally return count)) + +(defun helm-ucs-init () + "Initialize an helm buffer with ucs symbols. +Only math* symbols are collected." + (unless (> helm-ucs-max-len 0) + (setq helm-ucs-max-len + (helm-calculate-ucs-max-len))) + (with-current-buffer (helm-candidate-buffer + (get-buffer-create "*helm ucs*")) + ;; `ucs-names' fn will not run again, data is cached in + ;; var `ucs-names'. + (cl-loop for (n . v) in (ucs-names) + for len = (length n) + for diff = (+ (- helm-ucs-max-len len) 2) + unless (string= "" n) + do (progn (insert (concat + n ":" + (make-string + diff ? ))) + (if (fboundp 'ucs-insert) + (ucs-insert v) + ;; call `insert-char' with nil nil + ;; to shutup byte compiler in 24.1. + (insert-char v nil nil)) + (insert (format " #x%x" v)) + (insert "\n"))))) + +(defun helm-ucs-forward-char (_candidate) + (with-helm-current-buffer + (forward-char 1))) + +(defun helm-ucs-backward-char (_candidate) + (with-helm-current-buffer + (forward-char -1))) + +(defun helm-ucs-delete-backward (_candidate) + (with-helm-current-buffer + (delete-char -1))) + +(defun helm-ucs-insert (candidate n) + (with-helm-current-buffer + (string-match "^\\([^:]+\\): +\\(.\\) #x\\([a-f0-9]+\\)$" candidate) + (insert (match-string n candidate)))) + +(defun helm-ucs-insert-name (candidate) + (helm-ucs-insert candidate 1)) + +(defun helm-ucs-insert-char (candidate) + (helm-ucs-insert candidate 2)) + +(defun helm-ucs-insert-code (candidate) + (helm-ucs-insert candidate 3)) + +(defun helm-ucs-persistent-insert () + (interactive) + (with-helm-alive-p + (helm-attrset 'action-insert 'helm-ucs-insert-char) + (helm-execute-persistent-action 'action-insert))) + +(defun helm-ucs-persistent-forward () + (interactive) + (with-helm-alive-p + (helm-attrset 'action-forward 'helm-ucs-forward-char) + (helm-execute-persistent-action 'action-forward))) + +(defun helm-ucs-persistent-backward () + (interactive) + (with-helm-alive-p + (helm-attrset 'action-back 'helm-ucs-backward-char) + (helm-execute-persistent-action 'action-back))) + +(defun helm-ucs-persistent-delete () + (interactive) + (with-helm-alive-p + (helm-attrset 'action-delete 'helm-ucs-delete-backward) + (helm-execute-persistent-action 'action-delete))) + +(defvar helm-source-ucs + '((name . "Ucs names") + (init . helm-ucs-init) + (candidate-number-limit . 9999) + (candidates-in-buffer) + (mode-line . helm-ucs-mode-line-string) + (action . (("Insert character" . helm-ucs-insert-char) + ("Insert character name" . helm-ucs-insert-name) + ("Insert character code in hex" . helm-ucs-insert-code) + ("Forward char" . helm-ucs-forward-char) + ("Backward char" . helm-ucs-backward-char) + ("Delete char backward" . helm-ucs-delete-backward)))) + "Source for collecting `ucs-names' math symbols.") + +;;;###autoload +(defun helm-select-xfont () + "Preconfigured `helm' to select Xfont." + (interactive) + (helm-other-buffer 'helm-source-xfonts "*helm select* xfont")) + +;;;###autoload +(defun helm-ucs () + "Preconfigured helm for `ucs-names' math symbols." + (interactive) + (helm :sources 'helm-source-ucs + :keymap helm-ucs-map)) + +(provide 'helm-font) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-font.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-grep.el b/emacs.d/elpa/helm-20150507.2215/helm-grep.el new file mode 100644 index 0000000..0bf2264 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-grep.el @@ -0,0 +1,1229 @@ +;;; helm-grep.el --- Helm Incremental Grep. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) +(require 'grep) +(require 'helm-regexp) + +;;; load wgrep proxy if it's available +(require 'wgrep-helm nil t) + +(declare-function helm-buffer-list "helm-buffers") +(declare-function helm-elscreen-find-file "helm-elscreen" (file)) +(declare-function View-quit "view") +(declare-function doc-view-goto-page "doc-view" (page)) + + +(defgroup helm-grep nil + "Grep related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-grep-default-command + "grep --color=never -a -d skip %e -n%cH -e %p %f" + "Default grep format command for `helm-do-grep-1'. +Where: +'%e' format spec is for --exclude or --include grep options or + ack-grep --type option. (Not mandatory) + +'%c' format spec is for case-fold-search, + whether to use the -i option of grep. (Not mandatory) + When you specify this spec, helm grep will use smartcase + that is when a upcase character is found in pattern case will + be respected and no '-i' option will be used, otherwise, when + no upcase character is found in pattern always use '-i'. + If you don't want this behavior, don't use this spec and + specify or not the '-i' option. + Note that with ack-grep this is not needed, just specify + the '--smart-case' option. + +'%p' format spec is for pattern. (Mandatory) + +'%f' format spec is for filenames. (Mandatory) + +If your grep version doesn't support the --exclude/include args +don't specify the '%e' format spec. + +Helm also support ack-grep and git-grep , +here a default command example for ack-grep: + +\(setq helm-grep-default-command \"ack-grep -Hn --no-group --no-color %e %p %f\" + helm-grep-default-recurse-command \"ack-grep -H --no-group --no-color %e %p %f\") + +You can ommit the %e spec if you don't want to be prompted for types. + +NOTE: Helm for ack-grep support ANSI sequences, so you can remove +the \"--no-color\" option safely (recommended). + +To enable ANSI in grep it is a little more difficult: + 1) Modify env var + \(setenv \"GREP_COLORS\" \"ms=01;31:mc=01;31:sl=01;37:cx=:fn=35:ln=32:bn=32:se=36\") + 2) Add the option \"--color=always\". + +To enable ANSI color in git-grep just add \"--color=always\". +To customize the ANSI color in git-grep, GREP_COLORS have no effect, +you will have to setup this in your .gitconfig: + + [color \"grep\"] + match = black yellow + +where \"black\" is the foreground and \"yellow\" the background. +See the git documentation for more infos. + +`helm-grep-default-command' and `helm-grep-default-recurse-command'are +independents, so you can enable `helm-grep-default-command' with ack-grep +and `helm-grep-default-recurse-command' with grep if you want to be faster +on recursive grep. + +NOTE: Remote grepping is not available with ack-grep, + and badly supported with grep because tramp handle badly + repeated remote processes in a short delay (< to 5s)." + :group 'helm-grep + :type 'string) + +(defcustom helm-grep-default-recurse-command + "grep --color=never -a -d recurse %e -n%cH -e %p %f" + "Default recursive grep format command for `helm-do-grep-1'. +See `helm-grep-default-command' for format specs and infos about ack-grep." + :group 'helm-grep + :type 'string) + +(defcustom helm-default-zgrep-command + "zgrep -a -n%cH -e %p %f" + "Default command for Zgrep. +See `helm-grep-default-command' for infos on format specs. +Option --color=always is supported and can be used safely +to replace the helm internal match highlighting, +see `helm-grep-default-command' for more infos." + :group 'helm-grep + :type 'string) + +(defcustom helm-pdfgrep-default-command + "pdfgrep --color never -niH %s %s" + "Default command for pdfgrep. +Option --color always is not supported, expect +errors when executing actions." + :group 'helm-grep + :type 'string) + +(defcustom helm-grep-use-ioccur-style-keys t + "Use Arrow keys to jump to occurences." + :group 'helm-grep + :type 'boolean) + +(defcustom helm-pdfgrep-default-read-command nil + "Default command to read pdf files from pdfgrep. +Where '%f' format spec is filename and '%p' is page number. +e.g In Ubuntu you can set it to: + + \"evince --page-label=%p '%f'\" + +If set to nil `doc-view-mode' will be used instead of an external command." + :group 'helm-grep + :type 'string) + +(defcustom helm-grep-max-length-history 100 + "Max number of elements to save in `helm-grep-history'." + :group 'helm-grep + :type 'integer) + +(defcustom helm-zgrep-file-extension-regexp + ".*\\(\\.gz\\|\\.bz\\|\\.xz\\|\\.lzma\\)$" + "Default file extensions zgrep will search in." + :group 'helm-grep + :type 'string) + +(defcustom helm-do-grep-preselect-candidate nil + "When non--nil the file name of current buffer will be selected." + :group 'helm-grep + :type 'boolean) + +(defcustom helm-grep-preferred-ext nil + "This file extension will be preselected for grep." + :group 'helm-grep + :type 'string) + + +;;; Faces +;; +;; +(defgroup helm-grep-faces nil + "Customize the appearance of helm-grep." + :prefix "helm-" + :group 'helm-grep + :group 'helm-faces) + +(defface helm-grep-match + '((((background light)) :foreground "#b00000") + (((background dark)) :foreground "gold1")) + "Face used to highlight grep matches." + :group 'helm-grep-faces) + +(defface helm-grep-file + '((t (:foreground "BlueViolet" + :underline t))) + "Face used to highlight grep results filenames." + :group 'helm-grep-faces) + +(defface helm-grep-lineno + '((t (:foreground "Darkorange1"))) + "Face used to highlight grep number lines." + :group 'helm-grep-faces) + +(defface helm-grep-running + '((t (:foreground "Red"))) + "Face used in mode line when grep is running." + :group 'helm-grep-faces) + +(defface helm-grep-finish + '((t (:foreground "Green"))) + "Face used in mode line when grep is finish." + :group 'helm-grep-faces) + +(defface helm-grep-cmd-line + '((t (:inherit diff-added))) + "Face used to highlight grep command line when no results." + :group 'helm-grep-faces) + + +;;; Keymaps +;; +;; +(defvar helm-grep-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-") 'helm-goto-next-file) + (define-key map (kbd "M-") 'helm-goto-precedent-file) + (define-key map (kbd "C-c o") 'helm-grep-run-other-window-action) + (define-key map (kbd "C-c C-o") 'helm-grep-run-other-frame-action) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-x C-s") 'helm-grep-run-save-buffer) + (when helm-grep-use-ioccur-style-keys + (define-key map (kbd "") 'helm-execute-persistent-action) + (define-key map (kbd "") 'helm-grep-run-default-action)) + (define-key map (kbd "C-c ?") 'helm-grep-help) + (delq nil map)) + "Keymap used in Grep sources.") + +(defvar helm-pdfgrep-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-") 'helm-goto-next-file) + (define-key map (kbd "M-") 'helm-goto-precedent-file) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c ?") 'helm-pdfgrep-help) + map) + "Keymap used in pdfgrep.") + +(defvar helm-grep-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") 'helm-grep-mode-jump) + (define-key map (kbd "C-o") 'helm-grep-mode-jump-other-window) + (define-key map (kbd "") 'helm-grep-mode-jump-other-window-forward) + (define-key map (kbd "") 'helm-grep-mode-jump-other-window-backward) + (define-key map (kbd "") 'helm-gm-next-file) + (define-key map (kbd "") 'helm-gm-precedent-file) + (define-key map (kbd "M-n") 'helm-grep-mode-jump-other-window-forward) + (define-key map (kbd "M-p") 'helm-grep-mode-jump-other-window-backward) + (define-key map (kbd "M-N") 'helm-gm-next-file) + (define-key map (kbd "M-P") 'helm-gm-precedent-file) + map)) + + +;;; Internals vars +;; +;; +(defvar helm-rzgrep-cache (make-hash-table :test 'equal)) +(defvar helm-grep-default-function 'helm-grep-init) +(defvar helm-zgrep-recurse-flag nil) +(defvar helm-grep-history nil) +(defvar helm-grep-last-targets nil) +(defvar helm-grep-include-files nil) +(defvar helm-grep-in-recurse nil) +(defvar helm-grep-use-zgrep nil) +(defvar helm-grep-default-directory-fn nil + "A function that should return a directory to expand candidate to. +It is intended to use as a let-bound variable, DON'T set this globaly.") +(defvar helm-pdfgrep-targets nil) +(defvar helm-grep-last-cmd-line nil) +(defvar helm-grep-split-line-regexp "^\\([[:lower:][:upper:]]?:?.*?\\):\\([0-9]+\\):\\(.*\\)") + + +;;; Init +;; +;; +(defun helm-grep-prepare-candidates (candidates in-directory) + "Prepare filenames and directories CANDIDATES for grep command line." + ;; If one or more candidate is a directory, search in all files + ;; of this candidate (e.g /home/user/directory/*). + ;; If r option is enabled search also in subdidrectories. + ;; We need here to expand wildcards to support crap windows filenames + ;; as grep doesn't accept quoted wildcards (e.g "dir/*.el"). + (if helm-zgrep-recurse-flag + (mapconcat 'shell-quote-argument candidates " ") + ;; When candidate is a directory, search in all its files. + ;; NOTE that `file-expand-wildcards' will return also + ;; directories, they will be ignored by grep but not + ;; by ack-grep that will grep all files of this directory + ;; without recursing in their subdirs though, see that as a one + ;; level recursion with ack-grep. + ;; So I leave it as it is, considering it is a feature. [1] + (cl-loop for i in candidates append + (cond ((string-match "^git" helm-grep-default-command) + (list i)) + ;; Candidate is a directory and we use recursion or ack. + ((and (file-directory-p i) + (or helm-grep-in-recurse + ;; ack-grep accept directory [1]. + (helm-grep-use-ack-p))) + (list (expand-file-name i))) + ;; Grep doesn't support directory only when not in recurse. + ((file-directory-p i) + (file-expand-wildcards + (concat (file-name-as-directory (expand-file-name i)) "*") t)) + ;; Candidate is a file or wildcard and we use recursion, use the + ;; current directory instead of candidate. + ((and (or (file-exists-p i) (string-match "[*]" i)) + helm-grep-in-recurse) + (list (expand-file-name + (directory-file-name ; Needed for windoze. + (file-name-directory (directory-file-name i)))))) + ;; Else should be one or more file/directory + ;; possibly marked. + ;; When real is a normal filename without wildcard + ;; file-expand-wildcards returns a list of one file. + ;; wildcards should have been already handled by + ;; helm-read-file-name or helm-find-files but do it from + ;; here too in case we are called from elsewhere. + (t (file-expand-wildcards i t))) into all-files ; [1] + finally return + (let ((files (if (file-remote-p in-directory) + ;; Grep don't understand tramp filenames + ;; use the local name. + (mapcar #'(lambda (x) + (file-remote-p x 'localname)) + all-files) + all-files))) + (if (string-match "^git" helm-grep-default-command) + (mapconcat 'identity files " ") + (mapconcat 'shell-quote-argument files " ")))))) + +(defun helm-grep-command (&optional recursive) + (let* ((com (if recursive + helm-grep-default-recurse-command + helm-grep-default-command)) + (exe (and com (car (split-string com " "))))) + (if (and exe (string= exe "git")) "git-grep" exe))) + +(cl-defun helm-grep-use-ack-p (&key where) + (let* ((rec-com (helm-grep-command t)) + (norm-com (helm-grep-command)) + (norm-com-ack-p (string-match "\\`ack" norm-com)) + (rec-com-ack-p (and rec-com (string-match "\\`ack" rec-com)))) + (cl-case where + (default (and norm-com norm-com-ack-p)) + (recursive (and rec-com rec-com-ack-p)) + (strict (and norm-com rec-com rec-com-ack-p norm-com-ack-p)) + (t (and (not (and norm-com (string= norm-com "git-grep"))) + (or (and norm-com norm-com-ack-p) + (and rec-com rec-com-ack-p))))))) + +(defun helm-grep--prepare-cmd-line (only-files &optional include zgrep) + (let* ((default-directory (or (helm-default-directory) + (expand-file-name helm-ff-default-directory))) + (fnargs (helm-grep-prepare-candidates + only-files default-directory)) + (ignored-files (unless (helm-grep-use-ack-p) + (mapconcat + #'(lambda (x) + (concat "--exclude=" + (shell-quote-argument x))) + grep-find-ignored-files " "))) + (ignored-dirs (unless (helm-grep-use-ack-p) + (mapconcat + ;; Need grep version >=2.5.4 + ;; of Gnuwin32 on windoze. + #'(lambda (x) + (concat "--exclude-dir=" + (shell-quote-argument x))) + grep-find-ignored-directories " "))) + (exclude (unless (helm-grep-use-ack-p) + (if helm-grep-in-recurse + (concat (or include ignored-files) + " " ignored-dirs) + ignored-files))) + (types (and (helm-grep-use-ack-p) + ;; When %e format spec is not specified + ;; in `helm-grep-default-command' + ;; we need to pass an empty string + ;; to types to avoid error. + (or include ""))) + (smartcase (if (helm-grep-use-ack-p) "" + (unless (let ((case-fold-search nil)) + (string-match-p + "[[:upper:]]" helm-pattern)) "i")))) + (format-spec + helm-grep-default-command + (delq nil + (list (unless zgrep + (if types + (cons ?e types) + (cons ?e exclude))) + (cons ?c (or smartcase "")) + (cons ?p (shell-quote-argument helm-pattern)) + (cons ?f fnargs)))))) + +(defun helm-grep-init (cmd-line) + "Start an asynchronous grep process with CMD-LINE using ZGREP if non--nil." + (let* ((default-directory (or (expand-file-name helm-ff-default-directory) + (helm-default-directory))) + (zgrep (string-match "\\`zgrep" cmd-line)) + ;; Use pipe only with grep, zgrep or git-grep. + (process-connection-type (and (not zgrep) (helm-grep-use-ack-p))) + (tramp-verbose helm-tramp-verbose) + non-essential) + ;; Start grep process. + (helm-log "Starting Grep process in directory `%s'" default-directory) + (helm-log "Command line used was:\n\n%s" + (concat ">>> " (propertize cmd-line 'face 'helm-grep-cmd-line) "\n\n")) + (prog1 ; This function should return the process first. + (start-file-process-shell-command + "grep" helm-buffer cmd-line) + ;; Init sentinel. + (set-process-sentinel + (get-buffer-process helm-buffer) + #'(lambda (process event) + (let ((noresult (= (process-exit-status process) 1))) + (unless noresult + (helm-process-deferred-sentinel-hook + process event helm-ff-default-directory)) + (cond ((and noresult + ;; [FIXME] This is a workaround for zgrep + ;; that exit with code 1 + ;; after a certain amount of results. + (not (with-helm-buffer helm-grep-use-zgrep))) + (with-current-buffer helm-buffer + (insert (concat "* Exit with code 1, no result found," + " Command line was:\n\n " + (propertize helm-grep-last-cmd-line + 'face 'helm-grep-cmd-line))) + (setq mode-line-format + '(" " mode-line-buffer-identification " " + (:eval (format "L%s" (helm-candidate-number-at-point))) " " + (:eval (propertize + (format + "[%s process finished - (no results)] " + (if helm-grep-use-zgrep + "Zgrep" + (capitalize + (if helm-grep-in-recurse + (helm-grep-command t) + (helm-grep-command))))) + 'face 'helm-grep-finish)))))) + ((string= event "finished\n") + (with-helm-window + (setq mode-line-format + '(" " mode-line-buffer-identification " " + (:eval (format "L%s" (helm-candidate-number-at-point))) " " + (:eval (propertize + (format + "[%s process finished - (%s results)] " + (if helm-grep-use-zgrep + "Zgrep" + (capitalize + (if helm-grep-in-recurse + (helm-grep-command t) + (helm-grep-command)))) + (max (1- (count-lines + (point-min) + (point-max))) + 0)) + 'face 'helm-grep-finish)))) + (force-mode-line-update))) + ;; Catch error output in log. + (t (helm-log + "Error: %s %s" + (if helm-grep-use-zgrep "Zgrep" "Grep") + (replace-regexp-in-string "\n" "" event)))))))))) + +(defun helm-grep-collect-candidates () + (let ((cmd-line (helm-grep--prepare-cmd-line + helm-grep-last-targets + helm-grep-include-files + helm-grep-use-zgrep))) + (set (make-local-variable 'helm-grep-last-cmd-line) cmd-line) + (funcall helm-grep-default-function cmd-line))) + + +;;; Actions +;; +;; +(defun helm-grep-action (candidate &optional where mark) + "Define a default action for `helm-do-grep' on CANDIDATE. +WHERE can be one of other-window, elscreen, other-frame." + (let* ((split (helm-grep-split-line candidate)) + (lineno (string-to-number (nth 1 split))) + (loc-fname (or (with-current-buffer + (if (eq major-mode 'helm-grep-mode) + (current-buffer) + helm-buffer) + (get-text-property (point-at-bol) 'help-echo)) + (car split))) + (tramp-method (file-remote-p (or helm-ff-default-directory + default-directory) 'method)) + (tramp-host (file-remote-p (or helm-ff-default-directory + default-directory) 'host)) + (tramp-prefix (concat "/" tramp-method ":" tramp-host ":")) + (fname (if tramp-host + (concat tramp-prefix loc-fname) loc-fname))) + (cl-case where + (other-window (find-file-other-window fname)) + (elscreen (helm-elscreen-find-file fname)) + (other-frame (find-file-other-frame fname)) + (grep (helm-grep-save-results-1)) + (pdf (if helm-pdfgrep-default-read-command + (helm-pdfgrep-action-1 split lineno (car split)) + (find-file (car split)) (doc-view-goto-page lineno))) + (t (find-file fname))) + (unless (or (eq where 'grep) (eq where 'pdf)) + (helm-goto-line lineno)) + (when mark + (set-marker (mark-marker) (point)) + (push-mark (point) 'nomsg)) + ;; Save history + (unless (or helm-in-persistent-action + (eq major-mode 'helm-grep-mode) + (string= helm-pattern "")) + (setq helm-grep-history + (cons helm-pattern + (delete helm-pattern helm-grep-history))) + (when (> (length helm-grep-history) + helm-grep-max-length-history) + (setq helm-grep-history + (delete (car (last helm-grep-history)) + helm-grep-history)))))) + +(defun helm-grep-persistent-action (candidate) + "Persistent action for `helm-do-grep'. +With a prefix arg record CANDIDATE in `mark-ring'." + (if current-prefix-arg + (helm-grep-action candidate nil 'mark) + (helm-grep-action candidate)) + (helm-highlight-current-line)) + +(defun helm-grep-other-window (candidate) + "Jump to result in other window from helm grep." + (helm-grep-action candidate 'other-window)) + +(defun helm-grep-other-frame (candidate) + "Jump to result in other frame from helm grep." + (helm-grep-action candidate 'other-frame)) + +(defun helm-grep-jump-elscreen (candidate) + "Jump to result in elscreen from helm grep." + (helm-grep-action candidate 'elscreen)) + +(defun helm-goto-next-or-prec-file (n &optional type) + "Go to next or precedent candidate file in helm grep/etags buffers. +If N is positive go forward otherwise go backward." + (let* ((allow-mode (or (eq major-mode 'helm-grep-mode) + (eq major-mode 'helm-moccur-mode))) + (sel (if allow-mode + (buffer-substring (point-at-bol) (point-at-eol)) + (helm-get-selection nil t))) + (current-line-list (if (eq type 'etags) + (split-string sel ": +" t) + (helm-grep-split-line sel))) + (current-fname (nth 0 current-line-list)) + (bob-or-eof (if (eq n 1) 'eobp 'bobp)) + (mark-maybe #'(lambda () + (if allow-mode + (ignore) + (helm-mark-current-line))))) + (catch 'break + (while (not (funcall bob-or-eof)) + (forward-line n) ; Go forward or backward depending of n value. + ;; Exit when current-fname is not matched or in `helm-grep-mode' + ;; the line is not a grep line i.e 'fname:num:tag'. + (setq sel (buffer-substring (point-at-bol) (point-at-eol))) + (unless (or (string= current-fname + (car (if (eq type 'etags) + (split-string sel ": +" t) + (helm-grep-split-line sel)))) + (and (eq major-mode 'helm-grep-mode) + (not (get-text-property (point-at-bol) 'help-echo)))) + (funcall mark-maybe) + (throw 'break nil)))) + (cond ((and (> n 0) (eobp)) + (re-search-backward ".") + (forward-line 0) + (funcall mark-maybe)) + ((and (< n 0) (bobp)) + (helm-aif (next-single-property-change (point-at-bol) 'help-echo) + (goto-char it) + (forward-line 1)) + (funcall mark-maybe))))) + +;;;###autoload +(defun helm-goto-precedent-file () + "Go to precedent file in helm grep/etags buffers." + (interactive) + (let ((etagp (when (string= (assoc-default + 'name (helm-get-current-source)) "Etags") + 'etags))) + (with-helm-window + (helm-goto-next-or-prec-file -1 etagp)))) + +;;;###autoload +(defun helm-goto-next-file () + "Go to precedent file in helm grep/etags buffers." + (interactive) + (let ((etagp (when (string= (assoc-default + 'name (helm-get-current-source)) "Etags") + 'etags))) + (with-helm-window + (helm-goto-next-or-prec-file 1 etagp)))) + +(defun helm-grep-run-default-action () + "Run grep default action from `helm-do-grep-1'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-grep-action))) + +(defun helm-grep-run-other-window-action () + "Run grep goto other window action from `helm-do-grep-1'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-grep-other-window))) + +(defun helm-grep-run-other-frame-action () + "Run grep goto other frame action from `helm-do-grep-1'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-grep-other-frame))) + +;;;###autoload +(defun helm-grep-run-save-buffer () + "Run grep save results action from `helm-do-grep-1'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-grep-save-results))) + + +;;; helm-grep-mode +;; +;; +(defun helm-grep-save-results (candidate) + (helm-grep-action candidate 'grep)) + +(defun helm-grep-save-results-1 () + "Save helm grep result in a `helm-grep-mode' buffer." + (let ((buf "*hgrep*") + new-buf) + (when (get-buffer buf) + (setq new-buf (helm-read-string "GrepBufferName: " buf)) + (cl-loop for b in (helm-buffer-list) + when (and (string= new-buf b) + (not (y-or-n-p + (format "Buffer `%s' already exists overwrite? " + new-buf)))) + do (setq new-buf (helm-read-string "GrepBufferName: " "*hgrep "))) + (setq buf new-buf)) + (with-current-buffer (get-buffer-create buf) + (setq buffer-read-only t) + (let ((inhibit-read-only t)) + (erase-buffer) + (insert "-*- mode: helm-grep -*-\n\n" + (format "Grep Results for `%s':\n\n" helm-pattern)) + (save-excursion + (insert (with-current-buffer helm-buffer + (goto-char (point-min)) (forward-line 1) + (buffer-substring (point) (point-max)))))) + (helm-grep-mode) (pop-to-buffer buf)) + (message "Helm Grep Results saved in `%s' buffer" buf))) + +;;;###autoload +(define-derived-mode helm-grep-mode + special-mode "helm-grep" + "Major mode to provide actions in helm grep saved buffer. + +Special commands: +\\{helm-grep-mode-map}" + (set (make-local-variable 'helm-grep-last-cmd-line) + (with-helm-buffer helm-grep-last-cmd-line)) + (set (make-local-variable 'revert-buffer-function) + #'helm-grep-mode--revert-buffer-function)) + +(defun helm-grep-mode--revert-buffer-function (&optional _ignore-auto _noconfirm) + (goto-char (point-min)) + (re-search-forward "^Grep Results for" nil t) + (forward-line 0) + (when (re-search-forward "^$" nil t) + (forward-line 1)) + (let ((inhibit-read-only t)) + (delete-region (point) (point-max))) + (message "Reverting buffer...") + (set-process-sentinel + (start-file-process-shell-command + "hgrep" (generate-new-buffer "*hgrep revert*") helm-grep-last-cmd-line) + (lambda (process event) + (when (string= event "finished\n") + (with-current-buffer (current-buffer) + (let ((inhibit-read-only t)) + (save-excursion + (cl-loop for line in (with-current-buffer (process-buffer process) + (prog1 (split-string (buffer-string) "\n") + (kill-buffer))) + when (string-match helm-grep-split-line-regexp line) + do (insert (propertize + (car (helm-grep-filter-one-by-one line)) + ;; needed for wgrep. + 'helm-realvalue line) + "\n")))) + (message "Reverting buffer done")))))) + +;;;###autoload +(defun helm-gm-next-file () + (interactive) + (helm-goto-next-or-prec-file 1)) + +;;;###autoload +(defun helm-gm-precedent-file () + (interactive) + (helm-goto-next-or-prec-file -1)) + +;;;###autoload +(defun helm-grep-mode-jump () + (interactive) + (helm-grep-action + (buffer-substring (point-at-bol) (point-at-eol)))) + +(defun helm-grep-mode-jump-other-window-1 (arg) + (let ((candidate (buffer-substring (point-at-bol) (point-at-eol)))) + (condition-case nil + (progn + (save-selected-window + (helm-grep-action candidate 'other-window) + (recenter)) + (forward-line arg)) + (error nil)))) + +;;;###autoload +(defun helm-grep-mode-jump-other-window-forward () + (interactive) + (helm-grep-mode-jump-other-window-1 1)) + +;;;###autoload +(defun helm-grep-mode-jump-other-window-backward () + (interactive) + (helm-grep-mode-jump-other-window-1 -1)) + +;;;###autoload +(defun helm-grep-mode-jump-other-window () + (interactive) + (let ((candidate (buffer-substring (point-at-bol) (point-at-eol)))) + (condition-case nil + (helm-grep-action candidate 'other-window) + (error nil)))) + + +;;; ack-grep types +;; +;; +(defun helm-grep-hack-types () + "Return a list of known ack-grep types." + (with-temp-buffer + ;; "--help-types" works with both 1.96 and 2.1+, while + ;; "--help types" works only with 1.96 Issue #422. + ;; `helm-grep-command' should return the ack executable + ;; when this function is used in the right context + ;; i.e After checking is we are using ack-grep with + ;; `helm-grep-use-ack-p'. + (call-process (helm-grep-command t) nil t nil "--help-types") + (goto-char (point-min)) + (cl-loop while (re-search-forward + "^ *--\\(\\[no\\]\\)\\([^. ]+\\) *\\(.*\\)" nil t) + collect (cons (concat (match-string 2) + " [" (match-string 3) "]") + (match-string 2)) + collect (cons (concat "no" (match-string 2) + " [" (match-string 3) "]") + (concat "no" (match-string 2)))))) + +(defun helm-grep-ack-types-transformer (candidates _source) + (cl-loop for i in candidates + if (stringp i) + collect (rassoc i helm-grep-ack-types-cache) + else + collect i)) + +(defvar helm-grep-ack-types-cache nil) +(defun helm-grep-read-ack-type () + "Select types for the '--type' argument of ack-grep." + (require 'helm-mode) + (require 'helm-adaptive) + (setq helm-grep-ack-types-cache (helm-grep-hack-types)) + (let ((types (helm-comp-read + "Types: " helm-grep-ack-types-cache + :name "*Ack-grep types*" + :marked-candidates t + :must-match t + :fc-transformer '(helm-adaptive-sort + helm-grep-ack-types-transformer) + :buffer "*helm ack-types*"))) + (mapconcat #'(lambda (type) (concat "--type=" type)) types " "))) + + +;;; grep extensions +;; +;; +(defun helm-grep-guess-extensions (files) + "Try to guess file extensions in FILES list when using grep recurse. +These extensions will be added to command line with --include arg of grep." + (cl-loop with ext-list = (list helm-grep-preferred-ext "*") + with lst = (if (file-directory-p (car files)) + (directory-files + (car files) nil + directory-files-no-dot-files-regexp) + files) + for i in lst + for ext = (file-name-extension i 'dot) + for glob = (and ext (not (string= ext "")) + (concat "*" ext)) + unless (or (not glob) + (and glob-list (member glob glob-list)) + (and glob-list (member glob ext-list)) + (and glob-list (member glob grep-find-ignored-files))) + collect glob into glob-list + finally return (delq nil (append ext-list glob-list)))) + +(defun helm-grep-get-file-extensions (files) + "Try to return a list of file extensions to pass to '--include' arg of grep." + (let* ((all-exts (helm-grep-guess-extensions + (mapcar 'expand-file-name files))) + (extensions (helm-comp-read "Search Only in: " all-exts + :marked-candidates t + :fc-transformer 'helm-adaptive-sort + :buffer "*helm grep exts*" + :name "*helm grep extensions*"))) + (when (listp extensions) ; Otherwise it is empty string returned by C-RET. + ;; If extensions is a list of one string containing spaces, + ;; assume user entered more than one glob separated by space(s) and + ;; split this string to pass it later to mapconcat. + ;; e.g '("*.el *.py") + (cl-loop for i in extensions + append (split-string-and-unquote i " "))))) + + +;;; Set up source +;; +;; +(defvar helm-source-grep nil) +(defun helm-do-grep-1 (targets &optional recurse zgrep exts default-input) + "Launch grep on a list of TARGETS files. +When RECURSE is given use -r option of grep and prompt user +to set the --include args of grep. +You can give more than one arg separated by space. +e.g *.el *.py *.tex. +If you are using ack-grep, you will be prompted for --type +instead. +If prompt is empty '--exclude `grep-find-ignored-files' is used instead. +ZGREP when non--nil use zgrep instead, without prompting for a choice +in recurse, search being made on `helm-zgrep-file-extension-regexp'." + (when (and (helm-grep-use-ack-p) + helm-ff-default-directory + (file-remote-p helm-ff-default-directory)) + (error "Error: Remote operation not supported with ack-grep.")) + (let* (non-essential + (exts (and recurse + ;; [FIXME] I could handle this from helm-walk-directory. + (not zgrep) ; zgrep doesn't handle -r opt. + (not (helm-grep-use-ack-p :where 'recursive)) + (or exts (helm-grep-get-file-extensions targets)))) + (include-files (and exts + (mapconcat #'(lambda (x) + (concat "--include=" + (shell-quote-argument x))) + (if (> (length exts) 1) + (remove "*" exts) + exts) " "))) + (types (and (not include-files) + (not zgrep) + recurse + (helm-grep-use-ack-p :where 'recursive) + ;; When %e format spec is not specified + ;; ignore types and do not prompt for choice. + (string-match "%e" helm-grep-default-command) + (helm-grep-read-ack-type))) + (follow (and helm-follow-mode-persistent + (assoc-default 'follow helm-source-grep)))) + ;; When called as action from an other source e.g *-find-files + ;; we have to kill action buffer. + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + ;; If `helm-find-files' haven't already started, + ;; give a default value to `helm-ff-default-directory'. + (unless helm-ff-default-directory + (setq helm-ff-default-directory default-directory)) + ;; We need to store these vars locally + ;; to pass infos later to `helm-resume'. + (helm-set-local-variable 'helm-zgrep-recurse-flag (and recurse zgrep) + 'helm-grep-last-targets targets + 'helm-grep-include-files (or include-files types) + 'helm-grep-in-recurse recurse + 'helm-grep-use-zgrep zgrep + 'helm-grep-default-command + (cond (zgrep helm-default-zgrep-command) + (recurse helm-grep-default-recurse-command) + ;; When resuming the local value of + ;; `helm-grep-default-command' is used, only git-grep + ;; should need this. + (t helm-grep-default-command))) + ;; Setup the source. + (setq helm-source-grep + (helm-build-async-source + (if zgrep "Zgrep" (capitalize (if recurse + (helm-grep-command t) + (helm-grep-command)))) + :header-name (lambda (name) + (concat name "(C-c ? Help)")) + :candidates-process 'helm-grep-collect-candidates + :filter-one-by-one 'helm-grep-filter-one-by-one + :nohighlight t + :candidate-number-limit 9999 + :mode-line helm-grep-mode-line-string + :history 'helm-grep-history + :action (helm-make-actions + "Find File" 'helm-grep-action + "Find file other frame" 'helm-grep-other-frame + (lambda () (and (locate-library "elscreen") + "Find file in Elscreen")) + 'helm-grep-jump-elscreen + "Save results in grep buffer" 'helm-grep-save-results + "Find file other window" 'helm-grep-other-window) + :persistent-action 'helm-grep-persistent-action + :persistent-help "Jump to line (`C-u' Record in mark ring)" + :requires-pattern 2 + :follow follow)) + (helm + :sources 'helm-source-grep + :buffer (format "*helm %s*" (if zgrep "zgrep" (helm-grep-command recurse))) + :default default-input + :keymap helm-grep-map + :history 'helm-grep-history + :truncate-lines t))) + + + +;;; zgrep +;; +;; +(defun helm-ff-zgrep-1 (flist recursive) + (unwind-protect + (let* ((def-dir (or helm-ff-default-directory + default-directory)) + (only (if recursive + (or (gethash def-dir helm-rzgrep-cache) + (puthash + def-dir + (helm-walk-directory + def-dir + :directories nil + :path 'full + :match helm-zgrep-file-extension-regexp) + helm-rzgrep-cache)) + flist))) + (helm-do-grep-1 only recursive 'zgrep)) + (setq helm-zgrep-recurse-flag nil))) + + +;;; transformers +;; +;; +(defun helm-grep-split-line (line) + "Split a grep output line." + ;; The output of grep may send a truncated line in this chunk, + ;; so don't split until grep line is valid, that is + ;; once the second part of the line comes with next chunk + ;; send by process. + (when (string-match helm-grep-split-line-regexp line) + ;; Don't use split-string because buffer/file name or string + ;; may contain a ":". + (cl-loop for n from 1 to 3 collect (match-string n line)))) + +(defun helm-grep--filter-candidate-1 (candidate &optional dir) + (let* ((root (or dir (and helm-grep-default-directory-fn + (funcall helm-grep-default-directory-fn)))) + ansi-color-context ; seems this avoid non--translated fname entries. + (ansi-p (string-match-p ansi-color-regexp candidate)) + (line (if ansi-p (ansi-color-apply candidate) candidate)) + (split (helm-grep-split-line line)) + (fname (if (and root split) + (expand-file-name (car split) root) + (car-safe split))) + (lineno (nth 1 split)) + (str (nth 2 split))) + (when (and fname lineno str) + (cons (concat (propertize (file-name-nondirectory fname) + 'face 'helm-grep-file + 'help-echo fname) + ":" + (propertize lineno 'face 'helm-grep-lineno) + ":" + (if ansi-p str (helm-grep-highlight-match str))) + line)))) + +(defun helm-grep-filter-one-by-one (candidate) + "`filter-one-by-one' transformer function for `helm-do-grep'." + (let ((helm-grep-default-directory-fn + (or helm-grep-default-directory-fn + (lambda () (or helm-ff-default-directory + (helm-default-directory) + default-directory))))) + (helm-grep--filter-candidate-1 candidate))) + +(defun helm-grep-highlight-match (str &optional multi-match) + "Highlight in string STR all occurences matching `helm-pattern'." + (require 'helm-match-plugin) + (let (beg end) + (condition-case nil + (with-temp-buffer + (insert str) + (goto-char (point-min)) + (cl-loop for reg in (if multi-match + (cl-loop for r in (helm-mp-split-pattern + helm-pattern) + unless (string-match "\\`!" r) + collect r) + (list helm-pattern)) + do + (while (and (re-search-forward reg nil t) + (> (- (setq end (match-end 0)) + (setq beg (match-beginning 0))) 0)) + (add-text-properties beg end '(face helm-grep-match))) + do (goto-char (point-min))) + (buffer-string)) + (error nil)))) + + +;;; Grep from buffer list +;; +;; +(defun helm-grep-buffers-1 (candidate &optional zgrep) + "Run grep on all file--buffers or CANDIDATE if it is a file--buffer. +If one of selected buffers is not a file--buffer, +it is ignored and grep will run on all others file--buffers. +If only one candidate is selected and it is not a file--buffer, +switch to this buffer and run `helm-occur'. +If a prefix arg is given run grep on all buffers ignoring non--file-buffers." + (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg)) + (helm-ff-default-directory + (if (and helm-ff-default-directory + (file-remote-p helm-ff-default-directory)) + default-directory + helm-ff-default-directory)) + (cands (if prefarg + (buffer-list) + (helm-marked-candidates))) + (win-conf (current-window-configuration)) + ;; Non--fname and remote buffers are ignored. + (bufs (cl-loop for buf in cands + for fname = (buffer-file-name (get-buffer buf)) + when (and fname (not (file-remote-p fname))) + collect (expand-file-name fname)))) + (if bufs + (if zgrep + (helm-do-grep-1 bufs nil 'zgrep) + (helm-do-grep-1 bufs)) + ;; bufs is empty, thats mean we have only CANDIDATE + ;; and it is not a buffer-filename, fallback to occur. + (switch-to-buffer candidate) + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (helm-occur) + (when (eq helm-exit-status 1) + (set-window-configuration win-conf))))) + +(defun helm-grep-buffers (candidate) + "Action to grep buffers." + (helm-grep-buffers-1 candidate)) + +(defun helm-zgrep-buffers (candidate) + "Action to zgrep buffers." + (helm-grep-buffers-1 candidate 'zgrep)) + + +;;; Helm interface for pdfgrep +;; pdfgrep program +;; and a pdf-reader (e.g xpdf) are needed. +;; +(defvar helm-pdfgrep-default-function 'helm-pdfgrep-init) +(defun helm-pdfgrep-init (only-files) + "Start an asynchronous pdfgrep process in ONLY-FILES list." + (let* ((default-directory (or helm-ff-default-directory + default-directory)) + (fnargs (helm-grep-prepare-candidates + (if (file-remote-p default-directory) + (mapcar #'(lambda (x) + (file-remote-p x 'localname)) + only-files) + only-files) + default-directory)) + (cmd-line (format helm-pdfgrep-default-command + helm-pattern + fnargs)) + process-connection-type) + ;; Start pdf grep process. + (helm-log "Starting Pdf Grep process in directory `%s'" default-directory) + (helm-log "Command line used was:\n\n%s" + (concat ">>> " (propertize cmd-line 'face 'helm-grep-cmd-line) "\n\n")) + (prog1 + (start-file-process-shell-command + "pdfgrep" helm-buffer cmd-line) + (message nil) + (set-process-sentinel + (get-buffer-process helm-buffer) + #'(lambda (_process event) + (if (string= event "finished\n") + (with-helm-window + (setq mode-line-format + '(" " mode-line-buffer-identification " " + (:eval (format "L%s" (helm-candidate-number-at-point))) " " + (:eval (propertize + (format "[Pdfgrep Process Finish - %s result(s)] " + (max (1- (count-lines + (point-min) (point-max))) 0)) + 'face 'helm-grep-finish)))) + (force-mode-line-update)) + (helm-log "Error: Pdf grep %s" + (replace-regexp-in-string "\n" "" event)))))))) + +(defun helm-do-pdfgrep-1 (only) + "Launch pdfgrep with a list of ONLY files." + (unless (executable-find "pdfgrep") + (error "Error: No such program `pdfgrep'.")) + (let* (helm-grep-in-recurse) ; recursion is never used in pdfgrep. + ;; When called as action from an other source e.g *-find-files + ;; we have to kill action buffer. + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (setq helm-pdfgrep-targets only) + (helm + :sources (helm-build-async-source "PdfGrep" + :init (lambda () + ;; If `helm-find-files' haven't already started, + ;; give a default value to `helm-ff-default-directory'. + (setq helm-ff-default-directory (or helm-ff-default-directory + default-directory))) + :candidates-process (lambda () + (funcall helm-pdfgrep-default-function helm-pdfgrep-targets)) + :filter-one-by-one #'helm-grep-filter-one-by-one + :candidate-number-limit 9999 + :history 'helm-grep-history + :keymap helm-pdfgrep-map + :mode-line helm-pdfgrep-mode-line-string + :action #'helm-pdfgrep-action + :persistent-help "Jump to PDF Page" + :requires-pattern 2) + :buffer "*helm pdfgrep*" + :history 'helm-grep-history))) + +(defun helm-pdfgrep-action (candidate) + (helm-grep-action candidate 'pdf)) + +(defun helm-pdfgrep-action-1 (_split pageno fname) + (save-selected-window + (start-file-process-shell-command + "pdf-reader" nil + (format-spec helm-pdfgrep-default-read-command + (list (cons ?f fname) (cons ?p pageno)))))) + +;;;###autoload +(defun helm-do-grep () + "Preconfigured helm for grep. +Contrarily to Emacs `grep', no default directory is given, but +the full path of candidates in ONLY. +That allow to grep different files not only in `default-directory' but anywhere +by marking them (C-). If one or more directory is selected +grep will search in all files of these directories. +You can also use wildcard in the base name of candidate. +If a prefix arg is given use the -r option of grep (recurse). +The prefix arg can be passed before or after start file selection. +See also `helm-do-grep-1'." + (interactive) + (require 'helm-mode) + (let* ((preselection (or (dired-get-filename nil t) + (buffer-file-name (current-buffer)))) + (only (helm-read-file-name + "Search in file(s): " + :marked-candidates t + :preselect (and helm-do-grep-preselect-candidate + (if helm-ff-transformer-show-only-basename + (helm-basename preselection) + preselection)))) + (prefarg (or current-prefix-arg helm-current-prefix-arg))) + (helm-do-grep-1 only prefarg))) + +;;;###autoload +(defun helm-do-zgrep () + "Preconfigured helm for zgrep." + (interactive) + (require 'helm-mode) + (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg)) + (preselection (or (dired-get-filename nil t) + (buffer-file-name (current-buffer)))) + (ls (helm-read-file-name + "Search in file(s): " + :marked-candidates t + :preselect (and helm-do-grep-preselect-candidate + (if helm-ff-transformer-show-only-basename + (helm-basename preselection) + preselection))))) + (helm-ff-zgrep-1 ls prefarg))) + +;;;###autoload +(defun helm-do-pdfgrep () + "Preconfigured helm for pdfgrep." + (interactive) + (require 'helm-mode) + (let* ((preselection (or (dired-get-filename nil t) + (buffer-file-name (current-buffer)))) + (only (helm-read-file-name + "Search in file(s): " + :marked-candidates t + :test #'(lambda (file) + (or (string= (file-name-extension file) "pdf") + (string= (file-name-extension file) "PDF") + (file-directory-p file))) + :preselect (and helm-do-grep-preselect-candidate + (if helm-ff-transformer-show-only-basename + (helm-basename preselection) + preselection)))) + (helm-grep-default-function 'helm-pdfgrep-init)) + (helm-do-pdfgrep-1 only))) + + +(provide 'helm-grep) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-grep.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-help.el b/emacs.d/elpa/helm-20150507.2215/helm-help.el new file mode 100644 index 0000000..6c8b3c7 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-help.el @@ -0,0 +1,1716 @@ +;;; helm-help.el --- Help messages for Helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'helm) +(require 'helm-org) + + +(defgroup helm-help nil + "Embedded help for `helm'." + :group 'helm) + +(defface helm-helper + '((t :inherit helm-header)) + "Face for helm help string in minibuffer." + :group 'helm-help) + +(defcustom helm-documentation-file "~/.emacs.d/helm-doc.org" + "The file where you want to save helm documentation." + :group 'helm-help + :type 'string) + +(defvar helm-help--string-list '(helm-help-message + helm-buffer-help-message + helm-ff-help-message + helm-read-file-name-help-message + helm-generic-file-help-message + helm-grep-help-message + helm-pdfgrep-help-message + helm-etags-help-message + helm-ucs-help-message + helm-bookmark-help-message + helm-esh-help-message + helm-buffers-ido-virtual-help-message + helm-moccur-help-message + helm-top-help-message + helm-apt-help-message + helm-el-package-help-message + helm-M-x-help-message + helm-imenu-help-message + helm-colors-help-message + helm-semantic-help-message + helm-kmacro-help-message)) + + +;;;###autoload +(defun helm-documentation (arg) + "Helm documentation. +With a prefix arg refresh the documentation. + +Find here the documentation of all sources actually documented." + (interactive "P") + (when arg (delete-file helm-documentation-file) + (helm-aif (get-file-buffer helm-documentation-file) + (kill-buffer it))) + (unless (file-exists-p helm-documentation-file) + (with-temp-file helm-documentation-file + (erase-buffer) + (cl-loop for elm in helm-help--string-list + for str = (symbol-value elm) + do (insert (substitute-command-keys + (if (functionp str) (funcall str) str)))))) + (let ((helm-org-headings--nofilename t)) + (helm :sources (helm-source-org-headings-for-files + (list helm-documentation-file)) + :candidate-number-limit 99999 + :buffer "*helm documentation*"))) + +;;; Global help message - Used by `helm-help' +;; +;; +(defvar helm-help-message + (lambda () + (concat + "\n* Helm generic help\n" + "\\" + "\n`helm' is an Emacs incremental completion and selection narrowing framework. + +Narrow the list by typing some pattern, +Multiple patterns are allowed by splitting by space. +Select with natural Emacs operations, choose with RET. + +** Help + +C-h m : Run this generic help for helm. +C-c ? : Run specific helm help for current source. + +** Basic Operations + +C-p, Up: Previous Line +C-n, Down : Next Line +M-v, PageUp : Previous Page +C-v, PageDown : Next Page +Enter : Execute first (default) action / Select +M-< : First Line +M-> : Last Line +M-PageUp, C-M-S-v, C-M-y : Previous Page (other-window) +M-PageDown, C-M-v : Next Page (other-window) + +Tab, C-i : Show action list +Left : Previous Source +Right, C-o : Next Source +C-k : Delete pattern (with prefix arg delete from point to end) +C-j or C-z: Persistent Action (Execute action with helm session kept) + +** Shortcuts For nth Action + +f1-12: Execute nth 1 to 12 Action(s). + +** Visible Marks + +Visible marks store candidate. Some actions uses marked candidates. + +\\[helm-toggle-visible-mark] : Toggle Visible Mark +\\[helm-prev-visible-mark] : Previous Mark +\\[helm-next-visible-mark] : Next Mark + +** Miscellaneous Commands + +\\[helm-toggle-resplit-window] : Toggle vertical/horizontal split helm window. +\\[helm-quit-and-find-file] : Drop into `find-file'. +\\[helm-delete-current-selection] : Delete selected item (visually). +\\[helm-kill-selection-and-quit] : Kill display value of candidate and quit (with prefix arg kill the real value). +\\[helm-yank-selection] : Yank selection into pattern. +\\[helm-follow-mode] : Toggle automatical execution of persistent action. +\\[helm-follow-action-forward] : Run persistent action and goto next line. +\\[helm-follow-action-backward] : Run persistent action and goto previous line. +\\[helm-force-update] : Recalculate and redisplay candidates. + +** Global Commands + +\\\\[helm-resume] revives last `helm' session. +It is very useful, so you should bind any key.")) + "Detailed help message string for `helm'. +It also accepts function or variable symbol.") + +(defun helm-help-internal (bufname insert-content-fn) + "Show long message during `helm' session in BUFNAME. +INSERT-CONTENT-FN is the function that insert +text to be displayed in BUFNAME." + (let ((winconf (current-frame-configuration))) + (unwind-protect + (progn + (setq helm-suspend-update-flag t) + (set-buffer (get-buffer-create bufname)) + (switch-to-buffer bufname) + (delete-other-windows) + (delete-region (point-min) (point-max)) + (outline-mode) + (save-excursion + (funcall insert-content-fn)) + (setq cursor-type nil) + (buffer-disable-undo) + (helm-help-event-loop)) + (setq helm-suspend-update-flag nil) + (set-frame-configuration winconf)))) + +(defun helm-help-scroll-up (amount) + (condition-case _err + (scroll-up-command amount) + (beginning-of-buffer nil) + (end-of-buffer nil))) + +(defun helm-help-scroll-down (amount) + (condition-case _err + (scroll-down-command amount) + (beginning-of-buffer nil) + (end-of-buffer nil))) + +(defun helm-help-event-loop () + (let ((prompt (propertize + "[SPC,C-v,down,next:NextPage b,M-v,up,prior:PrevPage C-s/r:Isearch q:Quit]" + 'face 'helm-helper)) + scroll-error-top-bottom) + (cl-loop for event = (read-key prompt) do + (cl-case event + ((?\C-v ? down next) (helm-help-scroll-up helm-scroll-amount)) + ((?\M-v ?b up prior) (helm-help-scroll-down helm-scroll-amount)) + (?\C-s (isearch-forward)) + (?\C-r (isearch-backward)) + (?q (cl-return)) + (t (ignore)))))) + +;;;###autoload +(defun helm-help () + "Help of `helm'." + (interactive) + (with-helm-alive-p + (save-selected-window + (helm-help-internal + "*Helm Help*" + (lambda () + (insert (substitute-command-keys + (helm-interpret-value (or (assoc-default + 'help-message + (helm-get-current-source)) + helm-help-message))))))))) + +;;; `helm-buffer-list' help +;; +;; +(defvar helm-buffer-help-message + "\n* Helm Buffer\n + +** Helm buffers tips: + +*** Completion: + +**** Major-mode: + +You can enter a partial name of major-mode (e.g lisp, sh) to narrow down buffers. +To specify the major-mode, prefix it with \"*\" e.g \"*lisp\". +If you want to match all buffers but the ones with a specific major-mode (negation), +prefix the major-mode with \"!\" e.g \"*!lisp\". +If you want to specify more than one major-mode, separate them with \",\", +e.g \"*!lisp,!sh,!fun\" will list all buffers but the ones in lisp-mode, sh-mode and +fundamental-mode. + +Enter then a space and a pattern to narrow down to buffers matching this pattern. + +**** Search inside buffers: + +If you enter a space and a pattern prefixed by \"@\" helm will search for text matching +this pattern INSIDE the buffer (i.e not in the name of buffer). +NOTE that if you enter your pattern prefixed with \"@\" but escaped, helm will search a buffer +matching \"@pattern\" but will not search inside. + +**** Search by directory name: + +If you prefix the beginning of pattern with \"/\" the match will occur on directory name +of buffer, it is interesting to narrow down to one directory for example, subsequent string +entered after a space will match on buffer-name only. +Note that negation is not supported for matching on buffer-file-name. +You can specify more than one directory starting from helm v1.6.8 + +**** Fuzzy matching: + +Note that if `helm-buffers-fuzzy-matching' is non--nil you will have +fuzzy matching on buffer names (not on directory name matching and major-mode though). +A pattern starting with \"^\" will disable fuzzy matching and will match by exact regexp. + +**** Examples: + +if I enter in pattern prompt: +\"*lisp ^helm @moc\" +helm will narrow down the list by selecting only buffers that are in lisp mode, start by helm +and match \"moc\" in their contents. + +if I enter in pattern prompt: +\"*lisp ^helm moc\" +Notice there is no \"@\" this time +helm will look for lisp mode buffers starting by \"helm\" and have \"moc\" in their name. + +if I enter in pattern prompt: +\"*!lisp !helm\" +helm will narrow down to buffers that are not in \"lisp\" mode and that do not match \"helm\" + +if I enter in pattern prompt: +/helm/ w3 +helm will narrow down to buffers that are in any \"helm\" subdirectory and matching w3. + + +*** Creating buffers + +When creating a new buffer use \\[universal-argument] to choose a mode for your buffer in a list. +This list is customizable, see `helm-buffers-favorite-modes'. + +*** Killing buffers + +You have a command to kill buffer(s) and quit emacs and a command to kill buffers one by one +\(no marked\) without quitting helm. +You can run this persistent kill buffer command either with the regular +`helm-execute-persistent-action' called with a prefix arg (C-u C-j) or with its specific command +`helm-buffer-run-kill-persistent' see binding below. + +*** Meaning of colors and prefixes for buffers: + +Remote buffers are prefixed with '@'. +Red => Buffer have its file modified on disk by an external process. +Indianred2 => Buffer exists but its file have been deleted. +Orange => Buffer is modified and its file not saved to disk. +Italic => A non--file buffer. + +\n** Specific commands for `helm-buffers-list': +\\ +\\[helm-buffer-run-zgrep]\t\t->Grep Buffer(s) works as zgrep too (C-u grep all buffers but non--file buffers). +\\[helm-buffers-run-multi-occur]\t\t->Multi Occur buffer or marked buffers. (C-u toggle force searching current-buffer). +\\[helm-buffer-switch-other-window]\t\t->Switch other window. +\\[helm-buffer-switch-other-frame]\t\t->Switch other frame. +\\[helm-buffer-run-query-replace-regexp]\t\t->Query replace regexp in marked buffers. +\\[helm-buffer-run-query-replace]\t\t->Query replace in marked buffers. +\\[helm-buffer-run-ediff]\t\t->Ediff current buffer with candidate. If two marked buffers ediff those buffers. +\\[helm-buffer-run-ediff-merge]\t\t->Ediff merge current buffer with candidate. If two marked buffers ediff merge those buffers. +\\[helm-buffer-diff-persistent]\t\t->Toggle Diff buffer with saved file without quitting. +\\[helm-buffer-revert-persistent]\t\t->Revert buffer without quitting. +\\[helm-buffer-save-persistent]\t\t->Save buffer without quitting. +\\[helm-buffer-run-kill-buffers]\t\t->Delete marked buffers and quit. +\\[helm-buffer-run-kill-persistent]\t\t->Delete buffer without quitting helm. +\\[helm-toggle-all-marks]\t\t->Toggle all marks. +\\[helm-mark-all]\t\t->Mark all. +\\[helm-toggle-buffers-details]\t\t->Toggle details. +\\[helm-buffers-toggle-show-hidden-buffers]\t\t->Show hidden buffers. +\\[helm-buffers-mark-similar-buffers]\t\t->Mark all buffers with same type (color) than current. +\\[helm-buffer-help]\t\t->Display this help. +\n** Helm Map +\\{helm-map}") + +;;;###autoload +(defun helm-buffer-help () + "Help command for helm buffers." + (interactive) + (let ((helm-help-message helm-buffer-help-message)) + (helm-help))) + +;;; Find files help (`helm-find-files') +;; +;; +(defvar helm-ff-help-message + "\n* Helm Find Files\n + +** Helm find files tips: +\n*** Enter `~/' at end of pattern to quickly reach home directory. + +*** Enter `/' at end of pattern to quickly reach root of your file system. + +*** Enter `./' at end of pattern to quickly reach `default-directory' (initial start of session). + If you are already in `default-directory' this will move cursor on top. + +*** Enter `../' at end of pattern will reach upper directory, moving cursor on top. + NOTE: This different to using `C-l' in that `C-l' don't move cursor on top but stay on previous + subdir name. + +*** You can complete with partial basename (start on third char entered) + + e.g \"fob\" or \"fbr\" will complete \"foobar\" + but \"fb\" will wait for a third char for completing. + +*** Use `C-u C-j' to watch an image. + +*** `C-j' on a filename will expand in helm-buffer to this filename. + Second hit on `C-j' will display buffer filename. + Third hit on `C-j' will kill buffer filename. + NOTE: `C-u C-j' will display buffer directly. + +*** To browse images directories turn on `helm-follow-mode' and navigate with arrow keys. + You can also use `helm-follow-action-forward' and `helm-follow-action-backward' + (`C-'). + +*** You can turn off/on (toggle) autoupdate completion at any moment with `C-DEL'. + NOTE: On a terminal C- may not work, use in this case C-c . + +*** You can create a new directory and a new file at the same time. + just write the path in prompt and press `'. + e.g You can create \"~/new/newnew/newnewnew/my_newfile.txt\". + +*** To create a new directory, add a \"/\" at end of new name and press . + +*** To create a new file just write the filename not ending with \"/\". + +*** Recursive search from helm find files + +**** You can use helm browse project (see binding below). + +- With no prefix arg + If your current directory is under version control + with one of git or hg and you have installed helm-ls-git and/or helm-ls-hg + https://github.com/emacs-helm/helm-ls-git.git + https://github.com/emacs-helm/helm-ls-hg + you will see all your files under version control, otherwise + you will be back to helm-find-files. +- With one prefix arg + You will see all the files under this directory + and other subdirectories (recursion) and this list of files will be cached. +- With two prefix args + same but the cache will be refreshed. + +**** You can start a recursive search with Locate of Find (See commands below). + With Locate you can use a local db with a prefix arg; If the localdb doesn't already + exists, you will be prompted for its creation, if it exists and you want to refresh it, + give two prefix args. + +*** Insert filename at point or complete filename at point + +On insertion (no completion, i.e nothing at point): + +- `C-c i' => insert absolute file name. +- `C-u C-c i' => insert abbreviate file name. +- `C-u C-u C-c i' => insert relative file name. + +On completion: + +- target starts by ~/ => insert abbreviate file name. +- target starts by / or [a-z]:/ => insert full path. +- otherwise => insert relative file name. + +*** Using wildcard to select multiple files + +Use of wilcard is supported to give a set of files to an action: + +e.g +You can copy all the files with \".el\" extension by using \"*.el\" +and then run your copy action. + +You can do the same but with \"**.el\" (note the two stars), +this will select recursively all \".el\" files under current directory. + +NOTE: When using an action that involve an external backend (e.g grep), using \"**\" +is not advised (even if it works fine) because it will be slower to select all your files, +you have better time letting the backend doing it, it will be faster. +However, if you know you have not many files it is reasonable to use this, +also using not recursive wilcard (e.g \"*.el\") is perfectly fine for this. + +This feature (\"**\") is activated by default with the option `helm-file-globstar'. +The directory selection with \"**foo/\" like bash shopt globstar option is not supported yet. + +*** Bookmark your `helm-find-files' session + +You can bookmark your `helm-find-files' session with `C-x r m'. +You can retrieve later these bookmarks easily by using M-x helm-filtered-bookmarks. + +\n** Specific commands for `helm-find-files':\n +\\ +\\[helm-ff-run-locate]\t\t->Run Locate (C-u to specify locate db, M-n insert basename of candidate) +\\[helm-ff-run-browse-project]\t\t->Browse project (`C-u' recurse, `C-u C-u' recurse and refresh db) +\\[helm-ff-run-find-sh-command]\t\t->Run Find shell command from this directory. +\\[helm-ff-run-grep]\t\t->Run Grep (C-u Recursive). +\\[helm-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. +\\[helm-ff-run-zgrep]\t\t->Run zgrep (C-u Recursive). +\\[helm-ff-run-etags]\t\t->Run Etags (C-u use thing-at-point `C-u C-u' reload cache) +\\[helm-ff-run-rename-file]\t\t->Rename File (C-u Follow). +\\[helm-ff-run-query-replace-on-marked]\t\t->Query replace on marked files. +\\[helm-ff-run-copy-file]\t\t->Copy File (C-u Follow). +\\[helm-ff-run-byte-compile-file]\t\t->Byte Compile File (C-u Load). +\\[helm-ff-run-load-file]\t\t->Load File. +\\[helm-ff-run-symlink-file]\t\t->Symlink File. +\\[helm-ff-run-hardlink-file]\t\t->Hardlink file. +\\[helm-ff-run-delete-file]\t\t->Delete File. +\\[helm-ff-run-kill-buffer-persistent]\t\t->Kill buffer candidate without quitting. +\\[helm-ff-persistent-delete]\t\t->Delete file without quitting. +\\[helm-ff-run-switch-to-eshell]\t\t->Switch to Eshell. +\\[helm-ff-run-eshell-command-on-file]\t\t->Eshell command on file (C-u Apply on marked files, otherwise treat them sequentially). +\\[helm-ff-run-ediff-file]\t\t->Ediff file. +\\[helm-ff-run-ediff-merge-file]\t\t->Ediff merge file. +\\[helm-ff-run-complete-fn-at-point]\t\t->Complete file name at point. +\\[helm-ff-run-switch-other-window]\t\t->Switch other window. +\\[helm-ff-run-switch-other-frame]\t\t->Switch other frame. +\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). +\\[helm-ff-run-open-file-with-default-tool]\t\t->Open file externally with default tool. +\\[helm-ff-rotate-left-persistent]\t\t->Rotate Image Left. +\\[helm-ff-rotate-right-persistent]\t\t->Rotate Image Right. +\\[helm-find-files-up-one-level]\t\t->Go down precedent directory. +\\[helm-ff-run-switch-to-history]\t\t->Switch to last visited directories history. +\\[helm-ff-file-name-history]\t\t->Switch to file name history. +\\[helm-ff-properties-persistent]\t\t->Show file properties in a tooltip. +\\[helm-mark-all]\t\t->Mark all visibles candidates. +\\[helm-ff-run-toggle-auto-update]\t\t->Toggle auto expansion of directories. +\\[helm-unmark-all]\t\t->Unmark all candidates, visibles and invisibles. +\\[helm-ff-run-gnus-attach-files]\t\t->Gnus attach files to message buffer. +\\[helm-ff-run-print-file]\t\t->Print file, (C-u to refresh printers list). +\\[helm-enlarge-window]\t\t->Enlarge helm window. +\\[helm-narrow-window]\t\t->Narrow helm window. +\\[helm-ff-run-toggle-basename]\t\t->Toggle basename/fullpath. +\\[helm-ff-run-find-file-as-root]\t\t->Find file as root. +\\[helm-ff-run-insert-org-link]\t\t->Insert org link. +\\[helm-ff-help]\t\t->Display this help info. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-ff-help () + "Help command for `helm-find-files'." + (interactive) + (let ((helm-help-message helm-ff-help-message)) + (helm-help))) + +;;; Help for `helm-read-file-name' +;; +;; +(defvar helm-read-file-name-help-message + "\n* Helm read file name\n + +** Helm read file name tips: + +\n*** Enter `~/' at end of pattern to quickly reach home directory. + +*** Enter `/' at end of pattern to quickly reach root of your file system. + +*** Enter `./' at end of pattern to quickly reach `default-directory' (initial start of session). + If you are in `default-directory' move cursor on top. + +*** Enter `../' at end of pattern will reach upper directory, moving cursor on top. + NOTE: This different to using `C-l' in that `C-l' don't move cursor on top but stay on previous + subdir name. + +*** You can complete with partial basename (start on third char entered) + + e.g \"fob\" or \"fbr\" will complete \"foobar\" + but \"fb\" will wait for a third char for completing. + +*** Persistent actions: + +By default `helm-read-file-name' use the persistent actions of `helm-find-files'. + +**** Use `C-u C-j' to watch an image. + +**** `C-j' on a filename will expand in helm-buffer to this filename. + Second hit on `C-j' will display buffer filename. + Third hit on `C-j' will kill buffer filename. + NOTE: `C-u C-j' will display buffer directly. + +**** To browse images directories turn on `helm-follow-mode' and navigate with arrow keys. + +**** When you want to delete backward characters to e.g creating a new file or directory, + autoupdate may keep updating to an existent directory + preventing you to do so, in this case just hit C- and then . + This should not needed when copying/renaming files because autoupdate is disabled + by default in this case. + NOTE: On a terminal C- may not work, use in this case C-c . + +**** You can create a new directory and a new file at the same time, just write the path in prompt + and press . + e.g You can create \"~/new/newnew/newnewnew/my_newfile.txt\". + +**** To create a new directory, add a \"/\" at end of new name and press . + +**** To create a new file just write the filename not ending with \"/\". + +\n** Specific commands for helm-read-file-name:\n +\\ +\\[helm-find-files-up-one-level]\t\t->Go down precedent directory. +\\[helm-ff-run-toggle-auto-update]\t\t->Toggle auto expansion of directories. +\\[helm-ff-run-toggle-basename]\t\t->Toggle basename. +\\[helm-ff-file-name-history]\t\t->File name history. +C/\\[helm-cr-empty-string]\t\t->Maybe return empty string (unless `must-match'). +\\[helm-next-source]\t\t->Goto next source. +\\[helm-previous-source]\t->Goto previous source. +\\[helm-read-file-name-help]\t\t->Display this help info. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-read-file-name-help () + (interactive) + (let ((helm-help-message helm-read-file-name-help-message)) + (helm-help))) + +;;; Generic file help - Used by locate. +;; +;; +(defvar helm-generic-file-help-message + "\n* Helm Generic files\n + +** Helm generic file tips:\n + +*** Locate +You can add after writing search pattern any of the locate command line options. +e.g -b, -e, -n ...etc. +See Man locate for more infos. + +Some other sources (at the moment recentf and file in current directory sources) +support the -b flag for compatibility with locate when they are used with it. + +*** Browse project + +When your directory is not under version control, +don't forget to refresh your cache when files have been added/removed in your directory. + +*** Find command + +Recursively search files using \"find\" shell command. + +Candidates are all filenames that match all given globbing patterns. +This respects the options `helm-case-fold-search' and +`helm-findutils-search-full-path'. + +You can pass arbitrary options directly to find after a \"*\" separator. +For example, this would find all files matching \"book\" that are larger +than 1 megabyte: + +book * -size +1M + +\n** Specific commands for helm locate and others files sources: + +\\ +\\[helm-ff-run-toggle-basename]\t\t->Toggle basename. +\\[helm-ff-run-grep]\t\t->Run grep (C-u recurse). +\\[helm-ff-run-pdfgrep]\t\t->Run Pdfgrep on marked files. +\\[helm-ff-run-delete-file]\t\t->Delete file. +\\[helm-ff-run-ediff-file]\t\t->Ediff file. +\\[helm-ff-run-ediff-merge-file]\t\t->Ediff merge file. +\\[helm-ff-run-switch-other-window]\t\t->Switch other window. +\\[helm-ff-properties-persistent]\t\t->Show file properties. +\\[helm-ff-run-etags]\t\t->Run etags (C-u use tap, C-u C-u reload DB). +\\[helm-yank-text-at-point]\t\t->Yank text at point. +\\[helm-ff-run-open-file-externally]\t\t->Open file with external program (C-u to choose). +\\[helm-ff-run-open-file-with-default-tool]\t\t->Open file externally with default tool. +\\[helm-ff-run-insert-org-link]\t\t->Insert org link. +\\[helm-generic-file-help]\t\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-generic-file-help () + (interactive) + (let ((helm-help-message helm-generic-file-help-message)) + (helm-help))) + +;;; Grep help +;; +;; +(defvar helm-grep-help-message + "\n* Helm Grep\n +** Helm grep tips:\n +*** You can start grep with a prefix arg to recurse in subdirectories. +*** You can use wild card when selecting files (e.g *.el) +*** You can grep in many differents directories by marking files or wild cards. +*** You can save your results in a grep-mode buffer, see commands below. + +*** Important:\n +Grepping on remote file will work only with grep, not ack-grep, but it is +anyway bad supported as tramp doesn't support multiple process running in a +short delay (less than 5s actually) among other things, +so I strongly advice hitting `C-!' (i.e suspend process) +before entering anything in pattern, and hit again `C-!' when +your regexp is ready to send to remote process, even if helm is handling +this by delaying each process at 5s. +Or even better don't use tramp at all and mount your remote file system on SSHFS. + +\n** Specific commands for Helm Grep:\n +\\ +\\[helm-goto-next-file]\t->Next File. +\\[helm-goto-precedent-file]\t\t->Precedent File. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-grep-run-other-window-action]\t\t->Jump other window. +\\[helm-grep-run-other-frame-action]\t\t->Jump other frame. +\\[helm-grep-run-persistent-action]\t\t->Run persistent action (Same as `C-j'). +\\[helm-grep-run-default-action]\t\t->Run default action (Same as RET). +\\[helm-grep-run-save-buffer]\t\t->Save to a `grep-mode' enabled buffer. +\\[helm-grep-help]\t\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-grep-help () + (interactive) + (let ((helm-help-message helm-grep-help-message)) + (helm-help))) + +;;; Pdf grep help +;; +;; +(defvar helm-pdfgrep-help-message + "\n* Helm PdfGrep Map\n +\n** Specific commands for Pdf Grep:\n +\\ +\\[helm-goto-next-file]\t->Next File. +\\[helm-goto-precedent-file]\t\t->Precedent File. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-pdfgrep-help]\t\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-pdfgrep-help () + (interactive) + (let ((helm-help-message helm-pdfgrep-help-message)) + (helm-help))) + +;;; Etags help +;; +;; +(defvar helm-etags-help-message + "\n* Helm Etags Map\n +\n** Specific commands for Etags:\n +\\ +\\[helm-goto-next-file]\t->Next File. +\\[helm-goto-precedent-file]\t\t->Precedent File. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-etags-help]\t\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-etags-help () + "The help function for etags." + (interactive) + (let ((helm-help-message helm-etags-help-message)) + (helm-help))) + +;;; Ucs help +;; +;; +(defvar helm-ucs-help-message + "\n* Helm Ucs\n +\n** Specific commands for `helm-ucs':\n +\\ +\\[helm-ucs-persistent-insert]\t->Insert char. +\\[helm-ucs-persistent-forward]\t->Forward char. +\\[helm-ucs-persistent-backward]\t->Backward char. +\\[helm-ucs-persistent-delete]\t->Delete char backward. +\\[helm-ucs-help]\t\t->Show this help. + +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-ucs-help () + "Help command for `helm-ucs'." + (interactive) + (let ((helm-help-message helm-ucs-help-message)) + (helm-help))) + +;;; Bookmark help +;; +;; +(defvar helm-bookmark-help-message + "\n* Helm bookmark name\n +\n** Specific commands for bookmarks:\n +\\ +\\[helm-bookmark-run-jump-other-window]\t\t->Jump other window. +\\[helm-bookmark-run-delete]\t\t->Delete bookmark. +\\[helm-bookmark-run-edit]\t\t->Edit bookmark. +\\[helm-bookmark-toggle-filename]\t\t->Toggle bookmark location visibility. +\\[helm-bookmark-help]\t\t->Run this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-bookmark-help () + "Help command for bookmarks." + (interactive) + (let ((helm-help-message helm-bookmark-help-message)) + (helm-help))) + +;;; Eshell command on file help +;; +;; +(defvar helm-esh-help-message + "\n* Helm eshell on file\n +** Helm eshell on file tips: + +*** Passing extra args after filename: + +Normally your command or alias will be called with file as argument. + +e.g 'candidate_file' + +But you can also pass an argument or more after 'candidate_file' like this: + + %s [extra_args]\n + +'candidate_file' will be added at '%s' and your command will look at this: + + 'candidate_file' [extra_args] + +*** Specify many files as args (marked files): + +e.g file1 file2 ... + +Call `helm-find-files-eshell-command-on-file' with one prefix-arg +Otherwise you can pass one prefix-arg from the command selection buffer. +NOTE: This is not working on remote files. + +With two prefix-arg before starting or from the command selection buffer +the output is printed to your `current-buffer'. + +Note that with no prefix-arg or a prefix-arg value of '(16) (C-u C-u) +the command is called once for each file like this: + + file1 file2 etc... + +\n** Specific commands for `helm-find-files-eshell-command-on-file':\n +\\ +\\[helm-esh-help]\t\t->Display this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-esh-help () + "Help command for `helm-find-files-eshell-command-on-file'." + (interactive) + (let ((helm-help-message helm-esh-help-message)) + (helm-help))) + +;;; Ido virtual buffer help +;; +;; +(defvar helm-buffers-ido-virtual-help-message + "\n* Helm ido virtual buffers\n +\n** Specific commands for ido virtuals buffers:\n +\\ +\\[helm-ff-run-switch-other-window]\t\t->Switch other window. +\\[helm-ff-run-switch-other-frame]\t\t->Switch other frame. +\\[helm-ff-run-grep]\t\t->Grep file. +\\[helm-ff-run-zgrep]\t\t->Zgrep file. +\\[helm-ff-run-delete-file]\t\t->Delete file. +\\[helm-ff-run-open-file-externally]\t\t->Open file externally. +\\[helm-buffers-ido-virtual-help]\t\t->Display this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-buffers-ido-virtual-help () + "Help command for ido virtual buffers." + (interactive) + (let ((helm-help-message helm-buffers-ido-virtual-help-message)) + (helm-help))) + +;;; Moccur help +;; +;; +(defvar helm-moccur-help-message + "\n* Helm Moccur\n +** Helm Moccur tips: + +*** Matching +Multiple regexp matching is allowed, just enter a space to separate your regexps. + +Matching empty lines is supported with the regexp \"^$\", you will get the results +with only the buffer-name and the line number, you can of course save and edit these +results. + +*** Jump to the corresponding line in the searched buffer +You can do this with `C-j' (persistent-action), to do it repetitively +you can use `C-' and `C-' or enable `helm-follow-mode' with `C-c C-f'. + +*** Saving results +Same as with helm-grep, you can save the results with `C-x C-s'. +Of course if you don't save your results, you can get back your session +with `helm-resume'. + +*** Refreshing the resumed session. +When the buffer(s) where you ran helm-(m)occur have been modified, you will be +warned of this with the buffer flashing to red, you can refresh the buffer by running +`C-c C-u'. +This can be done automatically by customizing `helm-moccur-auto-update-on-resume'. + +*** Refreshing a saved buffer +Just hit `g' to update your buffer. + +*** Edit a saved buffer + +To do so you have to install wgrep +https://github.com/mhayashi1120/Emacs-wgrep +and then: + +1) C-c C-p to edit the buffer(s). +2) C-x C-s to save your changes. + +Tip: Use the excellent iedit https://github.com/tsdh/iedit +to modify occurences in your buffer. + +\n** Specific commands for Helm Moccur:\n +\\ +\\[helm-goto-next-file]\t->Next Buffer. +\\[helm-goto-precedent-file]\t\t->Precedent Buffer. +\\[helm-yank-text-at-point]\t\t->Yank Text at point in minibuffer. +\\[helm-moccur-run-goto-line-ow]\t\t->Goto line in other window. +\\[helm-moccur-run-goto-line-of]\t\t->Goto line in new frame. +\\[helm-moccur-help]\t\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-moccur-help () + (interactive) + (let ((helm-help-message helm-moccur-help-message)) + (helm-help))) + +;;; Helm Top +;; +;; +(defvar helm-top-help-message + "\n* Helm Top\n +\n** Helm Top tips: + +\n** Specific commands for Helm Top:\n +\\ +\\[helm-top-run-sort-by-com]\t->Sort by commands. +\\[helm-top-run-sort-by-cpu]\t->Sort by cpu usage. +\\[helm-top-run-sort-by-user]\t->Sort alphabetically by user. +\\[helm-top-run-sort-by-mem]\t->Sort by memory. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-top-help () + (interactive) + (let ((helm-help-message helm-top-help-message)) + (helm-help))) + +;;; Helm Apt +;; +;; +(defvar helm-apt-help-message + "\n* Helm Apt\n +\n** Helm Apt tips: + +\n** Specific commands for Helm Apt:\n +\\ +\\[helm-apt-show-all]\t->Show all packages. +\\[helm-apt-show-only-installed]\t->Show installed packages only. +\\[helm-apt-show-only-not-installed]\t->Show not installed packages only. +\\[helm-apt-show-only-deinstalled]\t-Show deinstalled (not purged yet) packages only.> +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-apt-help () + (interactive) + (let ((helm-help-message helm-apt-help-message)) + (helm-help))) + +;;; Helm elisp package +;; +;; +(defvar helm-el-package-help-message + "\n* Helm elisp package\n +\n** Helm elisp package tips: +*** Upgrade elisp packages + +To see upgradables packages hit . + +Then you can install all upgradables packages with the upgrade all action, +or upgrade only the specific packages by marking them (the new ones) and running +the upgrade action (visible only when there is upgradables packages). +Of course you can upgrade a single package by just running the upgrade action +without marking it. + +*** Meaning of flags prefixing packages (Emacs-25) + +- The flag \"S\" that prefix package names mean that this package is one of `package-selected-packages'. +This feature is only available with emacs-25. + +- The flag \"U\" that prefix package names mean that this package is no more needed. +This feature is only available with emacs-25. + +\n** Specific commands for Helm elisp package:\n +\\ +\\[helm-el-package-show-all]\t->Show all packages. +\\[helm-el-package-show-installed]\t->Show installed packages only. +\\[helm-el-package-show-uninstalled]\t->Show not installed packages only. +\\[helm-el-package-help]\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-el-package-help () + (interactive) + (let ((helm-help-message helm-el-package-help-message)) + (helm-help))) + +;;; Helm M-x +;; +;; +(defvar helm-M-x-help-message + "\n* Helm M-x\n +\n** Helm M-x tips: + +*** You can get help on any command with persistent action (C-j). + +*** All the prefix args passed BEFORE running `helm-M-x' are ignored, +you should have an error message if you do so. +When you want to pass prefix args, pass them AFTER starting `helm-M-x', +you will have a prefix arg counter appearing in mode-line notifying you +the amount of prefix args entered. + +\n** Specific commands for Helm M-x:\n +\\ +\\[helm-M-x-help]\t\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-M-x-help () + (interactive) + (let ((helm-help-message helm-M-x-help-message)) + (helm-help))) + +;;; helm-imenu +;; +;; +(defvar helm-imenu-help-message + "\n* Helm imenu\n +\n** Helm imenu tips: + +\n** Specific commands for Helm imenu:\n +\\ +\\[helm-imenu-help]\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-imenu-help () + (interactive) + (let ((helm-help-message helm-imenu-help-message)) + (helm-help))) + +;;; helm-colors +;; +;; +(defvar helm-colors-help-message + "\n* Helm colors\n +\n** Specific commands for Helm colors:\n +\\ +\\[helm-color-run-insert-name]\t\tInsert the entry'name. +\\[helm-color-run-kill-name]\t\tKill the entry's name. +\\[helm-color-run-insert-rgb]\t\tInsert entry in RGB format. +\\[helm-color-run-kill-rgb]\t\tKill entry in RGB format. +\\[helm-color-help]\t\tShow this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-color-help () + (interactive) + (let ((helm-help-message helm-colors-help-message)) + (helm-help))) + +;;; helm semantic +;; +;; +(defvar helm-semantic-help-message + "\n* Helm semantic\n +\n** Helm semantic tips: + +\n** Specific commands for Helm semantic:\n +\\ +\\[helm-semantic-help]\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-semantic-help () + (interactive) + (let ((helm-help-message helm-semantic-help-message)) + (helm-help))) + +;;; helm kmacro +;; +;; +(defvar helm-kmacro-help-message + "\n* Helm kmacro\n +\n** Helm kmacro tips: +- Start recording some keys with `f3' +- Record new kmacro with `f4' +- Start `helm-execute-kmacro' to list all your macros. + +Use persistent action to run your kmacro as many time as needed, +you can change of kmacro with `helm-next-line' `helm-previous-line'. + +NOTE: You can't record keys running helm commands except `helm-M-x' unless +you don't choose from there a command using helm completion. + +\n** Specific commands for Helm kmacro:\n +\\ +\\[helm-kmacro-help]\t->Show this help. +\n** Helm Map\n +\\{helm-map}") + +;;;###autoload +(defun helm-kmacro-help () + (interactive) + (let ((helm-help-message helm-kmacro-help-message)) + (helm-help))) + + +;;; Mode line strings +;; +;; +;;;###autoload +(defvar helm-buffer-mode-line-string + '("Buffer(s)" "\ +\\\ +\\[helm-buffer-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "String displayed in mode-line in `helm-source-buffers-list'")) + +;;;###autoload +(defvar helm-color-mode-line-string + '("Colors" "\ +\\\ +\\[helm-color-help]:Help/\ +\\[helm-color-run-insert-name]:Insert name/\ +\\[helm-color-run-insert-rgb]:Insert RGB/\ +with shift: Kill")) + +;;;###autoload +(defvar helm-buffers-ido-virtual-mode-line-string + '("Killed Buffer(s)" "\ +\\\ +\\[helm-buffers-ido-virtual-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "String displayed in mode-line in `helm-source-buffers-list'")) + +;;;###autoload +(defvar helm-ff-mode-line-string "\ +\\\ +\\[helm-ff-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "String displayed in mode-line in `helm-source-find-files'") + +;;;###autoload +(defvar helm-read-file-name-mode-line-string "\ +\\\ +\\[helm-read-file-name-help]:Help \ +C/\\[helm-cr-empty-string]:Empty \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "String displayed in mode-line in `helm-source-find-files'.") + +;;;###autoload +(defvar helm-generic-file-mode-line-string "\ +\\\ +\\[helm-generic-file-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend" + "String displayed in mode-line in Locate.") + +;;;###autoload +(defvar helm-grep-mode-line-string"\ +\\\ +\\[helm-grep-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend" + "String displayed in mode-line in `helm-do-grep'.") + +;;;###autoload +(defvar helm-pdfgrep-mode-line-string "\ +\\\ +\\[helm-pdfgrep-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend" + "String displayed in mode-line in `helm-do-pdfgrep'.") + +;;;###autoload +(defvar helm-etags-mode-line-string "\ +\\\ +\\[helm-etags-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "String displayed in mode-line in `helm-etags-select'.") + +;;;###autoload +(defvar helm-ucs-mode-line-string "\ +\\\ +\\[helm-ucs-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "String displayed in mode-line in `helm-ucs'.") + +;;;###autoload +(defvar helm-bookmark-mode-line-string + '("Bookmark(s)" "\ +\\\ +\\[helm-bookmark-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct") + "String displayed in mode-line in `helm-source-buffers-list'") + +;;;###autoload +(defvar helm-occur-mode-line "\ +\\\ +\\[helm-help]:Help \ +\\\ +\\[helm-occur-run-query-replace-regexp]:Query replace regexp \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-moccur-mode-line "\ +\\\ +\\[helm-moccur-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-comp-read-mode-line "\ +\\\ +C/\\[helm-cr-empty-string]:Empty \ +\\\ +\\[helm-help]:Help \ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct") + +;;;###autoload +(defvar helm-top-mode-line "\ +\\\ +\\[helm-top-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-apt-mode-line "\ +\\\ +\\[helm-apt-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-el-package-mode-line "\ +\\\ +\\[helm-el-package-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-M-x-mode-line "\ +\\\ +\\[helm-M-x-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-imenu-mode-line "\ +\\\ +\\[helm-imenu-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + +;;;###autoload +(defvar helm-semantic-mode-line "\ +\\\ +\\[helm-semantic-help]:Help \ +\\\ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct \ +\\[helm-toggle-suspend-update]:Tog.suspend") + + +;;; Attribute Documentation +;; +;; +;;;###autoload +(defun helm-describe-helm-attribute (helm-attribute) + "Display the full documentation of HELM-ATTRIBUTE. +HELM-ATTRIBUTE should be a symbol." + (interactive (list (intern + (completing-read + "Describe helm attribute: " + (mapcar 'symbol-name helm-attributes) + nil t)))) + (with-output-to-temp-buffer "*Help*" + (princ (get helm-attribute 'helm-attrdoc)))) + +(helm-document-attribute 'name "mandatory" + " The name of the source. It is also the heading which appears + above the list of matches from the source. Must be unique.") + +(helm-document-attribute 'header-name "optional" + " A function returning the display string of the header. Its + argument is the name of the source. This attribute is useful to + add an additional information with the source name.") + +(helm-document-attribute 'candidates "mandatory if candidates-in-buffer attribute is not provided" + " Specifies how to retrieve candidates from the source. It can + either be a variable name, a function called with no parameters + or the actual list of candidates. + + The list must be a list whose members are strings, symbols + or (DISPLAY . REAL) pairs. + + In case of (DISPLAY . REAL) pairs, the DISPLAY string is shown + in the Helm buffer, but the REAL one is used as action + argument when the candidate is selected. This allows a more + readable presentation for candidates which would otherwise be, + for example, too long or have a common part shared with other + candidates which can be safely replaced with an abbreviated + string for display purposes. + + Note that if the (DISPLAY . REAL) form is used then pattern + matching is done on the displayed string, not on the real + value. + + If the candidates have to be retrieved asynchronously (for + example, by an external command which takes a while to run) + then the function should start the external command + asynchronously and return the associated process object. + Helm will take care of managing the process (receiving the + output from it, killing it if necessary, etc.). The process + should return candidates matching the current pattern (see + variable `helm-pattern'.) + You should use instead `candidates-process' attribute for + async processes, a warning will popup when using async process + in a `candidates' attribute. + + Note that currently results from asynchronous sources appear + last in the helm buffer regardless of their position in + `helm-sources'.") + +(helm-document-attribute 'candidates-process + "Same as `candidates' attributes but for process function." + " You should use this attribute when using a function involving + an async process instead of `candidates'.") + +(helm-document-attribute 'action "mandatory if type attribute is not provided" + " It is a list of (DISPLAY . FUNCTION) pairs or FUNCTION. + FUNCTION is called with one parameter: the selected candidate. + + An action other than the default can be chosen from this list + of actions for the currently selected candidate (by default + with TAB). The DISPLAY string is shown in the completions + buffer and the FUNCTION is invoked when an action is + selected. The first action of the list is the default.") + +(helm-document-attribute 'coerce "optional" + " It's a function called with one argument: the selected + candidate. + + This function is intended for type convertion. In normal case, + the selected candidate (string) is passed to action + function. If coerce function is specified, it is called just + before action function. + + Example: converting string to symbol + (coerce . intern)") + +(helm-document-attribute 'type "optional if action attribute is provided" + " Indicates the type of the items the source returns. + + Merge attributes not specified in the source itself from + `helm-type-attributes'. + + This attribute is implemented by plug-in.") + +(helm-document-attribute 'init "optional" + " Function called with no parameters when helm is started. It + is useful for collecting current state information which can be + used to create the list of candidates later. + + For example, if a source needs to work with the current + directory then it can store its value here, because later + helm does its job in the minibuffer and in the + `helm-buffer' and the current directory can be different + there.") + +(helm-document-attribute 'match "optional" + " List of functions called with one parameter: a candidate. The + function should return non-nil if the candidate matches the + current pattern (see variable `helm-pattern'). + + This attribute allows the source to override the default + pattern matching based on `string-match'. It can be used, for + example, to implement a source for file names and do the + pattern matching on the basename of files, since it's more + likely one is typing part of the basename when searching for a + file, instead of some string anywhere else in its path. + + If the list contains more than one function then the list of + matching candidates from the source is constructed by appending + the results after invoking the first function on all the + potential candidates, then the next function, and so on. The + matching candidates supplied by the first function appear first + in the list of results and then results from the other + functions, respectively. + + This attribute has no effect for asynchronous sources (see + attribute `candidates'), since they perform pattern matching + themselves.") + +(helm-document-attribute 'candidate-transformer "optional" + " It's a function or a list of functions called with one argument + when the completion list from the source is built. The argument + is the list of candidates retrieved from the source. The + function should return a transformed list of candidates which + will be used for the actual completion. If it is a list of + functions, it calls each function sequentially. + + This can be used to transform or remove items from the list of + candidates. + + Note that `candidates' is run already, so the given transformer + function should also be able to handle candidates with (DISPLAY + . REAL) format.") + +(helm-document-attribute 'filtered-candidate-transformer "optional" + " It has the same format as `candidate-transformer', except the + function is called with two parameters: the candidate list and + the source. + + This transformer is run on the candidate list which is already + filtered by the current pattern. While `candidate-transformer' + is run only once, it is run every time the input pattern is + changed. + + It can be used to transform the candidate list dynamically, for + example, based on the current pattern. + + In some cases it may also be more efficent to perform candidate + transformation here, instead of with `candidate-transformer' + even if this transformation is done every time the pattern is + changed. For example, if a candidate set is very large then + `candidate-transformer' transforms every candidate while only + some of them will actually be dislpayed due to the limit + imposed by `helm-candidate-number-limit'. + + Note that `candidates' and `candidate-transformer' is run + already, so the given transformer function should also be able + to handle candidates with (DISPLAY . REAL) format. + + This option has no effect for asynchronous sources. (Not yet, + at least.") + +(helm-document-attribute 'action-transformer "optional" + " It's a function or a list of functions called with two + arguments when the action list from the source is + assembled. The first argument is the list of actions, the + second is the current selection. If it is a list of functions, + it calls each function sequentially. + + The function should return a transformed action list. + + This can be used to customize the list of actions based on the + currently selected candidate.") + +(helm-document-attribute 'pattern-transformer "optional" + " It's a function or a list of functions called with one argument + before computing matches. Its argument is `helm-pattern'. + Functions should return transformed `helm-pattern'. + + It is useful to change interpretation of `helm-pattern'.") + +(helm-document-attribute 'delayed "optional" + " Candidates from the source are shown only if the user stops + typing and is idle for `helm-idle-delay' seconds. + If a value is given to delayed attr, this value is used instead only + if it is > to `helm-idle-delay'.") + +(helm-document-attribute 'volatile "optional" + " Indicates the source assembles the candidate list dynamically, + so it shouldn't be cached within a single Helm + invocation. It is only applicable to synchronous sources, + because asynchronous sources are not cached.") + +(helm-document-attribute 'requires-pattern "optional" + " If present matches from the source are shown only if the + pattern is not empty. Optionally, it can have an integer + parameter specifying the required length of input which is + useful in case of sources with lots of candidates.") + +(helm-document-attribute 'persistent-action "optional" + " Can be a either a Function called with one parameter (the + selected candidate) or a cons cell where first element is this + same function and second element a symbol (e.g never-split) + that inform `helm-execute-persistent-action'to not split his + window to execute this persistent action.") + +(helm-document-attribute 'candidates-in-buffer "optional" + " Shortcut attribute for making and narrowing candidates using + buffers. This newly-introduced attribute prevents us from + forgetting to add volatile and match attributes. + + See docstring of `helm-candidates-in-buffer'. + + (candidates-in-buffer) is equivalent of three attributes: + (candidates . helm-candidates-in-buffer) + (volatile) + (match identity) + + (candidates-in-buffer . candidates-function) is equivalent of: + (candidates . candidates-function) + (volatile) + (match identity) + + This attribute is implemented by plug-in.") + +(helm-document-attribute 'search "optional" + " List of functions like `re-search-forward' or `search-forward'. + Buffer search function used by `helm-candidates-in-buffer'. + By default, `helm-candidates-in-buffer' uses + `re-search-forward'. This attribute is meant to be used with + (candidates . helm-candidates-in-buffer) or + (candidates-in-buffer) in short.") + +(helm-document-attribute 'get-line "optional" + " A function like `buffer-substring-no-properties' or `buffer-substring'. + This function converts point of line-beginning and point of line-end, + which represents a candidate computed by `helm-candidates-in-buffer'. + By default, `helm-candidates-in-buffer' uses + `buffer-substring-no-properties'.") + +(helm-document-attribute 'display-to-real "optional" + " Function called with one parameter; the selected candidate. + + The function transforms the selected candidate, and the result + is passed to the action function. The display-to-real + attribute provides another way to pass other string than one + shown in Helm buffer. + + Traditionally, it is possible to make candidates, + candidate-transformer or filtered-candidate-transformer + function return a list with (DISPLAY . REAL) pairs. But if REAL + can be generated from DISPLAY, display-to-real is more + convenient and faster.") + +(helm-document-attribute 'real-to-display "optional" + " Function called with one parameter; the selected candidate. + + The inverse of display-to-real attribute. + + The function transforms the selected candidate, which is passed + to the action function, for display. The real-to-display + attribute provides the other way to pass other string than one + shown in Helm buffer. + + Traditionally, it is possible to make candidates, + candidate-transformer or filtered-candidate-transformer + function return a list with (DISPLAY . REAL) pairs. But if + DISPLAY can be generated from REAL, real-to-display is more + convenient. + + Note that DISPLAY parts returned from candidates / + candidate-transformer are IGNORED as the name `display-to-real' + says.") + +(helm-document-attribute 'cleanup "optional" + " Function called with no parameters when *helm* buffer is + closed. It is useful for killing unneeded candidates buffer. + + Note that the function is executed BEFORE performing action.") + +(helm-document-attribute 'candidate-number-limit "optional" + " Override `helm-candidate-number-limit' only for this source.") + +(helm-document-attribute 'accept-empty "optional" + " Pass empty string \"\" to action function.") + +(helm-document-attribute 'dummy "optional" + " Set `helm-pattern' to candidate. If this attribute is + specified, The candidates attribute is ignored. + + This attribute is implemented by plug-in.") + +(helm-document-attribute 'multiline "optional" + " Enable to selection multiline candidates.") + +(helm-document-attribute 'update "optional" + (substitute-command-keys + " Function called with no parameters at before \"init\" function when \ +\\\\[helm-force-update] is pressed.")) + +(helm-document-attribute 'mode-line "optional" + " Source local `helm-mode-line-string' (included in + `mode-line-format'). It accepts also variable/function name.") + +(helm-document-attribute 'header-line "optional" + " Source local `header-line-format'. + It accepts also variable/function name. ") + +(helm-document-attribute + 'resume "optional" + " Function called with no parameters at end of initialization + when `helm-resume' is started. + If this function try to do something against `helm-buffer', \(e.g updating, + searching etc...\) probably you should run it in a timer to ensure + `helm-buffer' is ready.") + +(helm-document-attribute 'keymap "optional" + " Specific keymap for this source. + It is useful to have a keymap per source when using more than + one source. Otherwise, a keymap can be set per command with + `helm' argument KEYMAP. NOTE: when a source have `helm-map' as + keymap attr, the global value of `helm-map' will override the + actual local one.") + +(helm-document-attribute 'help-message "optional" + " Help message for this source. + If not present, `helm-help-message' value will be used.") + +(helm-document-attribute 'match-part "optional" + " Allow matching candidate in the line with `candidates-in-buffer'. + In candidates-in-buffer sources, match is done with + `re-search-forward' which allow matching only a regexp on the + `helm-buffer'; when this search is done, match-part allow + matching only a specific part of the current line e.g with a + line like this: + + filename:candidate-containing-the-word-filename + + What you want is to ignore \"filename\" part and match only + \"candidate-containing-the-word-filename\" + + So give a function matching only the part of candidate after \":\" + + If source contain match-part attribute, match is computed only + on part of candidate returned by the call of function provided + by this attribute. The function should have one arg, candidate, + and return only a specific part of candidate. + + NOTE: This have effect only on sources using + `candidates-in-buffer'.") + +(helm-document-attribute 'match-strict "optional" + " When specifying a match function within a source and + helm-match-plugin is enabled, the result of all matching + functions will be concatened, which in some cases is not what + is wanted. When using `match-strict' only this or these + functions will be used. You can specify those functions as a + list of functions or a single symbol function. For anonymous + function don't add the dot, e.g: + + \(match-strict (lambda () (foo))).") + +(helm-document-attribute 'nohighlight "optional" + " Disable highlight match in this source.") + +(helm-document-attribute 'no-matchplugin "optional" + " Disable matchplugin for this source.") + +(helm-document-attribute 'history "optional" + " Allow passing history variable to helm from source. + It should be a quoted symbol evaluated from source, i.e: + (history . ,'history-var)") + +(helm-document-attribute 'follow "optional" + " Enable `helm-follow-mode' for this source only. + You must give it a value of 1 or -1, though giving a -1 value + is surely not what you want, e.g: (follow . 1) + + See `helm-follow-mode' for more infos") + +(helm-document-attribute 'follow-delay "optional" + " `helm-follow-mode' will execute persistent-action after this delay. +Otherwise value of `helm-follow-input-idle-delay' is used if non--nil, +If none of these are found fallback to `helm-input-idle-delay'.") + +(helm-document-attribute 'allow-dups "optional" + " Allow helm collecting duplicates candidates.") + +(helm-document-attribute 'filter-one-by-one "optional" + " A transformer function that treat candidates one by one. + It is called with one arg the candidate. + It is faster than `filtered-candidate-transformer' or `candidates-transformer', + but should be used only in sources that recompute constantly their candidates, + e.g `helm-source-find-files'. + Filtering happen early and candidates are treated + one by one instead of re-looping on the whole list. + If used with `filtered-candidate-transformer' or `candidates-transformer' + these functions should treat the candidates transformed by the `filter-one-by-one' + function in consequence.") + +(helm-document-attribute 'nomark "optional" + " Don't allow marking candidates when this attribute is present.") + +(provide 'helm-help) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-help.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-imenu.el b/emacs.d/elpa/helm-20150507.2215/helm-imenu.el new file mode 100644 index 0000000..2bf44c4 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-imenu.el @@ -0,0 +1,183 @@ +;;; helm-imenu.el --- Helm interface for Imenu -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'imenu) +(require 'helm-utils) +(require 'helm-help) + + +(defgroup helm-imenu nil + "Imenu related libraries and applications for helm." + :group 'helm) + +(defcustom helm-imenu-delimiter " / " + "Delimit types of candidates and his value in `helm-buffer'." + :group 'helm-imenu + :type 'string) + +(defcustom helm-imenu-execute-action-at-once-if-one t + "Goto the candidate when only one is remaining." + :group 'helm-imenu + :type 'boolean) + +(defcustom helm-imenu-lynx-style-map t + "Use Arrow keys to jump to occurences." + :group 'helm-imenu + :type 'boolean) + + +;;; keymap +(defvar helm-imenu-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-imenu-help) + (when helm-imenu-lynx-style-map + (define-key map (kbd "") 'helm-maybe-exit-minibuffer) + (define-key map (kbd "") 'helm-execute-persistent-action)) + (delq nil map))) + + +;;; Internals +(defvar helm-cached-imenu-alist nil) +(make-variable-buffer-local 'helm-cached-imenu-alist) + +(defvar helm-cached-imenu-candidates nil) +(make-variable-buffer-local 'helm-cached-imenu-candidates) + +(defvar helm-cached-imenu-tick nil) +(make-variable-buffer-local 'helm-cached-imenu-tick) + + +(defvar helm-source-imenu nil "See (info \"(emacs)Imenu\")") + +(defclass helm-imenu-source (helm-source-sync) + ((candidates :initform 'helm-imenu-candidates) + (candidate-transformer :initform 'helm-imenu-transformer) + (persistent-action :initform 'helm-imenu-persistent-action) + (persistent-help :initform "Show this entry") + (keymap :initform helm-imenu-map) + (mode-line :initform helm-imenu-mode-line) + (action :initform 'helm-imenu-action))) + +(defcustom helm-imenu-fuzzy-match nil + "Enable fuzzy matching in `helm-source-imenu'." + :group 'helm-imenu + :type 'boolean + :set (lambda (var val) + (set var val) + (setq helm-source-imenu + (helm-make-source "Imenu" 'helm-imenu-source + :fuzzy-match helm-imenu-fuzzy-match)))) + +(defun helm-imenu-action (candidate) + "Default action for `helm-source-imenu'." + (imenu candidate) + ;; If semantic is supported in this buffer + ;; imenu used `semantic-imenu-goto-function' + ;; and position have been highlighted, + ;; no need to highlight again. + (unless (eq imenu-default-goto-function + 'semantic-imenu-goto-function) + (helm-highlight-current-line nil nil nil nil 'pulse))) + +(defun helm-imenu-persistent-action (candidate) + "Default persistent action for `helm-source-imenu'." + (imenu candidate) + (helm-highlight-current-line)) + +(defun helm-imenu-candidates () + (with-helm-current-buffer + (let ((tick (buffer-modified-tick))) + (if (eq helm-cached-imenu-tick tick) + helm-cached-imenu-candidates + (setq imenu--index-alist nil) + (prog1 (setq helm-cached-imenu-candidates + (let ((index (imenu--make-index-alist))) + (helm-imenu--candidates-1 + (delete (assoc "*Rescan*" index) index)))) + (setq helm-cached-imenu-tick tick)))))) + +(defun helm-imenu--candidates-1 (alist) + (cl-loop for elm in alist + append (if (imenu--subalist-p elm) + (helm-imenu--candidates-1 + (cl-loop for (e . v) in (cdr elm) collect + (cons (propertize + e 'helm-imenu-type (car elm)) + v))) + (and (cdr elm) ; bug in imenu, should not be needed. + (list elm))))) + +(defun helm-imenu--get-prop (item) + ;; property value of ITEM can have itself + ;; a property value which have itself a property value + ;; ...and so on; Return a list of all these + ;; properties values starting at ITEM. + (let* ((prop (get-text-property 0 'helm-imenu-type item)) + (lst (list prop item))) + (when prop + (while prop + (setq prop (get-text-property 0 'helm-imenu-type prop)) + (and prop (push prop lst))) + lst))) + +(defun helm-imenu-transformer (candidates) + (cl-loop for (k . v) in candidates + for types = (or (helm-imenu--get-prop k) + (list "Function" k)) + collect + (cons (mapconcat (lambda (x) + (propertize + x 'face (cond ((string= x "Variables") + 'font-lock-variable-name-face) + ((string= x "Function") + 'font-lock-function-name-face) + ((string= x "Types") + 'font-lock-type-face)))) + types helm-imenu-delimiter) + (cons k v)))) + +;;;###autoload +(defun helm-imenu () + "Preconfigured `helm' for `imenu'." + (interactive) + (unless helm-source-imenu + (setq helm-source-imenu + (helm-make-source "Imenu" 'helm-imenu-source + :fuzzy-match helm-imenu-fuzzy-match))) + (let ((imenu-auto-rescan t) + (str (thing-at-point 'symbol)) + (helm-execute-action-at-once-if-one + helm-imenu-execute-action-at-once-if-one)) + (helm :sources 'helm-source-imenu + :default (list (concat "\\_<" str "\\_>") str) + :candidate-number-limit 9999 + :buffer "*helm imenu*"))) + +(provide 'helm-imenu) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-imenu.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-info.el b/emacs.d/elpa/helm-20150507.2215/helm-info.el new file mode 100644 index 0000000..e38e64d --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-info.el @@ -0,0 +1,183 @@ +;;; helm-info.el --- Browse info index with helm -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-plugin) + +(declare-function Info-index-nodes "info" (&optional file)) +(declare-function Info-goto-node "info" (&optional fork)) +(declare-function Info-find-node "info.el" (filename nodename &optional no-going-back)) +(defvar Info-history) + + +(defgroup helm-info nil + "Info related Applications and libraries for Helm." + :group 'helm) + +;;; Build info-index sources with `helm-info-source' class. +;; +;; +(cl-defun helm-info-init (&optional (file (helm-attr 'info-file))) + ;; Allow reinit candidate buffer when using edebug. + (helm-aif (and debug-on-error + (helm-candidate-buffer)) + (kill-buffer it)) + (unless (helm-candidate-buffer) + (save-window-excursion + (info file) + (let ((tobuf (helm-candidate-buffer 'global)) + (infobuf (current-buffer)) + Info-history + start end) + (cl-dolist (node (Info-index-nodes)) + (Info-goto-node node) + (goto-char (point-min)) + (while (search-forward "\n* " nil t) + (unless (search-forward "Menu:\n" (1+ (point-at-eol)) t) + (setq start (point-at-bol) + end (point-at-eol)) + (with-current-buffer tobuf + (insert-buffer-substring infobuf start end) + (insert "\n"))))))))) + +(defun helm-info-goto (node-line) + (Info-goto-node (car node-line)) + (helm-goto-line (cdr node-line))) + +(defun helm-info-display-to-real (line) + (and (string-match + ;; This regexp is stolen from Info-apropos-matches + "\\* +\\([^\n]*.+[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?" line) + (cons (format "(%s)%s" (helm-attr 'info-file) (match-string 2 line)) + (string-to-number (or (match-string 3 line) "1"))))) + +(defclass helm-info-source (helm-source-in-buffer) + ((info-file :initarg :info-file + :initform nil + :custom 'string) + (init :initform #'helm-info-init) + (display-to-real :initform #'helm-info-display-to-real) + (get-line :initform #'buffer-substring) + (action :initform '(("Goto node" . helm-info-goto))))) + +(defmacro helm-build-info-source (fname &rest args) + `(helm-make-source (concat "Info Index: " ,fname) 'helm-info-source + :info-file ,fname ,@args)) + +(defun helm-build-info-index-command (name doc source buffer) + "Define an helm command NAME with documentation DOC. +Arg SOURCE will be an existing helm source named +`helm-source-info-' and BUFFER a string buffer name." + (defalias (intern (concat "helm-info-" name)) + (lambda () + (interactive) + (helm :sources source + :buffer buffer + :candidate-number-limit 1000)) + doc)) + +(defun helm-define-info-index-sources (var-value &optional commands) + "Define helm sources named helm-source-info-. +Sources are generated for all entries of `helm-default-info-index-list'. +If COMMANDS arg is non--nil build also commands named `helm-info'. +Where NAME is one of `helm-default-info-index-list'." + (cl-loop for str in var-value + for sym = (intern (concat "helm-source-info-" str)) + do (set sym (helm-build-info-source str)) + when commands + do (helm-build-info-index-command + str (format "Predefined helm for %s info." str) + sym (format "*helm info %s*" str)))) + +(defun helm-info-index-set (var value) + (set var value) + (helm-define-info-index-sources value t)) + +(defcustom helm-default-info-index-list + '("elisp" "cl" "org" "gnus" "tramp" "ratpoison" + "zsh" "bash" "coreutils" "fileutils" + "find" "sh-utils" "textutils" "libc" + "make" "automake" "autoconf" "eintr" + "emacs" "elib" "eieio" "gauche-refe" "guile" + "guile-tut" "goops" "screen" "latex" "gawk" + "sed" "m4" "wget" "binutils" "as" "bfd" "gprof" + "ld" "diff" "flex" "grep" "gzip" "libtool" + "texinfo" "info" "gdb" "stabs" "cvsbook" "cvs" + "bison" "id-utils" "global") + "Info Manual entries to use for building helm info index commands." + :group 'helm-info + :type '(repeat (choice string)) + :set 'helm-info-index-set) + +(defcustom helm-info-default-sources + '(helm-source-info-elisp + helm-source-info-cl + helm-source-info-eieio + helm-source-info-pages) + "The default sources to use in `helm-info-at-point'." + :group 'helm-info + :type '(repeat (choice symbol))) + + +;;; Info pages +(defvar helm-info--pages-cache nil + "Cache for all info pages on system.") + +(defun helm-info-pages-init () + "Collect candidates for initial Info node Top." + (if helm-info--pages-cache + helm-info--pages-cache + (let ((info-topic-regexp "\\* +\\([^:]+: ([^)]+)[^.]*\\)\\.") + topics) + (require 'info) + (with-temp-buffer + (Info-find-node "dir" "top") + (goto-char (point-min)) + (while (re-search-forward info-topic-regexp nil t) + (push (match-string-no-properties 1) topics)) + (kill-buffer)) + (setq helm-info--pages-cache topics)))) + +(defvar helm-source-info-pages + (helm-build-sync-source "Info Pages" + :init #'helm-info-pages-init + :candidates (lambda () helm-info--pages-cache) + :action '(("Show with Info" .(lambda (node-str) + (info (replace-regexp-in-string + "^[^:]+: " "" node-str))))) + :requires-pattern 2)) + +;;;###autoload +(defun helm-info-at-point () + "Preconfigured `helm' for searching info at point. +With a prefix-arg insert symbol at point." + (interactive) + (helm :sources helm-info-default-sources + :buffer "*helm info*")) + +(provide 'helm-info) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-info.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-locate.el b/emacs.d/elpa/helm-20150507.2215/helm-locate.el new file mode 100644 index 0000000..2c50ea6 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-locate.el @@ -0,0 +1,345 @@ +;;; helm-locate.el --- helm interface for locate. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;; NOTE for WINDOZE users: +;; You have to install Everything with his command line interface here: +;; http://www.voidtools.com/download.php + +;;; Code: + +(require 'cl-lib) +(require 'helm) + + +(defgroup helm-locate nil + "Locate related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-locate-db-file-regexp "m?locate\.db$" + "Default regexp to match locate database. +If nil Search in all files." + :type 'string + :group 'helm-locate) + +(defcustom helm-ff-locate-db-filename "locate.db" + "The basename of the locatedb file you use locally in your directories. +When this is set and `helm' find such a file in the directory from +where you launch locate, it will use this file and will not prompt you +for a db file. +Note that this happen only when locate is launched with a prefix arg." + :group 'helm-locate + :type 'string) + +(defcustom helm-locate-command nil + "A list of arguments for locate program. +Normally you should not have to modify this yourself. + +If nil it will be calculated when `helm-locate' startup +with these default values for different systems: + +Gnu/linux: \"locate %s -e -A %s\" +berkeley-unix: \"locate %s %s\" +windows-nt: \"es %s %s\" +Others: \"locate %s %s\" + +This string will be passed to format so it should end with `%s'. +The first format spec is used for the \"-i\" value of locate/es, +So don't set it directly but use `helm-locate-case-fold-search' +for this. +The \"-r\" option must be the last option, however if not specified you will +be able to specify it during helm invocation by prefixing the pattern +you enter with \"-r\"." + :type 'string + :group 'helm-locate) + +(defcustom helm-locate-create-db-command + "updatedb -l 0 -o %s -U %s" + "Command used to create a locale locate db file." + :type 'string + :group 'helm-locate) + +(defcustom helm-locate-case-fold-search helm-case-fold-search + "It have the same meaning as `helm-case-fold-search'. +The -i option of locate will be used depending of value of +`helm-pattern' when this is set to 'smart. +When nil \"-i\" will not be used at all. +and when non--nil it will always be used. +NOTE: the -i option of the \"es\" command used on windows does +the opposite of \"locate\" command." + :group 'helm-locate + :type 'symbol) + +(defcustom helm-locate-fuzzy-match nil + "Enable fuzzy matching in `helm-locate'." + :group 'helm-locate + :type 'boolean) + + +(defvar helm-generic-files-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-]") 'helm-ff-run-toggle-basename) + (define-key map (kbd "C-s") 'helm-ff-run-grep) + (define-key map (kbd "M-g s") 'helm-ff-run-grep) + (define-key map (kbd "M-g z") 'helm-ff-run-zgrep) + (define-key map (kbd "M-g p") 'helm-ff-run-pdfgrep) + (define-key map (kbd "M-D") 'helm-ff-run-delete-file) + (define-key map (kbd "C-=") 'helm-ff-run-ediff-file) + (define-key map (kbd "C-c =") 'helm-ff-run-ediff-merge-file) + (define-key map (kbd "C-c o") 'helm-ff-run-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-ff-run-switch-other-frame) + (define-key map (kbd "M-i") 'helm-ff-properties-persistent) + (define-key map (kbd "C-c C-x") 'helm-ff-run-open-file-externally) + (define-key map (kbd "C-c X") 'helm-ff-run-open-file-with-default-tool) + (define-key map (kbd "M-.") 'helm-ff-run-etags) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c @") 'helm-ff-run-insert-org-link) + (define-key map (kbd "C-c ?") 'helm-generic-file-help) + map) + "Generic Keymap for files.") + + +(defface helm-locate-finish + '((t (:foreground "Green"))) + "Face used in mode line when locate process is finish." + :group 'helm-locate) + + +(defun helm-ff-find-locatedb (&optional from-ff) + "Try to find if a local locatedb file is available. +The search is done in `helm-ff-default-directory' or +fall back to `default-directory' if FROM-FF is nil." + (when helm-ff-locate-db-filename + (cond ((and helm-ff-default-directory + from-ff + (file-exists-p (expand-file-name + helm-ff-locate-db-filename + helm-ff-default-directory)) + (expand-file-name + helm-ff-locate-db-filename + helm-ff-default-directory))) + ((and (not from-ff) + (file-exists-p (expand-file-name + helm-ff-locate-db-filename + default-directory)) + (expand-file-name + helm-ff-locate-db-filename + default-directory)))))) + +(defun helm-locate-1 (&optional localdb init from-ff default) + "Generic function to run Locate. +Prefix arg LOCALDB when (4) search and use a local locate db file when it +exists or create it, when (16) force update of existing db file +even if exists. +It have no effect when locate command is 'es'. +INIT is a string to use as initial input in prompt. +See `helm-locate-with-db' and `helm-locate'." + (require 'helm-mode) + (helm-locate-set-command) + (let ((pfn #'(lambda (candidate) + (if (file-directory-p candidate) + (message "Error: The locate Db should be a file") + (if (= (shell-command + (format helm-locate-create-db-command + candidate + helm-ff-default-directory)) + 0) + (message "New locatedb file `%s' created" candidate) + (error "Failed to create locatedb file `%s'" candidate))))) + (locdb (and localdb + (not (string-match "^es" helm-locate-command)) + (or (and (equal '(4) localdb) + (helm-ff-find-locatedb from-ff)) + (helm-read-file-name + "Create Locate Db file: " + :initial-input (expand-file-name "locate.db" + (or helm-ff-default-directory + default-directory)) + :preselect helm-locate-db-file-regexp + :test #'(lambda (x) + (if helm-locate-db-file-regexp + ;; Select only locate db files and directories + ;; to allow navigation. + (or (string-match + helm-locate-db-file-regexp x) + (file-directory-p x)) + x))))))) + (when (and locdb (or (equal localdb '(16)) + (not (file-exists-p locdb)))) + (funcall pfn locdb)) + (helm-locate-with-db (and localdb locdb) init default))) + +(defun helm-locate-set-command () + "Setup `helm-locate-command' if not already defined." + (unless helm-locate-command + (setq helm-locate-command + (cl-case system-type + (gnu/linux "locate %s -e -r %s") + (berkeley-unix "locate %s %s") + (windows-nt "es %s %s") + (t "locate %s %s"))))) + +(defvar helm-file-name-history nil) +(defun helm-locate-with-db (&optional db initial-input default) + "Run locate -d DB. +If DB is not given or nil use locate without -d option. +Argument DB can be given as a string or list of db files. +Argument INITIAL-INPUT is a string to use as initial-input. +See also `helm-locate'." + (when (and db (stringp db)) (setq db (list db))) + (helm-locate-set-command) + (let ((helm-ff-transformer-show-only-basename nil) + (helm-locate-command + (if db + (replace-regexp-in-string + "locate" + (format "locate -d %s" + (mapconcat 'identity + ;; Remove eventually + ;; marked directories by error. + (cl-loop for i in db + unless (file-directory-p i) + collect i) ":")) + helm-locate-command) + helm-locate-command))) + (setq helm-file-name-history (mapcar 'helm-basename file-name-history)) + (helm :sources 'helm-source-locate + :buffer "*helm locate*" + :input initial-input + :default default + :history 'helm-file-name-history))) + +(defun helm-locate-init () + "Initialize async locate process for `helm-source-locate'." + (let* ((locate-is-es (string-match "\\`es" helm-locate-command)) + (real-locate (string-match "\\`locate" helm-locate-command)) + (case-sensitive-flag (if locate-is-es "-i" "")) + (ignore-case-flag (if (or locate-is-es + (not real-locate)) "" "-i")) + (args (split-string helm-pattern " ")) + (cmd (format helm-locate-command + (cl-case helm-locate-case-fold-search + (smart (let ((case-fold-search nil)) + (if (string-match "[[:upper:]]" helm-pattern) + case-sensitive-flag + ignore-case-flag))) + (t (if helm-locate-case-fold-search + ignore-case-flag + case-sensitive-flag))) + (concat + ;; The pattern itself. + (shell-quote-argument (car args)) " " + ;; Possible locate args added + ;; after pattern, don't quote them. + (mapconcat 'identity (cdr args) " "))))) + (helm-log "Starting helm-locate process") + (helm-log "Command line used was:\n\n%s" + (concat ">>> " (propertize cmd 'face 'font-lock-comment-face) "\n\n")) + (prog1 + (start-process-shell-command + "locate-process" helm-buffer + cmd) + (set-process-sentinel + (get-buffer-process helm-buffer) + #'(lambda (_process event) + (if (string= event "finished\n") + (with-helm-window + (setq mode-line-format + '(" " mode-line-buffer-identification " " + (:eval (format "L%s" (helm-candidate-number-at-point))) " " + (:eval (propertize + (format "[Locate process finished - (%s results)]" + (max (1- (count-lines + (point-min) (point-max))) + 0)) + 'face 'helm-locate-finish)))) + (force-mode-line-update)) + (helm-log "Error: Locate %s" + (replace-regexp-in-string "\n" "" event)))))))) + +(defclass helm-locate-source (helm-source-async helm-type-file) + ((init :initform 'helm-locate-set-command) + (candidates-process :initform 'helm-locate-init) + (requires-pattern :initform 3) + (history :initform 'helm-file-name-history) + (keymap :initform helm-generic-files-map) + (help-message :initform helm-generic-file-help-message) + (candidate-number-limit :initform 9999) + (mode-line :initform helm-generic-file-mode-line-string))) + +(defvar helm-source-locate + (helm-make-source "Locate" 'helm-locate-source + :pattern-transformer 'helm-locate-pattern-transformer)) + +(defun helm-locate-pattern-transformer (pattern) + (if helm-locate-fuzzy-match + (cond ((string-match + " " (replace-regexp-in-string " -b" "" pattern)) pattern) + ((string-match "\\([^ ]*\\) -b" pattern) + (concat (helm--mapconcat-pattern + (match-string 1 pattern)) " -b")) + (t (helm--mapconcat-pattern pattern))) + pattern)) + +;;;###autoload +(defun helm-locate-read-file-name (prompt) + (let* (helm-ff-transformer-show-only-basename + (src `((name . "Locate read fname") + (init . helm-locate-set-command) + (candidates-process . helm-locate-init) + (action . identity) + (requires-pattern . 3) + (history . ,'helm-file-name-history) + (candidate-transformer . (helm-skip-boring-files + helm-highlight-files)) + (candidate-number-limit . 9999) + (no-matchplugin)))) + (or (helm :sources src + :prompt prompt + :buffer "*helm locate read fname*" + :resume 'noresume) + (keyboard-quit)))) + +;;;###autoload +(defun helm-locate (arg) + "Preconfigured `helm' for Locate. +Note: you can add locate options after entering pattern. +See 'man locate' for valid options and also `helm-locate-command'. + +You can specify a local database with prefix argument ARG. +With two prefix arg, refresh the current local db or create it +if it doesn't exists. +Many databases can be used: navigate and mark them. +See also `helm-locate-with-db'. + +To create a user specific db, use +\"updatedb -l 0 -o db_path -U directory\". +Where db_path is a filename matched by +`helm-locate-db-file-regexp'." + (interactive "P") + (setq helm-ff-default-directory default-directory) + (helm-locate-1 arg)) + +(provide 'helm-locate) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-locate.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-man.el b/emacs.d/elpa/helm-20150507.2215/helm-man.el new file mode 100644 index 0000000..cdf7c2a --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-man.el @@ -0,0 +1,102 @@ +;;; helm-man.el --- Man and woman UI -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) + +(declare-function woman-file-name-all-completions "woman.el" (topic)) +(declare-function Man-getpage-in-background "man.el" (topic)) +(declare-function helm-generic-sort-fn "helm-utils.el" (S1 S2)) + +(defgroup helm-man nil + "Man and Woman applications for helm." + :group 'helm) + +(defcustom helm-man-or-woman-function 'Man-getpage-in-background + "Default command to display a man page." + :group 'helm-man + :type '(radio :tag "Preferred command to display a man page" + (const :tag "Man" Man-getpage-in-background) + (const :tag "Woman" woman))) + +;; Internal +(defvar helm-man-pages nil + "All man pages on system. +Will be calculated the first time you invoke helm with this +source.") + +(defun helm-man-default-action (candidate) + "Default action for jumping to a woman or man page from helm." + (let ((wfiles (mapcar + 'car (woman-file-name-all-completions candidate)))) + (condition-case nil + (if (> (length wfiles) 1) + (let ((file (helm-comp-read + "ManFile: " wfiles :must-match t))) + (if (eq helm-man-or-woman-function 'Man-getpage-in-background) + (manual-entry (format "-l %s" file)) + (woman-find-file file))) + (funcall helm-man-or-woman-function candidate)) + ;; If woman is unable to format correctly + ;; use man instead. + (error (kill-buffer) ; Kill woman buffer. + (Man-getpage-in-background candidate))))) + +(defvar helm-source-man-pages + '((name . "Manual Pages") + (init . (lambda () + (require 'woman) + (require 'helm-utils) + (unless helm-man-pages + (setq helm-man-pages + (ignore-errors + (woman-file-name "" t) + (sort (mapcar 'car woman-topic-all-completions) + 'string-lessp)))) + (helm-init-candidates-in-buffer 'global helm-man-pages))) + (candidates-in-buffer) + (persistent-action . ignore) + (filtered-candidate-transformer + . (lambda (candidates _source) + (sort candidates #'helm-generic-sort-fn))) + (action . (("Display Man page" . helm-man-default-action))) + ;; Woman does not work OS X + ;; http://xahlee.org/emacs/modernization_man_page.html + (action-transformer . (lambda (actions candidate) + (if (eq system-type 'darwin) + '(("Display Man page" . man)) + actions))))) + +;;;###autoload +(defun helm-man-woman (arg) + "Preconfigured `helm' for Man and Woman pages. +With a prefix arg reinitialize the cache." + (interactive "P") + (when arg (setq helm-man-pages nil)) + (helm-other-buffer 'helm-source-man-pages "*Helm man woman*")) + +(provide 'helm-man) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-man.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-match-plugin.el b/emacs.d/elpa/helm-20150507.2215/helm-match-plugin.el new file mode 100644 index 0000000..c95bfb5 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-match-plugin.el @@ -0,0 +1,331 @@ +;;; helm-match-plugin.el --- Multiple regexp matching methods for helm -*- lexical-binding: t -*- + +;; Original Author: rubikitch + +;; Copyright (C) 2008 ~ 2011 rubikitch +;; Copyright (C) 2011 ~ 2015 Thierry Volpiatto + +;; Author: Thierry Volpiatto +;; URL: http://github.com/emacs-helm/helm + +;; 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 . + +;;; Code: + +(require 'helm) +(require 'cl-lib) + + +(defgroup helm-match-plugin nil + "Helm match plugin." + :group 'helm) + +(defcustom helm-mp-matching-method 'multi3 + "Matching method for helm match plugin. +You can set here different methods to match candidates in helm. +Here are the possible value of this symbol and their meaning: +- multi1: Respect order, prefix of pattern must match. +- multi2: Same but with partial match. +- multi3: The best, multiple regexp match, allow negation. +- multi3p: Same but prefix must match. +Default is multi3." + :type '(radio :tag "Matching methods for helm" + (const :tag "Multiple regexp 1 ordered with prefix match" multi1) + (const :tag "Multiple regexp 2 ordered with partial match" multi2) + (const :tag "Multiple regexp 3 matching no order, partial, best." multi3) + (const :tag "Multiple regexp 3p matching with prefix match" multi3p)) + :group 'helm-match-plugin) + + +;; Internal +(defconst helm-mp-default-match-functions + '(helm-mp-exact-match helm-mp-match)) +(defconst helm-mp-default-search-functions + '(helm-mp-exact-search helm-mp-search)) + + +;;; Build regexps +;; +;; +(defvar helm-mp-space-regexp "[\\ ] " + "Regexp to represent space itself in multiple regexp match.") + +(defun helm-mp-split-pattern (pattern) + "Split PATTERN if it contain spaces and return resulting list. +If spaces in PATTERN are escaped, don't split at this place. +i.e \"foo bar\"=> (\"foo\" \"bar\") +but \"foo\ bar\"=> (\"foobar\")." + (if (string= pattern "") + '("") + (cl-loop for s in (split-string + (replace-regexp-in-string helm-mp-space-regexp + "\000\000" pattern) + " " t) + collect (replace-regexp-in-string "\000\000" " " s)))) + +(defun helm-mp-1-make-regexp (pattern) + "Replace spaces in PATTERN with \"\.*\"." + (mapconcat 'identity (helm-mp-split-pattern pattern) ".*")) + + +;;; Exact match. +;; +;; +;; Internal. +(defvar helm-mp-exact-pattern-str nil) +(defvar helm-mp-exact-pattern-real nil) + +(defun helm-mp-exact-get-pattern (pattern) + (unless (equal pattern helm-mp-exact-pattern-str) + (setq helm-mp-exact-pattern-str pattern + helm-mp-exact-pattern-real (concat "\n" pattern "\n"))) + helm-mp-exact-pattern-real) + + +(defun helm-mp-exact-match (str &optional pattern) + (string= str (or pattern helm-pattern))) + +(defun helm-mp-exact-search (pattern &rest _ignore) + (and (search-forward (helm-mp-exact-get-pattern pattern) nil t) + (forward-line -1))) + + +;;; Prefix match +;; +;; +;; Internal +(defvar helm-mp-prefix-pattern-str nil) +(defvar helm-mp-prefix-pattern-real nil) + +(defun helm-mp-prefix-get-pattern (pattern) + (unless (equal pattern helm-mp-prefix-pattern-str) + (setq helm-mp-prefix-pattern-str pattern + helm-mp-prefix-pattern-real (concat "\n" pattern))) + helm-mp-prefix-pattern-real) + +(defun helm-mp-prefix-match (str &optional pattern) + (setq pattern (or pattern helm-pattern)) + (let ((len (length pattern))) + (and (<= len (length str)) + (string= (substring str 0 len) pattern )))) + +(defun helm-mp-prefix-search (pattern &rest _ignore) + (search-forward (helm-mp-prefix-get-pattern pattern) nil t)) + + +;;; Multiple regexp patterns 1 (order is preserved / prefix). +;; +;; +;; Internal +(defvar helm-mp-1-pattern-str nil) +(defvar helm-mp-1-pattern-real nil) + +(defun helm-mp-1-get-pattern (pattern) + (unless (equal pattern helm-mp-1-pattern-str) + (setq helm-mp-1-pattern-str pattern + helm-mp-1-pattern-real + (concat "^" (helm-mp-1-make-regexp pattern)))) + helm-mp-1-pattern-real) + +(cl-defun helm-mp-1-match (str &optional (pattern helm-pattern)) + (string-match (helm-mp-1-get-pattern pattern) str)) + +(defun helm-mp-1-search (pattern &rest _ignore) + (re-search-forward (helm-mp-1-get-pattern pattern) nil t)) + + +;;; Multiple regexp patterns 2 (order is preserved / partial). +;; +;; +;; Internal +(defvar helm-mp-2-pattern-str nil) +(defvar helm-mp-2-pattern-real nil) + +(defun helm-mp-2-get-pattern (pattern) + (unless (equal pattern helm-mp-2-pattern-str) + (setq helm-mp-2-pattern-str pattern + helm-mp-2-pattern-real + (concat "^.*" (helm-mp-1-make-regexp pattern)))) + helm-mp-2-pattern-real) + +(cl-defun helm-mp-2-match (str &optional (pattern helm-pattern)) + (string-match (helm-mp-2-get-pattern pattern) str)) + +(defun helm-mp-2-search (pattern &rest _ignore) + (re-search-forward (helm-mp-2-get-pattern pattern) nil t)) + + +;;; Multiple regexp patterns 3 (permutation). +;; +;; +;; Internal +(defvar helm-mp-3-pattern-str nil) +(defvar helm-mp-3-pattern-list nil) + +(defun helm-mp-3-get-patterns (pattern) + "Return `helm-mp-3-pattern-list', a list of predicate/regexp cons cells. +e.g ((identity . \"foo\") (identity . \"bar\")). +This is done only if `helm-mp-3-pattern-str' is same as PATTERN." + (unless (equal pattern helm-mp-3-pattern-str) + (setq helm-mp-3-pattern-str pattern + helm-mp-3-pattern-list + (helm-mp-3-get-patterns-internal pattern))) + helm-mp-3-pattern-list) + +(defun helm-mp-3-get-patterns-internal (pattern) + "Return a list of predicate/regexp cons cells. +e.g ((identity . \"foo\") (identity . \"bar\"))." + (unless (string= pattern "") + (cl-loop for pat in (helm-mp-split-pattern pattern) + collect (if (string= "!" (substring pat 0 1)) + (cons 'not (substring pat 1)) + (cons 'identity pat))))) + +(cl-defun helm-mp-3-match (str &optional (pattern helm-pattern)) + "Check if PATTERN match STR. +When PATTERN contain a space, it is splitted and matching is done +with the several resulting regexps against STR. +e.g \"bar foo\" will match \"foobar\" and \"barfoo\". +Argument PATTERN, a string, is transformed in a list of +cons cell with `helm-mp-3-get-patterns' if it contain a space. +e.g \"foo bar\"=>((identity . \"foo\") (identity . \"bar\")). +Then each predicate of cons cell(s) is called with regexp of same +cons cell against STR (a candidate). +i.e (identity (string-match \"foo\" \"foo bar\")) => t." + (let ((pat (helm-mp-3-get-patterns pattern))) + (cl-loop for (predicate . regexp) in pat + always (funcall predicate + (condition-case _err + ;; FIXME: Probably do nothing when + ;; using fuzzy leaving the job + ;; to the fuzzy fn. + (string-match regexp str) + (invalid-regexp nil)))))) + +(defun helm-mp-3-search-base (pattern searchfn1 searchfn2) + "Try to find PATTERN in `helm-buffer' with SEARCHFN1 and SEARCHFN2. +This is the search function for `candidates-in-buffer' enabled sources. +Use the same method as `helm-mp-3-match' except it search in buffer +instead of matching on a string. +i.e (identity (re-search-forward \"foo\" (point-at-eol) t)) => t." + (cl-loop with pat = (if (stringp pattern) + (helm-mp-3-get-patterns pattern) + pattern) + when (eq (caar pat) 'not) return + ;; Pass the job to `helm-search-match-part'. + (prog1 (list (point-at-bol) (point-at-eol)) + (forward-line 1)) + while (condition-case _err + (funcall searchfn1 (or (cdar pat) "") nil t) + (invalid-regexp nil)) + for bol = (point-at-bol) + for eol = (point-at-eol) + if (cl-loop for (pred . str) in (cdr pat) always + (progn (goto-char bol) + (funcall pred (condition-case _err + (funcall searchfn2 str eol t) + (invalid-regexp nil))))) + do (goto-char eol) and return t + else do (goto-char eol) + finally return nil)) + +(defun helm-mp-3-search (pattern &rest _ignore) + (when (stringp pattern) + (setq pattern (helm-mp-3-get-patterns pattern))) + (helm-mp-3-search-base + pattern 're-search-forward 're-search-forward)) + + +;;; mp-3p- (multiple regexp pattern 3 with prefix search) +;; +;; +(defun helm-mp-3p-match (str &optional pattern) + "Check if PATTERN match STR. +Same as `helm-mp-3-match' but more strict, matching against prefix also. +e.g \"bar foo\" will match \"barfoo\" but not \"foobar\" contrarily to +`helm-mp-3-match'." + (let* ((pat (helm-mp-3-get-patterns (or pattern helm-pattern))) + (first (car pat))) + (and (funcall (car first) (helm-mp-prefix-match str (cdr first))) + (cl-loop for (predicate . regexp) in (cdr pat) + always (funcall predicate (string-match regexp str)))))) + +(defun helm-mp-3p-search (pattern &rest _ignore) + (when (stringp pattern) + (setq pattern (helm-mp-3-get-patterns pattern))) + (helm-mp-3-search-base + pattern 'helm-mp-prefix-search 're-search-forward)) + + +;;; Generic multi-match/search functions +;; +;; +(cl-defun helm-mp-match (str &optional (pattern helm-pattern)) + (let ((fun (cl-ecase helm-mp-matching-method + (multi1 #'helm-mp-1-match) + (multi2 #'helm-mp-2-match) + (multi3 #'helm-mp-3-match) + (multi3p #'helm-mp-3p-match)))) + (funcall fun str pattern))) + +(defun helm-mp-search (pattern &rest _ignore) + (let ((fun (cl-ecase helm-mp-matching-method + (multi1 #'helm-mp-1-search) + (multi2 #'helm-mp-2-search) + (multi3 #'helm-mp-3-search) + (multi3p #'helm-mp-3p-search)))) + (funcall fun pattern))) + + +;;; source compiler +;; This is used only in old sources defined without helm-source. +;; +(defun helm-compile-source--match-plugin (source) + (if (assoc 'no-matchplugin source) + source + (let* ((searchers helm-mp-default-search-functions) + (defmatch (helm-aif (assoc-default 'match source) + (helm-mklist it))) + (defmatch-strict (helm-aif (assoc-default 'match-strict source) + (helm-mklist it))) + (defsearch (helm-aif (assoc-default 'search source) + (helm-mklist it))) + (defsearch-strict (helm-aif (assoc-default 'search-strict source) + (helm-mklist it))) + (matchfns (cond (defmatch-strict) + (defmatch + (append helm-mp-default-match-functions defmatch)) + (t helm-mp-default-match-functions))) + (searchfns (cond (defsearch-strict) + (defsearch + (append searchers defsearch)) + (t searchers)))) + `(,(if (assoc 'candidates-in-buffer source) + `(search ,@searchfns) `(match ,@matchfns)) + ,@source)))) + + +;; Enable match-plugin by default in old sources. +(add-to-list 'helm-compile-source-functions 'helm-compile-source--match-plugin) + +(provide 'helm-match-plugin) + + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-match-plugin.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-misc.el b/emacs.d/elpa/helm-20150507.2215/helm-misc.el new file mode 100644 index 0000000..88fee5f --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-misc.el @@ -0,0 +1,330 @@ +;;; helm-misc.el --- Various functions for helm -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) + + +(defgroup helm-misc nil + "Various Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-time-zone-home-location "Paris" + "The time zone of your home" + :group 'helm-misc + :type 'string) + +(defcustom helm-mini-default-sources '(helm-source-buffers-list + helm-source-recentf + helm-source-buffer-not-found) + "Default sources list used in `helm-mini'." + :group 'helm-misc + :type '(repeat (choice symbol))) + +(defface helm-time-zone-current + '((t (:foreground "green"))) + "Face used to colorize current time in `helm-world-time'." + :group 'helm-misc) + +(defface helm-time-zone-home + '((t (:foreground "red"))) + "Face used to colorize home time in `helm-world-time'." + :group 'helm-misc) + + +;;; Latex completion +(defvar LaTeX-math-menu) +(defun helm-latex-math-candidates () + "Collect candidates for latex math completion." + (cl-loop for i in (cddr LaTeX-math-menu) + for elm = (cl-loop for s in i when (vectorp s) + collect (cons (aref s 0) (aref s 1))) + append elm)) + +(defvar helm-source-latex-math + '((name . "Latex Math Menu") + (init . (lambda () + (with-helm-current-buffer + (LaTeX-math-mode 1)))) + (candidate-number-limit . 9999) + (candidates . helm-latex-math-candidates) + (action . (lambda (candidate) + (call-interactively candidate))))) + + +;;; Jabber Contacts (jabber.el) +(defun helm-jabber-online-contacts () + "List online Jabber contacts." + (with-no-warnings + (cl-loop for item in (jabber-concat-rosters) + when (get item 'connected) + collect + (if (get item 'name) + (cons (get item 'name) item) + (cons (symbol-name item) item))))) + +(defvar helm-source-jabber-contacts + '((name . "Jabber Contacts") + (init . (lambda () (require 'jabber))) + (candidates . (lambda () (mapcar 'car (helm-jabber-online-contacts)))) + (action . (lambda (x) + (jabber-chat-with + (jabber-read-account) + (symbol-name + (cdr (assoc x (helm-jabber-online-contacts))))))))) + +;;; World time +;; +(defun helm-time-zone-transformer (candidates _source) + (cl-loop for i in candidates + collect + (cond ((string-match (format-time-string "%H:%M" (current-time)) i) + (propertize i 'face 'helm-time-zone-current)) + ((string-match helm-time-zone-home-location i) + (propertize i 'face 'helm-time-zone-home)) + (t i)))) + +(defvar helm-source-time-world + '((name . "Time World List") + (init . (lambda () + (require 'time) + (let ((helm-buffer (helm-candidate-buffer 'global))) + (with-current-buffer helm-buffer + (display-time-world-display display-time-world-list))))) + (candidates-in-buffer) + (filtered-candidate-transformer . helm-time-zone-transformer))) + +;;; LaCarte +;; +;; +(declare-function lacarte-get-overall-menu-item-alist "ext:lacarte.el" (&optional MAPS)) + +(defun helm-lacarte-candidate-transformer (cands) + (mapcar (lambda (cand) + (let* ((item (car cand)) + (match (string-match "[^>] \\((.*)\\)$" item))) + (when match + (put-text-property (match-beginning 1) (match-end 1) + 'face 'helm-M-x-key item)) + cand)) + cands)) + +(defclass helm-lacarte (helm-source-sync helm-type-command) + ((init :initform (lambda () (require 'lacarte))) + (candidates :initform 'helm-lacarte-get-candidates) + (candidate-transformer :initform 'helm-lacarte-candidate-transformer) + (candidate-number-limit :initform 9999))) + +(defun helm-lacarte-get-candidates (&optional maps) + "Extract candidates for menubar using lacarte.el. +See http://www.emacswiki.org/cgi-bin/wiki/download/lacarte.el. +Optional argument MAPS is a list specifying which keymaps to use: it +can contain the symbols `local', `global', and `minor', mean the +current local map, current global map, and all current minor maps." + (with-helm-current-buffer + ;; FIXME: do we still need to remove possible '(nil) candidates. + (lacarte-get-overall-menu-item-alist maps))) + +;;;###autoload +(defun helm-browse-menubar () + "Helm interface to the menubar using lacarte.el." + (interactive) + (require 'lacarte) + (helm :sources (mapcar + (lambda (spec) (helm-make-source (car spec) 'helm-lacarte + :candidates (lambda () (helm-lacarte-get-candidates (cdr spec))))) + '(("Major Mode" . (local)) + ("Minor Modes" . (minor)) + ("Global Map" . (global)))) + :buffer "*helm lacarte*")) + +(defun helm-call-interactively (cmd-or-name) + "Execute CMD-OR-NAME as Emacs command. +It is added to `extended-command-history'. +`helm-current-prefix-arg' is used as the command's prefix argument." + (setq extended-command-history + (cons (helm-stringify cmd-or-name) + (delete (helm-stringify cmd-or-name) extended-command-history))) + (let ((current-prefix-arg helm-current-prefix-arg) + (cmd (helm-symbolify cmd-or-name))) + (if (stringp (symbol-function cmd)) + (execute-kbd-macro (symbol-function cmd)) + (setq this-command cmd) + (call-interactively cmd)))) + +;;; Minibuffer History +;; +;; +(defvar helm-source-minibuffer-history + (helm-build-sync-source "Minibuffer History" + :header-name (lambda (name) + (format "%s (%s)" name minibuffer-history-variable)) + :candidates + (lambda () + (let ((history (cl-loop for i in + (symbol-value minibuffer-history-variable) + unless (string= "" i) collect i))) + (if (consp (car history)) + (mapcar 'prin1-to-string history) + history))) + :migemo t + :multiline t + :action (lambda (candidate) + (delete-minibuffer-contents) + (insert candidate)))) + +;;; Shell history +;; +;; +(defun helm-comint-input-ring-action (candidate) + "Default action for comint history." + (with-helm-current-buffer + (delete-region (comint-line-beginning-position) (point-max)) + (insert candidate))) + +(defvar helm-source-comint-input-ring + '((name . "Comint history") + (candidates . (lambda () + (with-helm-current-buffer + (ring-elements comint-input-ring)))) + (action . helm-comint-input-ring-action)) + "Source that provide helm completion against `comint-input-ring'.") + + +;;; Helm ratpoison UI +;; +;; +(defvar helm-source-ratpoison-commands + '((name . "Ratpoison Commands") + (init . helm-ratpoison-commands-init) + (candidates-in-buffer) + (action ("Execute the command" . helm-ratpoison-commands-execute)) + (display-to-real . helm-ratpoison-commands-display-to-real) + (candidate-number-limit))) + +(defun helm-ratpoison-commands-init () + (unless (helm-candidate-buffer) + (with-current-buffer (helm-candidate-buffer 'global) + ;; with ratpoison prefix key + (save-excursion + (call-process "ratpoison" nil (current-buffer) nil "-c" "help")) + (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t) + (replace-match " \\1: \\2")) + (goto-char (point-max)) + ;; direct binding + (save-excursion + (call-process "ratpoison" nil (current-buffer) nil "-c" "help top")) + (while (re-search-forward "^\\([^ ]+\\) \\(.+\\)$" nil t) + (replace-match "\\1: \\2"))))) + +(defun helm-ratpoison-commands-display-to-real (display) + (and (string-match ": " display) + (substring display (match-end 0)))) + +(defun helm-ratpoison-commands-execute (candidate) + (call-process "ratpoison" nil nil nil "-ic" candidate)) + +;;; Helm stumpwm UI +;; +;; +(defvar helm-source-stumpwm-commands + '((name . "Stumpwm Commands") + (init . helm-stumpwm-commands-init) + (candidates-in-buffer) + (action ("Execute the command" . helm-stumpwm-commands-execute)) + (candidate-number-limit))) + +(defun helm-stumpwm-commands-init () + (with-current-buffer (helm-candidate-buffer 'global) + (save-excursion + (call-process "stumpish" nil (current-buffer) nil "commands")) + (while (re-search-forward "[ ]*\\([^ ]+\\)[ ]*\n?" nil t) + (replace-match "\n\\1\n")) + (delete-blank-lines) + (sort-lines nil (point-min) (point-max)) + (goto-char (point-max)))) + +(defun helm-stumpwm-commands-execute (candidate) + (call-process "stumpish" nil nil nil candidate)) + +;;;###autoload +(defun helm-world-time () + "Preconfigured `helm' to show world time." + (interactive) + (helm-other-buffer 'helm-source-time-world "*helm world time*")) + +;;;###autoload +(defun helm-insert-latex-math () + "Preconfigured helm for latex math symbols completion." + (interactive) + (helm-other-buffer 'helm-source-latex-math "*helm latex*")) + +;;;###autoload +(defun helm-ratpoison-commands () + "Preconfigured `helm' to execute ratpoison commands." + (interactive) + (helm-other-buffer 'helm-source-ratpoison-commands + "*helm ratpoison commands*")) + +;;;###autoload +(defun helm-stumpwm-commands() + (interactive) + (helm-other-buffer 'helm-source-stumpwm-commands + "*helm stumpwm commands*")) + +;;;###autoload +(defun helm-mini () + "Preconfigured `helm' lightweight version \(buffer -> recentf\)." + (interactive) + (require 'helm-files) + (unless helm-source-buffers-list + (setq helm-source-buffers-list + (helm-make-source "Buffers" 'helm-source-buffers))) + (let ((helm-ff-transformer-show-only-basename nil)) + (helm :sources helm-mini-default-sources + :buffer "*helm mini*" + :truncate-lines t))) + +;;;###autoload +(defun helm-minibuffer-history () + "Preconfigured `helm' for `minibuffer-history'." + (interactive) + (let ((enable-recursive-minibuffers t)) + (helm :sources 'helm-source-minibuffer-history + :buffer "*helm minibuffer-history*"))) + +;;;###autoload +(defun helm-comint-input-ring () + "Predefined `helm' that provide completion of `comint' history." + (interactive) + (when (derived-mode-p 'comint-mode) + (helm :sources 'helm-source-comint-input-ring + :input (buffer-substring-no-properties (comint-line-beginning-position) + (point-at-eol)) + :buffer "*helm comint history*"))) + + +(provide 'helm-misc) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-misc.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-mode.el b/emacs.d/elpa/helm-20150507.2215/helm-mode.el new file mode 100644 index 0000000..4dc44f7 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-mode.el @@ -0,0 +1,1132 @@ +;;; helm-mode.el --- Enable helm completion everywhere. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-files) + + +(defgroup helm-mode nil + "Enable helm completion." + :group 'helm) + +(defcustom helm-completing-read-handlers-alist + '((describe-function . helm-completing-read-symbols) + (describe-variable . helm-completing-read-symbols) + (debug-on-entry . helm-completing-read-symbols) + (find-function . helm-completing-read-symbols) + (trace-function . helm-completing-read-symbols) + (trace-function-foreground . helm-completing-read-symbols) + (trace-function-background . helm-completing-read-symbols) + (find-tag . helm-completing-read-with-cands-in-buffer) + (ffap-alternate-file . nil) + (tmm-menubar . nil)) + "Alist of handlers to replace `completing-read', `read-file-name' in `helm-mode'. +Each entry is a cons cell like \(emacs_command . completing-read_handler\) +where key and value are symbols. + +Each key is an Emacs command that use originaly `completing-read'. + +Each value maybe an helm function that take same arguments as +`completing-read' plus NAME and BUFFER, where NAME is the name of the new +helm source and BUFFER the name of the buffer we will use. +This function prefix name must start by \"helm\". + +See `helm-completing-read-symbols' for example. + +Note that this function will be reused for ALL the `completing-read' +of this command, so it should handle all cases, e.g +If first `completing-read' complete against symbols and +second `completing-read' should handle only buffer, +your specialized function should handle the both. + +If the value of an entry is nil completion will fall back to +emacs vanilla behavior. +e.g If you want to disable helm completion for `describe-function': +\(describe-function . nil\). + +Ido is also supported, you can use `ido-completing-read' and +`ido-read-file-name' as value of an entry or just 'ido. +e.g ido completion for `find-file': +\(find-file . ido\) +same as +\(find-file . ido-read-file-name\) +Note that you don't need to enable `ido-mode' for this to work." + :group 'helm-mode + :type '(alist :key-type symbol :value-type symbol)) + +(defcustom helm-comp-read-case-fold-search helm-case-fold-search + "Default Local setting of `helm-case-fold-search' for `helm-comp-read'. +See `helm-case-fold-search' for more info." + :group 'helm-mode + :type 'symbol) + +(defcustom helm-mode-handle-completion-in-region t + "Whether to replace or not `completion-in-region-function'. +This enable support for `completing-read-multiple' and `completion-at-point' +when non--nil." + :group 'helm-mode + :type 'boolean) + +(defcustom helm-mode-reverse-history t + "Display history source after current source in `helm-mode' handled commands." + :group 'helm-mode + :type 'boolean) + +(defcustom helm-mode-no-completion-in-region-in-modes nil + "A list of modes that do not want helm for `completion-in-region'." + :group 'helm-mode + :type 'boolean) + +(defcustom helm-completion-in-region-fuzzy-match nil + "Whether `helm-completion-in-region' use fuzzy matching or not. +Affect among others `completion-at-point', `completing-read-multiple'." + :group 'helm-mode + :type 'boolean) + + +(defvar helm-comp-read-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "") 'helm-cr-empty-string) + (define-key map (kbd "") 'helm-cr-empty-string) + map) + "Keymap for `helm-comp-read'.") + + +;;; Internal +;; +;; +;; Flag to know if `helm-pattern' have been added +;; to candidate list in `helm-comp-read'. +(defvar helm-cr-unknown-pattern-flag nil) + + +;;; Helm `completing-read' replacement +;; +;; +(defun helm-cr-empty-string () + "Return empty string." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action + #'(lambda (_candidate) + (identity ""))))) + +(defun helm-mode--keyboard-quit () + ;; Use this instead of `keyboard-quit' + ;; to avoid deactivating mark in current-buffer. + (let ((debug-on-quit nil)) + (signal 'quit nil))) + +(defun helm-comp-read-get-candidates (collection &optional test sort-fn alistp) + "Convert COLLECTION to list removing elements that don't match TEST. +See `helm-comp-read' about supported COLLECTION arguments. + +SORT-FN is a predicate to sort COLLECTION. + +ALISTP when non--nil will not use `all-completions' to collect +candidates because it doesn't handle alists correctly for helm. +i.e In `all-completions' the car of each pair is used as value. +In helm we want to use the cdr instead like \(display . real\), +so we return the alist as it is with no transformation by all-completions. + +e.g + +\(setq A '((a . 1) (b . 2) (c . 3))) +==>((a . 1) (b . 2) (c . 3)) +\(helm-comp-read \"test: \" A :alistp nil + :exec-when-only-one t + :initial-input \"a\") +==>\"a\" Which is not what we expect. + +\(helm-comp-read \"test: \" A :alistp t + :exec-when-only-one t + :initial-input \"1\") +==>\"1\" + +See docstring of `all-completions' for more info. + +If COLLECTION is an `obarray', a TEST should be needed. See `obarray'." + + (let ((cands + (cond ((vectorp collection) + (all-completions "" collection test)) + ((and (symbolp collection) (boundp collection) + ;; Issue #324 history is let-bounded and given + ;; quoted as hist argument of completing-read. + ;; See example in `rcirc-browse-url'. + (symbolp (symbol-value collection))) + nil) + ;; When collection is a symbol, most of the time + ;; it should be a symbol used as a minibuffer-history. + ;; The value of this symbol in this case return a list + ;; of string which maybe are converted later as symbol + ;; in special cases. + ;; we treat here commandp as a special case as it return t + ;; also with a string unless its last arg is provided. + ;; Also, the history collections generally collect their + ;; elements as string, so intern them to call predicate. + ((and (symbolp collection) (boundp collection) test) + (let ((predicate `(lambda (elm) + (condition-case err + (if (eq (quote ,test) 'commandp) + (funcall (quote ,test) (intern elm)) + (funcall (quote ,test) elm)) + (wrong-type-argument + (funcall (quote ,test) (intern elm))))))) + (all-completions "" (symbol-value collection) predicate))) + ((and (symbolp collection) (boundp collection)) + (all-completions "" (symbol-value collection))) + ;; Normally file completion should not be handled here, + ;; but special cases like `find-file-at-point' do it. + ;; Handle here specially such cases. + ((and (functionp collection) minibuffer-completing-file-name) + (cl-loop for f in (funcall collection helm-pattern test t) + unless (member f '("./" "../")) + if (string-match ffap-url-regexp helm-pattern) + collect f + else + collect (concat (file-name-as-directory + (helm-basedir helm-pattern)) f))) + ((functionp collection) + (funcall collection "" test t)) + ((and alistp test) + (cl-loop for i in collection when (funcall test i) collect i)) + (alistp collection) + (t (all-completions "" collection test))))) + (if sort-fn (sort cands sort-fn) cands))) + +(defun helm-cr-default-transformer (candidates _source) + "Default filter candidate function for `helm-comp-read'." + (cl-loop for c in candidates + for cand = (if (stringp c) (replace-regexp-in-string "\\s\\" "" c) c) + for pat = (replace-regexp-in-string "\\s\\" "" helm-pattern) + if (and (equal cand pat) helm-cr-unknown-pattern-flag) + collect + (cons (concat (propertize + " " 'display + (propertize "[?]" 'face 'helm-ff-prefix)) + c) + c) + into lst + else collect (if (and (stringp c) + (string-match "\n" c)) + (cons (replace-regexp-in-string "\n" "->" c) c) + c) + into lst + finally return (helm-fast-remove-dups lst :test 'equal))) + +(defun helm-comp-read--move-to-first-real-candidate () + (helm-aif (helm-get-selection nil 'withprop) + (when (string= (get-text-property 0 'display it) "[?]") + (helm-next-line)))) + +;;;###autoload +(cl-defun helm-comp-read (prompt collection + &key + test + initial-input + default + preselect + (buffer "*Helm Completions*") + must-match + fuzzy + reverse-history + (requires-pattern 0) + history + input-history + (case-fold helm-comp-read-case-fold-search) + (del-input t) + (persistent-action nil) + (persistent-help "DoNothing") + (mode-line helm-comp-read-mode-line) + (keymap helm-comp-read-map) + (name "Helm Completions") + candidates-in-buffer + exec-when-only-one + quit-when-no-cand + (volatile t) + sort + (fc-transformer 'helm-cr-default-transformer) + hist-fc-transformer + marked-candidates + nomark + (alistp t)) + "Read a string in the minibuffer, with helm completion. + +It is helm `completing-read' equivalent. + +- PROMPT is the prompt name to use. + +- COLLECTION can be a list, vector, obarray or hash-table. + It can be also a function that receives three arguments: + the values string, predicate and t. See `all-completions' for more details. + +Keys description: + +- TEST: A predicate called with one arg i.e candidate. + +- INITIAL-INPUT: Same as input arg in `helm'. + +- PRESELECT: See preselect arg of `helm'. + +- DEFAULT: This option is used only for compatibility with regular + Emacs `completing-read' (Same as DEFAULT arg of `completing-read'). + +- BUFFER: Name of helm-buffer. + +- MUST-MATCH: Candidate selected must be one of COLLECTION. + +- REVERSE-HISTORY: When non--nil display history source after current + source completion. + +- REQUIRES-PATTERN: Same as helm attribute, default is 0. + +- HISTORY: A list containing specific history, default is nil. + When it is non--nil, all elements of HISTORY are displayed in + a special source before COLLECTION. + +- INPUT-HISTORY: A symbol. the minibuffer input history will be + stored there, if nil or not provided, `minibuffer-history' + will be used instead. + +- CASE-FOLD: Same as `helm-case-fold-search'. + +- DEL-INPUT: Boolean, when non--nil (default) remove the partial + minibuffer input from HISTORY is present. + +- PERSISTENT-ACTION: A function called with one arg i.e candidate. + +- PERSISTENT-HELP: A string to document PERSISTENT-ACTION. + +- MODE-LINE: A string or list to display in mode line. + Default is `helm-comp-read-mode-line'. + +- KEYMAP: A keymap to use in this `helm-comp-read'. + (the keymap will be shared with history source) + +- NAME: The name related to this local source. + +- EXEC-WHEN-ONLY-ONE: Bound `helm-execute-action-at-once-if-one' + to non--nil. (possibles values are t or nil). + +- VOLATILE: Use volatile attribute \(enabled by default\). + +- SORT: A predicate to give to `sort' e.g `string-lessp'. + +- FC-TRANSFORMER: A `filtered-candidate-transformer' function. + +- HIST-FC-TRANSFORMER: A `filtered-candidate-transformer' + function for the history source. + +- MARKED-CANDIDATES: If non--nil return candidate or marked candidates as a list. + +- NOMARK: When non--nil don't allow marking candidates. + +- ALISTP: \(default is non--nil\) See `helm-comp-read-get-candidates'. + +- CANDIDATES-IN-BUFFER: when non--nil use a source build with + `helm-candidates-in-buffer' which is much faster. + Argument VOLATILE have no effect when CANDIDATES-IN-BUFFER is non--nil. + +Any prefix args passed during `helm-comp-read' invocation will be recorded +in `helm-current-prefix-arg', otherwise if prefix args were given before +`helm-comp-read' invocation, the value of `current-prefix-arg' will be used. +That's mean you can pass prefix args before or after calling a command +that use `helm-comp-read' See `helm-M-x' for example." + + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + (let ((action-fn `(("Sole action (Identity)" + . (lambda (candidate) + (if ,marked-candidates + (helm-marked-candidates) + (identity candidate))))))) + ;; Assume completion have been already required, + ;; so always use 'confirm. + (when (eq must-match 'confirm-after-completion) + (setq must-match 'confirm)) + (let* ((minibuffer-completion-confirm must-match) + (must-match-map (when must-match + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") + 'helm-confirm-and-exit-minibuffer) + map))) + (loc-map (if must-match-map + (make-composed-keymap + must-match-map (or keymap helm-map)) + (or keymap helm-map))) + (minibuffer-completion-predicate test) + (minibuffer-completion-table collection) + (helm-read-file-name-mode-line-string + (replace-regexp-in-string "helm-maybe-exit-minibuffer" + "helm-confirm-and-exit-minibuffer" + helm-read-file-name-mode-line-string)) + (get-candidates (lambda () + (let ((cands (helm-comp-read-get-candidates + collection test sort alistp))) + (setq helm-cr-unknown-pattern-flag nil) + (unless (or (eq must-match t) + (string= helm-pattern "") + (assoc helm-pattern cands) + (assoc (intern helm-pattern) cands) + (member helm-pattern cands)) + (setq cands (append (list + ;; Unquote helm-pattern + ;; when it is added + ;; as candidate. + (replace-regexp-in-string + "\\s\\" "" helm-pattern)) + cands)) + (setq helm-cr-unknown-pattern-flag t)) + (if (and default (not (string= default ""))) + (delq nil (cons default (delete default cands))) + cands)))) + (history-get-candidates (lambda () + (let ((all (helm-comp-read-get-candidates + history test nil alistp))) + (when all + (delete + "" + (helm-fast-remove-dups + (if (and default (not (string= default ""))) + (delq nil (cons default + (delete default all))) + all) + :test 'equal)))))) + (src-hist (helm-build-sync-source (format "%s History" name) + :candidates history-get-candidates + :fuzzy-match fuzzy + :filtered-candidate-transformer + (append '((lambda (candidates sources) + (cl-loop for i in candidates + ;; Input is added to history in completing-read's + ;; and may be regexp-quoted, so unquote it. + for cand = (replace-regexp-in-string "\\s\\" "" i) + collect cand))) + (and hist-fc-transformer (helm-mklist hist-fc-transformer))) + :persistent-action persistent-action + :persistent-help persistent-help + :mode-line mode-line + :action action-fn)) + (src (helm-build-sync-source name + :candidates get-candidates + :filtered-candidate-transformer fc-transformer + :requires-pattern requires-pattern + :persistent-action persistent-action + :persistent-help persistent-help + :fuzzy-match fuzzy + :mode-line mode-line + :action action-fn)) + (src-1 (helm-build-in-buffer-source name + :data get-candidates + :filtered-candidate-transformer fc-transformer + :requires-pattern requires-pattern + :persistent-action persistent-action + :fuzzy-match fuzzy + :persistent-help persistent-help + :mode-line mode-line + :action action-fn)) + (src-list (list src-hist + (if candidates-in-buffer + src-1 + (if volatile + (append src '((volatile))) + src)))) + (helm-execute-action-at-once-if-one exec-when-only-one) + (helm-quit-if-no-candidate quit-when-no-cand) + result) + (when nomark + (setq src-list (cl-loop for src in src-list + collect (cons '(nomark) src)))) + (when reverse-history (setq src-list (nreverse src-list))) + (add-hook 'helm-after-update-hook 'helm-comp-read--move-to-first-real-candidate) + (unwind-protect + (setq result (helm + :sources src-list + :input initial-input + :default default + :preselect preselect + :prompt prompt + :resume 'noresume + :case-fold-search case-fold + :keymap loc-map + :history (and (symbolp input-history) input-history) + :buffer buffer)) + (remove-hook 'helm-after-update-hook 'helm-comp-read--move-to-first-real-candidate)) + ;; Avoid adding an incomplete input to history. + (when (and result history del-input) + (cond ((and (symbolp history) ; History is a symbol. + (not (symbolp (symbol-value history)))) ; Fix Issue #324. + ;; Be sure history is not a symbol with a nil value. + (helm-aif (symbol-value history) (setcar it result))) + ((consp history) ; A list with a non--nil value. + (setcar history result)) + (t ; Possibly a symbol with a nil value. + (set history (list result))))) + (or + result + (when (and (eq helm-exit-status 0) + (eq must-match 'confirm)) + ;; Return empty string only if it is the DEFAULT + ;; value and helm-pattern is empty. + ;; otherwise return helm-pattern + (if (and (string= helm-pattern "") default) + default (identity helm-pattern))) + (unless (or (eq helm-exit-status 1) + must-match) ; FIXME this should not be needed now. + default) + (helm-mode--keyboard-quit))))) + +;; Generic completing-read +;; +;; Support also function as collection. +;; e.g M-x man is supported. +;; Support hash-table and vectors as collection. +;; NOTE: +;; Some crap emacs functions may not be supported +;; like ffap-alternate-file (bad use of completing-read) +;; and maybe others. +;; Provide a mode `helm-mode' which turn on +;; helm in all `completing-read' and `read-file-name' in Emacs. +;; +(defvar helm-completion-mode-string " Helm") + +(defvar helm-completion-mode-quit-message + "Helm completion disabled") + +(defvar helm-completion-mode-start-message + "Helm completion enabled") + +;;; Specialized handlers +;; +;; +(defun helm-completing-read-symbols + (prompt _collection test _require-match init + hist default _inherit-input-method name buffer) + "Specialized function for fast symbols completion in `helm-mode'." + (or + (helm + :sources (helm-build-in-buffer-source name + :init (lambda () + (require 'helm-elisp) + (helm-apropos-init (lambda (x) + (and (funcall test x) + (not (keywordp x)))) + (or (car-safe default) default))) + :filtered-candidate-transformer 'helm-apropos-default-sort-fn + :persistent-action 'helm-lisp-completion-persistent-action + :persistent-help "Show brief doc in mode-line") + :prompt prompt + :buffer buffer + :input init + :history hist + :resume 'noresume + :default (or default "")) + (helm-mode--keyboard-quit))) + + +;;; Generic completing read +;; +;; +(defun helm-completing-read-default-1 + (prompt collection test require-match + init hist default _inherit-input-method + name buffer &optional cands-in-buffer exec-when-only-one) + "Call `helm-comp-read' with same args as `completing-read'. +Extra optional arg CANDS-IN-BUFFER mean use `candidates-in-buffer' +method which is faster. +It should be used when candidate list don't need to rebuild dynamically." + (let ((history (or (car-safe hist) hist)) + (alistp cands-in-buffer)) + (when (and default (listp default)) + ;; When DEFAULT is a list move the list on head of COLLECTION + ;; and set it to its car. #bugfix `grep-read-files'. + (setq collection (if (listp collection) + (append default collection) + ;; Else COLLECTION is maybe a function or a table. + (prog1 + (append default (all-completions "" collection)) + ;; Ensure `all-completions' will not be used + ;; a second time to recompute COLLECTION [1]. + (setq alistp t)))) + (setq default (car default))) + (helm-comp-read + prompt collection + :test test + :history history + :reverse-history helm-mode-reverse-history + :input-history history + :must-match require-match + :alistp alistp ; Ensure `all-completions' is used when non-nil [1]. + :name name + :requires-pattern (if (and (string= default "") + (or (eq require-match 'confirm) + (eq require-match + 'confirm-after-completion))) + 1 0) + :candidates-in-buffer cands-in-buffer + :exec-when-only-one exec-when-only-one + :buffer buffer + ;; If DEF is not provided, fallback to empty string + ;; to avoid `thing-at-point' to be appended on top of list + :default (or default "") + ;; Fail with special characters (e.g in gnus "nnimap+gmail:") + ;; if regexp-quote is not used. + ;; when init is added to history, it will be unquoted by + ;; helm-comp-read. + :initial-input (helm-aif (pcase init + ((pred (stringp)) init) + ;; INIT is a cons cell. + (`(,l . ,_ll) l)) + (if minibuffer-completing-file-name it + (regexp-quote it)))))) + +(defun helm-completing-read-with-cands-in-buffer + (prompt collection test require-match + init hist default inherit-input-method + name buffer) + "Same as `helm-completing-read-default-1' but use candidates-in-buffer." + ;; Some commands like find-tag may use `read-file-name' from inside + ;; the calculation of collection. in this case it clash with + ;; candidates-in-buffer that reuse precedent data (files) which is wrong. + ;; So (re)calculate collection outside of main helm-session. + (let ((cands (all-completions "" collection))) + (helm-completing-read-default-1 prompt cands test require-match + init hist default inherit-input-method + name buffer t))) + +(cl-defun helm--completing-read-default + (prompt collection &optional + predicate require-match + initial-input hist def + inherit-input-method) + "An helm replacement of `completing-read'. +This function should be used only as a `completing-read-function'. + +Don't use it directly, use instead `helm-comp-read' in your programs. + +See documentation of `completing-read' and `all-completions' for details." + (let* ((current-command (or (helm-this-command) this-command)) + (str-command (helm-symbol-name current-command)) + (buf-name (format "*helm-mode-%s*" str-command)) + (entry (assq current-command + helm-completing-read-handlers-alist)) + (def-com (cdr-safe entry)) + (str-defcom (and def-com (symbol-name def-com))) + (def-args (list prompt collection predicate require-match + initial-input hist def inherit-input-method)) + ;; Append the two extra args needed to set the buffer and source name + ;; in helm specialized functions. + (any-args (append def-args (list str-command buf-name))) + helm-completion-mode-start-message ; Be quiet + helm-completion-mode-quit-message + ;; Be sure this pesty *completion* buffer doesn't popup. + ;; Note: `minibuffer-with-setup-hook' may setup a lambda + ;; calling `minibuffer-completion-help' or other minibuffer + ;; functions we DONT WANT here, in these cases removing the hook + ;; (a symbol) have no effect. Issue #448. + ;; But because `minibuffer-completion-table' and + ;; `minibuffer-completion-predicate' are not bound + ;; anymore here, these functions should have no effect now. + (minibuffer-setup-hook (remove 'minibuffer-completion-help + minibuffer-setup-hook)) + ;; Disable hack that could be used before `completing-read'. + ;; i.e (push ?\t unread-command-events). + unread-command-events) + (when (eq def-com 'ido) (setq def-com 'ido-completing-read)) + (unless (or (not entry) def-com) + ;; An entry in *read-handlers-alist exists but have + ;; a nil value, so we exit from here, disable `helm-mode' + ;; and run the command again with it original behavior. + ;; `helm-mode' will be restored on exit. + (cl-return-from helm--completing-read-default + (unwind-protect + (progn + (helm-mode -1) + (apply completing-read-function def-args)) + (helm-mode 1)))) + ;; If we use now `completing-read' we MUST turn off `helm-mode' + ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. + (when (or (eq def-com 'completing-read) + ;; All specialized functions are prefixed by "helm" + (and (stringp str-defcom) + (not (string-match "^helm" str-defcom)))) + (helm-mode -1)) + (unwind-protect + (cond (;; An helm specialized function exists, run it. + (and def-com helm-mode) + (apply def-com any-args)) + (;; Try to handle `ido-completing-read' everywhere. + (and def-com (eq def-com 'ido-completing-read)) + (setcar (memq collection def-args) + (all-completions "" collection predicate)) + (apply def-com def-args)) + (;; User set explicitely `completing-read' or something similar + ;; in *read-handlers-alist, use this with exactly the same + ;; args as in `completing-read'. + ;; If we are here `helm-mode' is now disabled. + def-com + (apply def-com def-args)) + (t ; Fall back to classic `helm-comp-read'. + (helm-completing-read-default-1 + prompt collection predicate require-match + initial-input hist def inherit-input-method + str-command buf-name))) + (helm-mode 1) + ;; When exiting minibuffer, `this-command' is set to + ;; `helm-exit-minibuffer', which is unwanted when starting + ;; on another `completing-read', so restore `this-command' to + ;; initial value when exiting. + (setq this-command current-command)))) + +;;; Generic read-file-name +;; +;; +(cl-defun helm-read-file-name + (prompt + &key + (name "Read File Name") + (initial-input (expand-file-name default-directory)) + (buffer "*Helm file completions*") + test + (case-fold helm-file-name-case-fold-search) + preselect + history + must-match + default + marked-candidates + nomark + (alistp t) + (persistent-action 'helm-find-files-persistent-action) + (persistent-help "Hit1 Expand Candidate, Hit2 or (C-u) Find file") + (mode-line helm-read-file-name-mode-line-string)) + "Read a file name with helm completion. +It is helm `read-file-name' emulation. + +Argument PROMPT is the default prompt to use. + +Keys description: + +- NAME: Source name, default to \"Read File Name\". + +- INITIAL-INPUT: Where to start read file name, default to `default-directory'. + +- BUFFER: `helm-buffer' name default to \"*Helm Completions*\". + +- TEST: A predicate called with one arg 'candidate'. + +- CASE-FOLD: Same as `helm-case-fold-search'. + +- PRESELECT: helm preselection. + +- HISTORY: Display HISTORY in a special source. + +- MUST-MATCH: Can be 'confirm, nil, or t. + +- MARKED-CANDIDATES: When non--nil return a list of marked candidates. + +- NOMARK: When non--nil don't allow marking candidates. + +- ALISTP: Don't use `all-completions' in history (take effect only on history). + +- PERSISTENT-ACTION: a persistent action function. + +- PERSISTENT-HELP: persistent help message. + +- MODE-LINE: A mode line message, default is `helm-read-file-name-mode-line-string'." + + (when (get-buffer helm-action-buffer) + (kill-buffer helm-action-buffer)) + ;; Assume completion have been already required, + ;; so always use 'confirm. + (when (eq must-match 'confirm-after-completion) + (setq must-match 'confirm)) + (let* ((action-fn `(("Sole action (Identity)" + . (lambda (candidate) + (if ,marked-candidates + (helm-marked-candidates :with-wildcard t) + (identity candidate)))))) + ;; Be sure we don't erase the underlying minibuffer if some. + (helm-ff-auto-update-initial-value + (and helm-ff-auto-update-initial-value + (not (minibuffer-window-active-p (minibuffer-window))))) + helm-full-frame + (hist (and history (helm-comp-read-get-candidates + history nil nil alistp))) + (minibuffer-completion-confirm must-match) + (must-match-map (when must-match + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") + 'helm-confirm-and-exit-minibuffer) + map))) + (cmap (if must-match-map + (make-composed-keymap + must-match-map helm-read-file-map) + helm-read-file-map)) + (minibuffer-completion-predicate test) + (minibuffer-completing-file-name t) + (helm-read-file-name-mode-line-string + (replace-regexp-in-string "helm-maybe-exit-minibuffer" + "helm-confirm-and-exit-minibuffer" + helm-read-file-name-mode-line-string)) + (src-list + (list + ;; History source. + (helm-build-sync-source (format "%s History" name) + :header-name (lambda (hname) + (concat hname helm-find-files-doc-header)) + :mode-line mode-line + :candidates hist + :nohighlight t + :persistent-action persistent-action + :persistent-help persistent-help + :nomark nomark + :action action-fn) + ;; Other source. + (helm-build-sync-source name + :header-name (lambda (hname) + (concat hname helm-find-files-doc-header)) + :init (lambda () + (setq helm-ff-auto-update-flag + helm-ff-auto-update-initial-value) + (setq helm-ff--auto-update-state + helm-ff-auto-update-flag)) + :mode-line mode-line + :nohighlight t + :candidates + (lambda () + (append (and (not (file-exists-p helm-pattern)) + (list helm-pattern)) + (if test + (cl-loop with hn = (helm-ff-tramp-hostnames) + for i in (helm-find-files-get-candidates + must-match) + when (or (member i hn) ; A tramp host + (funcall test i)) ; Test ok + collect i) + (helm-find-files-get-candidates must-match)))) + :filtered-candidate-transformer 'helm-ff-sort-candidates + :filter-one-by-one 'helm-ff-filter-candidate-one-by-one + :persistent-action persistent-action + :candidate-number-limit 9999 + :persistent-help persistent-help + :volatile t + :nomark nomark + :action action-fn))) + ;; Helm result. + (result (helm + :sources src-list + :input initial-input + :prompt prompt + :keymap cmap + :resume 'noresume + :case-fold-search case-fold + :default default + :buffer buffer + :preselect preselect))) + (or + (cond ((and result (stringp result) + (string= result "") "")) + ((and result + (stringp result) + (file-equal-p result initial-input) + default) + (if (listp default) (car default) default)) + ((and result (stringp result)) + (expand-file-name result)) + ((and result (listp result)) + (mapcar #'expand-file-name result)) + (t result)) + (when (and (not (string= helm-pattern "")) + (eq helm-exit-status 0) + (eq must-match 'confirm)) + (identity helm-pattern)) + (helm-mode--keyboard-quit)))) + +(defun helm-mode--default-filename (fname dir initial) + (unless dir (setq dir default-directory)) + (unless (file-name-absolute-p dir) + (setq dir (expand-file-name dir))) + (unless (or fname (consp fname)) + (setq fname (expand-file-name + (or initial buffer-file-name dir) + dir))) + (if (and fname (consp fname)) + (setq fname (cl-loop for f in fname + collect (expand-file-name f dir))) + (if (file-name-absolute-p fname) + fname (expand-file-name fname dir)))) + +(cl-defun helm--generic-read-file-name + (prompt &optional dir default-filename mustmatch initial predicate) + "Generic helm replacement of `read-file-name'. +Don't use it directly, use instead `helm-read-file-name' in your programs." + (let* ((init (or initial dir default-directory)) + (current-command (or (helm-this-command) this-command)) + (str-command (helm-symbol-name current-command)) + (helm--file-completion-sources + (cons str-command + (remove str-command helm--file-completion-sources))) + (buf-name (format "*helm-mode-%s*" str-command)) + (entry (assq current-command + helm-completing-read-handlers-alist)) + (def-com (cdr-safe entry)) + (str-defcom (and def-com (symbol-name def-com))) + (def-args (list prompt dir default-filename mustmatch initial predicate)) + ;; Append the two extra args needed to set the buffer and source name + ;; in helm specialized functions. + (any-args (append def-args (list str-command buf-name))) + (ido-state ido-mode) + helm-completion-mode-start-message ; Be quiet + helm-completion-mode-quit-message ; Same here + fname) + (setq default-filename (helm-mode--default-filename + default-filename dir initial)) + ;; Some functions that normally call `completing-read' can switch + ;; brutally to `read-file-name' (e.g find-tag), in this case + ;; the helm specialized function will fail because it is build + ;; for `completing-read', so set it to 'incompatible to be sure + ;; we switch to `helm-read-file-name' and don't try to call it + ;; with wrong number of args. + (when (eq def-com 'ido) + (setq def-com 'ido-read-file-name) (ido-mode 1)) + (when (and def-com (> (length (help-function-arglist def-com)) 8)) + (setq def-com 'incompatible)) + (unless (or (not entry) def-com) + (cl-return-from helm--generic-read-file-name + (unwind-protect + (progn + (helm-mode -1) + (apply read-file-name-function def-args)) + (helm-mode 1)))) + ;; If we use now `read-file-name' we MUST turn off `helm-mode' + ;; to avoid infinite recursion and CRASH. It will be reenabled on exit. + (when (or (eq def-com 'read-file-name) + (eq def-com 'ido-read-file-name) + (and (stringp str-defcom) + (not (string-match "^helm" str-defcom)))) + (helm-mode -1)) + (unwind-protect + (setq fname + (cond (;; A specialized function exists, run it + ;; with the two extra args specific to helm.. + (and def-com helm-mode + (not (eq def-com 'ido-read-file-name)) + (not (eq def-com 'incompatible))) + (apply def-com any-args)) + (;; Def-com value is `ido-read-file-name' + ;; run it with default args. + (and def-com (eq def-com 'ido-read-file-name)) + (ido-mode 1) + (apply def-com def-args)) + (;; Def-com value is `read-file-name' + ;; run it with default args. + (eq def-com 'read-file-name) + (apply def-com def-args)) + (t ; Fall back to classic `helm-read-file-name'. + (helm-read-file-name + prompt + :name str-command + :buffer buf-name + :default default-filename + :initial-input (expand-file-name init dir) + :alistp nil + :must-match mustmatch + :test predicate)))) + (helm-mode 1) + (ido-mode (if ido-state 1 -1)) + ;; Same comment as in `helm--completing-read-default'. + (setq this-command current-command)) + fname)) + +(defun helm-mode--advice-lisp--local-variables (old--fn &rest args) + (ignore-errors + (apply old--fn args))) + +(defun helm--completion-in-region (start end collection &optional predicate) + "[EXPERIMENTAL] Helm replacement of `completion--in-region'. +Can be used as value for `completion-in-region-function'." + (cl-declare (special require-match prompt)) + (if (memq major-mode helm-mode-no-completion-in-region-in-modes) + (funcall helm--old-completion-in-region-function + start end collection predicate) + (advice-add + 'lisp--local-variables + :around #'helm-mode--advice-lisp--local-variables) + (unwind-protect + (let* ((enable-recursive-minibuffers t) + (input (buffer-substring-no-properties start end)) + (current-command (or (helm-this-command) this-command)) + (str-command (symbol-name current-command)) + (buf-name (format "*helm-mode-%s*" str-command)) + (require-match (or (and (boundp 'require-match) require-match) + minibuffer-completion-confirm + ;; If prompt have not been propagated here, that's + ;; probably mean we have no prompt and we are in + ;; completion-at-point or friend, so use a non--nil + ;; value for require-match. + (not (boundp 'prompt)))) + ;; `completion-extra-properties' is let-bounded in `completion-at-point'. + ;; `afun' is a closure to call against each string in `data'. + ;; it provide the annotation info for each string. + ;; e.g "foo" => "foo " where foo is a function. + ;; See Issue #407. + (afun (plist-get completion-extra-properties :annotation-function)) + (data (all-completions input collection predicate)) + (init-space-suffix (unless helm-completion-in-region-fuzzy-match " ")) + ;; Assume that when `afun' and `predicate' are null + ;; we are in filename completion. + (file-comp-p (or (helm-mode--in-file-completion-p) + (and (null afun) (null predicate)))) + ;; Completion-at-point and friends have no prompt. + (result (if (stringp data) + data + (helm-comp-read + (or (and (boundp 'prompt) prompt) "Pattern: ") + (if file-comp-p + (cl-loop for f in data unless + (string-match "\\`\\.\\{1,2\\}/\\'" f) + collect f) + (if afun + (mapcar (lambda (s) + (let ((ann (funcall afun s))) + (if ann + (cons + (concat + s + (propertize + " " 'display + (propertize + ann + 'face 'completions-annotations))) + s) + s))) + data) + data)) + :name str-command + :fuzzy helm-completion-in-region-fuzzy-match + :nomark t + :initial-input + (cond ((and file-comp-p + (not (string-match "/\\'" input))) + (concat (helm-basename input) + (unless (string= input "") + init-space-suffix))) + ((string-match "/\\'" input) nil) + ((or (null require-match) + (stringp require-match)) + input) + (t (concat input init-space-suffix))) + :buffer buf-name + :fc-transformer (append (list 'helm-cr-default-transformer) + (list (lambda (candidates _source) + (sort candidates 'helm-generic-sort-fn)))) + :exec-when-only-one t + :quit-when-no-cand + #'(lambda () + ;; Delay message to overwrite "Quit". + (run-with-timer + 0.01 nil + #'(lambda () + (message "[No matches]"))) + t) ; exit minibuffer immediately. + :must-match require-match)))) + (when result + (delete-region (if (and file-comp-p + (save-excursion + (re-search-backward "~?/" start t))) + (match-end 0) start) + end) + (insert result))) + (advice-remove 'lisp--local-variables + #'helm-mode--advice-lisp--local-variables)))) + +(defun helm-mode--in-file-completion-p () + (with-helm-current-buffer + (run-hook-with-args-until-success 'file-name-at-point-functions))) + +(when (boundp 'completion-in-region-function) + (defconst helm--old-completion-in-region-function completion-in-region-function)) + +;;;###autoload +(define-minor-mode helm-mode + "Toggle generic helm completion. + +All functions in Emacs that use `completing-read' +or `read-file-name' and friends will use helm interface +when this mode is turned on. +However you can modify this behavior for functions of your choice +with `helm-completing-read-handlers-alist'. + +Called with a positive arg, turn on unconditionally, with a +negative arg turn off. +You can turn it on with `helm-mode'. + +Some crap emacs functions may not be supported, +e.g `ffap-alternate-file' and maybe others +You can add such functions to `helm-completing-read-handlers-alist' +with a nil value. + +Note: This mode is incompatible with Emacs23." + :group 'helm-mode + :global t + :lighter helm-completion-mode-string + (cl-assert (boundp 'completing-read-function) nil + "`helm-mode' not available, upgrade to Emacs-24") + (if helm-mode + (if (fboundp 'add-function) + (progn + (add-function :override completing-read-function + #'helm--completing-read-default) + (add-function :override read-file-name-function + #'helm--generic-read-file-name) + (when helm-mode-handle-completion-in-region + (add-function :override completion-in-region-function + #'helm--completion-in-region))) + (setq completing-read-function 'helm--completing-read-default + read-file-name-function 'helm--generic-read-file-name) + (when (and (boundp 'completion-in-region-function) + helm-mode-handle-completion-in-region) + (setq completion-in-region-function #'helm--completion-in-region)) + (message helm-completion-mode-start-message)) + (if (fboundp 'remove-function) + (progn + (remove-function completing-read-function #'helm--completing-read-default) + (remove-function read-file-name-function #'helm--generic-read-file-name) + (remove-function completion-in-region-function #'helm--completion-in-region)) + (setq completing-read-function (and (fboundp 'completing-read-default) + 'completing-read-default) + read-file-name-function (and (fboundp 'read-file-name-default) + 'read-file-name-default)) + (when (and (boundp 'completion-in-region-function) + (boundp 'helm--old-completion-in-region-function)) + (setq completion-in-region-function helm--old-completion-in-region-function)) + (message helm-completion-mode-quit-message)))) + +(provide 'helm-mode) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-mode.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-net.el b/emacs.d/elpa/helm-20150507.2215/helm-net.el new file mode 100644 index 0000000..702a3aa --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-net.el @@ -0,0 +1,607 @@ +;;; helm-net.el --- helm browse url and search web. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'url) +(require 'xml) +(require 'browse-url) + + +(defgroup helm-net nil + "Net related applications and libraries for Helm." + :group 'helm) + +(defcustom helm-google-suggest-default-browser-function nil + "The browse url function you prefer to use with google suggest. +When nil, use the first browser function available +See `helm-browse-url-default-browser-alist'." + :group 'helm-net + :type 'symbol) + +(defcustom helm-home-url "http://www.google.fr" + "Default url to use as home url." + :group 'helm-net + :type 'string) + +(defcustom helm-surfraw-default-browser-function nil + "The browse url function you prefer to use with surfraw. +When nil, fallback to `browse-url-browser-function'." + :group 'helm-net + :type 'symbol) + +(defcustom helm-google-suggest-url + "http://google.com/complete/search?output=toolbar&q=" + "URL used for looking up Google suggestions." + :type 'string + :group 'helm-net) + +(defcustom helm-google-suggest-search-url + "http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s" + "URL used for Google searching." + :type 'string + :group 'helm-net) + +(defcustom helm-google-suggest-use-curl-p nil + "When non--nil use CURL to get info from `helm-google-suggest-url'. +Otherwise `url-retrieve-synchronously' is used." + :type 'boolean + :group 'helm-net) + +(defcustom helm-yahoo-suggest-url + "http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=Generic&query=" + "Url used for looking up Yahoo suggestions." + :type 'string + :group 'helm-net) + +(defcustom helm-yahoo-suggest-search-url + "http://search.yahoo.com/search?&ei=UTF-8&fr&h=c&p=%s" + "Url used for Yahoo searching." + :type 'string + :group 'helm-net) + +(defcustom helm-surfraw-duckduckgo-url + "https://duckduckgo.com/lite/?q=%s&kp=1" + "The duckduckgo url. +This is a format string, don't forget the `%s'. +If you have personal settings saved on duckduckgo you should have +a personal url, see your settings on duckduckgo." + :type 'string + :group 'helm-net) + +(defcustom helm-wikipedia-suggest-url + "http://en.wikipedia.org/w/api.php?action=opensearch&search=" + "Url used for looking up Wikipedia suggestions." + :type 'string + :group 'helm-net) + +(defcustom helm-search-suggest-action-wikipedia-url + "https://en.wikipedia.org/wiki/Special:Search?search=%s" + "The Wikipedia search url. +This is a format string, don't forget the `%s'." + :type 'string + :group 'helm-net) + +(defcustom helm-wikipedia-summary-url + "http://en.wikipedia.org/w/api.php?action=parse&format=json&prop=text§ion=0&page=" + "URL for getting the summary of a Wikipedia topic." + :type 'string + :group 'helm-net) + +(defcustom helm-wikipedia-follow-delay 2 + "Delay before wikipedia summary popup." + :type 'number + :group 'helm-net) + +(defcustom helm-search-suggest-action-youtube-url + "http://www.youtube.com/results?aq=f&search_query=%s" + "The Youtube search url. +This is a format string, don't forget the `%s'." + :type 'string + :group 'helm-net) + +(defcustom helm-search-suggest-action-imdb-url + "http://www.imdb.com/find?s=all&q=%s" + "The IMDb search url. +This is a format string, don't forget the `%s'." + :type 'string + :group 'helm-net) + +(defcustom helm-search-suggest-action-google-maps-url + "http://maps.google.com/maps?f=q&source=s_q&q=%s" + "The Google Maps search url. +This is a format string, don't forget the `%s'." + :type 'string + :group 'helm-net) + +(defcustom helm-search-suggest-action-google-news-url + "http://www.google.com/search?safe=off&prmd=nvlifd&source=lnms&tbs=nws:1&q=%s" + "The Google News search url. +This is a format string, don't forget the `%s'." + :type 'string + :group 'helm-net) + + +;;; Additional actions for search suggestions +;; +;; +;; Internal + +(defun helm-search-suggest-perform-additional-action (url query) + "Perform the search via URL using QUERY as input." + (browse-url (format url (url-hexify-string query)))) + +(defvar helm-search-suggest-additional-actions + '(("Wikipedia" . (lambda (candidate) + (helm-search-suggest-perform-additional-action + helm-search-suggest-action-wikipedia-url + candidate))) + ("Youtube" . (lambda (candidate) + (helm-search-suggest-perform-additional-action + helm-search-suggest-action-youtube-url + candidate))) + ("IMDb" . (lambda (candidate) + (helm-search-suggest-perform-additional-action + helm-search-suggest-action-imdb-url + candidate))) + ("Google Maps" . (lambda (candidate) + (helm-search-suggest-perform-additional-action + helm-search-suggest-action-google-maps-url + candidate))) + ("Google News" . (lambda (candidate) + (helm-search-suggest-perform-additional-action + helm-search-suggest-action-google-news-url + candidate)))) + "List of additional actions for suggest sources.") + + +;;; Google Suggestions +;; +;; +;; Internal +(defvar helm-ggs-max-length-real-flag 0) +(defvar helm-ggs-max-length-num-flag 0) + +(defun helm-google-suggest-fetch (input) + "Fetch suggestions for INPUT from XML buffer. +Return an alist with elements like (data . number_results)." + (setq helm-ggs-max-length-real-flag 0 + helm-ggs-max-length-num-flag 0) + (let ((request (concat helm-google-suggest-url + (url-hexify-string input))) + (fetch #'(lambda () + (cl-loop + with result-alist = (xml-get-children + (car (xml-parse-region + (point-min) (point-max))) + 'CompleteSuggestion) + for i in result-alist + for data = (cdr (cl-caadr (assoc 'suggestion i))) + for nqueries = (cdr (cl-caadr (assoc 'num_queries i))) + for lqueries = (length (helm-ggs-set-number-result + nqueries)) + for ldata = (length data) + do + (progn + (when (> ldata helm-ggs-max-length-real-flag) + (setq helm-ggs-max-length-real-flag ldata)) + (when (> lqueries helm-ggs-max-length-num-flag) + (setq helm-ggs-max-length-num-flag lqueries))) + collect (cons data nqueries) into cont + finally return cont)))) + (if helm-google-suggest-use-curl-p + (with-temp-buffer + (call-process "curl" nil t nil request) + (funcall fetch)) + (with-current-buffer + (url-retrieve-synchronously request) + (funcall fetch))))) + +(defun helm-google-suggest-set-candidates (&optional request-prefix) + "Set candidates with result and number of google results found." + (let ((suggestions + (cl-loop with suggested-results = (helm-google-suggest-fetch + (or (and request-prefix + (concat request-prefix + " " helm-pattern)) + helm-pattern)) + for (real . numresult) in suggested-results + ;; Prepare number of results with "," + for fnumresult = (helm-ggs-set-number-result numresult) + ;; Calculate number of spaces to add before fnumresult + ;; if it is smaller than longest result + ;; `helm-ggs-max-length-num-flag'. + ;; e.g 1,234,567 + ;; 345,678 + ;; To be sure it is aligned properly. + for nspaces = (if (< (length fnumresult) + helm-ggs-max-length-num-flag) + (- helm-ggs-max-length-num-flag + (length fnumresult)) + 0) + ;; Add now the spaces before fnumresult. + for align-fnumresult = (concat (make-string nspaces ? ) + fnumresult) + for interval = (- helm-ggs-max-length-real-flag + (length real)) + for spaces = (make-string (+ 2 interval) ? ) + for display = (format "%s%s(%s results)" + real spaces align-fnumresult) + collect (cons display real)))) + (if (cl-loop for (_disp . dat) in suggestions + thereis (equal dat helm-pattern)) + suggestions + ;; if there is no suggestion exactly matching the input then + ;; prepend a Search on Google item to the list + (append + suggestions + (list (cons (concat "Search for " "'" helm-input "'" " on Google") + helm-input)))))) + +(defun helm-ggs-set-number-result (num) + (if num + (progn + (and (numberp num) (setq num (number-to-string num))) + (cl-loop for i in (reverse (split-string num "" t)) + for count from 1 + append (list i) into C + when (= count 3) + append (list ",") into C + and do (setq count 0) + finally return + (replace-regexp-in-string + "^," "" (mapconcat 'identity (reverse C) "")))) + "?")) + +(defun helm-google-suggest-action (candidate) + "Default action to jump to a google suggested candidate." + (let ((arg (format helm-google-suggest-search-url + (url-hexify-string candidate)))) + (helm-aif helm-google-suggest-default-browser-function + (funcall it arg) + (helm-browse-url arg)))) + +(defvar helm-google-suggest-default-function + 'helm-google-suggest-set-candidates + "Default function to use in helm google suggest.") + +(defvar helm-source-google-suggest + `((name . "Google Suggest") + (candidates . (lambda () + (funcall helm-google-suggest-default-function))) + (action . ,(cons '("Google Search" . helm-google-suggest-action) + helm-search-suggest-additional-actions)) + (volatile) + (keymap . ,helm-map) + (requires-pattern . 3))) + +(defun helm-google-suggest-emacs-lisp () + "Try to emacs lisp complete with google suggestions." + (helm-google-suggest-set-candidates "emacs lisp")) + + +;;; Yahoo suggestions +;; +;; +(defun helm-yahoo-suggest-fetch (input) + "Fetch Yahoo suggestions for INPUT from XML buffer. +Return an alist with elements like (data . number_results)." + (let ((request (concat helm-yahoo-suggest-url + (url-hexify-string input)))) + (with-current-buffer + (url-retrieve-synchronously request) + (cl-loop with result-alist = + (xml-get-children + (car (xml-parse-region + (point-min) (point-max))) + 'Result) + for i in result-alist + collect (cl-caddr i))))) + +(defun helm-yahoo-suggest-set-candidates () + "Set candidates with Yahoo results found." + (let ((suggestions (helm-yahoo-suggest-fetch helm-input))) + (or suggestions + (append + suggestions + (list (cons (concat "Search for " "'" helm-input "'" " on Yahoo") + helm-input)))))) + +(defun helm-yahoo-suggest-action (candidate) + "Default action to jump to a Yahoo suggested candidate." + (helm-browse-url (format helm-yahoo-suggest-search-url + (url-hexify-string candidate)))) + +(defvar helm-source-yahoo-suggest + `((name . "Yahoo Suggest") + (candidates . helm-yahoo-suggest-set-candidates) + (action . (("Yahoo Search" . helm-yahoo-suggest-action))) + (volatile) + (keymap . ,helm-map) + (requires-pattern . 3))) + +;;; Wikipedia suggestions +;; +;; +(declare-function json-read-from-string "json" (string)) +(defun helm-wikipedia-suggest-fetch () + "Fetch Wikipedia suggestions and return them as a list." + (require 'json) + (let ((request (concat helm-wikipedia-suggest-url + (url-hexify-string helm-pattern)))) + (if helm-google-suggest-use-curl-p + (with-temp-buffer + (call-process "curl" nil t nil request) + (helm-wikipedia--parse-buffer)) + (with-current-buffer + (url-retrieve-synchronously request) + (helm-wikipedia--parse-buffer))))) + +(defun helm-wikipedia--parse-buffer () + (goto-char (point-min)) + (when (re-search-forward "^\\[.+\\[\\(.*\\)\\]\\]" nil t) + (cl-loop for i across (aref (json-read-from-string (match-string 0)) 1) + collect i into result + finally return (or result + (append + result + (list (cons (format "Search for '%s' on wikipedia" + helm-pattern) + helm-pattern))))))) + +(defvar helm-wikipedia--summary-cache (make-hash-table :test 'equal)) +(defun helm-wikipedia-persistent-action (candidate) + (unless (string= (format "Search for '%s' on wikipedia" + helm-pattern) + (helm-get-selection nil t)) + (message "Fetching summary from Wikipedia...") + (let ((buf (get-buffer-create "*helm wikipedia summary*")) + result mess) + (while (progn + (setq result (or (gethash candidate helm-wikipedia--summary-cache) + (puthash candidate + (prog1 + (helm-wikipedia-fetch-summary candidate) + (setq mess "Done")) + helm-wikipedia--summary-cache))) + (when (and result + (listp result)) + (setq candidate (cdr result)) + (message "Redirected to %s" candidate) + t))) + (if (not result) + (message "Error when getting summary.") + (with-current-buffer buf + (erase-buffer) + (setq cursor-type nil) + (insert result) + (fill-region (point-min) (point-max)) + (goto-char (point-min))) + (display-buffer buf) + (message mess))))) + + +(defun helm-wikipedia-fetch-summary (input) + (let* ((request (concat helm-wikipedia-summary-url (url-hexify-string input)))) + (if helm-google-suggest-use-curl-p + (with-temp-buffer + (call-process "curl" nil t nil request) + (helm-wikipedia--parse-summary)) + (with-current-buffer + (url-retrieve-synchronously request) + (helm-wikipedia--parse-summary))))) + + +(defun helm-wikipedia--parse-summary () + (goto-char (point-min)) + (when (search-forward "{" nil t) + (let ((result (cdr (assoc '* + (assoc 'text + (assoc 'parse + (json-read-from-string + (buffer-substring-no-properties + (1- (point)) (point-max))))))))) + (when result + (if (string-match "]+>\\([^<]+\\)" result) + (cons 'redirect (match-string 1 result)) + + ;; find the beginning of the summary text in the result + + ;; check if there is a table before the summary and skip that + (when (or (string-match "\\(\n\\)?\n

" result) + ;; otherwise just find the first paragraph + (string-match "

" result)) + ;; remove cruft and do a simple formatting + (replace-regexp-in-string + "Cite error: .*" "" + (replace-regexp-in-string + " " "" + (replace-regexp-in-string + "\\[[^\]]+\\]" "" + (replace-regexp-in-string + "<[^>]*>" "" + (replace-regexp-in-string + "

\n

" "\n\n" + (substring result (match-end 0))))))))))))) + + +(defvar helm-source-wikipedia-suggest + `((name . "Wikipedia Suggest") + (candidates . helm-wikipedia-suggest-fetch) + (action . (("Wikipedia" . (lambda (candidate) + (helm-search-suggest-perform-additional-action + helm-search-suggest-action-wikipedia-url + candidate))))) + (persistent-action . helm-wikipedia-persistent-action) + (volatile) + (keymap . ,helm-map) + (follow . 1) + (follow-delay . ,helm-wikipedia-follow-delay) + (requires-pattern . 3))) + + +;;; Web browser functions. +;; +;; +;; If default setting of `w3m-command' is not +;; what you want and you modify it, you will have to reeval +;; also `helm-browse-url-default-browser-alist'. + +(defvar helm-browse-url-chromium-program "chromium-browser") +(defvar helm-browse-url-uzbl-program "uzbl-browser") +(defvar helm-browse-url-conkeror-program "conkeror") +(defvar helm-browse-url-default-browser-alist + `((,(or (and (boundp 'w3m-command) w3m-command) + "/usr/bin/w3m") . w3m-browse-url) + (,browse-url-firefox-program . browse-url-firefox) + (,helm-browse-url-chromium-program . helm-browse-url-chromium) + (,helm-browse-url-conkeror-program . helm-browse-url-conkeror) + (,helm-browse-url-uzbl-program . helm-browse-url-uzbl) + (,browse-url-kde-program . browse-url-kde) + (,browse-url-gnome-moz-program . browse-url-gnome-moz) + (,browse-url-mozilla-program . browse-url-mozilla) + (,browse-url-galeon-program . browse-url-galeon) + (,browse-url-netscape-program . browse-url-netscape) + (,browse-url-mosaic-program . browse-url-mosaic) + (,browse-url-xterm-program . browse-url-text-xterm) + ("emacs" . eww-browse-url)) + "*Alist of \(executable . function\) to try to find a suitable url browser.") + +(cl-defun helm-generic-browser (url cmd-name &rest args) + "Browse URL with NAME browser." + (let ((proc (concat cmd-name " " url))) + (message "Starting %s..." cmd-name) + (apply 'start-process proc nil cmd-name + (append args (list url))) + (set-process-sentinel + (get-process proc) + #'(lambda (process event) + (when (string= event "finished\n") + (message "%s process %s" process event)))))) + +(defun helm-browse-url-chromium (url &optional _ignore) + "Browse URL with google chrome browser." + (interactive "sURL: ") + (helm-generic-browser + url helm-browse-url-chromium-program)) + +(defun helm-browse-url-uzbl (url &optional _ignore) + "Browse URL with uzbl browser." + (interactive "sURL: ") + (helm-generic-browser url helm-browse-url-uzbl-program "-u")) + +(defun helm-browse-url-conkeror (url &optional _ignore) + "Browse URL with conkeror browser." + (interactive "sURL: ") + (helm-generic-browser url helm-browse-url-conkeror-program)) + +(defun helm-browse-url-default-browser (url &rest args) + "Find the first available browser and ask it to load URL." + (let ((default-browser-fn + (cl-loop for (exe . fn) in helm-browse-url-default-browser-alist + thereis (and exe (executable-find exe) (fboundp fn) fn)))) + (if default-browser-fn + (apply default-browser-fn url args) + (error "No usable browser found")))) + +(defun helm-browse-url (url &rest args) + "Default command to browse URL." + (if browse-url-browser-function + (browse-url url args) + (helm-browse-url-default-browser url args))) + + +;;; Surfraw +;; +;; Need external program surfraw. +;; + +;; Internal +(defvar helm-surfraw-engines-history nil) +(defvar helm-surfraw-input-history nil) +(defvar helm-surfraw--elvi-cache nil) + +(defun helm-build-elvi-list () + "Return list of all engines and descriptions handled by surfraw." + (or helm-surfraw--elvi-cache + (setq helm-surfraw--elvi-cache + (cdr (with-temp-buffer + (call-process "surfraw" nil t nil "-elvi") + (split-string (buffer-string) "\n")))))) + +;;;###autoload +(defun helm-surfraw (pattern engine) + "Preconfigured `helm' to search PATTERN with search ENGINE." + (interactive (list (read-string "SearchFor: " + nil 'helm-surfraw-input-history + (thing-at-point 'symbol)) + (helm-comp-read + "Engine: " + (helm-build-elvi-list) + :must-match t + :name "Surfraw Search Engines" + :del-input nil + :history helm-surfraw-engines-history))) + (let* ((engine-nodesc (car (split-string engine))) + (url (if (string= engine-nodesc "duckduckgo") + ;; "sr duckduckgo -p foo" is broken, workaround. + (format helm-surfraw-duckduckgo-url + (url-hexify-string pattern)) + (with-temp-buffer + (apply 'call-process "surfraw" nil t nil + (append (list engine-nodesc "-p") (split-string pattern))) + (replace-regexp-in-string + "\n" "" (buffer-string))))) + (browse-url-browser-function (or helm-surfraw-default-browser-function + browse-url-browser-function))) + (if (string= engine-nodesc "W") + (helm-browse-url helm-home-url) + (helm-browse-url url) + (setq helm-surfraw-engines-history + (cons engine (delete engine helm-surfraw-engines-history)))))) + +;;;###autoload +(defun helm-google-suggest () + "Preconfigured `helm' for google search with google suggest." + (interactive) + (helm-other-buffer 'helm-source-google-suggest "*helm google*")) + +;;;###autoload +(defun helm-yahoo-suggest () + "Preconfigured `helm' for Yahoo searching with Yahoo suggest." + (interactive) + (helm-other-buffer 'helm-source-yahoo-suggest "*helm yahoo*")) + +;;;###autoload +(defun helm-wikipedia-suggest () + "Preconfigured `helm' for Wikipedia lookup with Wikipedia suggest." + (interactive) + (helm :sources 'helm-source-wikipedia-suggest + :buffer "*helm wikipedia*")) + + +(provide 'helm-net) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-net.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-org.el b/emacs.d/elpa/helm-20150507.2215/helm-org.el new file mode 100644 index 0000000..6570016 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-org.el @@ -0,0 +1,148 @@ +;;; helm-org.el --- Helm for org headlines and keywords completion -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: +(require 'cl-lib) +(require 'helm) +(require 'org) + +(defgroup helm-org nil + "Org related functions for helm." + :group 'helm) + +(defcustom helm-org-headings-fontify nil + "Fontify org buffers before parsing them. +This reflect fontification in helm-buffer when non--nil. +NOTE: This will be slow on large org buffers." + :group 'helm-org + :type 'boolean) + +;; Internal +(defvar helm-org-headings--nofilename nil) + +;;; Org capture templates +;; +;; +(defvar org-capture-templates) +(defun helm-source-org-capture-templates () + (helm-build-sync-source "Org Capture Templates:" + :candidates (cl-loop for template in org-capture-templates + collect `(,(nth 1 template) . ,(nth 0 template))) + :action '(("Do capture" . (lambda (template-shortcut) + (org-capture nil template-shortcut)))))) + +;;; Org headings +;; +;; +(defun helm-org-goto-marker (marker) + (switch-to-buffer (marker-buffer marker)) + (goto-char (marker-position marker)) + (org-show-context) + (org-show-entry)) + +(cl-defun helm-source-org-headings-for-files (filenames + &optional (min-depth 1) (max-depth 8)) + (helm-build-sync-source "Org Headings" + :candidates (helm-org-get-candidates filenames min-depth max-depth) + :action '(("Go to line" . helm-org-goto-marker) + ("Refile to this heading" . helm-org-heading-refile) + ("Insert link to this heading" + . helm-org-insert-link-to-heading-at-marker)))) + +(defun helm-org-insert-link-to-heading-at-marker (marker) + (with-current-buffer (marker-buffer marker) + (let ((heading-name (save-excursion (goto-char (marker-position marker)) + (nth 4 (org-heading-components)))) + (file-name (buffer-file-name))) + (with-helm-current-buffer + (org-insert-link + file-name (concat "file:" file-name "::*" heading-name)))))) + +(defun helm-org-heading-refile (marker) + (with-helm-current-buffer + (org-cut-subtree)) + (let ((target-level (with-current-buffer (marker-buffer marker) + (goto-char (marker-position marker)) + (org-current-level)))) + (helm-org-goto-marker marker) + (org-end-of-subtree t t) + (org-paste-subtree (+ target-level 1)))) + +(defun helm-org-get-candidates (filenames min-depth max-depth) + (apply #'append + (mapcar (lambda (filename) + (helm-get-org-candidates-in-file + filename min-depth max-depth + helm-org-headings-fontify + helm-org-headings--nofilename)) + filenames))) + +(defun helm-get-org-candidates-in-file (filename min-depth max-depth + &optional fontify nofname) + (with-current-buffer (pcase filename + ((pred bufferp) filename) + ((pred stringp) (find-file-noselect filename))) + (and fontify (jit-lock-fontify-now)) + (let ((match-fn (if fontify 'match-string 'match-string-no-properties))) + (save-excursion + (goto-char (point-min)) + (cl-loop with width = (window-width) + while (re-search-forward org-complex-heading-regexp nil t) + if (let ((num-stars (length (match-string-no-properties 1)))) + (and (>= num-stars min-depth) (<= num-stars max-depth))) + collect `(,(let ((heading (funcall match-fn 4)) + (file (unless nofname + (concat (helm-basename filename) ":"))) + (level (length (match-string-no-properties 1)))) + (org-format-outline-path + (append (org-get-outline-path t level heading) + (list heading)) width file)) + . ,(point-marker))))))) + +;;;###autoload +(defun helm-org-agenda-files-headings () + (interactive) + (helm :sources (helm-source-org-headings-for-files (org-agenda-files)) + :candidate-number-limit 99999 + :buffer "*helm org headings*")) + +;;;###autoload +(defun helm-org-in-buffer-headings () + (interactive) + (let ((helm-org-headings--nofilename t)) + (helm :sources (helm-source-org-headings-for-files + (list (current-buffer))) + :candidate-number-limit 99999 + :buffer "*helm org inbuffer*"))) + +;;;###autoload +(defun helm-org-capture-templates () + (interactive) + (helm :sources (helm-source-org-capture-templates) + :candidate-number-limit 99999 + :buffer "*helm org capture templates*")) + + +(provide 'helm-org) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-org.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-pkg.el b/emacs.d/elpa/helm-20150507.2215/helm-pkg.el new file mode 100644 index 0000000..bb6a8d5 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-pkg.el @@ -0,0 +1,8 @@ +(define-package "helm" "20150507.2215" "Helm is an Emacs incremental and narrowing framework" + '((emacs "24") + (cl-lib "0.5") + (async "1.2")) + :url "https://emacs-helm.github.io/helm/") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/helm-20150507.2215/helm-plugin.el b/emacs.d/elpa/helm-20150507.2215/helm-plugin.el new file mode 100644 index 0000000..976a734 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-plugin.el @@ -0,0 +1,137 @@ +;;; helm-plugin.el --- Helm plugins -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) + + +;;; Plug-in: `info-index' +;; +;; +(defun helm-make-info-source (source file) + `(,@source + (name . ,(concat "Info Index: " file)) + (info-file . ,file) + (init . helm-info-init) + (display-to-real . helm-info-display-to-real) + (get-line . buffer-substring) + (candidates-in-buffer) + (action ("Goto node" . helm-info-goto)))) + +(defun helm-compile-source--info-index (source) + (helm-aif (helm-interpret-value (assoc-default 'info-index source)) + (helm-make-info-source source it) + source)) + +(add-to-list 'helm-compile-source-functions 'helm-compile-source--info-index) + +(helm-document-attribute 'info-index "info-index plugin" + " Create a source of info index very easily. + + Example: + + (defvar helm-source-info-wget '((info-index . \"wget\"))") + + +;;; Plug-in: `candidates-file' +;; +;; List all lines in a file. +(defun helm-compile-source--candidates-file (source) + (if (assoc-default 'candidates-file source) + `((init helm-p-candidates-file-init + ,@(let ((orig-init (assoc-default 'init source))) + (cond ((null orig-init) nil) + ((functionp orig-init) (list orig-init)) + (t orig-init)))) + (candidates-in-buffer) + ,@source) + source)) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--candidates-file) + +(defun helm-p-candidates-file-init () + (cl-destructuring-bind (file &optional updating) + (helm-mklist (helm-attr 'candidates-file)) + (setq file (helm-interpret-value file)) + (with-current-buffer (helm-candidate-buffer 'global) + (insert-file-contents file) + (when updating + (buffer-disable-undo) + (font-lock-mode -1) + (auto-revert-mode 1))))) + +(helm-document-attribute 'candidates-file "candidates-file plugin" + " Use a file as the candidates buffer. + + 1st argument is a filename, string or function name or variable + name. If optional 2nd argument is non-nil, the file is opened with + `auto-revert-mode' enabled. + + Example: + + \(defvar helm-source-test-file + '((name . \"test1\") + (candidates-file \"~/.emacs.el\" t))) + + Will list all lines in .emacs.el.") + + +;;; Plug-in: `persistent-help' +;; +;; Add help about persistent action in `helm-buffer' header. +(defun helm-compile-source--persistent-help (source) + (if (assoc 'header-line source) + source + (append source '((header-line . helm-persistent-help-string))))) +(add-to-list 'helm-compile-source-functions 'helm-compile-source--persistent-help) + +(defun helm-persistent-help-string () + (substitute-command-keys + (concat "\\\\[helm-execute-persistent-action]: " + (or (helm-interpret-value (helm-attr 'persistent-help)) + (helm-aif (or (assoc-default + 'persistent-action + (helm-get-current-source)) + (assoc-default + 'action (helm-get-current-source))) + (cond ((symbolp it) + (symbol-name it)) + ((listp it) + (or (ignore-errors (caar it)) "")))) + "") + " (keeping session)"))) + + +;;; Document new attributes +;; +;; +(helm-document-attribute 'persistent-help "persistent-help plug-in" + " A string to explain persistent-action of this source. It also + accepts a function or a variable name.") + + +(provide 'helm-plugin) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-plugin ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-regexp.el b/emacs.d/elpa/helm-20150507.2215/helm-regexp.el new file mode 100644 index 0000000..5b2b2fc --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-regexp.el @@ -0,0 +1,643 @@ +;;; helm-regexp.el --- In buffer regexp searching and replacement for helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) +(require 'helm-plugin) + + +(defgroup helm-regexp nil + "Regexp related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-moccur-always-search-in-current nil + "Helm multi occur always search in current buffer when non--nil." + :group 'helm-regexp + :type 'boolean) + +(defcustom helm-moccur-use-ioccur-style-keys t + "Similar to `helm-grep-use-ioccur-style-keys' but for multi occur." + :group 'helm-regexp + :type 'boolean) + +(defcustom helm-moccur-auto-update-on-resume nil + "Allow auto updating helm-(m)occur buffer when outdated. +noask => Always update without asking +nil => Don't update but signal buffer needs update +never => Never update and do not signal buffer needs update +Any other non--nil value update after confirmation." + :group 'helm-regexp + :type '(radio :tag "Allow auto updating helm-(m)occur buffer when outdated." + (const :tag "Always update without asking" noask) + (const :tag "Never update and do not signal buffer needs update" never) + (const :tag "Don't update but signal buffer needs update" nil) + (const :tag "Update after confirmation" t))) + + +(defface helm-moccur-buffer + '((t (:foreground "DarkTurquoise" :underline t))) + "Face used to highlight moccur buffer names." + :group 'helm-regexp) + +(defface helm-resume-need-update + '((t (:background "red"))) + "Face used to flash moccur buffer when it needs update." + :group 'helm-regexp) + + +(defvar helm-moccur-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-") 'helm-goto-next-file) + (define-key map (kbd "M-") 'helm-goto-precedent-file) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c ?") 'helm-moccur-help) + (define-key map (kbd "C-c o") 'helm-moccur-run-goto-line-ow) + (define-key map (kbd "C-c C-o") 'helm-moccur-run-goto-line-of) + (define-key map (kbd "C-x C-s") 'helm-moccur-run-save-buffer) + (when helm-moccur-use-ioccur-style-keys + (define-key map (kbd "") 'helm-execute-persistent-action) + (define-key map (kbd "") 'helm-moccur-run-default-action)) + (delq nil map)) + "Keymap used in Moccur source.") + + +(defvar helm-build-regexp-history nil) +(defun helm-query-replace-regexp (_candidate) + "Query replace regexp from `helm-regexp'. +With a prefix arg replace only matches surrounded by word boundaries, +i.e Don't replace inside a word, regexp is surrounded with \\bregexp\\b." + (let ((regexp helm-input)) + (apply 'query-replace-regexp + (helm-query-replace-args regexp)))) + +(defun helm-kill-regexp-as-sexp (_candidate) + "Kill regexp in a format usable in lisp code." + (helm-regexp-kill-new + (prin1-to-string helm-input))) + +(defun helm-kill-regexp (_candidate) + "Kill regexp as it is in `helm-pattern'." + (helm-regexp-kill-new helm-input)) + +(defun helm-query-replace-args (regexp) + "create arguments of `query-replace-regexp' action in `helm-regexp'." + (let ((region-only (helm-region-active-p))) + (list + regexp + (query-replace-read-to regexp + (format "Query replace %sregexp %s" + (if helm-current-prefix-arg "word " "") + (if region-only "in region " "")) + t) + helm-current-prefix-arg + (when region-only (region-beginning)) + (when region-only (region-end))))) + +(defvar helm-source-regexp + (helm-build-in-buffer-source "Regexp Builder" + :init (lambda () + (helm-init-candidates-in-buffer + 'global (with-temp-buffer + (insert-buffer-substring helm-current-buffer) + (buffer-string)))) + :get-line #'helm-regexp-get-line + :persistent-action #'helm-regexp-persistent-action + :persistent-help "Show this line" + :multiline t + :matchplugin nil + :requires-pattern 2 + :mode-line "Press TAB to select action." + :action '(("Kill Regexp as sexp" . helm-kill-regexp-as-sexp) + ("Query Replace Regexp (C-u Not inside word.)" + . helm-query-replace-regexp) + ("Kill Regexp" . helm-kill-regexp)))) + +(defun helm-regexp-get-line (s e) + (let ((matches (match-data)) + (line (buffer-substring s e))) + (propertize + (cl-loop with ln = (format "%5d: %s" (line-number-at-pos s) line) + for i from 0 to (1- (/ (length matches) 2)) + concat (format "\n %s'%s'" (format "Group %d: " i) + (match-string i)) + into ln1 + finally return (concat ln ln1)) + 'helm-realvalue s))) + +(defun helm-regexp-persistent-action (pt) + (helm-goto-char pt) + (helm-highlight-current-line)) + +(defun helm-regexp-kill-new (input) + (kill-new input) + (message "Killed: %s" input)) + +(defun helm-quote-whitespace (candidate) + "Quote whitespace, if some, in string CANDIDATE." + (replace-regexp-in-string " " "\\\\ " candidate)) + + +;;; Occur +;; +;; +(defvar helm-source-occur nil) +(defun helm-occur-init-source () + (unless helm-source-occur + (setq helm-source-occur + (helm-make-source "Occur" 'helm-source-multi-occur)))) + + +;;; Multi occur +;; +;; + +;; Internal +(defvar helm-multi-occur-buffer-list nil) +(defvar helm-multi-occur-buffer-tick nil) +(defun helm-moccur-init () + "Create the initial helm multi occur buffer." + (helm-init-candidates-in-buffer + 'global + (cl-loop with buffers = (helm-attr 'moccur-buffers) + for buf in buffers + for bufstr = (with-current-buffer buf (buffer-string)) + do (add-text-properties + 0 (length bufstr) + `(buffer-name ,(buffer-name (get-buffer buf))) + bufstr) + concat bufstr))) + +(defun helm-moccur--next-or-previous-char () + (save-excursion + (or (re-search-forward "^." nil t) + (re-search-backward "^." nil t)))) + +(defun helm-moccur-get-line (beg end) + "Format line for `helm-source-moccur'." + (prog1 + (format "%s:%d:%s" + (get-text-property (if (= beg end) + (helm-moccur--next-or-previous-char) + beg) + 'buffer-name) + (save-restriction + (narrow-to-region (or (previous-single-property-change + (point) 'buffer-name) 1) + (or (next-single-property-change + (if (= beg end) + (helm-moccur--next-or-previous-char) + (point)) + 'buffer-name) + (point-max))) + (line-number-at-pos beg)) + ;; When matching empty line, use empty string + ;; to allow saving and modifying with wgrep. + (if (= beg end) "" (buffer-substring beg end))) + ;; When matching empty line, forward char ("\n") + ;; to not be blocked forever here. + (when (= beg end) (forward-char 1)))) + +(cl-defun helm-moccur-action (candidate + &optional (method (quote buffer)) mark) + "Jump to CANDIDATE with METHOD. +arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame." + (require 'helm-grep) + (let* ((split (helm-grep-split-line candidate)) + (buf (car split)) + (lineno (string-to-number (nth 1 split))) + (split-pat (helm-mp-split-pattern helm-pattern))) + (cl-case method + (buffer (switch-to-buffer buf)) + (buffer-other-window (switch-to-buffer-other-window buf)) + (buffer-other-frame (switch-to-buffer-other-frame buf))) + (helm-goto-line lineno) + ;; Move point to the nearest matching regexp from bol. + (cl-loop for reg in split-pat + when (save-excursion + (condition-case _err + (re-search-forward reg (point-at-eol) t) + (invalid-regexp nil))) + collect (match-beginning 0) into pos-ls + finally (when pos-ls (goto-char (apply #'min pos-ls)))) + (when mark + (set-marker (mark-marker) (point)) + (push-mark (point) 'nomsg)))) + +(defun helm-moccur-persistent-action (candidate) + (helm-moccur-goto-line candidate) + (helm-highlight-current-line)) + +(defun helm-moccur-goto-line (candidate) + "From multi occur, switch to buffer and go to nth 1 CANDIDATE line." + (helm-moccur-action + candidate 'buffer (or current-prefix-arg ; persistent. + helm-current-prefix-arg))) ; exit. + +(defun helm-moccur-goto-line-ow (candidate) + "Go to CANDIDATE line in other window. +Same as `helm-moccur-goto-line' but go in other window." + (helm-moccur-action + candidate 'buffer-other-window + (or current-prefix-arg ; persistent. + helm-current-prefix-arg))) ; exit. + +(defun helm-moccur-goto-line-of (candidate) + "Go to CANDIDATE line in new frame. +Same as `helm-moccur-goto-line' but go in new frame." + (helm-moccur-action + candidate 'buffer-other-frame + (or current-prefix-arg ; persistent. + helm-current-prefix-arg))) ; exit. + +(defun helm-moccur-run-goto-line-ow () + "Run goto line other window action from `helm-source-moccur'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-moccur-goto-line-ow))) + +(defun helm-moccur-run-goto-line-of () + "Run goto line new frame action from `helm-source-moccur'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-moccur-goto-line-of))) + +(defun helm-moccur-run-default-action () + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-moccur-goto-line))) + +(defvar helm-source-moccur nil) +(defclass helm-source-multi-occur (helm-source-in-buffer) + ((init :initform (lambda () + (require 'helm-grep) + (helm-moccur-init))) + (filter-one-by-one :initform 'helm-moccur-filter-one-by-one) + (get-line :initform helm-moccur-get-line) + (nohighlight :initform t) + (migemo :initform t) + (action :initform '(("Go to Line" . helm-moccur-goto-line) + ("Goto line other window" . helm-moccur-goto-line-ow) + ("Goto line new frame" . helm-moccur-goto-line-of))) + (persistent-action :initform 'helm-moccur-persistent-action) + (persistent-help :initform "Go to line") + (recenter :initform t) + (resume :initform 'helm-moccur-resume-fn) + (candidate-number-limit :initform 9999) + (mode-line :initform helm-moccur-mode-line) + (keymap :initform helm-moccur-map) + (history :initform 'helm-grep-history) + (requires-pattern :initform 2))) + +(defun helm-moccur-resume-fn () + (with-helm-buffer + (let (new-tick-ls buffer-is-modified) + (set (make-local-variable 'helm-multi-occur-buffer-list) + (cl-loop for b in helm-multi-occur-buffer-list + when (buffer-live-p (get-buffer b)) + collect b)) + (setq buffer-is-modified (/= (length helm-multi-occur-buffer-list) + (length (helm-attr 'moccur-buffers)))) + (helm-attrset 'moccur-buffers helm-multi-occur-buffer-list) + (setq new-tick-ls (cl-loop for b in helm-multi-occur-buffer-list + collect (buffer-chars-modified-tick (get-buffer b)))) + (when buffer-is-modified + (setq helm-multi-occur-buffer-tick new-tick-ls)) + (cl-assert (> (length helm-multi-occur-buffer-list) 0) nil + "helm-resume error: helm-(m)occur buffer list is empty") + (unless (eq helm-moccur-auto-update-on-resume 'never) + (when (or buffer-is-modified + (cl-loop for b in helm-multi-occur-buffer-list + for new-tick = (buffer-chars-modified-tick (get-buffer b)) + for tick in helm-multi-occur-buffer-tick + thereis (/= tick new-tick))) + (helm-aif helm-moccur-auto-update-on-resume + (when (or (eq it 'noask) + (y-or-n-p "Helm (m)occur Buffer outdated, update? ")) + (run-with-idle-timer 0.1 nil (lambda () + (with-helm-buffer + (helm-force-update) + (message "Helm (m)occur Buffer have been udated") + (sit-for 1) (message nil)))) + (unless buffer-is-modified (setq helm-multi-occur-buffer-tick new-tick-ls))) + (run-with-idle-timer 0.1 nil (lambda () + (with-helm-buffer + (let ((ov (make-overlay (save-excursion + (goto-char (point-min)) + (forward-line 1) + (point)) + (point-max)))) + (overlay-put ov 'face 'helm-resume-need-update) + (sit-for 0.3) (delete-overlay ov) + (message "[Helm occur Buffer outdated (C-c C-u to update)]"))))) + (unless buffer-is-modified + (with-helm-after-update-hook + (setq helm-multi-occur-buffer-tick new-tick-ls) + (message "Helm (m)occur Buffer have been udated"))))))))) + +(defun helm-moccur-filter-one-by-one (candidate) + "`filter-one-by-one' function for `helm-source-moccur'." + (require 'helm-grep) + (let* ((split (helm-grep-split-line candidate)) + (buf (car split)) + (lineno (nth 1 split)) + (str (nth 2 split))) + (cons (concat (propertize + buf + 'face 'helm-moccur-buffer + 'help-echo (buffer-file-name + (get-buffer buf)) + 'buffer-name buf) + ":" + (propertize lineno 'face 'helm-grep-lineno) + ":" + (helm-grep-highlight-match str t)) + candidate))) + +(defun helm-multi-occur-1 (buffers &optional input) + "Main function to call `helm-source-moccur' with BUFFERS list." + (let ((bufs (if helm-moccur-always-search-in-current + (cons + ;; will become helm-current-buffer later. + (buffer-name (current-buffer)) + (remove helm-current-buffer buffers)) + buffers))) + (unless helm-source-moccur + (setq helm-source-moccur + (helm-make-source "Moccur" 'helm-source-multi-occur))) + (helm-attrset 'moccur-buffers bufs helm-source-moccur) + (helm-set-local-variable 'helm-multi-occur-buffer-list bufs) + (helm-set-local-variable + 'helm-multi-occur-buffer-tick + (cl-loop for b in bufs + collect (buffer-chars-modified-tick (get-buffer b))))) + (helm :sources 'helm-source-moccur + :buffer "*helm multi occur*" + :history 'helm-grep-history + :input input + :truncate-lines t)) + +;;;###autoload +(defun helm-moccur-run-save-buffer () + "Run grep save results action from `helm-do-grep-1'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action 'helm-moccur-save-results))) + + +;;; helm-moccur-mode +;; +;; +(defvar helm-moccur-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") 'helm-moccur-mode-goto-line) + (define-key map (kbd "C-o") 'helm-moccur-mode-goto-line-ow) + (define-key map (kbd "") 'helm-moccur-mode-goto-line-ow-forward) + (define-key map (kbd "") 'helm-moccur-mode-goto-line-ow-backward) + (define-key map (kbd "") 'helm-gm-next-file) + (define-key map (kbd "") 'helm-gm-precedent-file) + (define-key map (kbd "M-n") 'helm-moccur-mode-goto-line-ow-forward) + (define-key map (kbd "M-p") 'helm-moccur-mode-goto-line-ow-backward) + (define-key map (kbd "M-N") 'helm-gm-next-file) + (define-key map (kbd "M-P") 'helm-gm-precedent-file) + map)) + +(defun helm-moccur-mode-goto-line () + (interactive) + (helm-aif (get-text-property (point) 'helm-realvalue) + (helm-moccur-goto-line it))) + +(defun helm-moccur-mode-goto-line-ow () + (interactive) + (helm-aif (get-text-property (point) 'helm-realvalue) + (helm-moccur-goto-line-ow it))) + +(defun helm-moccur-mode-goto-line-ow-forward-1 (arg) + (condition-case nil + (progn + (save-selected-window + (helm-moccur-mode-goto-line-ow) + (recenter)) + (forward-line arg)) + (error nil))) + +(defun helm-moccur-mode-goto-line-ow-forward () + (interactive) + (helm-moccur-mode-goto-line-ow-forward-1 1)) + +(defun helm-moccur-mode-goto-line-ow-backward () + (interactive) + (helm-moccur-mode-goto-line-ow-forward-1 -1)) + +(defun helm-moccur-save-results (_candidate) + "Save helm moccur results in a `helm-moccur-mode' buffer." + (let ((buf "*hmoccur*") + new-buf) + (when (get-buffer buf) + (setq new-buf (helm-read-string "OccurBufferName: " buf)) + (cl-loop for b in (helm-buffer-list) + when (and (string= new-buf b) + (not (y-or-n-p + (format "Buffer `%s' already exists overwrite? " + new-buf)))) + do (setq new-buf (helm-read-string "OccurBufferName: " "*hmoccur "))) + (setq buf new-buf)) + (with-current-buffer (get-buffer-create buf) + (setq buffer-read-only t) + (let ((inhibit-read-only t)) + (erase-buffer) + (insert "-*- mode: helm-moccur -*-\n\n" + (format "Moccur Results for `%s':\n\n" helm-pattern)) + (save-excursion + (insert (with-current-buffer helm-buffer + (goto-char (point-min)) (forward-line 1) + (buffer-substring (point) (point-max)))))) + (helm-moccur-mode) (pop-to-buffer buf)) + (message "Helm Moccur Results saved in `%s' buffer" buf))) + +;;;###autoload +(define-derived-mode helm-moccur-mode + special-mode "helm-moccur" + "Major mode to provide actions in helm moccur saved buffer. + +Special commands: +\\{helm-moccur-mode-map}" + (set (make-local-variable 'helm-multi-occur-buffer-list) + (with-helm-buffer helm-multi-occur-buffer-list)) + (set (make-local-variable 'revert-buffer-function) + #'helm-moccur-mode--revert-buffer-function)) + +(defun helm-moccur-mode--revert-buffer-function (&optional _ignore-auto _noconfirm) + (goto-char (point-min)) + (let (pattern) + (when (re-search-forward "^Moccur Results for `\\(.*\\)'" nil t) + (setq pattern (match-string 1)) + (forward-line 0) + (when (re-search-forward "^$" nil t) + (forward-line 1)) + (let ((inhibit-read-only t) + (buffer (current-buffer)) + (buflst helm-multi-occur-buffer-list)) + (delete-region (point) (point-max)) + (message "Reverting buffer...") + (save-excursion + (with-temp-buffer + (insert + "\n" + (cl-loop for buf in buflst + for bufstr = (or (and (buffer-live-p (get-buffer buf)) + (with-current-buffer buf + (buffer-string))) + "") + unless (string= bufstr "") + do (add-text-properties + 0 (length bufstr) + `(buffer-name ,(buffer-name (get-buffer buf))) + bufstr) + concat bufstr) + "\n") + (goto-char (point-min)) + (cl-loop while (re-search-forward pattern nil t) + for line = (helm-moccur-get-line (point-at-bol) (point-at-eol)) + when line + do (with-current-buffer buffer + (insert + (propertize + (car (helm-moccur-filter-one-by-one line)) + 'helm-real-value line) + "\n"))))) + (message "Reverting buffer done"))))) + + +;;; Predefined commands +;; +;; + +;;;###autoload +(defun helm-regexp () + "Preconfigured helm to build regexps. +`query-replace-regexp' can be run from there against found regexp." + (interactive) + (save-restriction + (when (and (helm-region-active-p) + ;; Don't narrow to region if buffer is already narrowed. + (not (helm-current-buffer-narrowed-p (current-buffer)))) + (narrow-to-region (region-beginning) (region-end))) + (helm :sources helm-source-regexp + :buffer "*helm regexp*" + :prompt "Regexp: " + :history 'helm-build-regexp-history))) + +;;;###autoload +(defun helm-occur () + "Preconfigured helm for Occur." + (interactive) + (helm-occur-init-source) + (let ((bufs (list (buffer-name (current-buffer))))) + (helm-attrset 'moccur-buffers bufs helm-source-occur) + (helm-set-local-variable 'helm-multi-occur-buffer-list bufs) + (helm-set-local-variable + 'helm-multi-occur-buffer-tick + (cl-loop for b in bufs + collect (buffer-chars-modified-tick (get-buffer b))))) + (helm :sources 'helm-source-occur + :buffer "*helm occur*" + :history 'helm-grep-history + :preselect (and (memq 'helm-source-occur helm-sources-using-default-as-input) + (format "%s:%d:" (buffer-name) (line-number-at-pos (point)))) + :truncate-lines t)) + +;;;###autoload +(defun helm-occur-from-isearch () + "Invoke `helm-occur' from isearch." + (interactive) + (let ((input (if isearch-regexp + isearch-string + (regexp-quote isearch-string))) + (bufs (list (buffer-name (current-buffer))))) + (isearch-exit) + (helm-occur-init-source) + (helm-attrset 'moccur-buffers bufs helm-source-occur) + (helm-set-local-variable 'helm-multi-occur-buffer-list bufs) + (helm-set-local-variable + 'helm-multi-occur-buffer-tick + (cl-loop for b in bufs + collect (buffer-chars-modified-tick (get-buffer b)))) + (helm :sources 'helm-source-occur + :buffer "*helm occur*" + :history 'helm-grep-history + :input input + :truncate-lines t))) + +;;;###autoload +(defun helm-multi-occur (buffers) + "Preconfigured helm for multi occur. + + BUFFERS is a list of buffers to search through. +With a prefix arg, reverse the behavior of +`helm-moccur-always-search-in-current'. +The prefix arg can be set before calling `helm-multi-occur' +or during the buffer selection." + (interactive (list (helm-comp-read + "Buffers: " (helm-buffer-list) + :marked-candidates t))) + (let ((helm-moccur-always-search-in-current + (if (or current-prefix-arg + helm-current-prefix-arg) + (not helm-moccur-always-search-in-current) + helm-moccur-always-search-in-current))) + (helm-multi-occur-1 buffers))) + +;;;###autoload +(defun helm-multi-occur-from-isearch (&optional _arg) + "Invoke `helm-multi-occur' from isearch. + +With a prefix arg, reverse the behavior of +`helm-moccur-always-search-in-current'. +The prefix arg can be set before calling +`helm-multi-occur-from-isearch' or during the buffer selection." + (interactive "p") + (let (buf-list + helm-moccur-always-search-in-current + (input (if isearch-regexp + isearch-string + (regexp-quote isearch-string)))) + (isearch-exit) + (setq buf-list (helm-comp-read "Buffers: " + (helm-buffer-list) + :name "Occur in buffer(s)" + :marked-candidates t)) + (setq helm-moccur-always-search-in-current + (if (or current-prefix-arg + helm-current-prefix-arg) + (not helm-moccur-always-search-in-current) + helm-moccur-always-search-in-current)) + (helm-multi-occur-1 buf-list input))) + + +(provide 'helm-regexp) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-regexp.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-ring.el b/emacs.d/elpa/helm-20150507.2215/helm-ring.el new file mode 100644 index 0000000..2cc122b --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-ring.el @@ -0,0 +1,413 @@ +;;; helm-ring.el --- kill-ring, mark-ring, and register browsers for helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) +(require 'helm-elisp) + +(declare-function undo-tree-restore-state-from-register "ext:undo-tree.el" (register)) + + +(defgroup helm-ring nil + "Ring related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-kill-ring-threshold 3 + "Minimum length of a candidate to be listed by `helm-source-kill-ring'." + :type 'integer + :group 'helm-ring) + +(defcustom helm-kill-ring-max-lines-number 5 + "Max number of lines displayed per candidate in kill-ring browser. +If nil or zero (disabled), don't truncate candidate, show all." + :type '(choice (const :tag "Disabled" nil) + (integer :tag "Max number of lines")) + :group 'helm-ring) + +(defcustom helm-register-max-offset 160 + "Max size of string register entries before truncating." + :group 'helm-ring + :type 'integer) + + +;;; Kill ring +;; +;; +(defvar helm-kill-ring-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-y") 'helm-next-line) + (define-key map (kbd "M-u") 'helm-previous-line) + map) + "Keymap for `helm-show-kill-ring'.") + +(defvar helm-source-kill-ring + (helm-build-sync-source "Kill Ring" + :init (lambda () (helm-attrset 'last-command last-command)) + :candidates #'helm-kill-ring-candidates + :filtered-candidate-transformer #'helm-kill-ring-transformer + :action '(("Yank" . helm-kill-ring-action) + ("Delete" . (lambda (candidate) + (cl-loop for cand in (helm-marked-candidates) + do (setq kill-ring + (delete cand kill-ring)))))) + :persistent-action (lambda (_candidate) (ignore)) + :persistent-help "DoNothing" + :keymap helm-kill-ring-map + :migemo t + :multiline t) + "Source for browse and insert contents of kill-ring.") + +(defun helm-kill-ring-candidates () + (cl-loop for kill in (helm-fast-remove-dups kill-ring :test 'equal) + unless (or (< (length kill) helm-kill-ring-threshold) + (string-match "\\`[\n[:blank:]]+\\'" kill)) + collect kill)) + +(defun helm-kill-ring-transformer (candidates _source) + "Display only the `helm-kill-ring-max-lines-number' lines of candidate." + (cl-loop for i in candidates + when (get-text-property 0 'read-only i) + do (set-text-properties 0 (length i) '(read-only nil) i) + for nlines = (with-temp-buffer (insert i) (count-lines (point-min) (point-max))) + if (and helm-kill-ring-max-lines-number + (> nlines helm-kill-ring-max-lines-number)) + collect (cons + (with-temp-buffer + (insert i) + (goto-char (point-min)) + (concat + (buffer-substring + (point-min) + (save-excursion + (forward-line helm-kill-ring-max-lines-number) + (point))) + "[...]")) i) + else collect i)) + +(defun helm-kill-ring-action (str) + "Insert STR in `kill-ring' and set STR to the head. +If this action is executed just after `yank', +replace with STR as yanked string." + (with-helm-current-buffer + (setq kill-ring (delete str kill-ring)) + (if (not (eq (helm-attr 'last-command helm-source-kill-ring) 'yank)) + (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) + ;; from `yank-pop' + (let ((inhibit-read-only t) + (before (< (point) (mark t)))) + (if before + (funcall (or yank-undo-function 'delete-region) (point) (mark t)) + (funcall (or yank-undo-function 'delete-region) (mark t) (point))) + (setq yank-undo-function nil) + (set-marker (mark-marker) (point) helm-current-buffer) + (run-with-timer 0.01 nil `(lambda () (insert-for-yank ,str))) + ;; Set the window start back where it was in the yank command, + ;; if possible. + (set-window-start (selected-window) yank-window-start t) + (when before + ;; This is like exchange-point-and-mark, but doesn't activate the mark. + ;; It is cleaner to avoid activation, even though the command + ;; loop would deactivate the mark because we inserted text. + (goto-char (prog1 (mark t) + (set-marker (mark-marker) (point) helm-current-buffer)))))) + (kill-new str))) + + + + +;;;; +;; DO NOT use these sources with other sources use +;; the commands `helm-mark-ring', `helm-global-mark-ring' or +;; `helm-all-mark-rings' instead. + +(defun helm-mark-ring-get-marks (pos) + (save-excursion + (goto-char pos) + (forward-line 0) + (let ((line (car (split-string (thing-at-point 'line) "[\n\r]")))) + (when (string= "" line) + (setq line "")) + (format "%7d: %s" (line-number-at-pos) line)))) + +(defun helm-mark-ring-get-candidates () + (with-helm-current-buffer + (cl-loop with marks = (if (mark t) (cons (mark-marker) mark-ring) mark-ring) + for i in marks + for m = (helm-mark-ring-get-marks i) + unless (and recip (member m recip)) + collect m into recip + finally return recip))) + +(defvar helm-source-mark-ring + (helm-build-sync-source "mark-ring" + :candidates #'helm-mark-ring-get-candidates + :action '(("Goto line" + . (lambda (candidate) + (helm-goto-line (string-to-number candidate))))) + :persistent-action (lambda (candidate) + (helm-goto-line (string-to-number candidate)) + (helm-highlight-current-line)) + :persistent-help "Show this line")) + + +;;; Global-mark-ring +(defvar helm-source-global-mark-ring + (helm-build-sync-source "global-mark-ring" + :candidates #'helm-global-mark-ring-get-candidates + :action '(("Goto line" + . (lambda (candidate) + (let ((items (split-string candidate ":"))) + (switch-to-buffer (cl-second items)) + (helm-goto-line (string-to-number (car items))))))) + :persistent-action (lambda (candidate) + (let ((items (split-string candidate ":"))) + (switch-to-buffer (cl-second items)) + (helm-goto-line (string-to-number (car items))) + (helm-highlight-current-line))) + :persistent-help "Show this line")) + +(defun helm-global-mark-ring-format-buffer (marker) + (with-current-buffer (marker-buffer marker) + (goto-char marker) + (forward-line 0) + (let ((line (car (split-string (thing-at-point 'line) "[\n\r]")))) + (when (string= "" line) (setq line "")) + (format "%7d:%s: %s" + (line-number-at-pos) (marker-buffer marker) line)))) + +(defun helm-global-mark-ring-get-candidates () + (let ((marks global-mark-ring)) + (when marks + (cl-loop for i in marks + for mb = (marker-buffer i) + for gm = (unless (or (string-match "^ " (format "%s" mb)) + (null mb)) + (helm-global-mark-ring-format-buffer i)) + when (and gm (not (member gm recip))) + collect gm into recip + finally return recip)))) + + +;;;; +;;; Insert from register +(defvar helm-source-register + (helm-build-sync-source "Registers" + :candidates #'helm-register-candidates + :action-transformer #'helm-register-action-transformer + :multiline t + :action nil) + "See (info \"(emacs)Registers\")") + +(defun helm-register-candidates () + "Collecting register contents and appropriate commands." + (cl-loop for (char . val) in register-alist + for key = (single-key-description char) + for string-actions = + (cond + ((numberp val) + (list (int-to-string val) + 'insert-register + 'increment-register)) + ((markerp val) + (let ((buf (marker-buffer val))) + (if (null buf) + (list "a marker in no buffer") + (list (concat + "a buffer position:" + (buffer-name buf) + ", position " + (int-to-string (marker-position val))) + 'jump-to-register + 'insert-register)))) + ((and (consp val) (window-configuration-p (car val))) + (list "window configuration." + 'jump-to-register)) + ((and (vectorp val) + (fboundp 'undo-tree-register-data-p) + (undo-tree-register-data-p (elt val 1))) + (list + "Undo-tree entry." + 'undo-tree-restore-state-from-register)) + ((or (and (vectorp val) (eq 'registerv (aref val 0))) + (and (consp val) (frame-configuration-p (car val)))) + (list "frame configuration." + 'jump-to-register)) + ((and (consp val) (eq (car val) 'file)) + (list (concat "file:" + (prin1-to-string (cdr val)) + ".") + 'jump-to-register)) + ((and (consp val) (eq (car val) 'file-query)) + (list (concat "file:a file-query reference: file " + (car (cdr val)) + ", position " + (int-to-string (car (cdr (cdr val)))) + ".") + 'jump-to-register)) + ((consp val) + (let ((lines (format "%4d" (length val)))) + (list (format "%s: %s\n" lines + (truncate-string-to-width + (mapconcat 'identity (list (car val)) + "^J") (- (window-width) 15))) + 'insert-register))) + ((stringp val) + (list + ;; without properties + (concat (substring-no-properties + val 0 (min (length val) helm-register-max-offset)) + (if (> (length val) helm-register-max-offset) + "[...]" "")) + 'insert-register + 'append-to-register + 'prepend-to-register)) + (t + "GARBAGE!")) + collect (cons (format "Register %3s:\n %s" key (car string-actions)) + (cons char (cdr string-actions))))) + +(defun helm-register-action-transformer (_actions register-and-functions) + "Decide actions by the contents of register." + (cl-loop with func-actions = + '((insert-register + "Insert Register" . + (lambda (c) (insert-register (car c)))) + (jump-to-register + "Jump to Register" . + (lambda (c) (jump-to-register (car c)))) + (append-to-register + "Append Region to Register" . + (lambda (c) (append-to-register + (car c) (region-beginning) (region-end)))) + (prepend-to-register + "Prepend Region to Register" . + (lambda (c) (prepend-to-register + (car c) (region-beginning) (region-end)))) + (increment-register + "Increment Prefix Arg to Register" . + (lambda (c) (increment-register + helm-current-prefix-arg (car c)))) + (undo-tree-restore-state-from-register + "Restore Undo-tree register" + (lambda (c) (and (fboundp 'undo-tree-restore-state-from-register) + (undo-tree-restore-state-from-register (car c)))))) + for func in (cdr register-and-functions) + for cell = (assq func func-actions) + when cell + collect (cdr cell))) + +;;;###autoload +(defun helm-mark-ring () + "Preconfigured `helm' for `helm-source-mark-ring'." + (interactive) + (helm :sources 'helm-source-mark-ring + :resume 'noresume + :buffer "*helm mark*")) + +;;;###autoload +(defun helm-global-mark-ring () + "Preconfigured `helm' for `helm-source-global-mark-ring'." + (interactive) + (helm :sources 'helm-source-global-mark-ring + :resume 'noresume + :buffer "*helm global mark*")) + +;;;###autoload +(defun helm-all-mark-rings () + "Preconfigured `helm' for `helm-source-global-mark-ring' and \ +`helm-source-mark-ring'." + (interactive) + (helm :sources '(helm-source-mark-ring + helm-source-global-mark-ring) + :resume 'noresume + :buffer "*helm mark ring*")) + +;;;###autoload +(defun helm-register () + "Preconfigured `helm' for Emacs registers." + (interactive) + (helm :sources 'helm-source-register + :resume 'noresume + :buffer "*helm register*")) + +;;;###autoload +(defun helm-show-kill-ring () + "Preconfigured `helm' for `kill-ring'. +It is drop-in replacement of `yank-pop'. + +First call open the kill-ring browser, next calls move to next line." + (interactive) + (let ((enable-recursive-minibuffers t)) + (helm :sources helm-source-kill-ring + :buffer "*helm kill ring*" + :resume 'noresume + :allow-nest t))) + +(defvar helm-kmacro-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-kmacro-help) + map)) + +;;;###autoload +(defun helm-execute-kmacro () + "Keyboard macros with helm interface. +Define your macros with `f3' and `f4'. +See (info \"(emacs) Keyboard Macros\") for detailed infos. +This command is useful when used with persistent action." + (interactive) + (helm :sources + (helm-build-sync-source "Kmacro" + :candidates (lambda () + (helm-fast-remove-dups + (cons (kmacro-ring-head) + kmacro-ring) + :test 'equal)) + :multiline t + :keymap helm-kmacro-map + :candidate-transformer + (lambda (candidates) + (cl-loop for c in candidates collect + (propertize (help-key-description (car c) nil) + 'helm-realvalue c))) + :persistent-help "Execute kmacro" + :action + (helm-make-actions + "Execute kmacro (`C-u ' to execute times)" + (lambda (candidate) + (interactive) + ;; Move candidate on top of list for next use. + (setq kmacro-ring (delete candidate kmacro-ring)) + (kmacro-push-ring) + (kmacro-split-ring-element candidate) + (kmacro-exec-ring-item + candidate helm-current-prefix-arg)))) + :buffer "*helm kmacro*")) + +(provide 'helm-ring) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-ring.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-semantic.el b/emacs.d/elpa/helm-20150507.2215/helm-semantic.el new file mode 100644 index 0000000..72ab49c --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-semantic.el @@ -0,0 +1,209 @@ +;;; helm-semantic.el --- Helm interface for Semantic -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Daniel Hackney +;; Author: Daniel Hackney + +;; 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: + +;; Uses `candidates-in-buffer' for speed. + +;;; Code: + +(require 'cl-lib) +(require 'semantic) +(require 'helm-imenu) + +(declare-function pulse-momentary-highlight-one-line "pulse.el" (point &optional face)) + +(defgroup helm-semantic nil + "Semantic tags related libraries and applications for helm." + :group 'helm) + +(defcustom helm-semantic-lynx-style-map t + "Use Arrow keys to jump to occurences." + :group 'helm-semantic + :type 'boolean) + +(defcustom helm-semantic-display-style 'semantic-format-tag-summarize + "Function to present a semantic tag." + :group 'helm-semantic + :type '(radio + (const :tag "Default" semantic-format-tag-summarize) + (const :tag "Prototype" semantic-format-tag-prototype))) + +;;; keymap +(defvar helm-semantic-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-semantic-help) + (when helm-semantic-lynx-style-map + (define-key map (kbd "") 'helm-maybe-exit-minibuffer) + (define-key map (kbd "") 'helm-execute-persistent-action)) + (delq nil map))) + +;; Internals vars +(defvar helm-semantic--tags-cache nil) + +(defun helm-semantic--fetch-candidates (tags depth &optional class) + "Write the contents of TAGS to the current buffer." + (let ((class class) cur-type) + (cl-dolist (tag tags) + (when (listp tag) + (cl-case (setq cur-type (semantic-tag-class tag)) + ((function variable type) + (let ((spaces (make-string (* depth 2) ?\s)) + (type-p (eq cur-type 'type))) + (unless (and (> depth 0) (not type-p)) + (setq class nil)) + (insert + (if (and class (not type-p)) + (format "%s%s(%s) " + spaces (if (< depth 2) "" "├►") class) + spaces) + ;; Save the tag for later + (propertize (funcall helm-semantic-display-style tag nil t) + 'semantic-tag tag) + "\n") + (and type-p (setq class (car tag))) + ;; Recurse to children + (unless (eq cur-type 'function) + (helm-semantic--fetch-candidates + (semantic-tag-components tag) (1+ depth) class)))) + + ;; Don't do anything with packages or includes for now + ((package include) + (insert + (propertize (funcall helm-semantic-display-style tag nil t) + 'semantic-tag tag) + "\n") + ) + ;; Catch-all + (t)))))) + +(defun helm-semantic-default-action (_candidate &optional persistent) + ;; By default, helm doesn't pass on the text properties of the selection. + ;; Fix this. + (helm-log-run-hook 'helm-goto-line-before-hook) + (with-current-buffer helm-buffer + (when (looking-at " ") + (goto-char (next-single-property-change + (point-at-bol) 'semantic-tag nil (point-at-eol)))) + (let ((tag (get-text-property (point) 'semantic-tag))) + (semantic-go-to-tag tag) + (unless persistent + (pulse-momentary-highlight-one-line (point)))))) + +(defun helm-semantic--maybe-set-needs-update () + (with-helm-current-buffer + (let ((tick (buffer-modified-tick))) + (unless (eq helm-cached-imenu-tick tick) + (setq helm-cached-imenu-tick tick) + (semantic-parse-tree-set-needs-update))))) + +(defvar helm-source-semantic nil) + +(defclass helm-semantic-source (helm-source-in-buffer) + ((init :initform (lambda () + (helm-semantic--maybe-set-needs-update) + (setq helm-semantic--tags-cache (semantic-fetch-tags)) + (with-current-buffer (helm-candidate-buffer 'global) + (let ((major-mode (with-helm-current-buffer major-mode))) + (helm-semantic--fetch-candidates helm-semantic--tags-cache 0))))) + (get-line :initform 'buffer-substring) + (persistent-help :initform "Show this entry") + (keymap :initform 'helm-semantic-map) + (mode-line :initform helm-semantic-mode-line) + (persistent-action :initform (lambda (elm) + (helm-semantic-default-action elm t) + (helm-highlight-current-line))) + (action :initform 'helm-semantic-default-action))) + +(defcustom helm-semantic-fuzzy-match nil + "Enable fuzzy matching in `helm-source-semantic'." + :group 'helm-semantic + :type 'boolean + :set (lambda (var val) + (set var val) + (setq helm-source-semantic + (helm-make-source "Semantic Tags" 'helm-semantic-source + :fuzzy-match helm-semantic-fuzzy-match)))) + +;;;###autoload +(defun helm-semantic (arg) + "Preconfigured `helm' for `semantic'. +If ARG is supplied, pre-select symbol at point instead of current" + (interactive "P") + (let ((tag (helm-aif (semantic-current-tag-parent) + (cons (format "\\_<%s\\_>" (car it)) + (format "\\_<%s\\_>" (car (semantic-current-tag)))) + (format "\\_<%s\\_>" (car (semantic-current-tag)))))) + (unless helm-source-semantic + (setq helm-source-semantic + (helm-make-source "Semantic Tags" 'helm-semantic-source + :fuzzy-match helm-semantic-fuzzy-match))) + (helm :sources 'helm-source-semantic + :candidate-number-limit 9999 + :preselect (if arg + (thing-at-point 'symbol) + tag) + :buffer "*helm semantic*"))) + +;;;###autoload +(defun helm-semantic-or-imenu (arg) + "Run `helm' with `semantic' or `imenu'. +If ARG is supplied, pre-select symbol at point instead of current +semantic tag in scope. + +If `semantic-mode' is active in the current buffer, then use +semantic for generating tags, otherwise fall back to `imenu'. +Fill in the symbol at point by default." + (interactive "P") + (unless helm-source-semantic + (setq helm-source-semantic + (helm-make-source "Semantic Tags" 'helm-semantic-source + :fuzzy-match helm-semantic-fuzzy-match))) + (unless helm-source-imenu + (setq helm-source-imenu + (helm-make-source "Imenu" 'helm-imenu-source + :fuzzy-match helm-imenu-fuzzy-match))) + (let* ((source (if (semantic-active-p) + 'helm-source-semantic + 'helm-source-imenu)) + (imenu-p (eq source 'helm-source-imenu)) + (imenu-auto-rescan imenu-p) + (helm-execute-action-at-once-if-one + (and imenu-p + helm-imenu-execute-action-at-once-if-one)) + (tag (helm-aif (semantic-current-tag-parent) + (cons (format "\\_<%s\\_>" (car it)) + (format "\\_<%s\\_>" (car (semantic-current-tag)))) + (format "\\_<%s\\_>" (car (semantic-current-tag)))))) + (helm :sources source + :candidate-number-limit 9999 + :preselect (if (or arg imenu-p) + (thing-at-point 'symbol) + tag) + :buffer "*helm semantic/imenu*"))) + +(provide 'helm-semantic) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-semantic.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-source.el b/emacs.d/elpa/helm-20150507.2215/helm-source.el new file mode 100644 index 0000000..a55e127 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-source.el @@ -0,0 +1,1153 @@ +;;; helm-source.el --- Helm source creation. -*- lexical-binding: t -*- + +;; Copyright (C) 2015 Thierry Volpiatto + +;; Author: Thierry Volpiatto +;; URL: http://github.com/emacs-helm/helm + +;; 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: + +;; Interface to create helm sources easily. +;; Actually the eieo objects are transformed in alist for compatibility. +;; In the future this package should allow creating source as eieo objects +;; without conversion to alist, teaching helm to read such a structure. +;; The compatibility with alists would be kept. + +;;; Code: + +(require 'cl-lib) +(require 'eieio) + + +(defgeneric helm--setup-source (source) + "Prepare slots and handle slot errors before creating a helm source.") + +(defgeneric helm-setup-user-source (source) + "Allow users modifying slots in SOURCE just before creation.") + + +;;; Classes for sources +;; +;; +(defclass helm-source () + ((name + :initarg :name + :initform nil + :custom string + :documentation + " The name of the source. + A string which is also the heading which appears + above the list of matches from the source. Must be unique.") + + (header-name + :initarg :header-name + :initform nil + :custom function + :documentation + " A function returning the display string of the header. + Its argument is the name of the source. This attribute is useful to + add an additional information with the source name. + It doesn't modify the name of the source.") + + (init + :initarg :init + :initform nil + :custom function + :documentation + " Function called with no parameters when helm is started. + It is useful for collecting current state information which can be + used to create the list of candidates later. + Initialization of `candidates-in-buffer' is done here + with `helm-init-candidates-in-buffer'.") + + (candidates + :initarg :candidates + :initform nil + :custom (choice function list) + :documentation + " Specifies how to retrieve candidates from the source. + It can either be a variable name, a function called with no parameters + or the actual list of candidates. + + The list must be a list whose members are strings, symbols + or (DISPLAY . REAL) pairs. + + In case of (DISPLAY . REAL) pairs, the DISPLAY string is shown + in the Helm buffer, but the REAL one is used as action + argument when the candidate is selected. This allows a more + readable presentation for candidates which would otherwise be, + for example, too long or have a common part shared with other + candidates which can be safely replaced with an abbreviated + string for display purposes. + + Note that if the (DISPLAY . REAL) form is used then pattern + matching is done on the displayed string, not on the real + value.") + + (update + :initarg :update + :initform nil + :custom function + :documentation + " Function called with no parameters at before \"init\" function + when `helm-force-update' is called.") + + (cleanup + :initarg :cleanup + :initform nil + :custom function + :documentation + " Function called with no parameters when *helm* buffer is + closed. It is useful for killing unneeded candidates buffer. + + Note that the function is executed BEFORE performing action.") + + (delayed + :initarg :delayed + :initform nil + :custom (choice null integer) + :documentation + " Candidates from the source are shown only if the user stops + typing and is idle for `helm-idle-delay' seconds. + If a value is given to delayed attr, this value is used instead only + if it is > to `helm-idle-delay'.") + + (keymap + :initarg :keymap + :initform nil + :custom sexp + :documentation + " Specific keymap for this source. + It is useful to have a keymap per source when using more than + one source. Otherwise, a keymap can be set per command with + `helm' argument KEYMAP. NOTE: when a source have `helm-map' as + keymap attr, the global value of `helm-map' will override the + actual local one.") + + (action + :initarg :action + :initform 'identity + :custom (alist :key-type string + :value-type function) + :documentation + " It is a list of (DISPLAY . FUNCTION) pairs or FUNCTION. + FUNCTION is called with one parameter: the selected candidate. + + An action other than the default can be chosen from this list + of actions for the currently selected candidate (by default + with TAB). The DISPLAY string is shown in the completions + buffer and the FUNCTION is invoked when an action is + selected. The first action of the list is the default. + + You should use `helm-make-actions' to build this alist easily.") + + (persistent-action + :initarg :persistent-action + :initform nil + :custom function + :documentation + " Can be a either a Function called with one parameter (the + selected candidate) or a cons cell where first element is this + same function and second element a symbol (e.g never-split) + that inform `helm-execute-persistent-action'to not split his + window to execute this persistent action.") + + (persistent-help + :initarg :persistent-help + :initform nil + :custom string + :documentation + " A string to explain persistent-action of this source. It also + accepts a function or a variable name. + It will be displayed in source header.") + + (help-message + :initarg :help-message + :initform nil + :custom (choice string function) + :documentation + " Help message for this source. + If not present, `helm-help-message' value will be used.") + + (multiline + :initarg :multiline + :initform nil + :custom boolean + :documentation + " Enable to selection multiline candidates.") + + (requires-pattern + :initarg :requires-pattern + :initform nil + :custom integer + :documentation + " If present matches from the source are shown only if the + pattern is not empty. Optionally, it can have an integer + parameter specifying the required length of input which is + useful in case of sources with lots of candidates.") + + (candidate-transformer + :initarg :candidate-transformer + :initform nil + :custom (choice function list) + :documentation + " It's a function or a list of functions called with one argument + when the completion list from the source is built. The argument + is the list of candidates retrieved from the source. The + function should return a transformed list of candidates which + will be used for the actual completion. If it is a list of + functions, it calls each function sequentially. + + This can be used to transform or remove items from the list of + candidates. + + Note that `candidates' is run already, so the given transformer + function should also be able to handle candidates with (DISPLAY + . REAL) format.") + + (filtered-candidate-transformer + :initarg :filtered-candidate-transformer + :initform nil + :custom (choice function list) + :documentation + " It has the same format as `candidate-transformer', except the + function is called with two parameters: the candidate list and + the source. + + This transformer is run on the candidate list which is already + filtered by the current pattern. While `candidate-transformer' + is run only once, it is run every time the input pattern is + changed. + + It can be used to transform the candidate list dynamically, for + example, based on the current pattern. + + In some cases it may also be more efficent to perform candidate + transformation here, instead of with `candidate-transformer' + even if this transformation is done every time the pattern is + changed. For example, if a candidate set is very large then + `candidate-transformer' transforms every candidate while only + some of them will actually be displayed due to the limit + imposed by `helm-candidate-number-limit'. + + Note that `candidates' and `candidate-transformer' is run + already, so the given transformer function should also be able + to handle candidates with (DISPLAY . REAL) format.") + + (filter-one-by-one + :initarg :filter-one-by-one + :initform nil + :custom (choice function list) + :documentation + " A transformer function that treat candidates one by one. + It is called with one arg the candidate. + It is faster than `filtered-candidate-transformer' or + `candidates-transformer', but should be used only in sources + that recompute constantly their candidates, e.g `helm-source-find-files'. + Filtering happen early and candidates are treated + one by one instead of re-looping on the whole list. + If used with `filtered-candidate-transformer' or `candidates-transformer' + these functions should treat the candidates transformed by the + `filter-one-by-one' function in consequence.") + + (display-to-real + :initarg :display-to-real + :initform nil + :custom function + :documentation + " Function called with one parameter; the selected candidate. + + The function transforms the selected candidate, and the result + is passed to the action function. The display-to-real + attribute provides another way to pass to action other string than + the one shown in Helm buffer. + + Traditionally, it is possible to make candidates, + candidate-transformer or filtered-candidate-transformer + function return a list with (DISPLAY . REAL) pairs. But if REAL + can be generated from DISPLAY, display-to-real is more + convenient and faster. + + NOTE: This is deprecated and you have better time using `filter-one-by-one'.") + + (real-to-display + :initarg :real-to-display + :initform nil + :custom function + :documentation + " Function called with one parameter; the selected candidate. + The real value of candidates will be shown in display. + See `display-to-real'.") + + (action-transformer + :initarg :action-transformer + :initform nil + :custom (choice function list) + :documentation + " It's a function or a list of functions called with two + arguments when the action list from the source is + assembled. The first argument is the list of actions, the + second is the current selection. If it is a list of functions, + it calls each function sequentially. + + The function should return a transformed action list. + + This can be used to customize the list of actions based on the + currently selected candidate.") + + (pattern-transformer + :initarg :pattern-transformer + :initform nil + :custom (choice function list) + :documentation + " It's a function or a list of functions called with one argument + before computing matches. Its argument is `helm-pattern'. + Functions should return transformed `helm-pattern'. + + It is useful to change interpretation of `helm-pattern'.") + + (candidate-number-limit + :initarg :candidate-number-limit + :initform nil + :custom integer + :documentation + " Override `helm-candidate-number-limit' only for this source.") + + (volatile + :initarg :volatile + :initform nil + :custom boolean + :documentation + " Indicates the source assembles the candidate list dynamically, + so it shouldn't be cached within a single Helm + invocation. It is only applicable to synchronous sources, + because asynchronous sources are not cached.") + + (match + :initarg :match + :initform nil + :custom (choice function list) + :documentation + " List of functions called with one parameter: a candidate. The + function should return non-nil if the candidate matches the + current pattern (see variable `helm-pattern'). + + When using `candidates-in-buffer' its default value is `identity' and + don't have to be changed, use the `search' slot instead. + + This attribute allows the source to override the default + pattern matching based on `string-match'. It can be used, for + example, to implement a source for file names and do the + pattern matching on the basename of files, since it's more + likely one is typing part of the basename when searching for a + file, instead of some string anywhere else in its path. + + If the list contains more than one function then the list of + matching candidates from the source is constructed by appending + the results after invoking the first function on all the + potential candidates, then the next function, and so on. The + matching candidates supplied by the first function appear first + in the list of results and then results from the other + functions, respectively. + + This attribute has no effect for asynchronous sources (see + attribute `candidates'), since they perform pattern matching + themselves. + + Note that FUZZY-MATCH slot will overhide value of this slot.") + + (fuzzy-match + :initarg :fuzzy-match + :initform nil + :custom boolean + :documentation + " Enable fuzzy matching in this source. + This will overwrite settings in MATCH slot, and for + sources built with child class `helm-source-in-buffer' the SEARCH slot. + This is an easy way of enabling fuzzy matching, but you can use the MATCH + or SEARCH slots yourself if you want something more elaborated, mixing + different type of match (See `helm-source-buffers' class for example).") + + (nomark + :initarg :nomark + :initform nil + :custom boolean + :documentation + " Don't allow marking candidates when this attribute is present.") + + (nohighlight + :initarg :nohighlight + :initform nil + :custom boolean + :documentation + " Disable highlighting matches in this source. + This will disable generic highlighting of matches, + but some specialized highlighting can be done from elsewhere, + i.e from `filtered-candidate-transformer' or `filter-one-by-one' slots. + So use this to either disable completely highlighting in your source, + or to disable highlighting and use a specialized highlighting matches + function for this source. + Remember that this function should run AFTER all filter functions if those + filter functions are modifying face properties, though it is possible to + avoid this by using new `add-face-text-property' in your filter functions.") + + (allow-dups + :initarg :allow-dups + :initform nil + :custom boolean + :documentation + " Allow helm collecting duplicates candidates.") + + (recenter + :initarg :recenter + :initform nil + :custom boolean + :documentation + " `recenter' after jumping to candidate.") + + (history + :initarg :history + :initform nil + :custom symbol + :documentation + " Allow passing history variable to helm from source. + It should be a quoted symbol.") + + (coerce + :initarg :coerce + :initform nil + :custom function + :documentation + " It's a function called with one argument: the selected candidate. + This function is intended for type convertion. In normal case, + the selected candidate (string) is passed to action + function. If coerce function is specified, it is called just + before action function. + + Example: converting string to symbol + (coerce . intern)") + + (mode-line + :initarg :mode-line + :initform nil + :custom (choice string sexp) + :documentation + " Source local `helm-mode-line-string' (included in + `mode-line-format'). It accepts also variable/function name.") + + (header-line + :initarg :header-line + :initform nil + :custom (choice string function) + :documentation + " Source local `header-line-format'. + It accepts also variable/function name.") + + (resume + :initarg :resume + :initform nil + :custom function + :documentation + " Function called with no parameters at end of initialization + when `helm-resume' is started. + If this function try to do something against `helm-buffer', \(e.g updating, + searching etc...\) probably you should run it in a timer to ensure + `helm-buffer' is ready.") + + (follow + :initarg :follow + :initform nil + :custom integer + :documentation + " Enable `helm-follow-mode' for this source only. + You must give it a value of 1 or -1, though giving a -1 value + is surely not what you want, e.g: (follow . 1) + + See `helm-follow-mode' for more infos.") + + (follow-delay + :initarg :follow-delay + :initform nil + :custom integer + :documentation + " `helm-follow-mode' will execute persistent-action after this delay. + Otherwise value of `helm-follow-input-idle-delay' is used if non--nil, + If none of these are found fallback to `helm-input-idle-delay'.") + + (dont-plug + :initarg :dont-plug + :initform '(helm-compile-source--persistent-help) + :custom list + :documentation + " A list of compile functions plugin to ignore.") + + (migemo + :initarg :migemo + :initform nil + :custom boolean + :documentation + " Needed for Japanese input with helm-migemo.el. + If you are not Japanese, ignore this.") + + (matchplugin + :initarg :matchplugin + :initform t + :custom boolean) + + (match-part + :initarg :match-part + :initform nil + :custom function + :documentation + " Allow matching only one part of candidate. + If source contain match-part attribute, match is computed only + on part of candidate returned by the call of function provided + by this attribute. The function should have one arg, candidate, + and return only a specific part of candidate.") + + (before-init-hook + :initarg :before-init-hook + :initform nil + :custom symbol + :documentation + " A local hook that run at beginning of initilization of this source. + i.e Before the creation of `helm-buffer'.") + + (after-init-hook + :initarg :after-init-hook + :initform nil + :custom symbol + :documentation + " A local hook that run at end of initilization of this source. + i.e After the creation of `helm-buffer'.")) + + "Main interface to define helm sources." + :abstract t) + +(defclass helm-source-sync (helm-source) + ((candidates + :initform '("ERROR: You must specify the `candidates' slot, either with a list or a function")) + + (dont-plug + :initform '(helm-compile-source--match-plugin + helm-compile-source--persistent-help)) + + (match-strict + :initarg :match-strict + :initform nil + :custom function + :documentation + " When specifying a match function within a source and + helm-match-plugin is enabled, the result of all matching + functions will be concatened, which in some cases is not what + is wanted. When using `match-strict' only this or these + functions will be used. You can specify those functions as a + list of functions or a single symbol function. + + NOTE: This have the same effect as using :MATCHPLUGIN nil.")) + + "Use this class to make helm sources using a list of candidates. +This list should be given as a normal list, a variable handling a list +or a function returning a list. +Matching is done basically with `string-match' against each candidate.") + +(defclass helm-source-async (helm-source) + ((candidates-process + :initarg :candidates-process + :initform nil + :custom function + :documentation + " This attribute is used to define a process as candidate. + The value must be a process. + + NOTE: + When building the source at runtime you can give directly a process + as value, otherwise wrap the process call into a function. + The process buffer should be nil, otherwise, if you use + `helm-buffer' give to the process a sentinel.") + + (matchplugin :initform nil) + (dont-plug :initform '(helm-compile-source--match-plugin + helm-compile-source--persistent-help))) + + "Use this class to define a helm source calling an external process. +The :candidates slot is not allowed even if described because this class +inherit from `helm-source'.") + +(defclass helm-source-in-buffer (helm-source) + ((init + :initform 'helm-default-init-source-in-buffer-function) + + (data + :initarg :data + :initform nil + :custom (choice list string) + :documentation + " A string or a list that will be used to feed the `helm-candidates-buffer'. + This data will be passed in a function added to the init slot and + the buffer will be build with `helm-init-candidates-in-buffer'. + This is an easy and fast method to build a `candidates-in-buffer' source.") + + (dont-plug + :initform '(helm-compile-source--candidates-in-buffer + helm-compile-source--match-plugin + helm-compile-source--persistent-help)) + + (candidates + :initform 'helm-candidates-in-buffer) + + (volatile + :initform t) + + (match + :initform '(identity)) + + (get-line + :initarg :get-line + :initform 'buffer-substring-no-properties + :custom function + :documentation + " A function like `buffer-substring-no-properties' or `buffer-substring'. + This function converts point of line-beginning and point of line-end, + which represents a candidate computed by `helm-candidates-in-buffer'. + By default, `helm-candidates-in-buffer' uses + `buffer-substring-no-properties'.") + + (search + :initarg :search + :initform '(helm-candidates-in-buffer-search-default-fn) + :custom (choice function list) + :documentation + " List of functions like `re-search-forward' or `search-forward'. + Buffer search function used by `helm-candidates-in-buffer'. + By default, `helm-candidates-in-buffer' uses `re-search-forward'. + The function should take one arg PATTERN. + If your search function needs to handle negation like matchplugin, + this function should returns in such case a cons cell of two integers defining + the beg and end positions to match in the line previously matched by + `re-search-forward' or similar, and move point to next line + (See how the `helm-mp-3-search-base' and `helm-fuzzy-search' functions are working). + + NOTE: FUZZY-MATCH slot will overhide value of this slot.") + + (search-strict + :initarg :search-strict + :initform nil + :custom function + :documentation + " When specifying a search function within a source and + helm-match-plugin is enabled, the result of all searching + functions will be concatened, which in some cases is not what + is wanted. When using `search-strict' only this or these + functions will be used. You can specify those functions as a + list of functions or a single symbol function. + + NOTE: This have the same effect as using a nil value for + :MATCHPLUGIN slot.")) + + "Use this source to make helm sources storing candidates inside a buffer. +Contrarily to `helm-source-sync' candidates are matched using a function +like `re-search-forward', see below documentation of :search slot.") + +(defclass helm-source-dummy (helm-source) + ((candidates + :initform '("dummy")) + + (filtered-candidate-transformer + :initform 'helm-dummy-candidate) + + (matchplugin + :initform nil) + + (accept-empty + :initarg :accept-empty + :initform t + :custom boolean + :documentation + " Allow exiting with an empty string. + You should keep the default value.") + + (match + :initform 'identity) + + (volatile + :initform t))) + +(defclass helm-source-in-file (helm-source-in-buffer) + ((init :initform (lambda () + (let ((file (helm-attr 'candidates-file))) + (with-current-buffer (helm-candidate-buffer 'global) + (insert-file-contents file))))) + (candidates-file + :initarg :candidates-file + :initform nil + :custom string + :documentation "A filename.")) + + "The contents of the file will be used as candidates in buffer.") + + +;;; Classes for types. +;; +;; Files +(defclass helm-type-file (helm-source) () + "A class to define helm type file.") + +(defmethod helm--setup-source :primary ((_source helm-type-file))) + +(defmethod helm--setup-source :before ((source helm-type-file)) + (set-slot-value + source 'action + (helm-make-actions + "Find file" 'helm-find-many-files + "Find file as root" 'helm-find-file-as-root + "Find file other window" 'find-file-other-window + "Find file other frame" 'find-file-other-frame + "Open dired in file's directory" 'helm-open-dired + "Grep File(s) `C-u recurse'" 'helm-find-files-grep + "Zgrep File(s) `C-u Recurse'" 'helm-ff-zgrep + "Pdfgrep File(s)" 'helm-ff-pdfgrep + "Insert as org link" 'helm-files-insert-as-org-link + "Checksum File" 'helm-ff-checksum + "Ediff File" 'helm-find-files-ediff-files + "Ediff Merge File" 'helm-find-files-ediff-merge-files + "Etags `M-., C-u tap, C-u C-u reload tag file'" + 'helm-ff-etags-select + "View file" 'view-file + "Insert file" 'insert-file + "Add marked files to file-cache" 'helm-ff-cache-add-file + "Delete file(s)" 'helm-delete-marked-files + "Open file externally (C-u to choose)" 'helm-open-file-externally + "Open file with default tool" 'helm-open-file-with-default-tool + "Find file in hex dump" 'hexl-find-file)) + (set-slot-value source 'persistent-help "Show this file") + (set-slot-value source 'action-transformer '(helm-transform-file-load-el + helm-transform-file-browse-url + helm-transform-file-cache)) + (set-slot-value source 'candidate-transformer '(helm-skip-boring-files + helm-highlight-files + helm-w32-pathname-transformer))) + +;; Bookmarks +(defclass helm-type-bookmark (helm-source) () + "A class to define type bookmarks.") + +(defmethod helm--setup-source :primary ((_source helm-type-bookmark))) + +(defmethod helm--setup-source :before ((source helm-type-bookmark)) + (set-slot-value + source 'action (helm-make-actions + "Jump to bookmark" 'helm-bookmark-jump + "Jump to BM other window" 'helm-bookmark-jump-other-window + "Bookmark edit annotation" 'bookmark-edit-annotation + "Bookmark show annotation" 'bookmark-show-annotation + "Delete bookmark(s)" 'helm-delete-marked-bookmarks + "Edit Bookmark" 'helm-bookmark-edit-bookmark + "Rename bookmark" 'helm-bookmark-rename + "Relocate bookmark" 'bookmark-relocate)) + (set-slot-value source 'keymap helm-bookmark-map) + (set-slot-value source 'mode-line helm-bookmark-mode-line-string)) + +;; Buffers +(defclass helm-type-buffer (helm-source) () + "A class to define type buffer.") + +(defmethod helm--setup-source :primary ((_source helm-type-buffer))) + +(defmethod helm--setup-source :before ((source helm-type-buffer)) + (set-slot-value + source 'action (helm-make-actions + "Switch to buffer(s)" 'helm-switch-to-buffers + (lambda () (and (locate-library "popwin") + "Switch to buffer in popup window")) + 'popwin:popup-buffer + "Switch to buffer(s) other window `C-c o'" + 'helm-switch-to-buffers-other-window + "Switch to buffer other frame `C-c C-o'" + 'switch-to-buffer-other-frame + (lambda () (and (locate-library "elscreen") + "Display buffer in Elscreen")) + 'helm-find-buffer-on-elscreen + "Query replace regexp `C-M-%'" + 'helm-buffer-query-replace-regexp + "Query replace `M-%'" 'helm-buffer-query-replace + "View buffer" 'view-buffer + "Display buffer" 'display-buffer + "Grep buffers `M-g s' (C-u grep all buffers)" + 'helm-zgrep-buffers + "Multi occur buffer(s) `C-s'" 'helm-multi-occur-as-action + "Revert buffer(s) `M-U'" 'helm-revert-marked-buffers + "Insert buffer" 'insert-buffer + "Kill buffer(s) `M-D'" 'helm-kill-marked-buffers + "Diff with file `C-='" 'diff-buffer-with-file + "Ediff Marked buffers `C-c ='" 'helm-ediff-marked-buffers + "Ediff Merge marked buffers `M-='" + (lambda (candidate) + (helm-ediff-marked-buffers candidate t)))) + (set-slot-value source 'persistent-help "Show this buffer") + (set-slot-value + source 'filtered-candidate-transformer + '(helm-skip-boring-buffers + helm-buffers-sort-transformer + helm-highlight-buffers))) + +;; Functions +(defclass helm-type-function (helm-source) () + "A class to define helm type function.") + +(defmethod helm--setup-source :primary ((_source helm-type-function))) + +(defmethod helm--setup-source :before ((source helm-type-function)) + (set-slot-value + source 'action (helm-make-actions + "Describe command" 'describe-function + "Add command to kill ring" 'helm-kill-new + "Go to command's definition" 'find-function + "Debug on entry" 'debug-on-entry + "Cancel debug on entry" 'cancel-debug-on-entry + "Trace function" 'trace-function + "Trace function (background)" 'trace-function-background + "Untrace function" 'untrace-function)) + (set-slot-value source 'action-transformer + 'helm-transform-function-call-interactively) + (set-slot-value source 'candidate-transformer + 'helm-mark-interactive-functions) + (set-slot-value source 'coerce 'helm-symbolify)) + +;; Commands +(defclass helm-type-command (helm-source) () + "A class to define helm type command.") + +(defmethod helm--setup-source :primary ((_source helm-type-command))) + +(defmethod helm--setup-source :before ((source helm-type-command)) + (set-slot-value + source 'action (append (helm-make-actions + "Call interactively" 'helm-call-interactively) + (helm-actions-from-type-function))) + (set-slot-value source 'coerce 'helm-symbolify) + (set-slot-value source 'persistent-action 'describe-function)) + +;; Timers +(defclass helm-type-timers (helm-source) () + "A class to define helm type timers.") + +(defmethod helm--setup-source :primary ((_source helm-type-timers))) + +(defmethod helm--setup-source :before ((source helm-type-timers)) + (set-slot-value + source 'action + '(("Cancel Timer" . (lambda (_timer) + (let ((mkd (helm-marked-candidates))) + (cl-loop for timer in mkd + do (cancel-timer timer))))) + ("Describe Function" . (lambda (tm) + (describe-function (timer--function tm)))) + ("Find Function" . (lambda (tm) + (find-function (timer--function tm)))))) + (set-slot-value source 'persistent-action + (lambda (tm) + (describe-function (timer--function tm)))) + (set-slot-value source 'persistent-help "Describe Function")) + + +;;; Error functions +;; +;; +(defun helm-default-init-source-in-buffer-function () + (helm-init-candidates-in-buffer 'global + '("ERROR: No buffer handling your data, use either the `init' slot or the `data' slot."))) + + +;;; Internal Builder functions. +;; +;; +(defun helm--create-source (object) + "[INTERNAL] Build a helm source from OBJECT. +Where OBJECT is an instance of an eieio class." + (cl-loop for s in (object-slots object) + for slot-val = (slot-value object s) + when slot-val + collect (cons s (unless (eq t slot-val) slot-val)))) + +(defun helm-make-source (name class &rest args) + "Build a `helm' source named NAME with ARGS for CLASS. +Argument NAME is a string which define the source name, so no need to use +the keyword :name in your source, NAME will be used instead. +Argument CLASS is an eieio class object. +Arguments ARGS are keyword value pairs as defined in CLASS." + (declare (indent 2)) + (let ((source (apply #'make-instance class name args))) + (set-slot-value source 'name name) + (helm--setup-source source) + (helm-setup-user-source source) + (helm--create-source source))) + +(defun helm-make-type (class &rest args) + (let ((source (apply #'make-instance class args))) + (set-slot-value source 'name nil) + (helm--setup-source source) + (helm--create-source source))) + +(defun helm-source-mp-get-search-or-match-fns (source method) + (require 'helm-match-plugin) + (let ((searchers (and (eq method 'search) + helm-mp-default-search-functions)) + (defmatch (helm-aif (slot-value source 'match) + (helm-mklist it))) + (defmatch-strict (helm-aif (and (eq method 'match) + (slot-value source 'match-strict)) + (helm-mklist it))) + (defsearch (helm-aif (and (eq method 'search) + (slot-value source 'search)) + (helm-mklist it))) + (defsearch-strict (helm-aif (and (eq method 'search-strict) + (slot-value source 'search-strict)) + (helm-mklist it)))) + (cl-case method + (match (cond (defmatch-strict) + (defmatch + (append helm-mp-default-match-functions defmatch)) + (t helm-mp-default-match-functions))) + (search (cond (defsearch-strict) + (defsearch + (append searchers defsearch)) + (t searchers)))))) + + +;;; Modifiers +;; +(cl-defun helm-source-add-action-to-source-if (name fn source predicate + &optional (index 4)) + "Same as `helm-add-action-to-source-if' but for SOURCE defined as eieio object. +You can use this inside a `helm--setup-source' method for a SOURCE defined as +an eieio class." + (let* ((actions (slot-value source 'action)) + (action-transformers (slot-value source 'action-transformer)) + (new-action (list (cons name fn))) + (transformer `(lambda (actions candidate) + (cond ((funcall (quote ,predicate) candidate) + (helm-append-at-nth + actions (quote ,new-action) ,index)) + (t actions))))) + (when (symbolp actions) + (set-slot-value source 'action (list (cons "Default action" actions)))) + (when (symbolp action-transformers) + (setq action-transformers (list action-transformers))) + (set-slot-value + source + 'action-transformer + (delq nil (append (list transformer) action-transformers))))) + +;;; Methods to access types slots. +;; +;; +(defmethod helm-source-get-action-from-type ((object helm-type-file)) + (slot-value object 'action)) + +(defmethod helm-source-get-action-from-type ((object helm-type-buffer)) + (slot-value object 'action)) + +(defmethod helm-source-get-action-from-type ((object helm-type-bookmark)) + (slot-value object 'action)) + +(defmethod helm-source-get-action-from-type ((object helm-type-function)) + (slot-value object 'action)) + + +;;; Methods to build sources. +;; +;; +(defun helm-source--persistent-help-string (string source) + (substitute-command-keys + (concat "\\\\[helm-execute-persistent-action]: " + (or (format "%s (keeping session)" string) + (slot-value source 'header-line))))) + +(defun helm-source--header-line (source) + (substitute-command-keys + (concat "\\\\[helm-execute-persistent-action]: " + (helm-aif (or (slot-value source 'persistent-action) + (slot-value source 'action)) + (cond ((or (symbolp it) (functionp it)) + (helm-symbol-name it)) + ((listp it) + (let ((action (car it))) + ;; It comes from :action ("foo" . function). + (if (stringp (car action)) + (car action) + ;; It comes from :persistent-action + ;; (function . 'nosplit) Fix Issue #788. + (if (or (symbolp action) + (functionp action)) + (helm-symbol-name action))))) + (t "")) + "") + " (keeping session)"))) + +(defmethod helm--setup-source :primary ((_source helm-source))) + +(defmethod helm--setup-source :before ((source helm-source)) + (helm-aif (slot-value source 'keymap) + (and (symbolp it) (set-slot-value source 'keymap (symbol-value it)))) + (set-slot-value source 'header-line (helm-source--header-line source)) + (helm-aif (slot-value source 'persistent-help) + (set-slot-value source 'header-line + (helm-source--persistent-help-string it source))) + (when (and (slot-value source 'fuzzy-match) helm-fuzzy-sort-fn) + (set-slot-value source 'filtered-candidate-transformer + (helm-aif (slot-value source 'filtered-candidate-transformer) + (append (helm-mklist it) + (list helm-fuzzy-sort-fn)) + (list helm-fuzzy-sort-fn)))) + (unless (slot-value source 'nohighlight) + (set-slot-value source 'filtered-candidate-transformer + (helm-aif (slot-value source 'filtered-candidate-transformer) + (append (helm-mklist it) + (list #'helm-fuzzy-highlight-matches)) + (list #'helm-fuzzy-highlight-matches))))) + +(defmethod helm-setup-user-source ((_source helm-source))) + +(defmethod helm--setup-source ((source helm-source-sync)) + (when (slot-value source 'fuzzy-match) + (helm-aif (slot-value source 'match) + (set-slot-value source 'match (append (helm-mklist it) + (list helm-fuzzy-match-fn))) + (set-slot-value source 'match helm-fuzzy-match-fn))) + (when (slot-value source 'matchplugin) + (set-slot-value source 'match + (helm-source-mp-get-search-or-match-fns source 'match)))) + +(defmethod helm--setup-source ((source helm-source-in-buffer)) + (let ((cur-init (slot-value source 'init))) + (helm-aif (slot-value source 'data) + (set-slot-value + source + 'init (delq + nil + (list + (and (null (eq 'helm-default-init-source-in-buffer-function + cur-init)) + cur-init) + (lambda () + (helm-init-candidates-in-buffer + 'global + (if (functionp it) (funcall it) it)))))))) + (when (slot-value source 'fuzzy-match) + (helm-aif (slot-value source 'search) + (set-slot-value source 'search (append (helm-mklist it) + (list helm-fuzzy-search-fn))) + (set-slot-value source 'search (list helm-fuzzy-search-fn)))) + (when (slot-value source 'matchplugin) + (set-slot-value + source 'search (helm-source-mp-get-search-or-match-fns source 'search))) + (let ((mtc (slot-value source 'match))) + (cl-assert (or (equal '(identity) mtc) + (eq 'identity mtc)) + nil "Invalid slot value for `match'") + (cl-assert (eq (slot-value source 'volatile) t) + nil "Invalid slot value for `volatile'"))) + +(defmethod helm--setup-source ((source helm-source-async)) + (cl-assert (null (slot-value source 'candidates)) + nil "Incorrect use of `candidates' use `candidates-process' instead") + (cl-assert (null (slot-value source 'matchplugin)) + nil "`matchplugin' not allowed in async sources.")) + +(defmethod helm--setup-source ((source helm-source-dummy)) + (let ((mtc (slot-value source 'match))) + (cl-assert (or (equal '(identity) mtc) + (eq 'identity mtc)) + nil "Invalid slot value for `match'") + (cl-assert (eq (slot-value source 'volatile) t) + nil "Invalid slot value for `volatile'") + (cl-assert (equal (slot-value source 'candidates) '("dummy")) + nil "Invalid slot value for `candidates'") + (cl-assert (eq (slot-value source 'accept-empty) t) + nil "Invalid slot value for `accept-empty'"))) + + +;;; User functions +;; +;; Sources +(defmacro helm-build-sync-source (name &rest args) + "Build a synchronous helm source with name NAME. +Args ARGS are keywords provided by `helm-source-sync'." + (declare (indent 1)) + `(helm-make-source ,name 'helm-source-sync ,@args)) + +(defmacro helm-build-async-source (name &rest args) + "Build a asynchronous helm source with name NAME. +Args ARGS are keywords provided by `helm-source-async'." + (declare (indent 1)) + `(helm-make-source ,name 'helm-source-async ,@args)) + +(defmacro helm-build-in-buffer-source (name &rest args) + "Build a helm source with name NAME using `candidates-in-buffer' method. +Args ARGS are keywords provided by `helm-source-in-buffer'." + (declare (indent 1)) + `(helm-make-source ,name 'helm-source-in-buffer ,@args)) + +(defmacro helm-build-dummy-source (name &rest args) + "Build a helm source with name NAME using `dummy' method. +Args ARGS are keywords provided by `helm-source-dummy'." + (declare (indent 1)) + `(helm-make-source ,name 'helm-source-dummy ,@args)) + +(defmacro helm-build-in-file-source (name file &rest args) + "Build a helm source with NAME name using `candidates-in-files' method. +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)) + `(helm-make-source ,name 'helm-source-in-file + :candidates-file ,file ,@args)) + +;; Types +(defun helm-actions-from-type-file () + (let ((source (make-instance 'helm-type-file))) + (helm--setup-source source) + (helm-source-get-action-from-type source))) + +(defun helm-build-type-file () + (helm-make-type 'helm-type-file)) + +(defun helm-actions-from-type-function () + (let ((source (make-instance 'helm-type-function))) + (helm--setup-source source) + (helm-source-get-action-from-type source))) + +(defun helm-build-type-function () + (helm-make-type 'helm-type-function)) + +(defun helm-actions-from-type-command () + (let ((source (make-instance 'helm-type-command))) + (helm--setup-source source) + (helm-source-get-action-from-type source))) + +(defun helm-build-type-command () + (helm-make-type 'helm-type-command)) + +(provide 'helm-source) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-source ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-sys.el b/emacs.d/elpa/helm-20150507.2215/helm-sys.el new file mode 100644 index 0000000..2c3ce07 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-sys.el @@ -0,0 +1,299 @@ +;;; helm-sys.el --- System related functions for helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) + + +(defgroup helm-sys nil + "System related helm library." + :group 'helm) + +(defface helm-top-columns + '((t :inherit helm-header)) + "Face for helm help string in minibuffer." + :group 'helm-sys) + + +(defun helm-top-command-set-fn (var _value) + (set var + (cl-case system-type + (darwin "env COLUMNS=%s ps -axo pid,user,pri,nice,ucomm,tty,start,vsz,%%cpu,%%mem,etime,command") + (t "env COLUMNS=%s top -b -n 1")))) + +(defcustom helm-top-command "env COLUMNS=%s top -b -n 1" + "Top command used to display output of top. +To use top command, a version supporting batch mode (-b option) is needed. +On Mac OSX top command doesn't support this, so ps command +is used by default instead. +If you modify this the number and order of elements displayed +should be the same as top command to have the sort commands +working properly, that is 12 elements with the 2 first being +PID and USER and the last 4 being %CPU, %MEM, TIME and COMMAND. +A format string where %s will be replaced with `frame-width'." + :group 'helm-sys + :type 'string + :set 'helm-top-command-set-fn) + + +;;; Top (process) +;; +;; +(defvar helm-top-sort-fn nil) +(defvar helm-top-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "C-c ?") 'helm-top-help) + (define-key map (kbd "M-P") 'helm-top-run-sort-by-cpu) + (define-key map (kbd "M-C") 'helm-top-run-sort-by-com) + (define-key map (kbd "M-M") 'helm-top-run-sort-by-mem) + (define-key map (kbd "M-U") 'helm-top-run-sort-by-user) + map)) + +(defvar helm-source-top + (helm-build-in-buffer-source "Top" + :header-name (lambda (name) (concat name " (Press C-c C-u to refresh)")) + :init #'helm-top-init + :nomark t + :display-to-real #'helm-top-display-to-real + :persistent-action #'helm-top-sh-persistent-action + :persistent-help "SIGTERM" + :mode-line helm-top-mode-line + :follow 'never + :keymap helm-top-map + :filtered-candidate-transformer #'helm-top-sort-transformer + :action-transformer #'helm-top-action-transformer)) + +(defun helm-top-transformer (candidates _source) + "Transformer for `helm-top'. +Return empty string for non--valid candidates." + (cl-loop for disp in candidates collect + (cond ((string-match "^ *[0-9]+" disp) disp) + ((string-match "^ *PID" disp) + (cons (propertize disp 'face 'helm-top-columns) "")) + (t (cons disp ""))))) + +(defun helm-top-action-transformer (actions _candidate) + "Action transformer for `top'. +Show actions only on line starting by a PID." + (let ((disp (helm-get-selection nil t))) + (cond ((string-match "^ *[0-9]+" disp) + (list '("kill (SIGTERM)" . (lambda (pid) (helm-top-sh "TERM" pid))) + '("kill (SIGKILL)" . (lambda (pid) (helm-top-sh "KILL" pid))) + '("kill (SIGINT)" . (lambda (pid) (helm-top-sh "INT" pid))) + '("kill (Choose signal)" + . (lambda (pid) + (helm-top-sh + (helm-comp-read (format "Kill [%s] with signal: " pid) + '("ALRM" "HUP" "INT" "KILL" "PIPE" "POLL" + "PROF" "TERM" "USR1" "USR2" "VTALRM" + "STKFLT" "PWR" "WINCH" "CHLD" "URG" + "TSTP" "TTIN" "TTOU" "STOP" "CONT" + "ABRT" "FPE" "ILL" "QUIT" "SEGV" + "TRAP" "SYS" "EMT" "BUS" "XCPU" "XFSZ") + :must-match t) + pid))))) + (t actions)))) + +(defun helm-top-sh (sig pid) + "Run kill shell command with signal SIG on PID for `helm-top'." + (let ((cmd (format "kill -%s %s" sig pid))) + (message "Executed %s\n%s" cmd (shell-command-to-string cmd)))) + +(defun helm-top-sh-persistent-action (pid) + (delete-other-windows) + (helm-top-sh "TERM" pid) + (helm-force-update)) + +(defun helm-top-init () + "Insert output of top command in candidate buffer." + (unless helm-top-sort-fn (helm-top-set-mode-line "CPU")) + (with-current-buffer (helm-candidate-buffer 'global) + (call-process-shell-command + (format helm-top-command (frame-width)) + nil (current-buffer)))) + +(defun helm-top-display-to-real (line) + "Return pid only from LINE." + (car (split-string line))) + +;; Sort top command + +(defun helm-top-set-mode-line (str) + (if (string-match "Sort:\\[\\(.*\\)\\] " helm-top-mode-line) + (setq helm-top-mode-line (replace-match str nil nil helm-top-mode-line 1)) + (setq helm-top-mode-line (concat (format "Sort:[%s] " str) helm-top-mode-line)))) + +(defun helm-top-sort-transformer (candidates source) + (helm-top-transformer + (if helm-top-sort-fn + (cl-loop for c in candidates + if (string-match "^ *[0-9]+" c) + collect c into pid-cands + else collect c into header-cands + finally return (append + header-cands + (sort pid-cands helm-top-sort-fn))) + candidates) + source)) + +(defun helm-top-sort-by-com (s1 s2) + (let* ((split-1 (split-string s1)) + (split-2 (split-string s2)) + (com-1 (nth 11 split-1)) + (com-2 (nth 11 split-2))) + (string< com-1 com-2))) + +(defun helm-top-sort-by-mem (s1 s2) + (let* ((split-1 (split-string s1)) + (split-2 (split-string s2)) + (mem-1 (string-to-number (nth 9 split-1))) + (mem-2 (string-to-number (nth 9 split-2)))) + (> mem-1 mem-2))) + +(defun helm-top-sort-by-user (s1 s2) + (let* ((split-1 (split-string s1)) + (split-2 (split-string s2)) + (user-1 (nth 1 split-1)) + (user-2 (nth 1 split-2))) + (string< user-1 user-2))) + +(defun helm-top-run-sort-by-com () + (interactive) + (helm-top-set-mode-line "COM") + (setq helm-top-sort-fn 'helm-top-sort-by-com) + (helm-force-update)) + +(defun helm-top-run-sort-by-cpu () + (interactive) + (helm-top-set-mode-line "CPU") + (setq helm-top-sort-fn nil) + (helm-force-update)) + +(defun helm-top-run-sort-by-mem () + (interactive) + (helm-top-set-mode-line "MEM") + (setq helm-top-sort-fn 'helm-top-sort-by-mem) + (helm-force-update)) + +(defun helm-top-run-sort-by-user () + (interactive) + (helm-top-set-mode-line "USER") + (setq helm-top-sort-fn 'helm-top-sort-by-user) + (helm-force-update)) + + +;;; X RandR resolution change +;; +;; +;;; FIXME I do not care multi-display. + +(defun helm-xrandr-info () + "Return a pair with current X screen number and current X display name." + (with-temp-buffer + (call-process "xrandr" nil (current-buffer) nil + "--current") + (let (screen output) + (goto-char (point-min)) + (save-excursion + (when (re-search-forward "\\(^Screen \\)\\([0-9]\\):" nil t) + (setq screen (match-string 2)))) + (when (re-search-forward "^\\(.*\\) connected" nil t) + (setq output (match-string 1))) + (list screen output)))) + +(defun helm-xrandr-screen () + "Return current X screen number." + (car (helm-xrandr-info))) + +(defun helm-xrandr-output () + "Return current X display name." + (cadr (helm-xrandr-info))) + +(defvar helm-source-xrandr-change-resolution + '((name . "Change Resolution") + (candidates + . (lambda () + (with-temp-buffer + (call-process "xrandr" nil (current-buffer) nil + "--screen" (helm-xrandr-screen) "-q") + (goto-char 1) + (cl-loop with modes = nil + while (re-search-forward " \\([0-9]+x[0-9]+\\)" nil t) + for mode = (match-string 1) + unless (member mode modes) + collect mode into modes + finally return modes)))) + (action + ("Change Resolution" + . (lambda (mode) + (call-process "xrandr" nil nil nil + "--screen" (helm-xrandr-screen) + "--output" (helm-xrandr-output) + "--mode" mode)))))) + + +;;; Emacs process +;; +;; +(defvar helm-source-emacs-process + '((name . "Emacs Process") + (init . (lambda () (list-processes--refresh))) + (candidates . (lambda () (mapcar #'process-name (process-list)))) + (persistent-action . (lambda (elm) + (delete-process (get-process elm)) + (helm-delete-current-selection))) + (persistent-help . "Kill Process") + (action ("Kill Process" . (lambda (elm) + (delete-process (get-process elm))))))) + + +;;;###autoload +(defun helm-top () + "Preconfigured `helm' for top command." + (interactive) + (save-window-excursion + (unless helm-alive-p (delete-other-windows)) + (helm :sources 'helm-source-top + :buffer "*helm top*" :full-frame t + :candidate-number-limit 9999 + :preselect "^\\s-*[0-9]+"))) + +;;;###autoload +(defun helm-list-emacs-process () + "Preconfigured `helm' for emacs process." + (interactive) + (helm-other-buffer 'helm-source-emacs-process "*helm process*")) + +;;;###autoload +(defun helm-xrandr-set () + (interactive) + (helm :sources 'helm-source-xrandr-change-resolution + :buffer "*helm xrandr*")) + +(provide 'helm-sys) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-sys.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-tags.el b/emacs.d/elpa/helm-20150507.2215/helm-tags.el new file mode 100644 index 0000000..1e2ec22 --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-tags.el @@ -0,0 +1,318 @@ +;;; helm-tags.el --- Helm for Etags. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'helm-utils) + + +(defgroup helm-tags nil + "Tags related Applications and libraries for Helm." + :group 'helm) + +(defcustom helm-etags-tag-file-name "TAGS" + "Etags tag file name." + :type 'string + :group 'helm-tags) + +(defcustom helm-etags-tag-file-search-limit 10 + "The limit level of directory to search tag file. +Don't search tag file deeply if outside this value." + :type 'number + :group 'helm-tags) + +(defcustom helm-etags-match-part-only t + "Whether to match only the tag part of CANDIDATE in +helm-source-etags-select." + :type 'boolean + :group 'helm-tags) + +(defcustom helm-etags-execute-action-at-once-if-one t + "Whether to jump straight to the selected tag if there's only +one match." + :type 'boolean + :group 'helm-tags) + + +(defgroup helm-tags-faces nil + "Customize the appearance of helm-tags faces." + :prefix "helm-" + :group 'helm-tags + :group 'helm-faces) + +(defface helm-etags-file + '((t (:foreground "Lightgoldenrod4" + :underline t))) + "Face used to highlight etags filenames." + :group 'helm-tags-faces) + + +;;; Etags +;; +;; +(defun helm-etags-run-switch-other-window () + "Run switch to other window action from `helm-source-etags-select'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action + (lambda (c) + (helm-etags-action-goto 'find-file-other-window c))))) + +(defun helm-etags-run-switch-other-frame () + "Run switch to other frame action from `helm-source-etags-select'." + (interactive) + (with-helm-alive-p + (helm-quit-and-execute-action + (lambda (c) + (helm-etags-action-goto 'find-file-other-frame c))))) + +(defvar helm-etags-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (define-key map (kbd "M-") 'helm-goto-next-file) + (define-key map (kbd "M-") 'helm-goto-precedent-file) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-c ?") 'helm-etags-help) + (define-key map (kbd "C-c o") 'helm-etags-run-switch-other-window) + (define-key map (kbd "C-c C-o") 'helm-etags-run-switch-other-frame) + map) + "Keymap used in Etags.") + +(defvar helm-etags-mtime-alist nil + "Store the last modification time of etags files here.") +(defvar helm-etags-cache (make-hash-table :test 'equal) + "Cache content of etags files used here for faster access.") + +(defun helm-etags-get-tag-file (&optional directory) + "Return the path of etags file if found. +Lookes recursively in parents directorys for a +`helm-etags-tag-file-name' file." + ;; Get tag file from `default-directory' or upper directory. + (let ((current-dir (helm-etags-find-tag-file-directory + (or directory default-directory)))) + ;; Return nil if not find tag file. + (when current-dir + (expand-file-name helm-etags-tag-file-name current-dir)))) + +(defun helm-etags-all-tag-files () + "Return files from the following sources; + 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. + 2) `tags-file-name', which is commonly set by `find-tag' command. + 3) `tags-table-list' which is commonly set by `visit-tags-table' command." + (helm-fast-remove-dups + (delq nil + (append (list (helm-etags-get-tag-file) + tags-file-name) + tags-table-list)) + :test 'equal)) + +(defun helm-etags-find-tag-file-directory (current-dir) + "Try to find the directory containing tag file. +If not found in CURRENT-DIR search in upper directory." + (let ((file-exists? #'(lambda (dir) + (let ((tag-path (expand-file-name + helm-etags-tag-file-name dir))) + (and (stringp tag-path) + (file-regular-p tag-path) + (file-readable-p tag-path)))))) + (cl-loop with count = 0 + until (funcall file-exists? current-dir) + ;; Return nil if outside the value of + ;; `helm-etags-tag-file-search-limit'. + if (= count helm-etags-tag-file-search-limit) + do (cl-return nil) + ;; Or search upper directories. + else + do (cl-incf count) + (setq current-dir (expand-file-name (concat current-dir "../"))) + finally return current-dir))) + +(defun helm-etags-get-header-name (_x) + "Create header name for this helm etags session." + (concat "Etags in " + (with-helm-current-buffer + (helm-etags-get-tag-file)))) + +(defun helm-etags-create-buffer (file) + "Create the `helm-buffer' based on contents of etags tag FILE." + (let* ((tag-fname file) + max + (split (with-current-buffer (find-file-noselect tag-fname) + (prog1 + (split-string (buffer-string) "\n" 'omit-nulls) + (setq max (line-number-at-pos (point-max))) + (kill-buffer)))) + (progress-reporter (make-progress-reporter "Loading tag file..." 0 max))) + (cl-loop + with fname + with cand + for i in split for count from 0 + for elm = (unless (string-match "^\x0c" i) + (helm-aif (string-match "\177" i) + (substring i 0 it) + i)) + do (cond ((and elm (string-match "^\\([^,]+\\),[0-9]+$" elm)) + (setq fname (propertize (match-string 1 elm) + 'face 'helm-etags-file))) + (elm (setq cand (concat fname ": " elm))) + (t (setq cand nil))) + when cand do (progn + (insert (concat cand "\n")) + (progress-reporter-update progress-reporter count))))) + +(defun helm-etags-init () + "Feed `helm-buffer' using `helm-etags-cache' or tag file. +If no entry in cache, create one." + (let ((tagfiles (helm-etags-all-tag-files))) + (when tagfiles + (with-current-buffer (helm-candidate-buffer 'global) + (dolist (f tagfiles) + (helm-aif (gethash f helm-etags-cache) + ;; An entry is present in cache, insert it. + (insert it) + ;; No entry, create a new buffer using content of tag file (slower). + (helm-etags-create-buffer f) + ;; Store content of buffer in cache. + (puthash f (buffer-string) helm-etags-cache) + ;; Store or set the last modification of tag file. + (helm-aif (assoc f helm-etags-mtime-alist) + ;; If an entry exists modify it. + (setcdr it (helm-etags-mtime f)) + ;; No entry create a new one. + (add-to-list 'helm-etags-mtime-alist + (cons f (helm-etags-mtime f)))))))))) + +(defun helm-etags-split-line (line) + (let ((regexp "\\`\\([[:lower:][:upper:]]?:?.*?\\): \\(.*\\)")) + (when (string-match regexp line) + (cl-loop for n from 1 to 2 collect (match-string n line))))) + +(defvar helm-source-etags-select nil + "Helm source for Etags.") + +(defun helm-etags-build-source () + (helm-build-in-buffer-source "Etags" + :header-name 'helm-etags-get-header-name + :init 'helm-etags-init + :get-line 'buffer-substring + :match-part (lambda (candidate) + ;; Match only the tag part of CANDIDATE + ;; and not the filename. + (if helm-etags-match-part-only + ;; Ignore the first part of the tag + ;; which is irrelevant + ;;(e.g in "(cl-defun foo" search only if "foo" match) + (cadr (split-string + (cadr (helm-etags-split-line candidate)))) + candidate)) + :mode-line helm-etags-mode-line-string + :keymap helm-etags-map + :action '(("Go to tag" . (lambda (c) + (helm-etags-action-goto 'find-file c))) + ("Go to tag in other window" . (lambda (c) + (helm-etags-action-goto + 'find-file-other-window + c))) + ("Go to tag in other frame" . (lambda (c) + (helm-etags-action-goto + 'find-file-other-frame + c)))) + :persistent-help "Go to line" + :persistent-action (lambda (candidate) + (helm-etags-action-goto 'find-file candidate) + (helm-highlight-current-line)))) + +(defvar find-tag-marker-ring) + +(defun helm-etags-action-goto (switcher candidate) + "Helm default action to jump to an etags entry in other window." + (require 'etags) + (helm-log-run-hook 'helm-goto-line-before-hook) + (let* ((split (helm-etags-split-line candidate)) + (fname (cl-loop for tagf being the hash-keys of helm-etags-cache + for f = (expand-file-name + (car split) (file-name-directory tagf)) + when (file-exists-p f) + return f)) + (elm (cadr split))) + (if (null fname) + (error "file %s not found" fname) + (ring-insert find-tag-marker-ring (point-marker)) + (funcall switcher fname) + (goto-char (point-min)) + (search-forward elm nil t) + (goto-char (match-beginning 0))))) + +(defun helm-etags-mtime (file) + "Last modification time of etags tag FILE." + (cadr (nth 5 (file-attributes file)))) + +(defun helm-etags-file-modified-p (file) + "Check if tag FILE have been modified in this session. +If FILE is nil return nil." + (let ((last-modif (and file + (assoc-default file helm-etags-mtime-alist)))) + (and last-modif + (/= last-modif (helm-etags-mtime file))))) + + +;;;###autoload +(defun helm-etags-select (arg) + "Preconfigured helm for etags. +If called with a prefix argument or if any of the tag files have +been modified, reinitialize cache. + +This function aggregates three sources of tag files: + + 1) An automatically located file in the parent directories, by `helm-etags-get-tag-file'. + 2) `tags-file-name', which is commonly set by `find-tag' command. + 3) `tags-table-list' which is commonly set by `visit-tags-table' command." + (interactive "P") + (let ((tag-files (helm-etags-all-tag-files)) + (helm-execute-action-at-once-if-one helm-etags-execute-action-at-once-if-one) + (str (if (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)) + (thing-at-point 'symbol)))) + (if (cl-notany 'file-exists-p tag-files) + (message "Error: No tag file found. Create with etags shell command, or visit with `find-tag' or `visit-tags-table'.") + (cl-loop for k being the hash-keys of helm-etags-cache + unless (member k tag-files) + do (remhash k helm-etags-cache)) + (mapc (lambda (f) + (when (or (equal arg '(4)) + (and helm-etags-mtime-alist + (helm-etags-file-modified-p f))) + (remhash f helm-etags-cache))) + tag-files) + (unless helm-source-etags-select + (setq helm-source-etags-select + (helm-etags-build-source))) + (helm :sources 'helm-source-etags-select + :keymap helm-etags-map + :default (list (concat "\\_<" str "\\_>") str) + :buffer "*helm etags*")))) + +(provide 'helm-tags) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm-tags.el ends here diff --git a/emacs.d/elpa/helm-20150507.2215/helm-utils.el b/emacs.d/elpa/helm-20150507.2215/helm-utils.el new file mode 100644 index 0000000..6e5853a --- /dev/null +++ b/emacs.d/elpa/helm-20150507.2215/helm-utils.el @@ -0,0 +1,871 @@ +;;; helm-utils.el --- Utilities Functions for helm. -*- lexical-binding: t -*- + +;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto + +;; 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 . + +;;; Code: + +(require 'cl-lib) +(require 'helm) +(require 'compile) ; Fixme: Is this needed? +(require 'dired) + +(declare-function helm-find-files-1 "helm-files.el" (fname &optional preselect)) +(defvar winner-boring-buffers) + + +(defgroup helm-utils nil + "Utilities routines for Helm." + :group 'helm) + +(defcustom helm-su-or-sudo "sudo" + "What command to use for root access." + :type 'string + :group 'helm-utils) + +(defcustom helm-yank-symbol-first nil + "`helm-yank-text-at-point' yanks symbol at point on first +invocation if this is non-nil." + :type 'boolean + :group 'helm-utils) + +(defcustom helm-default-kbsize 1024.0 + "Default Kbsize to use for showing files size. +It is a float, usually 1024.0 but could be 1000.0 on some systems." + :group 'helm-utils + :type 'float) + +(defcustom helm-highlight-number-lines-around-point 15 + "Number of lines around point where matched items are highlighted." + :group 'helm-utils + :type 'integer) + +(defcustom helm-buffers-to-resize-on-pa nil + "A list of helm buffers where the helm-window should be reduced on persistent actions." + :group 'helm-utils + :type '(repeat (choice string))) + +(defcustom helm-resize-on-pa-text-height 12 + "The size of the helm-window when resizing on persistent action." + :group 'helm-utils + :type 'integer) + + +(defvar helm-goto-line-before-hook '(helm-save-current-pos-to-mark-ring) + "Run before jumping to line. +This hook run when jumping from `helm-goto-line', `helm-etags-default-action', +and `helm-imenu-default-action'.") + +(defvar helm-save-pos-before-jump-register ?_ + "The register where `helm-save-pos-to-register-before-jump' save position.") + + +;;; Faces. +;; +(defface helm-selection-line + '((t (:inherit highlight :distant-foreground "black"))) + "Face used in the `helm-current-buffer' when jumping to candidate." + :group 'helm-faces) + +(defface helm-match-item + '((t (:inherit isearch))) + "Face used to highlight item matched in a selected line." + :group 'helm-faces) + + +;; CUA workaround +(defadvice cua-delete-region (around helm-avoid-cua activate) + (ignore-errors ad-do-it)) + +(defadvice copy-region-as-kill (around helm-avoid-cua activate) + (if cua-mode + (ignore-errors ad-do-it) + ad-do-it)) + + +;;; Utils functions +;; +;; +(defun helm-ff-find-printers () + "Return a list of available printers on Unix systems." + (when (executable-find "lpstat") + (let ((printer-list (with-temp-buffer + (call-process "lpstat" nil t nil "-a") + (split-string (buffer-string) "\n")))) + (cl-loop for p in printer-list + for printer = (car (split-string p)) + when printer + collect printer)))) + +(defun helm-switch-to-buffers (buffer-or-name &optional other-window) + "Switch to buffer BUFFER-OR-NAME. +If more than one buffer marked switch to these buffers in separate windows. +If OTHER-WINDOW is specified keep current-buffer and switch to others buffers +in separate windows." + (let* ((mkds (helm-marked-candidates)) + (size (/ (window-height) (length mkds)))) + (or (<= window-min-height size) + (error "Too many buffers to visit simultaneously.")) + (helm-aif (cdr mkds) + (progn + (if other-window + (switch-to-buffer-other-window (car mkds)) + (switch-to-buffer (car mkds))) + (save-selected-window + (cl-loop for b in it + do (progn + (select-window (split-window)) + (switch-to-buffer b))))) + (if other-window + (switch-to-buffer-other-window buffer-or-name) + (switch-to-buffer buffer-or-name))))) + +(defun helm-switch-to-buffers-other-window (buffer-or-name) + "switch to buffer BUFFER-OR-NAME in other window. +See `helm-switch-to-buffers' for switching to marked buffers." + (helm-switch-to-buffers buffer-or-name t)) + +(cl-defmacro helm-position (item seq &key (test 'eq) all) + "A simple and faster replacement of CL `position'. +Return position of first occurence of ITEM found in SEQ. +Argument SEQ can be a string, in this case ITEM have to be a char. +Argument ALL, if non--nil specify to return a list of positions of +all ITEM found in SEQ." + (let ((key (if (stringp seq) 'across 'in))) + `(cl-loop for c ,key ,seq + for index from 0 + when (funcall ,test c ,item) + if ,all collect index into ls + else return index + finally return ls))) + +(defun helm-substring (str width) + "Return the substring of string STR from 0 to WIDTH. +Handle multibyte characters by moving by columns." + (with-temp-buffer + (save-excursion + (insert str)) + (move-to-column width) + (buffer-substring (point-at-bol) (point)))) + +(cl-defun helm-substring-by-width (str width &optional (endstr "...")) + "Truncate string STR to end at column WIDTH. +Similar to `truncate-string-to-width'. +Add ENDSTR (default \"...\") at end of truncated STR. +Add spaces at end if needed to reach WIDTH when STR is shorter than WIDTH." + (cl-loop for ini-str = str + then (substring ini-str 0 (1- (length ini-str))) + for sw = (string-width ini-str) + when (<= sw width) return + (concat ini-str endstr (make-string (- width sw) ? )))) + +(defun helm-string-multibyte-p (str) + "Check if string STR contains multibyte characters." + (cl-loop for c across str + thereis (> (char-width c) 1))) + +(defun helm-get-pid-from-process-name (process-name) + "Get pid from running process PROCESS-NAME." + (cl-loop with process-list = (list-system-processes) + for pid in process-list + for process = (assoc-default 'comm (process-attributes pid)) + when (and process (string-match process-name process)) + return pid)) + +(cl-defun helm-current-buffer-narrowed-p (&optional + (buffer helm-current-buffer)) + "Check if BUFFER is narrowed. +Default is `helm-current-buffer'." + (with-current-buffer buffer + (let ((beg (point-min)) + (end (point-max)) + (total (buffer-size))) + (or (/= beg 1) (/= end (1+ total)))))) + +(defun helm-region-active-p () + (and transient-mark-mode mark-active (/= (mark) (point)))) + +(defun helm-goto-char (loc) + "Go to char, revealing if necessary." + (goto-char loc) + (when (or (eq major-mode 'org-mode) + (and (boundp 'outline-minor-mode) + outline-minor-mode)) + (require 'org) ; On some old Emacs versions org may not be loaded. + (org-reveal))) + +(defun helm-goto-line (lineno &optional noanim) + "Goto LINENO opening only outline headline if needed. +Animation is used unless NOANIM is non--nil." + (helm-log-run-hook 'helm-goto-line-before-hook) + (goto-char (point-min)) + (helm-goto-char (point-at-bol lineno)) + (unless noanim + (helm-highlight-current-line nil nil nil nil 'pulse))) + +(defun helm-save-pos-to-register-before-jump () + "Save current buffer position to `helm-save-pos-before-jump-register'. +To use this add it to `helm-goto-line-before-hook'." + (with-helm-current-buffer + (unless helm-in-persistent-action + (point-to-register helm-save-pos-before-jump-register)))) + +(defun helm-save-current-pos-to-mark-ring () + "Save current buffer position to mark ring. +To use this add it to `helm-goto-line-before-hook'." + (with-helm-current-buffer + (unless helm-in-persistent-action + (set-marker (mark-marker) (point)) + (push-mark (point) 'nomsg)))) + +;;;###autoload +(defun helm-show-all-in-this-source-only (arg) + "Show only current source of this helm session with all its candidates. +With a numeric prefix arg show only the ARG number of candidates." + (interactive "p") + (with-helm-window + (with-helm-default-directory (helm-default-directory) + (let ((helm-candidate-number-limit (and (> arg 1) arg))) + (helm-set-source-filter + (list (assoc-default 'name (helm-get-current-source)))))))) + +;;;###autoload +(defun helm-display-all-sources () + "Display all sources previously hidden by `helm-set-source-filter'." + (interactive) + (helm-set-source-filter nil)) + +(defun helm-displaying-source-names () + "Return the list of sources name for this helm session." + (with-current-buffer helm-buffer + (goto-char (point-min)) + (cl-loop with pos + while (setq pos (next-single-property-change (point) 'helm-header)) + do (goto-char pos) + collect (buffer-substring-no-properties (point-at-bol)(point-at-eol)) + do (forward-line 1)))) + +(defun helm-skip-entries (seq regexp-list) + "Remove entries which matches one of REGEXP-LIST from SEQ." + (cl-loop for i in seq + unless (cl-loop for regexp in regexp-list + thereis (and (stringp i) + (string-match regexp i))) + collect i)) + +(defun helm-shadow-entries (seq regexp-list) + "Put shadow property on entries in SEQ matching a regexp in REGEXP-LIST." + (let ((face 'italic)) + (cl-loop for i in seq + if (cl-loop for regexp in regexp-list + thereis (and (stringp i) + (string-match regexp i))) + collect (propertize i 'face face) + else collect i))) + +(defun helm-describe-function (func) + "FUNC is symbol or string." + (describe-function (helm-symbolify func)) + (message nil)) + +(defun helm-describe-variable (var) + "VAR is symbol or string." + (describe-variable (helm-symbolify var)) + (message nil)) + +(defun helm-find-function (func) + "FUNC is symbol or string." + (find-function (helm-symbolify func))) + +(defun helm-find-variable (var) + "VAR is symbol or string." + (find-variable (helm-symbolify var))) + +(defun helm-kill-new (candidate &optional replace) + "CANDIDATE is symbol or string. +See `kill-new' for argument REPLACE." + (kill-new (helm-stringify candidate) replace)) + +(cl-defun helm-fast-remove-dups (seq &key (test 'eq)) + "Remove duplicates elements in list SEQ. +This is same as `remove-duplicates' but with memoisation. +It is much faster, especially in large lists. +A test function can be provided with TEST argument key. +Default is `eq'." + (cl-loop with cont = (make-hash-table :test test) + for elm in seq + unless (gethash elm cont) + do (puthash elm elm cont) + finally return + (cl-loop for i being the hash-values in cont collect i))) + +(defun helm-remove-if-not-match (regexp seq) + "Remove all elements of SEQ that don't match REGEXP." + (cl-loop for s in seq + for str = (cond ((symbolp s) + (symbol-name s)) + ((consp s) + (car s)) + (t s)) + when (string-match-p regexp str) + collect s)) + +(defun helm-remove-if-match (regexp seq) + "Remove all elements of SEQ that match REGEXP." + (cl-loop for s in seq + for str = (cond ((symbolp s) + (symbol-name s)) + ((consp s) + (car s)) + (t s)) + unless (string-match-p regexp str) + collect s)) + +(defun helm-handle-winner-boring-buffers () + "Add `helm-buffer' to `winner-boring-buffers' when quitting/exiting helm. +Add this function to `helm-cleanup-hook' when you don't want to see helm buffers +after running winner-undo/redo." + (require 'winner) + (cl-pushnew helm-buffer winner-boring-buffers :test 'equal)) +(add-hook 'helm-cleanup-hook #'helm-handle-winner-boring-buffers) + +;;;###autoload +(defun helm-quit-and-find-file () + "Drop into `helm-find-files' from `helm'. +If current selection is a buffer or a file, `helm-find-files' +from its directory." + (interactive) + (require 'helm-grep) + (helm-run-after-quit + (lambda (f) + (if (file-exists-p f) + (helm-find-files-1 (file-name-directory f) + (concat + "^" + (regexp-quote + (if helm-ff-transformer-show-only-basename + (helm-basename f) f)))) + (helm-find-files-1 f))) + (let* ((sel (helm-get-selection)) + (grep-line (and (stringp sel) + (helm-grep-split-line sel))) + (bmk-name (and (stringp sel) + (not grep-line) + (replace-regexp-in-string "\\`\\*" "" sel))) + (bmk (and bmk-name (assoc bmk-name bookmark-alist))) + (buf (helm-aif (get-buffer sel) (buffer-name it))) + (default-preselection (or (buffer-file-name helm-current-buffer) + default-directory))) + (cond + ;; Buffer. + (buf (or (buffer-file-name sel) + (car (rassoc buf dired-buffers)) + (and (with-current-buffer buf + (eq major-mode 'org-agenda-mode)) + org-directory + (expand-file-name org-directory)) + (with-current-buffer buf default-directory))) + ;; Bookmark. + (bmk (helm-aif (bookmark-get-filename bmk) + (if (and ffap-url-regexp + (string-match ffap-url-regexp it)) + it (expand-file-name it)) + default-directory)) + ((or (file-remote-p sel) + (file-exists-p sel)) + (expand-file-name sel)) + ;; Grep. + ((and grep-line (file-exists-p (car grep-line))) + (expand-file-name (car grep-line))) + ;; Occur. + (grep-line + (with-current-buffer (get-buffer (car grep-line)) + (or (buffer-file-name) default-directory))) + ;; Url. + ((and ffap-url-regexp (string-match ffap-url-regexp sel)) sel) + ;; Default. + (t default-preselection))))) + +;; Same as `vc-directory-exclusion-list'. +(defvar helm-walk-ignore-directories + '("SCCS" "RCS" "CVS" "MCVS" ".svn" ".git" ".hg" ".bzr" + "_MTN" "_darcs" "{arch}" ".gvfs")) + +(cl-defun helm-walk-directory (directory &key (path 'basename) + (directories t) + match skip-subdirs) + "Walk through DIRECTORY tree. +Argument PATH can be one of basename, relative, full, or a function +called on file name, default to basename. +Argument DIRECTORIES when non--nil (default) return also directories names, +otherwise skip directories names. +Argument MATCH can be a predicate or a regexp. +Argument SKIP-SUBDIRS when non--nil will skip `helm-walk-ignore-directories' +unless it is given as a list of directories, in this case this list will be used +instead of `helm-walk-ignore-directories'." + (let* ((result '()) + (fn (cl-case path + (basename 'file-name-nondirectory) + (relative 'file-relative-name) + (full 'identity) + (t path)))) + (cl-labels ((ls-rec (dir) + (unless (and skip-subdirs + (member (helm-basename dir) + (if (listp skip-subdirs) + skip-subdirs + helm-walk-ignore-directories))) + (cl-loop with ls = (sort (file-name-all-completions "" dir) + 'string-lessp) + for f in ls + ;; Use `directory-file-name' to remove the final slash. + ;; Needed to avoid infloop on symlinks symlinking + ;; a directory inside it [1]. + for file = (directory-file-name + (expand-file-name f dir)) + unless (member f '("./" "../")) + ;; A directory. + if (char-equal (aref f (1- (length f))) ?/) + do (progn (when directories + (push (funcall fn file) result)) + ;; Don't recurse in symlinks. + ;; `file-symlink-p' have to be called + ;; on the directory with its final + ;; slash removed [1]. + (and (not (file-symlink-p file)) + (ls-rec file))) + else do + (if match + (and (if (functionp match) + (funcall match f) + (and (stringp match) + (string-match match f))) + (push (funcall fn file) result)) + (push (funcall fn file) result)))))) + (ls-rec directory) + (nreverse result)))) + +(defun helm-generic-sort-fn (s1 s2) + "Sort predicate function for helm candidates. +Args S1 and S2 can be single or \(display . real\) candidates, +that is sorting is done against real value of candidate." + (let* ((reg1 (concat "\\_<" helm-pattern "\\_>")) + (reg2 (concat "\\_<" helm-pattern)) + (split (split-string helm-pattern)) + (str1 (if (consp s1) (cdr s1) s1)) + (str2 (if (consp s2) (cdr s2) s2)) + (score #'(lambda (str r1 r2 lst) + (cond ((string-match r1 str) 4) + ((and (string-match " " helm-pattern) + (string-match (concat "\\_<" (car lst)) str) + (cl-loop for r in (cdr lst) + always (string-match r str))) 3) + ((and (string-match " " helm-pattern) + (cl-loop for r in lst always (string-match r str))) 2) + ((string-match r2 str) 1) + (t 0)))) + (sc1 (funcall score str1 reg1 reg2 split)) + (sc2 (funcall score str2 reg1 reg2 split))) + (cond ((or (zerop (string-width helm-pattern)) + (and (zerop sc1) (zerop sc2))) + (string-lessp str1 str2)) + ((= sc1 sc2) + (< (length str1) (length str2))) + (t (> sc1 sc2))))) + +(defun helm-basename (fname &optional ext) + "Print FNAME with any leading directory components removed. +If specified, also remove filename extension EXT." + (let ((non-essential t)) + (if (and ext (or (string= (file-name-extension fname) ext) + (string= (file-name-extension fname t) ext)) + (not (file-directory-p fname))) + (file-name-sans-extension (file-name-nondirectory fname)) + (file-name-nondirectory (directory-file-name fname))))) + +(defun helm-basedir (fname) + "Return the base directory of filename." + (helm-aif (and fname (file-name-directory fname)) + (file-name-as-directory it))) + +(defun helm-ff-get-host-from-tramp-invalid-fname (fname) + "Extract hostname from an incomplete tramp file name. +Return nil on valid file name remote or not." + (let* ((str (helm-basename fname)) + (split (split-string str ":")) + (meth (car (member (car split) (mapcar 'car tramp-methods))))) + (when (and meth (<= (length split) 2)) + (cadr split)))) + +(cl-defun helm-file-human-size (size &optional (kbsize helm-default-kbsize)) + "Return a string showing SIZE of a file in human readable form. +SIZE can be an integer or a float depending it's value. +`file-attributes' will take care of that to avoid overflow error. +KBSIZE if a floating point number, defaulting to `helm-default-kbsize'." + (let ((M (cons "M" (/ size (expt kbsize 2)))) + (G (cons "G" (/ size (expt kbsize 3)))) + (K (cons "K" (/ size kbsize))) + (B (cons "B" size))) + (cl-loop with result = B + for (a . b) in + (cl-loop for (x . y) in (list M G K B) + unless (< y 1) collect (cons x y)) + when (< b (cdr result)) do (setq result (cons a b)) + finally return (if (string= (car result) "B") + (format "%s" size) + (format "%.1f%s" (cdr result) (car result)))))) + +(cl-defun helm-file-attributes + (file &key type links uid gid access-time modif-time + status size mode gid-change inode device-num dired human-size + mode-type mode-owner mode-group mode-other (string t)) + "Return `file-attributes' elements of FILE separately according to key value. +Availables keys are: +- TYPE: Same as nth 0 `files-attributes' if STRING is nil + otherwise return either symlink, directory or file (default). +- LINKS: See nth 1 `files-attributes'. +- UID: See nth 2 `files-attributes'. +- GID: See nth 3 `files-attributes'. +- ACCESS-TIME: See nth 4 `files-attributes', however format time + when STRING is non--nil (the default). +- MODIF-TIME: See nth 5 `files-attributes', same as above. +- STATUS: See nth 6 `files-attributes', same as above. +- SIZE: See nth 7 `files-attributes'. +- MODE: See nth 8 `files-attributes'. +- GID-CHANGE: See nth 9 `files-attributes'. +- INODE: See nth 10 `files-attributes'. +- DEVICE-NUM: See nth 11 `files-attributes'. +- DIRED: A line similar to what 'ls -l' return. +- HUMAN-SIZE: The size in human form, see `helm-file-human-size'. +- MODE-TYPE, mode-owner,mode-group, mode-other: Split what + nth 7 `files-attributes' return in four categories. +- STRING: When non--nil (default) `helm-file-attributes' return + more friendly values. +If you want the same behavior as `files-attributes' , +\(but with return values in proplist\) use a nil value for STRING. +However when STRING is non--nil, time and type value are different from what +you have in `file-attributes'." + (let* ((all (cl-destructuring-bind + (type links uid gid access-time modif-time + status size mode gid-change inode device-num) + (file-attributes file string) + (list :type (if string + (cond ((stringp type) "symlink") ; fname + (type "directory") ; t + (t "file")) ; nil + type) + :links links + :uid uid + :gid gid + :access-time (if string + (format-time-string + "%Y-%m-%d %R" access-time) + access-time) + :modif-time (if string + (format-time-string + "%Y-%m-%d %R" modif-time) + modif-time) + :status (if string + (format-time-string + "%Y-%m-%d %R" status) + status) + :size size + :mode mode + :gid-change gid-change + :inode inode + :device-num device-num))) + (modes (helm-split-mode-file-attributes (cl-getf all :mode)))) + (cond (type (cl-getf all :type)) + (links (cl-getf all :links)) + (uid (cl-getf all :uid)) + (gid (cl-getf all :gid)) + (access-time (cl-getf all :access-time)) + (modif-time (cl-getf all :modif-time)) + (status (cl-getf all :status)) + (size (cl-getf all :size)) + (mode (cl-getf all :mode)) + (gid-change (cl-getf all :gid-change)) + (inode (cl-getf all :inode)) + (device-num (cl-getf all :device-num)) + (dired + (concat + (helm-split-mode-file-attributes (cl-getf all :mode) t) " " + (number-to-string (cl-getf all :links)) " " + (cl-getf all :uid) ":" + (cl-getf all :gid) " " + (if human-size + (helm-file-human-size (cl-getf all :size)) + (int-to-string (cl-getf all :size))) " " + (cl-getf all :modif-time))) + (human-size (helm-file-human-size (cl-getf all :size))) + (mode-type (cl-getf modes :mode-type)) + (mode-owner (cl-getf modes :user)) + (mode-group (cl-getf modes :group)) + (mode-other (cl-getf modes :other)) + (t (append all modes))))) + +(defun helm-split-mode-file-attributes (str &optional string) + "Split mode file attributes STR into a proplist. +If STRING is non--nil return instead a space separated string." + (cl-loop with type = (substring str 0 1) + with cdr = (substring str 1) + for i across cdr + for count from 1 + if (<= count 3) + concat (string i) into user + if (and (> count 3) (<= count 6)) + concat (string i) into group + if (and (> count 6) (<= count 9)) + concat (string i) into other + finally return + (if string + (mapconcat 'identity (list type user group other) " ") + (list :mode-type type :user user :group group :other other)))) + +(defun helm-current-directory () + "Return current-directory name at point. +Useful in dired buffers when there is inserted subdirs." + (if (eq major-mode 'dired-mode) + (dired-current-directory) + default-directory)) + +(defmacro with-helm-display-marked-candidates (buffer-or-name candidates &rest body) + (declare (indent 0) (debug t)) + (helm-with-gensyms (buffer window) + `(let* ((,buffer (temp-buffer-window-setup ,buffer-or-name)) + ,window) + (unwind-protect + (with-current-buffer ,buffer + (dired-format-columns-of-files ,candidates) + (select-window + (setq ,window (temp-buffer-window-show + ,buffer + '(display-buffer-below-selected + (window-height . fit-window-to-buffer))))) + (progn ,@body)) + (quit-window 'kill ,window))))) + +;;; Persistent Action Helpers +;; +;; +;; Internal +(defvar helm-match-line-overlay nil) +(defvar helm--match-item-overlays nil) + +(defun helm-highlight-current-line (&optional start end buf face pulse) + "Highlight and underline current position" + (let* ((start (or start (line-beginning-position))) + (end (or end (1+ (line-end-position)))) + (start-match (if (or (zerop helm-highlight-number-lines-around-point) + (null helm-highlight-number-lines-around-point)) + start + (save-excursion + (forward-line + (- helm-highlight-number-lines-around-point)) + (point-at-bol)))) + (end-match (if (or (zerop helm-highlight-number-lines-around-point) + (null helm-highlight-number-lines-around-point)) + end + (save-excursion + (forward-line + helm-highlight-number-lines-around-point) + (point-at-eol)))) + (args (list start end buf))) + (if (not helm-match-line-overlay) + (setq helm-match-line-overlay (apply 'make-overlay args)) + (apply 'move-overlay helm-match-line-overlay args)) + (overlay-put helm-match-line-overlay + 'face (or face 'helm-selection-line)) + (catch 'empty-line + (cl-loop with ov + for r in (helm-remove-if-match + "\\`!" (split-string helm-pattern)) + do (save-excursion + (goto-char start-match) + (while (condition-case _err + (re-search-forward r end-match t) + (invalid-regexp nil)) + (let ((s (match-beginning 0)) + (e (match-end 0))) + (if (= s e) + (throw 'empty-line nil) + (push (setq ov (make-overlay s e)) + helm--match-item-overlays) + (overlay-put ov 'face 'helm-match-item) + (overlay-put ov 'priority 1))))))) + (recenter) + (when pulse + (sit-for 0.3) + (helm-match-line-cleanup)))) + +(defun helm-match-line-cleanup () + (when helm-match-line-overlay + (delete-overlay helm-match-line-overlay) + (setq helm-match-line-overlay nil)) + (when helm--match-item-overlays + (mapc 'delete-overlay helm--match-item-overlays))) + +(defun helm-match-line-update () + (when helm-match-line-overlay + (delete-overlay helm-match-line-overlay) + (helm-highlight-current-line))) + +(defun helm-persistent-autoresize-hook () + (when (and helm-buffers-to-resize-on-pa + (member helm-buffer helm-buffers-to-resize-on-pa) + (eq helm-split-window-state 'vertical)) + (set-window-text-height (helm-window) helm-resize-on-pa-text-height))) + +(add-hook 'helm-after-persistent-action-hook 'helm-persistent-autoresize-hook) +(add-hook 'helm-cleanup-hook 'helm-match-line-cleanup) +(add-hook 'helm-after-persistent-action-hook 'helm-match-line-update) + +(defun helm-w32-prepare-filename (file) + "Convert filename FILE to something usable by external w32 executables." + (replace-regexp-in-string ; For UNC paths + "/" "\\" + (replace-regexp-in-string ; Strip cygdrive paths + "/cygdrive/\\(.\\)" "\\1:" + file nil nil) nil t)) + +;;;###autoload +(defun helm-w32-shell-execute-open-file (file) + (interactive "fOpen file:") + (with-no-warnings + (w32-shell-execute "open" (helm-w32-prepare-filename file)))) + +(defun helm-open-file-with-default-tool (file) + "Open FILE with the default tool on this platform." + (let (process-connection-type) + (if (eq system-type 'windows-nt) + (helm-w32-shell-execute-open-file file) + (start-process "helm-open-file-with-default-tool" + nil + (cond ((eq system-type 'gnu/linux) + "xdg-open") + ((or (eq system-type 'darwin) ;; Mac OS X + (eq system-type 'macos)) ;; Mac OS 9 + "open")) + file)))) + +(defun helm-open-dired (file) + "Opens a dired buffer in FILE's directory. If FILE is a +directory, open this directory." + (if (file-directory-p file) + (dired file) + (dired (file-name-directory file)) + (dired-goto-file file))) + +(defun helm-require-or-error (feature function) + (or (require feature nil t) + (error "Need %s to use `%s'." feature function))) + +(defun helm-find-file-as-root (candidate) + (let* ((buf (helm-basename candidate)) + (host (file-remote-p candidate 'host)) + (remote-path (format "/%s:%s:%s" + helm-su-or-sudo + (or host "") + (expand-file-name + (if host + (file-remote-p candidate 'localname) + candidate)))) + non-essential) + (if (buffer-live-p (get-buffer buf)) + (progn + (set-buffer buf) + (find-alternate-file remote-path)) + (find-file remote-path)))) + +(defun helm-find-many-files (_ignore) + (let ((helm--reading-passwd-or-string t)) + (mapc 'find-file (helm-marked-candidates)))) + +(defun helm-quit-and-execute-action (action) + "Quit current helm session and execute ACTION." + (setq helm-saved-action action) + (helm-exit-minibuffer)) + +;; Yank text at point. +;; +;; +;; Internal +(defvar helm-yank-point nil) + +;;;###autoload +(defun helm-yank-text-at-point () + "Yank text at point in `helm-current-buffer' into minibuffer. +If `helm-yank-symbol-first' is non--nil the first yank +grabs the entire symbol." + (interactive) + (with-helm-current-buffer + (let ((fwd-fn (if helm-yank-symbol-first + 'forward-symbol 'forward-word))) + ;; Start to initial point if C-w have never been hit. + (unless helm-yank-point (setq helm-yank-point (point))) + (save-excursion + (goto-char helm-yank-point) + (funcall fwd-fn 1) + (helm-set-pattern + (concat + helm-pattern (replace-regexp-in-string + "\\`\n" "" + (buffer-substring-no-properties + helm-yank-point (point))))) + (setq helm-yank-point (point)))))) + +(defun helm-reset-yank-point () + (setq helm-yank-point nil)) + +(defun helm-read-repeat-string (prompt &optional count) + "Prompt as many time PROMPT is not empty. +If COUNT is non--nil add a number after each prompt." + (cl-loop with elm + while (not (string= elm "")) + for n from 1 + do (when count + (setq prompt (concat prompt (int-to-string n) ": "))) + collect (setq elm (helm-read-string prompt)) into lis + finally return (remove "" lis))) + +(add-hook 'helm-cleanup-hook 'helm-reset-yank-point) +(add-hook 'helm-after-initialize-hook 'helm-reset-yank-point) + +(defun helm-html-bookmarks-to-alist (file url-regexp bmk-regexp) + "Parse html bookmark FILE and return an alist with (title . url) as elements." + (let (bookmarks-alist url title) + (with-temp-buffer + (insert-file-contents file) + (goto-char (point-min)) + (while (re-search-forward "href=\\|^ *

q\" '(foo bar baz) 2) + +Each time \" q\" is pressed the next function is executed, if you wait +More than 2 seconds, next hit will run again the first function and so on." + (define-key keymap key (helm-make-multi-command functions delay))) + +;;;###autoload +(defmacro helm-multi-key-defun (name docstring funs &optional delay) + "Define NAME as a multi-key command running FUNS. +After DELAY seconds the FUNS list is reinitialised. +See `helm-define-multi-key'." + (declare (indent 2)) + (setq docstring (if docstring (concat docstring "\n\n") + "This is a helmish multi-key command.")) + `(defalias (quote ,name) (helm-make-multi-command ,funs ,delay) ,docstring)) + +(defun helm-make-multi-command (functions &optional delay) + "Return an anonymous multi-key command running FUNCTIONS. +Run each function of FUNCTIONS list in turn when called within DELAY seconds." + (declare (indent 1)) + (let ((funs functions) + (iter (cl-gensym "helm-iter-key")) + (timeout delay)) + (eval (list 'defvar iter nil)) + #'(lambda () (interactive) (helm-run-multi-key-command funs iter timeout)))) + +(defun helm-run-multi-key-command (functions iterator delay) + (let ((fn #'(lambda () + (cl-loop for count from 1 to (length functions) + collect count))) + next) + (unless (and (symbol-value iterator) + ;; Reset iterator when another key is pressed. + (eq this-command real-last-command)) + (set iterator (helm-iter-list (funcall fn)))) + (setq next (helm-iter-next (symbol-value iterator))) + (unless next + (set iterator (helm-iter-list (funcall fn))) + (setq next (helm-iter-next (symbol-value iterator)))) + (and next (symbol-value iterator) (call-interactively (nth (1- next) functions))) + (when delay (run-with-idle-timer delay nil `(lambda () + (setq ,iterator nil)))))) + +(defun helm-iter-list (seq) + "Return an iterator object from SEQ." + (let ((lis seq)) + (lambda () + (let ((elm (car lis))) + (setq lis (cdr lis)) + elm)))) + +(defun helm-iter-next (iterator) + "Return next elm of ITERATOR." + (funcall iterator)) + +(helm-multi-key-defun helm-toggle-resplit-and-swap-windows + "Multi key command to resplit and swap helm window. +First call run `helm-toggle-resplit-window', +second call within 0.5s run `helm-swap-windows'." + '(helm-toggle-resplit-window helm-swap-windows) 1) + +;;;###autoload +(defun helm-define-key-with-subkeys (map key subkey command + &optional other-subkeys menu exit-fn) + "Allow defining in MAP a KEY and SUBKEY to COMMAND. + +This allow typing KEY to call COMMAND the first time and +type only SUBKEY on subsequent calls. + +Arg MAP is the keymap to use, SUBKEY is the initial short keybinding to +call COMMAND. + +Arg OTHER-SUBKEYS is an alist specifying other short keybindings +to use once started. +e.g: + +\(helm-define-key-with-subkeys global-map + \(kbd \"C-x v n\") ?n 'git-gutter:next-hunk '((?p . git-gutter:previous-hunk))\) + + +In this example, `C-x v n' will run `git-gutter:next-hunk' +subsequent hits on \"n\" will run this command again +and subsequent hits on \"p\" will run `git-gutter:previous-hunk'. + +Arg MENU is a string to display in minibuffer +to describe SUBKEY and OTHER-SUBKEYS. +Arg EXIT-FN specify a function to run on exit. + +Any other keys pressed run their assigned command defined in MAP +and exit the loop running EXIT-FN if specified. + +NOTE: SUBKEY and OTHER-SUBKEYS bindings support +only char syntax actually (e.g ?n) +so don't use strings, vectors or whatever to define them." + (declare (indent 1)) + (define-key map key + (lambda () + (interactive) + (unwind-protect + (progn + (call-interactively command) + (while (let ((input (read-key menu)) other kb com) + (setq last-command-event input) + (cond + ((eq input subkey) + (call-interactively command) + t) + ((setq other (assoc input other-subkeys)) + (call-interactively (cdr other)) + t) + (t + (setq kb (vector last-command-event)) + (setq com (lookup-key map kb)) + (if (commandp com) + (call-interactively com) + (setq unread-command-events + (nconc (mapcar 'identity kb) + unread-command-events))) + nil))))) + (and exit-fn (funcall exit-fn)))))) + + +;;; Keymap +;; +;; +(defvar helm-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-map) + (define-key map (kbd "") 'helm-next-line) + (define-key map (kbd "") 'helm-previous-line) + (define-key map (kbd "C-n") 'helm-next-line) + (define-key map (kbd "C-p") 'helm-previous-line) + (define-key map (kbd "") 'helm-follow-action-forward) + (define-key map (kbd "") 'helm-follow-action-backward) + (define-key map (kbd "") 'helm-previous-page) + (define-key map (kbd "") 'helm-next-page) + (define-key map (kbd "M-v") 'helm-previous-page) + (define-key map (kbd "C-v") 'helm-next-page) + (define-key map (kbd "M-<") 'helm-beginning-of-buffer) + (define-key map (kbd "M->") 'helm-end-of-buffer) + (define-key map (kbd "C-g") 'helm-keyboard-quit) + (define-key map (kbd "") 'helm-next-source) + (define-key map (kbd "") 'helm-previous-source) + (define-key map (kbd "") 'helm-maybe-exit-minibuffer) + (define-key map (kbd "C-i") 'helm-select-action) + (define-key map (kbd "C-z") 'helm-execute-persistent-action) + (define-key map (kbd "C-j") 'helm-execute-persistent-action) + (define-key map (kbd "C-o") 'helm-next-source) + (define-key map (kbd "C-l") 'helm-recenter-top-bottom-other-window) + (define-key map (kbd "M-C-l") 'helm-reposition-window-other-window) + (define-key map (kbd "C-M-v") 'helm-scroll-other-window) + (define-key map (kbd "M-") 'helm-scroll-other-window) + (define-key map (kbd "C-M-y") 'helm-scroll-other-window-down) + (define-key map (kbd "C-M-S-v") 'helm-scroll-other-window-down) + (define-key map (kbd "M-") 'helm-scroll-other-window-down) + (define-key map (kbd "") 'helm-scroll-other-window) + (define-key map (kbd "") 'helm-scroll-other-window-down) + (define-key map (kbd "C-@") 'helm-toggle-visible-mark) + (define-key map (kbd "C-SPC") 'helm-toggle-visible-mark) + (define-key map (kbd "M-SPC") 'helm-toggle-visible-mark) + (define-key map (kbd "M-[") nil) + (define-key map (kbd "M-(") 'helm-prev-visible-mark) + (define-key map (kbd "M-)") 'helm-next-visible-mark) + (define-key map (kbd "C-k") 'helm-delete-minibuffer-contents) + (define-key map (kbd "C-x C-f") 'helm-quit-and-find-file) + (define-key map (kbd "M-m") 'helm-toggle-all-marks) + (define-key map (kbd "M-a") 'helm-mark-all) + (define-key map (kbd "M-u") 'helm-unmark-all) + (define-key map (kbd "C-w") 'helm-yank-text-at-point) + (define-key map (kbd "C-M-a") 'helm-show-all-in-this-source-only) + (define-key map (kbd "C-M-e") 'helm-display-all-sources) + (define-key map (kbd "C-r") 'undefined) + (define-key map (kbd "C-s") 'undefined) + (define-key map (kbd "M-s") 'undefined) + (define-key map (kbd "C-}") 'helm-narrow-window) + (define-key map (kbd "C-{") 'helm-enlarge-window) + (define-key map (kbd "C-c -") 'helm-swap-windows) + (define-key map (kbd "C-c C-d") 'helm-delete-current-selection) + (define-key map (kbd "C-c C-y") 'helm-yank-selection) + (define-key map (kbd "C-c C-k") 'helm-kill-selection-and-quit) + (define-key map (kbd "C-c C-i") 'helm-copy-to-buffer) + (define-key map (kbd "C-c C-f") 'helm-follow-mode) + (define-key map (kbd "C-c C-u") 'helm-force-update) + (define-key map (kbd "M-p") 'previous-history-element) + (define-key map (kbd "M-n") 'next-history-element) + (define-key map (kbd "C-!") 'helm-toggle-suspend-update) + (define-key map (kbd "C-x b") 'helm-resume-previous-session-after-quit) + (define-key map (kbd "C-x C-b") 'helm-resume-list-buffers-after-quit) + ;; Disable `file-cache-minibuffer-complete'. + (define-key map (kbd "") 'undefined) + ;; 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-debug-output) + ;; Use `describe-mode' key in `global-map'. + (define-key map [f1] nil) ; Allow to eval keymap without errors. + (define-key map (kbd "C-h C-h") 'undefined) + (define-key map (kbd "C-h h") 'undefined) + (cl-dolist (k (where-is-internal 'describe-mode global-map)) + (define-key map k 'helm-help)) + ;; Bind all actions from 1 to 12 to their corresponding nth index+1. + (cl-loop for n from 0 to 12 do + (define-key map (kbd (format "" (1+ n))) + `(lambda () + (interactive) + (helm-select-nth-action ,n)))) + map) + "Keymap for helm.") + + +(defgroup helm nil + "Open helm." + :prefix "helm-" :group 'convenience) + +(defcustom helm-completion-window-scroll-margin 5 + " `scroll-margin' to use for helm completion window. +Which see. Set to 0 to disable. +NOTE: This have no effect when `helm-display-source-at-screen-top' +id non--nil." + :group 'helm + :type 'integer) + +(defcustom helm-display-source-at-screen-top t + "Display candidates at the top of screen. +This happen when using `helm-next-source' and `helm-previous-source'. +NOTE: When non--nil (default) disable `helm-completion-window-scroll-margin'." + :group 'helm + :type 'boolean) + +(defcustom helm-candidate-number-limit 100 + "Limit candidate number globally. +Do not show more candidates than this limit from individual sources. +It is usually pointless to show hundreds of matches +when the pattern is empty, because it is much simpler to type a +few characters to narrow down the list of potential candidates. + +Set it to nil if you don't want this limit." + :group 'helm + :type '(choice (const :tag "Disabled" nil) integer)) + +(defcustom helm-idle-delay 0.01 + "Be idle for this many seconds, before updating in delayed sources. +This is useful for sources involving heavy operations +\(like launching external programs\), so that candidates +from the source are not retrieved unnecessarily if the user keeps typing. + +It also can be used to declutter the results helm displays, +so that results from certain sources are not shown with every +character typed, only if the user hesitates a bit. +Be sure to know what you are doing when modifying this." + :group 'helm + :type 'float) + +(defcustom helm-input-idle-delay 0.01 + "Be idle for this many seconds, before updating. + +Unlike `helm-idle-delay', it is also effective for non-delayed sources. +If nil, candidates are collected immediately. + +Note: If this value is too low compared to `helm-idle-delay', +you may have duplicated sources when using multiples sources. +Safe value is always >= `helm-idle-delay'. +Default settings are equal value for both. +Be sure to know what you are doing when modifying this." + :group 'helm + :type 'float) + +(defcustom helm-exit-idle-delay 0 + "Be idle for this many seconds before exiting minibuffer while helm is updating. +Note that this does nothing when helm-buffer is up to date +\(i.e exit without delay in this condition\)." + :group 'helm + :type 'float) + +(defcustom helm-full-frame nil + "Use current window to show the candidates. +If t then Helm doesn't pop up a new window." + :group 'helm + :type 'boolean) + +(defvaralias 'helm-samewindow 'helm-full-frame) +(make-obsolete-variable 'helm-samewindow 'helm-full-frame "1.4.8.1") + +(defcustom helm-quick-update nil + "If non-nil, suppress displaying sources which are out of screen at first. +They are treated as delayed sources at this input. +This flag makes `helm' a bit faster with many sources." + :group 'helm + :type 'boolean) + +(defcustom helm-candidate-separator + "--------------------" + "Candidates separator of `multiline' source." + :group 'helm + :type 'string) + +(defcustom helm-save-configuration-functions + '(set-window-configuration . current-window-configuration) + "The functions used to restore/save window or frame configurations. +It is a pair where the car is the function to restore window or frame config, +and the cdr is the function to save the window or frame config. + +If you want to save and restore frame configuration, set this variable to + '\(set-frame-configuration . current-frame-configuration\) +NOTE: This may not work properly with own-frame minibuffer settings. +Older version saves/restores frame configuration, but the default is changed now +because flickering can occur in some environment." + :group 'helm + :type 'sexp) + +(defcustom helm-persistent-action-use-special-display nil + "If non-nil, use `special-display-function' in persistent action." + :group 'helm + :type 'boolean) + +(defcustom helm-scroll-amount nil + "Scroll amount when scrolling other window in a helm session. +It is used by `helm-scroll-other-window' +and `helm-scroll-other-window-down'. + +If you prefer scrolling line by line, set this value to 1." + :group 'helm + :type 'integer) + +(defcustom helm-display-function 'helm-default-display-buffer + "Function to display *helm* buffer. +It is `helm-default-display-buffer' by default, +which affects `helm-full-frame'." + :group 'helm + :type 'symbol) + +(defcustom helm-case-fold-search 'smart + "Add 'smart' option to `case-fold-search'. +When smart is enabled, ignore case in the search strings +if pattern contains no uppercase characters. +Otherwise, with a nil or t value, the behavior is same as +`case-fold-search'. +Default value is smart, other possible values are nil and t. +NOTE: This have no effect in asynchronous sources, you will +have to implement a similar feature directly in the process. +See in helm-grep.el how it is implemented." + :group 'helm + :type '(choice (const :tag "Ignore case" t) + (const :tag "Respect case" nil) + (other :tag "Smart" 'smart))) + +(defcustom helm-file-name-case-fold-search + (if (memq system-type + '(cygwin windows-nt ms-dos darwin)) + t + helm-case-fold-search) + "Local setting of `helm-case-fold-search' for reading filenames. + +See `helm-case-fold-search' for more info." + :group 'helm + :type 'symbol) + +(defcustom helm-reuse-last-window-split-state nil + "Reuse the last state of window split, vertical or horizontal. +That is when you use `helm-toggle-resplit-window' the next helm session +will reuse the same window scheme than the one of last session unless +`helm-split-window-default-side' is 'same or 'other." + :group 'helm + :type 'boolean) + +(defcustom helm-split-window-preferred-function 'helm-split-window-default-fn + "Default function used for splitting window." + :group 'helm + :type 'function) + +(defcustom helm-split-window-default-side 'below + "The default side to display `helm-buffer'. +Must be one acceptable arg for `split-window' SIDE, +that is 'below, 'above, 'left or 'right. + +Other acceptable values are 'same which always display `helm-buffer' +in current window and 'other that display `helm-buffer' below if only one +window or in `other-window-for-scrolling' if available. + +A nil value as same effect as 'below. +If `helm-full-frame' is non--nil, it take precedence on this. + +See also `helm-split-window-in-side-p' and `helm-always-two-windows' that +take precedence on this. + +NOTE: this have no effect if `helm-split-window-preferred-function' is not +`helm-split-window-default-fn' unless this new function handle this." + :group 'helm + :type 'symbol) + +(defcustom helm-split-window-in-side-p nil + "Force splitting inside selected window when non--nil. +See also `helm-split-window-default-side'. + +NOTE: this have no effect if `helm-split-window-preferred-function' is not +`helm-split-window-default-fn' unless this new function handle this." + :group 'helm + :type 'boolean) + +(defcustom helm-always-two-windows nil + "When non--nil helm will use two windows in this frame. +That is one window to display `helm-buffer' and one to display +`helm-current-buffer'. +Note: this have no effect when `helm-split-window-in-side-p' is non--nil, +or when `helm-split-window-default-side' is set to 'same. +When `helm-autoresize-mode' is enabled, setting this to nil +will have no effect until this mode will be disabled." + :group 'helm + :type 'boolean) + +(defcustom helm-sources-using-default-as-input '(helm-source-imenu + helm-source-info-elisp + helm-source-etags-select) + "List of helm sources that need to use `helm-maybe-use-default-as-input'. +When a source is member of this list, default `thing-at-point' +will be used as input." + :group 'helm + :type '(repeat (choice symbol))) + +(defcustom helm-delete-minibuffer-contents-from-point t + "When non--nil, `helm-delete-minibuffer-contents' delete region from `point'. +Otherwise delete `minibuffer-contents'. +See documentation of `helm-delete-minibuffer-contents'." + :group 'helm + :type 'boolean) + +(defcustom helm-follow-mode-persistent nil + "Retrieve last state of `helm-follow-mode' in next helm session when non--nil. +This will not make it persistent through emacs sessions though, +you will have to set explicitely the `follow' attribute in the source where +you want this mode enabled definitely." + :group 'helm + :type 'boolean) + +(defcustom helm-prevent-escaping-from-minibuffer t + "Prevent escaping from minibuffer during helm session." + :group 'helm + :type 'boolean) + +(defcustom helm-truncate-lines nil + "Truncate long lines when non--nil. +See `truncate-lines'." + :group 'helm + :type 'boolean) + +(defcustom helm-move-to-line-cycle-in-source nil + "Move to end or beginning of source when reaching top or bottom of source. +This happen when using `helm-next/previous-line'." + :group 'helm + :type 'boolean) + +(defcustom helm-fuzzy-match-fn 'helm-fuzzy-match + "The function for fuzzy matching in `helm-source-sync' based sources." + :group 'helm + :type 'function) + +(defcustom helm-fuzzy-search-fn 'helm-fuzzy-search + "The function for fuzzy matching in `helm-source-in-buffer' based sources." + :group 'helm + :type 'function) + +(defcustom helm-fuzzy-sort-fn 'helm-fuzzy-matching-default-sort-fn + "The sort transformer function used in fuzzy matching. +When nil no sorting will be done." + :group 'helm + :type 'function) + +(defcustom helm-fuzzy-matching-highlight-fn 'helm-fuzzy-default-highlight-match + "The function to highlight matches in fuzzy matching. +When nil no highlighting will be done." + :group 'helm + :type 'function) + +(defcustom helm-autoresize-max-height 40 + "Specifies a maximum height and defaults to the height of helm window's frame in percentage. + +See `fit-window-to-buffer' for more infos." + :group 'helm + :type 'integer) + +(defcustom helm-autoresize-min-height 10 + "Specifies a minimum height and defaults to the height of helm window's frame in percentage. + +If nil the default of `window-min-height' is used +See `fit-window-to-buffer' for more infos." + :group 'helm + :type 'integer) + +(defcustom helm-input-method-verbose-flag nil + "The default value of `input-method-verbose-flag' to use in helm minibuffer. +It is nil by default to allow helm updating and exiting without turning off +the input method when complex methods are in use, if you set it to any other +value allowed by `input-method-verbose-flag' you will have at each time you want +to exit or helm update to disable the `current-input-method' with `C-\\'." + :group 'helm + :type '(radio :tag "A flag to control extra guidance given by input methods in helm." + (const :tag "Never provide guidance" nil) + (const :tag "Always provide guidance" t) + (const :tag "Provide guidance only in complex methods" complex-only))) + +(defcustom helm-display-header-line t + "Display header-line when non nil." + :group 'helm + :type 'boolean) + +(defcustom helm-file-globstar t + "Same as globstar bash shopt option. +When non--nil a pattern beginning with two stars will expand recursively. +Directories expansion is not supported yet." + :group 'helm + :type 'boolean) + +(defcustom helm-inherit-input-method t + "Inherit `current-input-method' from `current-buffer' when non--nil. +The default is to enable this by default, the user can toggle the current +input method with `toggle-input-method'." + :group 'helm + :type 'boolean) + +;;; Faces +;; +;; +(defgroup helm-faces nil + "Customize the appearance of helm." + :prefix "helm-" + :group 'faces + :group 'helm) + +(defface helm-source-header + '((((background dark)) + :background "#22083397778B" + :foreground "white" + :weight bold :height 1.3 :family "Sans Serif") + (((background light)) + :background "#abd7f0" + :foreground "black" + :weight bold :height 1.3 :family "Sans Serif")) + "Face for source header in the helm buffer." + :group 'helm-faces) + +(defface helm-visible-mark + '((((min-colors 88) (background dark)) + (:background "green1" :foreground "black")) + (((background dark)) + (:background "green" :foreground "black")) + (((background light)) :background "#d1f5ea") + (((min-colors 88)) + (:background "green1")) + (t (:background "green"))) + "Face for visible mark." + :group 'helm-faces) + +(defface helm-header + '((t (:inherit header-line))) + "Face for header lines in the helm buffer." + :group 'helm-faces) + +(defface helm-candidate-number + '((((background dark)) :background "Yellow" :foreground "black") + (((background light)) :background "#faffb5" :foreground "black")) + "Face for candidate number in mode-line." :group 'helm-faces) + +(defface helm-selection + '((((background dark)) :background "ForestGreen" + :distant-foreground "black") + (((background light)) :background "#b5ffd1" + :distant-foreground "black")) + "Face for currently selected item in the helm buffer." + :group 'helm-faces) + +(defface helm-separator + '((((background dark)) :foreground "red") + (((background light)) :foreground "#ffbfb5")) + "Face for multiline source separator." + :group 'helm-faces) + +(defface helm-action + '((t (:underline t))) + "Face for action lines in the helm action buffer." + :group 'helm-faces) + +(defface helm-prefarg + '((((background dark)) :foreground "green") + (((background light)) :foreground "red")) + "Face for showing prefix arg in mode-line." + :group 'helm-faces) + +(defface helm-match + '((((background light)) :foreground "#b00000") + (((background dark)) :foreground "gold1")) + "Face used to highlight matches." + :group 'helm) + + +;;; Variables. +;; +;; +(defvar helm-type-attributes nil + "It's a list of \(TYPE ATTRIBUTES ...\). +ATTRIBUTES are the same as attributes for `helm-sources'. +TYPE connects the value to the appropriate sources. +Don't set this directly, use instead `define-helm-type-attribute'. + +This allows specifying common attributes for several sources. +For example, sources which provide files can specify +common attributes with a `file' type.") + +(defvar helm-source-filter nil + "A list of source names to be displayed. +Other sources won't appear in the search results. +If nil then there is no filtering. +See also `helm-set-source-filter'.") + +(defvar helm-action-buffer "*helm action*" + "Buffer showing actions.") + +(defvar helm-selection-overlay nil + "Overlay used to highlight the currently selected item.") + +(defvar helm-async-processes nil + "List of information about asynchronous processes managed by helm.") + +(defvar helm-before-initialize-hook nil + "Run before helm initialization. +This hook is run before init functions in `helm-sources', +that is before creation of `helm-buffer'. +Local variables for `helm-buffer' that need a value from `current-buffer' +can be set here with `helm-set-local-variable'.") + +(defvar helm-after-initialize-hook nil + "Run after helm initialization. +This hook run inside `helm-buffer' once created. +Variables are initialized and the `helm-buffer' is created. +But the `helm-buffer' has no contents.") + +(defvar helm-update-hook nil + "Run after the helm buffer was updated according the new input pattern. +This hook is run at the beginning of buffer. +The first candidate is selected after running this hook. +See also `helm-after-update-hook'.") + +(defvar helm-after-update-hook nil + "Run after the helm buffer was updated according the new input pattern. +This is very similar to `helm-update-hook' but selection is not moved. +It is useful to select a particular object instead of the first one.") + +(defvar helm-cleanup-hook nil + "Run after helm minibuffer is closed. +IOW this hook is executed BEFORE performing action.") + +(defvar helm-select-action-hook nil + "Run when opening the action buffer.") + +(defvar helm-before-action-hook nil + "Run before executing action. +Contrarily to `helm-cleanup-hook', +this hook run before helm minibuffer is closed +and before performing action.") + +(defvar helm-after-action-hook nil + "Run after executing action.") + +(defvar helm-exit-minibuffer-hook nil + "Run just before exiting minibuffer.") + +(defvar helm-after-persistent-action-hook nil + "Run after executing persistent action.") + +(defvar helm-move-selection-before-hook nil + "Run before moving selection in `helm-buffer'.") + +(defvar helm-move-selection-after-hook nil + "Run after moving selection in `helm-buffer'.") + +(defvar helm-window-configuration-hook nil + "Run when switching to and back from action buffer.") + +(defconst helm-restored-variables + '(helm-candidate-number-limit + helm-source-filter + helm-source-in-each-line-flag + helm-map + helm-sources) + "Variables which are restored after `helm' invocation.") + +(defvar helm-execute-action-at-once-if-one nil + "Execute default action and exit when only one candidate is remaining.") + +(defvar helm-quit-if-no-candidate nil + "Quit when there is no candidates when non--nil. +This variable accepts a function, which is executed if no candidate.") + +(defvar helm-maybe-use-default-as-input nil + "Use :default arg of `helm' as input to update display. +Note that if also :input is specified as `helm' arg, it will take +precedence on :default.") + +(defvar helm-source-in-each-line-flag nil + "Non-nil means add helm-source text-property in each candidate. +experimental feature.") + +(defvar helm-debug-variables nil + "A list of helm variables to show in `helm-debug-output'. +Otherwise all variables started with `helm-' are shown.") + +(defvar helm-debug-buffer "*Debug Helm Log*") + +(defvar helm-debug nil + "If non-nil, write log message into `helm-debug-buffer' buffer. +It is disabled by default because `helm-debug-buffer' grows quickly.") + +(defvar helm-compile-source-functions + '(helm-compile-source--type + helm-compile-source--dummy + helm-compile-source--candidates-in-buffer) + "Functions to compile elements of `helm-sources' (plug-in).") + +(defvar helm-mode-line-string "\ +\\\ +\\[helm-help]:Help \ +\\[helm-select-action]:Act \ +\\[helm-maybe-exit-minibuffer]/\ +f1/f2/f-n:NthAct" + "Help string displayed in mode-line in `helm'. +It can be a string or a list of two args, in this case, +first arg is a string that will be used as name for candidates number, +second arg any string to display in mode line. +If nil, use default `mode-line-format'.") + + +;;; Internal Variables +;; +;; +(defvar helm-current-prefix-arg nil + "Record `current-prefix-arg' when exiting minibuffer.") +(defvar helm-saved-action nil + "Saved value of the currently selected action by key.") +(defvar helm-saved-current-source nil + "Value of the current source when the action list is shown.") +(defvar helm-compiled-sources nil + "Compiled version of `helm-sources'.") +(defvar helm-in-persistent-action nil + "Flag whether in persistent-action or not.") +(defvar helm-last-buffer nil + "`helm-buffer' of previously `helm' session.") +(defvar helm-saved-selection nil + "Value of the currently selected object when the action list is shown.") +(defvar helm-sources nil + "[INTERNAL] Value of current sources in use, a list.") +(defvar helm-buffer "*helm*" + "Buffer showing completions.") +(defvar helm-current-buffer nil + "Current buffer when `helm' is invoked.") +(defvar helm-buffer-file-name nil + "Variable `buffer-file-name' when `helm' is invoked.") +(defvar helm-candidate-cache (make-hash-table :test 'equal) + "Holds the available candidate within a single helm invocation.") +(defvar helm-pattern "" + "The input pattern used to update the helm buffer.") +(defvar helm-input "" + "The input typed in the candidates panel.") +(defvar helm-input-local nil + "Internal, store locally `helm-pattern' value for later use in `helm-resume'.") +(defvar helm-source-name nil) +(defvar helm-current-source nil) +(defvar helm-candidate-buffer-alist nil) +(defvar helm-match-hash (make-hash-table :test 'equal)) +(defvar helm-cib-hash (make-hash-table :test 'equal)) +(defvar helm-tick-hash (make-hash-table :test 'equal)) +(defvar helm-issued-errors nil) +(defvar helm-debug-root-directory nil + "When non--nil, save helm log to `helm-last-log-file'. +Be aware that if you set that, you will end up with a huge directory +of log files, so use that only for debugging purpose. +See `helm-log-save-maybe' for more info.") +(defvar helm-last-log-file nil + "The name of the last helm session log file.") +(defvar helm-follow-mode nil) +(defvar helm--local-variables nil) +(defvar helm-split-window-state nil) +(defvar helm--window-side-state nil) +(defvar helm-selection-point nil) +(defvar helm-alive-p nil) +(defvar helm-visible-mark-overlays nil) +(defvar helm-update-blacklist-regexps '("^" "^ *" "$" "!" " " "\\b" + "\\<" "\\>" "\\_<" "\\_>" ".*")) +(defvar helm-suspend-update-flag nil) +(defvar helm-force-updating-p nil) +(defvar helm-exit-status 0 + "Flag to inform whether helm have exited or quitted. +Exit with 0 mean helm have exited executing an action. +Exit with 1 mean helm have quitted with \\[keyboard-quit] +It is useful for example to restore a window config if helm abort +in special cases. +See `helm-exit-minibuffer' and `helm-keyboard-quit'.") +(defvar helm-minibuffer-confirm-state nil) +(defvar helm-quit nil) +(defvar helm-attributes nil "List of all `helm' attributes.") +(defvar helm-buffers nil + "All of `helm-buffer' in most recently used order.") +(defvar helm-current-position nil + "Cons of \(point . window-start\) when `helm' is invoked. +It is needed to restore position in `helm-current-buffer' +when `helm' is keyboard-quitted.") +(defvar helm-last-frame-or-window-configuration nil + "Used to store window or frame configuration when helm start.") +(defvar helm-onewindow-p nil) +(defvar helm-types nil) +(defvar helm--mode-line-string-real nil) ; The string to display in mode-line. +(defvar helm-persistent-action-display-window nil) +(defvar helm-marked-candidates nil + "Marked candadates. List of \(source . real\) pair.") +(defvar helm--mode-line-display-prefarg nil) +(defvar helm--temp-follow-flag nil + "[INTERNAL] A simple flag to notify persistent action we are following.") +(defvar helm--reading-passwd-or-string nil) +(defvar helm--in-update nil) +(defvar helm--in-fuzzy nil) + +;; Utility: logging +(defun helm-log (format-string &rest args) + "Log message `helm-debug' is non-nil. +Messages are written to the `helm-debug-buffer' buffer. + +Argument FORMAT-STRING is a string to use with `format'. +Use optional arguments ARGS like in `format'." + (when helm-debug + (with-current-buffer (get-buffer-create helm-debug-buffer) + (outline-mode) + (buffer-disable-undo) + (set (make-local-variable 'inhibit-read-only) t) + (goto-char (point-max)) + (insert (let ((tm (current-time))) + (format (concat (if (string-match "Start session" format-string) + "* " "** ") + "%s.%06d (%s)\n %s\n") + (format-time-string "%H:%M:%S" tm) + (nth 2 tm) + (helm-log-get-current-function) + (apply #'format (cons format-string args)))))))) + +(defun helm-log-run-hook (hook) + "Run HOOK like `run-hooks' but write these actions to helm log buffer." + (helm-log "Executing %s with value = %S" hook (symbol-value hook)) + (helm-log "Executing %s with global value = %S" hook (default-value hook)) + (run-hooks hook) + (helm-log "executed %s" hook)) + +(defun helm-log-get-current-function () + "Get function name calling `helm-log'. +The original idea is from `tramp-debug-message'." + (cl-loop with exclude-func-re = "^helm-\\(?:interpret\\|log\\|.*funcall\\)" + for btn from 1 to 40 + for btf = (cl-second (backtrace-frame btn)) + for fn = (if (symbolp btf) (symbol-name btf) "") + if (and (string-match "^helm" fn) + (not (string-match exclude-func-re fn))) + return fn)) + +(defun helm-log-error (&rest args) + "Accumulate error messages into `helm-issued-errors'. +ARGS are args given to `format'. +e.g (helm-log-error \"Error %s: %s\" (car err) (cdr err))." + (apply 'helm-log (concat "ERROR: " (car args)) (cdr args)) + (let ((msg (apply 'format args))) + (unless (member msg helm-issued-errors) + (add-to-list 'helm-issued-errors msg)))) + +(defun helm-log-save-maybe () + "May be save log buffer to `helm-last-log-file'. +If `helm-debug-root-directory' is non--nil and a valid directory, +a directory named 'helm-debug-' +will be created there and the log recorded in a file named +at the date and time of today in this directory." + (when (and (stringp helm-debug-root-directory) + (file-directory-p helm-debug-root-directory) + helm-debug) + (let ((logdir (expand-file-name (concat "helm-debug-" + (format-time-string "%Y%m%d")) + helm-debug-root-directory))) + (make-directory logdir t) + (with-current-buffer (get-buffer-create helm-debug-buffer) + (write-region (point-min) (point-max) + (setq helm-last-log-file + (expand-file-name + (format-time-string "%Y%m%d-%H%M%S") + logdir)) + nil 'silent) + (kill-buffer))))) + +;;;###autoload +(defun helm-debug-open-last-log () + "Open helm log file of last helm session. +If `helm-last-log-file' is nil, switch to `helm-debug-buffer' ." + (interactive) + (if helm-last-log-file + (view-file helm-last-log-file) + (switch-to-buffer helm-debug-buffer) + (view-mode 1) (visual-line-mode 1))) + +(defun helm-print-error-messages () + "Print error messages in `helm-issued-errors'." + (and helm-issued-errors + (message "Helm issued errors: %s" + (mapconcat 'identity (reverse helm-issued-errors) "\n")))) + + +;; Programming Tools +(defmacro helm-aif (test-form then-form &rest else-forms) + "Like `if' but set the result of TEST-FORM in a temprary variable called `it'. +THEN-FORM and ELSE-FORMS are then excuted just like in `if'." + (declare (indent 2) (debug t)) + `(let ((it ,test-form)) + (if it ,then-form ,@else-forms))) + +(defun helm-mklist (obj) + "If OBJ is a list \(but not lambda\), return itself. +Otherwise make a list with one element." + (if (and (listp obj) (not (functionp obj))) + obj + (list obj))) + +(defun helm-this-command () + "Return the actual command in action. +Like `this-command' but return the real command, +not `exit-minibuffer' or unwanted functions." + (cl-loop with bl = '(helm-maybe-exit-minibuffer + helm-confirm-and-exit-minibuffer + helm-exit-minibuffer + exit-minibuffer) + for count from 1 to 50 + for btf = (backtrace-frame count) + for fn = (cl-second btf) + if (and + ;; In some case we may have in the way an + ;; advice compiled resulting in byte-code, + ;; ignore it (Issue #691). + (symbolp fn) + (commandp fn) + (not (memq fn bl))) + return fn + else + if (and (eq fn 'call-interactively) + (> (length btf) 2)) + return (cadr (cdr btf)))) + +(defun helm-flatten-list (seq &optional omit-nulls) + "Return a list of all single elements of sublists in SEQ." + (let (result) + (cl-labels ((flatten (seq) + (cl-loop + for elm in seq + if (and (or elm + (null omit-nulls)) + (or (atom elm) + (functionp elm) + (and (consp elm) + (cdr elm) + (atom (cdr elm))))) + do (push elm result) + else do (flatten elm)))) + (flatten seq)) + (nreverse result))) + + +;; Test tools +(defmacro with-helm-time-after-update (&rest body) + (helm-with-gensyms (start-time time-elapsed) + `(let ((,start-time (float-time)) ,time-elapsed) + (add-hook 'helm-after-update-hook + (lambda () + (setq ,time-elapsed (- (float-time) ,start-time)) + (keyboard-quit))) + (unwind-protect ,@body + (remove-hook 'helm-after-update-hook + (lambda () + (setq ,time-elapsed (- (float-time) ,start-time)) + (keyboard-quit)))) + ,time-elapsed))) + + +;; Helm API + +(defun helm-buffer-get () + "Return `helm-action-buffer' if shown otherwise `helm-buffer'." + (if (helm-action-window) + helm-action-buffer + helm-buffer)) + +(defun helm-window () + "Window of `helm-buffer'." + (get-buffer-window (helm-buffer-get) 0)) + +(defun helm-action-window () + "Window of `helm-action-buffer'." + (get-buffer-window helm-action-buffer 'visible)) + +(defmacro with-helm-window (&rest body) + "Be sure BODY is excuted in the helm window." + (declare (indent 0) (debug t)) + `(with-selected-window (helm-window) + ,@body)) + +(defmacro with-helm-current-buffer (&rest body) + "Eval BODY inside `helm-current-buffer'." + (declare (indent 0) (debug t)) + `(with-current-buffer (or (and (buffer-live-p helm-current-buffer) + helm-current-buffer) + (setq helm-current-buffer + (current-buffer))) + ,@body)) + +(defmacro with-helm-buffer (&rest body) + "Eval BODY inside `helm-buffer'." + (declare (indent 0) (debug t)) + `(with-current-buffer (helm-buffer-get) + ,@body)) + +(defmacro with-helm-restore-variables (&rest body) + "Restore `helm-restored-variables' after executing BODY." + (declare (indent 0) (debug t)) + (helm-with-gensyms (orig-vars) + `(let ((,orig-vars (mapcar (lambda (v) + (cons v (symbol-value v))) + helm-restored-variables))) + (unwind-protect (progn ,@body) + (cl-loop for (var . value) in ,orig-vars + do (set var value)) + (helm-log "restore variables"))))) + +(defmacro with-helm-default-directory (directory &rest body) + (declare (indent 2) (debug t)) + `(let ((default-directory (or (and ,directory + (file-name-as-directory ,directory)) + default-directory))) + ,@body)) + +(defun helm-default-directory () + "Return the local value of `default-directory' in `helm-buffer'." + (buffer-local-value 'default-directory (get-buffer helm-buffer))) + +(defmacro with-helm-temp-hook (hook &rest body) + "Execute temporarily BODY as a function for HOOK." + (declare (indent 1) (debug t)) + (helm-with-gensyms (fun) + `(progn + (defun ,fun () + (unwind-protect + (progn ,@body) + (remove-hook ,hook (quote ,fun)))) + (add-hook ,hook (quote ,fun))))) + +(defmacro with-helm-after-update-hook (&rest body) + "Execute BODY at end of `helm-update'." + (declare (indent 0) (debug t)) + `(with-helm-temp-hook 'helm-after-update-hook ,@body)) + +(defmacro with-helm-alive-p (&rest body) + "Return error when BODY run outside helm context." + (declare (indent 0) (debug t)) + `(progn + (if helm-alive-p + (progn ,@body) + (error "Running helm command outside of context")))) + +(cl-defun helm-attr (attribute-name + &optional (src (helm-get-current-source)) compute) + "Get the value of ATTRIBUTE-NAME of SRC. +If SRC is omitted, use current source. +If COMPUTE is non--nil compute value of ATTRIBUTE-NAME +with `helm-interpret-value'." + (helm-aif (or (assq attribute-name src) + (helm-get-attribute-from-source-type attribute-name src)) + (if compute (helm-interpret-value (cdr it)) (cdr it)))) + +(cl-defun helm-attr-defined (attribute-name + &optional (src (helm-get-current-source))) + "Return non-nil if ATTRIBUTE-NAME of SRC is defined. +if SRC is omitted, use current source." + (and (helm-attr attribute-name src) t)) + +(cl-defun helm-attrset (attribute-name value + &optional + (src (helm-get-current-source)) + alter-type) + "Set the value of ATTRIBUTE-NAME of source SRC to VALUE. +If ATTRIBUTE-NAME doesn't exists in source it is created with value VALUE. +If ALTER-TYPE is non--nil alter the value of ATTRIBUTE-NAME in `helm-attributes' +if it exists. +If SRC is omitted, use current source. +If operation succeed, return value, otherwise nil." + (let ((from-type (helm-get-attribute-from-source-type attribute-name src)) + done) + (helm-aif (or (assq attribute-name src) + (and alter-type from-type)) + (prog1 (setcdr it value) (setq done t)) + (unless from-type + (setcdr src (cons (cons attribute-name value) (cdr src))) + (setq done t))) + (and done value))) + +(defun helm-get-attribute-from-source-type (attribute source) + "Get ATTRIBUTE from type attribute of SOURCE." + (when (assq 'type source) + (assq attribute + (assq (cdr (assq 'type source)) + helm-type-attributes)))) + +(defun helm-get-attribute-from-type (attribute type) + "Get ATTRIBUTE from TYPE. +arg TYPE is an existing type defined in `helm-type-attributes'." + (assq attribute (assq type helm-type-attributes))) + +(defun helm-get-actions-from-type (source) + "Get actions list from type attribute of SOURCE." + (when (assq 'type source) + (helm-get-attribute-from-source-type 'action source))) + +(defun helm-inherit-attribute-from-source (attribute source) + "Get the ATTRIBUTE of SOURCE." + (helm-aif (assq attribute source) + it + (helm-get-attribute-from-source-type attribute source))) + +(defun helm-append-at-nth (seq elm index) + "Append ELM at INDEX in SEQ." + (let ((len (length seq))) + (cond ((> index len) (setq index len)) + ((< index 0) (setq index 0))) + (if (zerop index) + (append elm seq) + (cl-loop for i in seq + for count from 1 collect i + when (= count index) + if (listp elm) append elm + else collect elm)))) + +(defun helm-add-action-to-source (name fn source &optional index) + "Add new action NAME linked to function FN to SOURCE. +Function FN should be a valid function that take one arg i.e candidate, +argument NAME is a string that will appear in action menu +and SOURCE should be an existing helm source already loaded. +If INDEX is specified, action is added in action list at INDEX, +otherwise it is added at end. +This allow user to add a specific action to an existing source +without modifying source code." + (let ((actions (helm-attr 'action source)) + (new-action (list (cons name fn)))) + (when (symbolp actions) + (setq actions (list (cons "Default action" actions)))) + (helm-attrset 'action + (if index + (helm-append-at-nth actions new-action index) + (append actions new-action)) + source))) + +(defun helm-delete-action-from-source (action-or-name source) + "Delete ACTION-OR-NAME from SOURCE. +ACTION-OR-NAME can either be the name of action or the symbol function +associated to name." + (let* ((actions (helm-attr 'action source)) + (del-action (if (symbolp action-or-name) + (rassoc action-or-name actions) + (assoc action-or-name actions)))) + (helm-attrset 'action (delete del-action actions) source))) + +(cl-defun helm-add-action-to-source-if (name fn source predicate + &optional (index 4) test-only) + "Add new action NAME linked to function FN to SOURCE. +Action NAME will be available when the current candidate matches PREDICATE. +This function add an entry in the `action-transformer' attribute +of SOURCE (or create one if not found). +Function PREDICATE should take one arg candidate. +Function FN should be a valid function that take one arg i.e candidate, +argument NAME is a string that will appear in action menu +and SOURCE should be an existing helm source already loaded. +If INDEX is specified, action is added in action list at INDEX. +Value of INDEX should be always >=1, default to 4. +This allow user to add a specific `action-tranformer' +to an existing source without modifying source code. +E.g +Add the action \"Byte compile file async\" linked to +function 'async-byte-compile-file to source `helm-source-find-files' +only when predicate helm-ff-candidates-lisp-p return non--nil: + +\(helm-add-action-to-source-if \"Byte compile file async\" + 'async-byte-compile-file + helm-source-find-files + 'helm-ff-candidates-lisp-p\)." + (let* ((actions (helm-attr 'action source)) + (action-transformers (helm-attr 'action-transformer source)) + (new-action (list (cons name fn))) + (transformer `(lambda (actions candidate) + (cond ((funcall (quote ,predicate) candidate) + (helm-append-at-nth + actions (quote ,new-action) ,index)) + (t actions))))) + (when (symbolp actions) + (helm-attrset 'action (list (cons "Default action" actions)) source)) + (when (symbolp action-transformers) + (setq action-transformers (list action-transformers))) + (if test-only ; debug + (delq nil (append (list transformer) action-transformers)) + (helm-attrset 'action-transformer + (helm-fast-remove-dups + (delq nil (append (list transformer) action-transformers)) + :test 'equal) + source)))) + +(defun helm-set-source-filter (sources) + "Set the value of `helm-source-filter' to SOURCES and update. + +This function sets a filter for helm sources and it may be +called while helm is running. It can be used to toggle +displaying of sources dynamically. For example, additional keys +can be bound into `helm-map' to display only the file-related +results if there are too many matches from other sources and +you're after files only: + +Shift+F shows only file results from some sources: + +\(define-key helm-map \"F\" 'helm-my-show-files-only) + +\(defun helm-my-show-files-only () + (interactive) + (helm-set-source-filter '(\"File Name History\" + \"Files from Current Directory\"))) + +Shift+A shows all results: + +\(define-key helm-map \"A\" 'helm-my-show-all) + +\(defun helm-my-show-all () + (interactive) + (helm-set-source-filter nil)) + +The -my- part is added to avoid collisions with +existing Helm function names." + (let ((cur-disp-sel (with-current-buffer helm-buffer + (helm-get-selection nil t)))) + (setq helm-source-filter (helm--normalize-filter-sources sources)) + (helm-log "helm-source-filter = %S" helm-source-filter) + ;; Use force-update to run init/update functions. + (helm-force-update (and (stringp cur-disp-sel) + (regexp-quote cur-disp-sel))))) + +(defun helm--normalize-filter-sources (sources) + (cl-loop for s in sources collect + (cond ((symbolp s) + (assoc-default 'name (symbol-value s))) + ((listp s) + (assoc-default 'name s)) + ((stringp s) s)))) + +(defun helm-set-sources (sources &optional no-init no-update) + "Set SOURCES during `helm' invocation. +If NO-INIT is non-nil, skip executing init functions of SOURCES. +If NO-UPDATE is non-nil, skip executing `helm-update'." + (with-current-buffer helm-buffer + (setq helm-compiled-sources nil + helm-sources sources) + (helm-log "helm-compiled-sources = %S" helm-compiled-sources) + (helm-log "helm-sources = %S" helm-sources)) + (unless no-init (helm-funcall-foreach 'init)) + (unless no-update (helm-update))) + +(defun helm-get-sources () + "Return compiled `helm-sources', which is memoized. + +Attributes: + +- type + `helm-type-attributes' are merged in. +- candidates-buffer + candidates, volatile and match attribute are created." + (cond + ;; action + ((helm-action-window) + helm-sources) + ;; memoized + (helm-compiled-sources) + ;; first time + (t + (prog1 + (setq helm-compiled-sources + (helm-compile-sources + helm-sources helm-compile-source-functions)) + (helm-log "helm-compiled-sources = %S" helm-compiled-sources))))) + +(cl-defun helm-get-selection (&optional (buffer nil buffer-s) + force-display-part) + "Return the currently selected item or nil. +if BUFFER is nil or unspecified, use helm-buffer as default value. +If FORCE-DISPLAY-PART is non-nil, return the display string. +If FORCE-DISPLAY-PART value is 'withprop the display string is returned +with its properties." + (setq buffer (if (and buffer buffer-s) buffer helm-buffer)) + (unless (helm-empty-buffer-p buffer) + (with-current-buffer buffer + (let* ((disp-fn (if (eq force-display-part 'withprop) + 'buffer-substring + 'buffer-substring-no-properties)) + (selection + (or (and (not force-display-part) + (get-text-property (overlay-start + helm-selection-overlay) + 'helm-realvalue)) + ;; It is needed to return properties of DISP in some case, + ;; e.g for `helm-confirm-and-exit-minibuffer', + ;; so use `buffer-substring' here when 'withprop is specified. + (let ((disp (funcall + disp-fn + (overlay-start helm-selection-overlay) + (1- (overlay-end helm-selection-overlay)))) + (source (helm-get-current-source))) + (helm-aif (and (not force-display-part) + (assoc-default 'display-to-real source)) + (helm-funcall-with-source source it disp) + disp))))) + (unless (equal selection "") + (helm-log "selection = %S" selection) + selection))))) + +(defun helm-get-actions-from-current-source () + "Return the associated action for the selected candidate. +It is a function symbol \(sole action\) or list +of \(action-display . function\)." + (unless (helm-empty-buffer-p (helm-buffer-get)) + (helm-aif (helm-attr 'action-transformer) + (helm-composed-funcall-with-source + (helm-get-current-source) it + (helm-attr 'action) (helm-get-selection)) + (helm-attr 'action)))) + +(defun helm-get-current-source () + "Return the source for the current selection. +Allow also checking if helm-buffer contain candidates." + (or helm-current-source + (with-current-buffer (helm-buffer-get) + (or + ;; This happen only when `helm-source-in-each-line-flag' + ;; is non--nil and there is candidates in buffer. + (get-text-property (point) 'helm-source) + ;; Return nil when no--candidates. + (cl-block exit + ;; This goto-char shouldn't be necessary, but point is moved to + ;; point-min somewhere else which shouldn't happen. + (goto-char (overlay-start helm-selection-overlay)) + (let* ((header-pos (or (helm-get-previous-header-pos) + (helm-get-next-header-pos))) + (source-name + (save-excursion + (unless header-pos + (cl-return-from exit nil)) + (goto-char header-pos) + (helm-current-line-contents)))) + (cl-loop for source in (helm-get-sources) thereis + (and (equal (assoc-default 'name source) source-name) + source)))))))) + +(defun helm-buffer-is-modified (buffer) + "Return non-nil when BUFFER is modified since `helm' was invoked." + (let* ((b (get-buffer buffer)) + (key (concat (buffer-name b) "/" (helm-attr 'name))) + (source-tick (or (gethash key helm-tick-hash) 0)) + (buffer-tick (buffer-chars-modified-tick b)) + (modifiedp (/= source-tick buffer-tick))) + (puthash key buffer-tick helm-tick-hash) + (helm-log "buffer = %S" buffer) + (helm-log "modifiedp = %S" modifiedp) + modifiedp)) + +(defun helm-current-buffer-is-modified () + "Check if `helm-current-buffer' is modified since `helm' was invoked." + (helm-buffer-is-modified helm-current-buffer)) + +(defun helm-run-after-quit (function &rest args) + "Perform an action after quitting `helm'. +The action is to call FUNCTION with arguments ARGS." + (setq helm-quit t) + (helm-kill-async-processes) + (helm-log "function = %S" function) + (helm-log "args = %S" args) + (apply 'run-with-timer 0.1 nil function args) + (helm-exit-minibuffer)) + + +(defun define-helm-type-attribute (type definition &optional doc) + "Register type attribute of TYPE as DEFINITION with DOC. +DOC is displayed in `helm-type-attributes' docstring. + +Use this function is better than setting `helm-type-attributes' directly." + (cl-loop for i in definition do + ;; without `ignore-errors', error at emacs22 + (ignore-errors (setf i (delete nil i)))) + (helm-add-type-attribute type definition) + (and doc (helm-document-type-attribute type doc)) + nil) + +(defun helm-document-attribute (attribute short-doc &optional long-doc) + "Register ATTRIBUTE documentation introduced by plug-in. +SHORT-DOC is displayed beside attribute name. +LONG-DOC is displayed below attribute name and short documentation." + (if long-doc + (setq short-doc (concat "(" short-doc ")")) + (setq long-doc short-doc + short-doc "")) + (add-to-list 'helm-attributes attribute t) + (put attribute 'helm-attrdoc + (concat "- " (symbol-name attribute) + " " short-doc "\n\n" long-doc "\n"))) + +(put 'helm-document-attribute 'lisp-indent-function 2) + +(defun helm-interpret-value (value &optional source) + "Interpret VALUE as variable, function or literal and return it. +If VALUE is a function, call it with no arguments and return the value. +If SOURCE compute VALUE for this source. +If VALUE is a variable, return the value. +If VALUE is a symbol, but it is not a function or a variable, cause an error. +Otherwise, return VALUE itself." + (cond ((and source (functionp value)) + (helm-funcall-with-source source value)) + ((functionp value) + (funcall value)) + ((and (symbolp value) (boundp value)) + (symbol-value value)) + ((symbolp value) + (error + "helm-interpret-value: Symbol must be a function or a variable")) + (t + value))) + +(defun helm-set-local-variable (&rest args) + "Bind each pair in ARGS locally to `helm-buffer'. +Use this to set local vars before calling helm. +Usage: helm-set-local-variable ([VAR VALUE]...) +Just like `setq' except that the vars are not set sequentially. +IOW Don't use VALUE of previous VAR to eval the VALUE of next VAR. +When helm is alive use `make-local-variable' as usual on `helm-buffer'. + +\(fn VAR VALUE ...)" + (setq helm--local-variables + (append (cl-loop for i on args by #'cddr + collect (cons (car i) (cadr i))) + helm--local-variables))) + +(defun helm-make-actions (&rest args) + "Build an alist with (NAME . ACTION) elements with each pairs in ARGS. +Where NAME is a string or a function returning a string or nil and ACTION +a function. +If NAME returns nil the pair is skipped. + +\(fn NAME ACTION ...)" + (cl-loop for i on args by #'cddr + for name = (car i) + when (functionp name) + do (setq name (funcall name)) + when name + collect (cons name (cadr i)))) + +;; Core: API helper +(cl-defun helm-empty-buffer-p (&optional (buffer helm-buffer)) + "Check if BUFFER have candidates. +Default value for BUFFER is `helm-buffer'." + (zerop (buffer-size (and buffer (get-buffer buffer))))) + +(defun helm-empty-source-p () + "Check if current source contains candidates. +This happen only in certains cases when e.g the last element +of a source is deleted without updating the source." + (with-helm-window + (or (helm-empty-buffer-p) + (and (helm-end-of-source-p) + (eq (point-at-bol) (point-at-eol)) + (or + (save-excursion + (forward-line -1) + (helm-pos-header-line-p)) + (bobp)))))) + +(defun helm-symbol-name (obj) + (if (or (consp obj) (byte-code-function-p obj)) + "Anonymous" + (symbol-name obj))) + + +;; Core: tools +(defun helm-current-line-contents () + "Current line string without properties." + (buffer-substring-no-properties (point-at-bol) (point-at-eol))) + +(defun helm-funcall-with-source (source functions &rest args) + "Call from SOURCE FUNCTIONS list or single function FUNCTIONS with ARGS. +FUNCTIONS can be a symbol or a list of functions. +Return the result of last function call." + (let ((helm-source-name (assoc-default 'name source)) + (helm-current-source source) + (funs (if (functionp functions) (list functions) functions))) + (helm-log "helm-source-name = %S" helm-source-name) + (helm-log "functions = %S" functions) + (helm-log "args = %S" args) + (cl-loop with result for fn in funs + do (setq result (apply fn args)) + finally return result))) + +(defun helm-funcall-foreach (sym &optional sources) + "Call the associated function to SYM for each source if any." + (let ((sources (or sources (helm-get-sources)))) + (cl-dolist (source sources) + (helm-aif (assoc-default sym source) + (helm-funcall-with-source source it))))) + +(defun helm-normalize-sources (sources) + "If SOURCES is only one source, make a list of one element." + (cond ((or (and sources + (symbolp sources)) + (and (listp sources) (assq 'name sources))) + (list sources)) + (sources) + (t helm-sources))) + +(defun helm-get-candidate-number (&optional in-current-source) + "Return candidates number in `helm-buffer'. +If IN-CURRENT-SOURCE is provided return number of candidates +in the source where point is." + (with-current-buffer (helm-buffer-get) + (if (or (helm-empty-buffer-p) + (helm-empty-source-p)) + 0 + (save-excursion + (if in-current-source + (goto-char (helm-get-previous-header-pos)) + (goto-char (point-min))) + (forward-line 1) + (if (helm-pos-multiline-p) + (save-excursion + (cl-loop with count-multi = 1 + while (and (not (if in-current-source + (save-excursion + (forward-line 2) + (or (helm-pos-header-line-p) (eobp))) + (eobp))) + (search-forward helm-candidate-separator nil t)) + do (cl-incf count-multi) + finally return count-multi)) + (save-excursion + (cl-loop with ln = 0 + while (not (if in-current-source + (or (helm-pos-header-line-p) (eobp)) + (eobp))) + unless (helm-pos-header-line-p) + do (cl-incf ln) + do (forward-line 1) finally return ln))))))) + +(defmacro with-helm-quittable (&rest body) + "If an error occur in execution of BODY, quit helm safely." + (declare (indent 0) (debug t)) + `(condition-case _v + (let (inhibit-quit) + ,@body) + (quit (setq quit-flag t) + (setq helm-quit t) + (exit-minibuffer) + (keyboard-quit) + ;; See comment about this in `with-local-quit'. + (eval '(ignore nil))))) + +(defun helm-compose (arg-lst func-lst) + "Apply arguments specified in ARG-LST with each function of FUNC-LST. +The result of each function will be the new `car' of ARG-LST. +Each function in FUNC-LST must accept (length ARG-LST) arguments +\(See examples below) . +This function allows easy sequencing of transformer functions. +Where generally, ARG-LST is '(candidates-list source) and FUNC-LST a +list of transformer functions that take one or two arguments depending +we are using 'filtered-candidate-transformer' or 'candidate-transformer'. +e.g +filtered-candidate-transformer: +\(helm-compose '((1 2 3 4 5 6 7) + '((name . \"A helm source\") (candidates . (a b c)))) + '((lambda (candidates _source) + (cl-loop for i in candidates + when (cl-oddp i) collect i)) + (lambda (candidates _source) + (cl-loop for i in candidates collect (1+ i))))) +=>(2 4 6 8) + +candidate-transformer: +\(helm-compose '((1 2 3 4 5 6 7)) + '((lambda (candidates) + (cl-loop for i in candidates + when (cl-oddp i) collect i)) + (lambda (candidates) + (cl-loop for i in candidates collect (1+ i))))) +=> (2 4 6 8)." + (cl-dolist (func func-lst) + (setcar arg-lst (apply func arg-lst))) + (car arg-lst)) + +(defun helm-composed-funcall-with-source (source funcs &rest args) + "With SOURCE apply `helm-funcall-with-source' with each FUNCS and ARGS. +This is used in transformers to modify candidates list." + (if (functionp funcs) + (apply 'helm-funcall-with-source source funcs args) + (apply 'helm-funcall-with-source source + (lambda (&rest oargs) (helm-compose oargs funcs)) + args))) + +(defun helm-stringify (str-or-sym) + "Get string of STR-OR-SYM." + (if (stringp str-or-sym) + str-or-sym + (symbol-name str-or-sym))) + +(defun helm-symbolify (str-or-sym) + "Get symbol of STR-OR-SYM." + (if (symbolp str-or-sym) + str-or-sym + (intern str-or-sym))) + + +;; Core: entry point +;; `:allow-nest' is not in this list because it is treated before. +(defconst helm-argument-keys + '(:sources :input :prompt :resume + :preselect :buffer :keymap :default :history)) + +;;;###autoload +(defun helm (&rest plist) + "Main function to execute helm sources. + +Keywords supported: +:sources :input :prompt :resume :preselect +:buffer :keymap :default :history :allow-nest + +Extra LOCAL-VARS keywords are supported, see below. + +PLIST is a list like \(:key1 val1 :key2 val2 ...\) or +\(&optional sources input prompt resume + preselect buffer keymap default history\). + +Basic keywords are the following: + +\:sources + +A list of sources used for this session. It also accepts a +symbol, interpreted as a variable of a helm source +i.e (a symbol can be passed instead of a list of sources). +It also accepts an alist representing a helm source, which is +detected by \(assq 'name ANY-SOURCES\). +NOTE: In this case the source is embedded in the helm command and +have no symbol name, so it is not reachable from outside. +It will be referenced in `helm-sources' as a whole alist. + +\:input + +Temporary value of `helm-pattern', ie. initial input of minibuffer. + +\:prompt + +Prompt other than \"pattern: \". + +\:resume + +If t, Resurrect previously instance of `helm'. Skip the initialization. +If 'noresume, this instance of `helm' cannot be resumed. + +\:preselect + +Initially selected candidate. Specified by exact candidate or a regexp. + +\:buffer + +`helm-buffer' instead of *helm*. + +\:keymap + +`helm-map' for current `helm' session. + +\:default + +A default argument that will be inserted in minibuffer \ +with \\\\[next-history-element]. +When nil or not present `thing-at-point' will be used instead. +If `helm-maybe-use-default-as-input' is non--nil display will be +updated using :default arg as input unless :input is specified, +which in this case will take precedence on :default +This is a string or a list, in this case the car of the list will +be used as initial default input, but you will be able to cycle in this +list with \\\\[next-history-element]. + +\:history + +By default all minibuffer input is pushed to `minibuffer-history', +if an argument HISTORY is provided, input will be pushed to HISTORY. +History element should be a symbol. + +\:allow-nest + +Allow running this helm command within a running helm session. + +Of course, conventional arguments are supported, the two are same. + +\(helm :sources sources :input input :prompt prompt :resume resume + :preselect preselect :buffer buffer :keymap keymap :default default + :history history\) + +and + +\(helm sources input prompt resume preselect buffer keymap default history\) + +are the same. + +However the use of non keyword args is deprecated and should not be used. + +Other keywords are interpreted as local variables of this helm session. +The `helm-' prefix can be omitted. For example, + +\(helm :sources 'helm-source-buffers-list + :buffer \"*buffers*\" :candidate-number-limit 10\) + +means starting helm session with `helm-source-buffers' +source in *buffers* buffer and set variable `helm-candidate-number-limit' +to 10 as session local variable. + +\(fn &key SOURCES INPUT PROMPT RESUME PRESELECT BUFFER KEYMAP DEFAULT HISTORY ALLOW-NEST OTHER-LOCAL-VARS)" + (let ((fn (cond ((or (and helm-alive-p (plist-get plist :allow-nest)) + (and helm-alive-p (memq 'allow-nest plist))) + #'helm-nest) + ((keywordp (car plist)) + #'helm) + (t #'helm-internal)))) + (if (and helm-alive-p (eq fn #'helm)) + (if (helm-alive-p) + ;; A helm session is normally running. + (error "Error: Trying to run helm within a running helm session") + ;; A helm session is already running and user jump somewhere else + ;; without desactivating it. + (with-helm-buffer + (prog1 + (message "Aborting an helm session running in background") + ;; `helm-alive-p' will be reset in unwind-protect forms. + (helm-keyboard-quit)))) + (if (keywordp (car plist)) + ;; Parse `plist' and move not regular `helm-argument-keys' + ;; to `helm--local-variables', then calling helm on itself + ;; with normal arguments (the non--arguments-keys removed) + ;; will end up in [1]. + (progn + (setq helm--local-variables + (append helm--local-variables + ;; Vars passed by keyword on helm call + ;; take precedence on same vars + ;; that may have been passed before helm call. + (helm-parse-keys plist))) + (apply fn (mapcar #'(lambda (key) (plist-get plist key)) + helm-argument-keys))) + (apply fn plist))))) ; [1] fn == helm-internal. + +(defun helm-alive-p () + "Check if `helm' is alive. +An `helm' session is considered alive if `helm-alive-p' is non--nil, +the `helm-buffer' is visible, and cursor is in minibuffer." + (and helm-alive-p + (get-buffer-window helm-buffer 'visible) + (minibuffer-window-active-p (minibuffer-window)) + (minibufferp (current-buffer)))) + +(defun helm-parse-keys (keys) + "Parse the KEYS arguments of `helm'. +Return only the keys that are not in `helm-argument-keys', +prefix them with \"helm\" and convert them to alist. +This allow to add arguments that are not part of `helm-argument-keys', +but are valid helm variables. +e.g :candidate-number-limit will be bound to `helm-candidate-number-limit' +in source. + + (helm-parse-keys '(:sources ((name . \"test\") + (candidates . (a b c))) + :buffer \"toto\" + :candidate-number-limit 4)) + ==> ((helm-candidate-number-limit . 4))." + + (cl-loop for (key value) on keys by #'cddr + for symname = (substring (symbol-name key) 1) + for sym = (intern (if (string-match "^helm-" symname) + symname + (concat "helm-" symname))) + unless (memq key helm-argument-keys) + collect (cons sym value))) + +;;; Core: entry point helper +(defun helm-internal (&optional + any-sources any-input + any-prompt any-resume + any-preselect any-buffer + any-keymap any-default any-history) + "The internal helm function called by `helm'. +For ANY-SOURCES ANY-INPUT ANY-PROMPT ANY-RESUME ANY-PRESELECT ANY-BUFFER and +ANY-KEYMAP ANY-DEFAULT ANY-HISTORY See `helm'." + ;; Activate the advice for `tramp-read-passwd'. + (if (fboundp 'advice-add) + (progn + (advice-add 'tramp-read-passwd :around #'helm--advice-tramp-read-passwd) + (advice-add 'ange-ftp-get-passwd :around #'helm--advice-ange-ftp-get-passwd)) + (ad-activate 'tramp-read-passwd) + (ad-activate 'ange-ftp-get-passwd)) + (helm-log (concat "[Start session] " (make-string 41 ?+))) + (helm-log "any-prompt = %S" any-prompt) + (helm-log "any-preselect = %S" any-preselect) + (helm-log "any-buffer = %S" any-buffer) + (helm-log "any-keymap = %S" any-keymap) + (helm-log "any-default = %S" any-default) + (helm-log "any-history = %S" any-history) + (let ((non-essential t) + (input-method-verbose-flag helm-input-method-verbose-flag) + (old--cua cua-mode) + (helm-maybe-use-default-as-input + (or helm-maybe-use-default-as-input ; it is let-bounded so use it. + (cl-loop for s in (helm-normalize-sources any-sources) + thereis (memq s helm-sources-using-default-as-input))))) + ;; cua-mode overhide local helm bindings. + ;; disable this stupid thing if enabled. + (and cua-mode (cua-mode -1)) + (unwind-protect + (condition-case-unless-debug _v + (let ( ;; `helm-source-name' is non-nil + ;; when `helm' is invoked by action, reset it. + helm-source-name + helm-current-source + helm-in-persistent-action + helm-quit + (helm-buffer (or any-buffer helm-buffer))) + (with-helm-restore-variables + (helm-initialize + any-resume any-input any-default any-sources) + (helm-display-buffer helm-buffer) + (when helm-prevent-escaping-from-minibuffer + (helm--remap-mouse-mode 1)) ; Disable mouse bindings. + (add-hook 'post-command-hook 'helm--maybe-update-keymap) + (helm-log "show prompt") + (unwind-protect + (helm-read-pattern-maybe + any-prompt any-input any-preselect + any-resume any-keymap any-default any-history) + (helm-cleanup))) + (prog1 + (unless helm-quit (helm-execute-selection-action)) + (helm-log (concat "[End session] " (make-string 41 ?-))))) + (quit + (helm-restore-position-on-quit) + (helm-log (concat "[End session (quit)] " (make-string 34 ?-))) + nil)) + (remove-hook 'post-command-hook 'helm--maybe-update-keymap) + (if (fboundp 'advice-add) + (progn + (advice-remove 'tramp-read-passwd + #'helm--advice-tramp-read-passwd) + (advice-remove 'ange-ftp-get-passwd + #'helm--advice-ange-ftp-get-passwd)) + (ad-deactivate 'tramp-read-passwd) + (ad-deactivate 'ange-ftp-get-passwd)) + (helm-log "helm-alive-p = %S" (setq helm-alive-p nil)) + (helm--remap-mouse-mode -1) ; Reenable mouse bindings. + (setq helm-alive-p nil) + ;; Reset helm-pattern so that lambda's using it + ;; before running helm will not start with its old value. + (setq helm-pattern "") + (and old--cua (cua-mode 1)) + (helm-log-save-maybe)))) + + +;;; Helm resume +;; +;; +(defun helm-resume (arg) + "Resurrect previously invoked `helm'. +Called with a prefix arg, allow choosing among all existing +helm buffers. i.e choose among various helm sessions. +Called from lisp, you can specify a buffer-name as a string with ARG." + (interactive "P") + (let (any-buffer helm-full-frame cur-dir) + (if arg + (if (and (stringp arg) (bufferp (get-buffer arg))) + (setq any-buffer arg) + (setq any-buffer (helm-resume-select-buffer))) + (setq any-buffer helm-last-buffer)) + (cl-assert any-buffer nil + "helm-resume: No helm buffers found to resume") + ;; Reset `cursor-type' to nil as it have been set to t + ;; when quitting previous session. + (with-current-buffer any-buffer (setq cursor-type nil)) + (setq helm-full-frame (buffer-local-value + 'helm-full-frame (get-buffer any-buffer))) + (setq helm-compiled-sources nil) + (setq cur-dir (buffer-local-value + 'default-directory (get-buffer any-buffer))) + (unless (buffer-live-p helm-current-buffer) + ;; `helm-current-buffer' may have been killed. + (setq helm-current-buffer (current-buffer))) + ;; Restart with same `default-directory' value this session + ;; was initially started with. + (with-helm-default-directory cur-dir + (helm + :sources (buffer-local-value + 'helm-sources (get-buffer any-buffer)) + :input (buffer-local-value 'helm-input-local (get-buffer any-buffer)) + :resume t + :buffer any-buffer)))) + +(defun helm-resume-previous-session-after-quit (arg) + "Resume previous helm session within running helm." + (interactive "p") + (if (and helm-alive-p (> (length helm-buffers) arg)) + (helm-run-after-quit `(lambda () (helm-resume (nth ,arg helm-buffers)))) + (message "No previous helm sessions to resume yet!"))) + +(defun helm-resume-list-buffers-after-quit () + "List resumable helm buffers within running helm." + (interactive) + (if (and helm-alive-p (> (length helm-buffers) 0)) + (helm-run-after-quit #'(lambda () (helm-resume t))) + (message "No previous helm sessions to resume yet!"))) + +(defun helm-resume-p (any-resume) + "Whether current helm session is resumed or not." + (eq any-resume t)) + +(defun helm-resume-select-buffer () + "Select an `helm-buffer' in `helm-buffers' list to resume a helm session. +Return nil if no `helm-buffer' found." + (when helm-buffers + (or (helm :sources '(((name . "Resume helm buffer") + (candidates . helm-buffers) + (action . identity))) + :resume 'noresume + :buffer "*helm resume*") + (keyboard-quit)))) + + +;;;###autoload +(defun helm-other-buffer (any-sources any-buffer) + "Simplified interface of `helm' with other `helm-buffer'. +Call `helm' with only ANY-SOURCES and ANY-BUFFER as args." + (helm :sources any-sources :buffer any-buffer)) + +(defun helm-nest (&rest same-as-helm) + "Allow calling `helm' whithin a running helm session. +Arguments SAME-AS-HELM are the same as `helm', which see." + (with-helm-window + (let ((orig-helm-current-buffer helm-current-buffer) + (orig-helm-buffer helm-buffer) + (orig-helm--in-fuzzy helm--in-fuzzy) + (orig-helm-last-frame-or-window-configuration + helm-last-frame-or-window-configuration) + (orig-one-window-p helm-onewindow-p)) + (unwind-protect + (let (helm-current-position + helm-current-buffer + helm-pattern + (helm-buffer (or (cl-getf same-as-helm :buffer) + (nth 5 same-as-helm) + "*Helm*")) + helm-sources + helm-compiled-sources + (helm-full-frame t) + (enable-recursive-minibuffers t)) + (apply #'helm same-as-helm)) + (with-current-buffer orig-helm-buffer + (setq helm-alive-p t) ; Nested session set this to nil on exit. + (setq helm-buffer orig-helm-buffer) + (setq helm--in-fuzzy orig-helm--in-fuzzy) + (helm-initialize-overlays helm-buffer) + (unless (helm-empty-buffer-p) (helm-mark-current-line t)) + (setq helm-last-frame-or-window-configuration + orig-helm-last-frame-or-window-configuration) + (setq cursor-type nil) + (setq helm-current-buffer orig-helm-current-buffer) + (setq helm-onewindow-p orig-one-window-p)))))) + + +;;; Core: Accessors +;; +(defun helm-current-position (save-or-restore) + "Restore or save current position in `helm-current-buffer'. +Argument SAVE-OR-RESTORE is one of save or restore." + (cl-case save-or-restore + (save + (helm-log "Save position at %S" (cons (point) (window-start))) + (setq helm-current-position (cons (point) (window-start)))) + (restore + (helm-log "Restore position at %S in buffer %s" + helm-current-position + (buffer-name (current-buffer))) + (goto-char (car helm-current-position)) + ;; Fix this position with the NOFORCE arg of `set-window-start' + ;; otherwise, if there is some other buffer than `helm-current-buffer' + ;; one, position will be lost. + (set-window-start (selected-window) (cdr helm-current-position) t)))) + + +(defun helm-frame-or-window-configuration (save-or-restore) + "Save or restore last frame or window configuration. +Possible value of SAVE-OR-RESTORE are 'save and 'restore. +window or frame configuration is saved/restored according to values of +`helm-save-configuration-functions'." + (helm-log "helm-save-configuration-functions = %S" + helm-save-configuration-functions) + (let ((window-persistent-parameters (append '((no-other-window . t)) + window-persistent-parameters))) + (cl-case save-or-restore + (save (setq helm-last-frame-or-window-configuration + (funcall (cdr helm-save-configuration-functions)))) + (restore (funcall (car helm-save-configuration-functions) + helm-last-frame-or-window-configuration) + ;; Restore frame focus. + ;; This is needed for minibuffer own-frame config + ;; when recursive minibuffers are in use. + ;; e.g M-: + helm-minibuffer-history. + (let ((frame (if (minibufferp helm-current-buffer) + (selected-frame) + (last-nonminibuffer-frame)))) + (select-frame-set-input-focus frame)))))) + +(defun helm-split-window-default-fn (window) + (let (split-width-threshold) + (if (and (fboundp 'window-in-direction) + ;; Don't try to split when starting in a minibuffer + ;; e.g M-: and try to use helm-show-kill-ring. + (not (minibufferp helm-current-buffer))) + (if (or (one-window-p t) + helm-split-window-in-side-p) + (split-window + (selected-window) nil (if (eq helm-split-window-default-side 'other) + 'below helm-split-window-default-side)) + ;; If more than one window reuse one of them. + (cl-case helm-split-window-default-side + (left (or (helm-window-in-direction 'left) + (helm-window-in-direction 'above) + (selected-window))) + (above (or (helm-window-in-direction 'above) + (helm-window-in-direction 'left) + (selected-window))) + (right (or (helm-window-in-direction 'right) + (helm-window-in-direction 'below) + (selected-window))) + (below (or (helm-window-in-direction 'below) + (helm-window-in-direction 'right) + (selected-window))) + (same (selected-window)) + (other (other-window-for-scrolling)) + (t (or (window-next-sibling) (selected-window))))) + (split-window-sensibly window)))) + +(defun helm-window-in-direction (direction) + "Same as `window-in-direction' but check if window is dedicated." + (helm-aif (window-in-direction direction) + (and (not (window-dedicated-p it)) it))) + + +;;; Display helm buffer +;; +;; +(defun helm-display-buffer (buffer) + "Display BUFFER. +The function used to display `helm-buffer'." + (let (pop-up-frames + (split-window-preferred-function + helm-split-window-preferred-function) + (helm-split-window-default-side + (if (and (not helm-full-frame) + helm-reuse-last-window-split-state) + (cond ((eq helm-split-window-default-side 'same) 'same) + ((eq helm-split-window-default-side 'other) 'other) + (helm--window-side-state) + (t helm-split-window-default-side)) + helm-split-window-default-side))) + (prog1 + (funcall (with-current-buffer buffer helm-display-function) buffer) + (setq helm-onewindow-p (one-window-p t)) + ;; Don't allow other-window and friends switching out of minibuffer. + (when helm-prevent-escaping-from-minibuffer + (helm-prevent-switching-other-window))))) + +(cl-defun helm-prevent-switching-other-window (&key (enabled t)) + "Allow setting `no-other-window' window parameter in all windows. +Arg ENABLE will be the value of the `no-other-window' window property." + (walk-windows + #'(lambda (w) + (unless (window-dedicated-p w) + (set-window-parameter w 'no-other-window enabled))) + 0)) + +(defun helm-default-display-buffer (buffer) + "Default function to display `helm-buffer' BUFFER. +It uses `switch-to-buffer' or `pop-to-buffer' depending of value of +`helm-full-frame' and/or `helm-split-window-default-side'." + (if (or (buffer-local-value 'helm-full-frame (get-buffer buffer)) + (and (eq helm-split-window-default-side 'same) + (one-window-p t))) + (progn (delete-other-windows) (switch-to-buffer buffer)) + (when (and (or helm-always-two-windows helm-autoresize-mode) + (not (eq helm-split-window-default-side 'same)) + (not (minibufferp helm-current-buffer)) + (not helm-split-window-in-side-p)) + (delete-other-windows)) + (pop-to-buffer buffer))) + + +;;; Core: initialize +;; +(defun helm-initialize (any-resume any-input any-default any-sources) + "Start initialization of `helm' session. +For ANY-RESUME ANY-INPUT ANY-DEFAULT and ANY-SOURCES See `helm'." + (helm-log "start initialization: any-resume=%S any-input=%S" + any-resume any-input) + (helm-frame-or-window-configuration 'save) + (setq helm-sources (helm-normalize-sources any-sources)) + (setq helm--in-fuzzy + (cl-loop for s in helm-sources + for matchfns = (helm-match-functions + (if (symbolp s) (symbol-value s) s)) + for searchfns = (helm-search-functions + (if (symbolp s) (symbol-value s) s)) + when (or (member 'helm-fuzzy-match matchfns) + (member 'helm-fuzzy-search searchfns)) + return t)) + (helm-log "sources = %S" helm-sources) + (helm-current-position 'save) + (if (helm-resume-p any-resume) + (helm-initialize-overlays (helm-buffer-get)) + (helm-initial-setup any-default)) + (setq helm-alive-p t) + (unless (eq any-resume 'noresume) + (helm-recent-push helm-buffer 'helm-buffers) + (setq helm-last-buffer helm-buffer)) + (when any-input + (setq helm-input any-input + helm-pattern any-input) + (helm--fuzzy-match-maybe-set-pattern)) + ;; If a `resume' attribute is present `helm-funcall-foreach' + ;; will run its function. + (when (helm-resume-p any-resume) + (helm-funcall-foreach 'resume)) + (helm-log "end initialization")) + +(defun helm-initialize-overlays (buffer) + "Initialize helm overlays in BUFFER." + (helm-log "overlay setup") + (if helm-selection-overlay + ;; make sure the overlay belongs to the helm buffer if + ;; it's newly created + (move-overlay helm-selection-overlay (point-min) (point-min) + (get-buffer buffer)) + + (setq helm-selection-overlay + (make-overlay (point-min) (point-min) (get-buffer buffer))) + (overlay-put helm-selection-overlay 'face 'helm-selection) + (overlay-put helm-selection-overlay 'priority 1))) + +(defun helm-restore-position-on-quit () + "Restore position in `helm-current-buffer' when quitting." + (helm-current-position 'restore)) + +(defun helm-recent-push (elt list-var) + "Add ELT to the value of LIST-VAR as most recently used value." + (let ((m (member elt (symbol-value list-var)))) + (and m (set list-var (delq (car m) (symbol-value list-var)))) + (push elt (symbol-value list-var)))) + +(defun helm--current-buffer () + "[internal] Return `current-buffer' BEFORE `helm-buffer' is initialized. +Note that this will return the minibuffer in use after helm have started, +so to get the buffer where helm started while in a helm session, +use `helm-current-buffer'. +It is intended to use this only in `helm-initial-setup'." + (if (minibuffer-window-active-p (minibuffer-window)) + ;; If minibuffer is active be sure to use it's buffer + ;; as `helm-current-buffer', this allow to use helm + ;; from an already active minibuffer (M-: etc...) + (window-buffer (active-minibuffer-window)) + ;; Fix Issue #456 + ;; Use this instead of `current-buffer' to ensure + ;; helm session started in helm-mode from a completing-read + ;; Use really the buffer where we started and not the one + ;; where the completing-read is wrapped. i.e + ;; (with-current-buffer SOME-OTHER-BUFFER (completing-read [...]) + (window-buffer (with-selected-window (minibuffer-window) + (minibuffer-selected-window))))) + +(defun helm-initial-setup (any-default) + "Initialize helm settings and set up the helm buffer." + (helm-log-run-hook 'helm-before-initialize-hook) + (cl-loop for s in (helm-get-sources) + for hook = (assoc-default 'before-init-hook s) + when hook do (helm-log-run-hook hook)) + ;; For initialization of helm locals vars that need + ;; a value from current buffer, it is here. + (helm-set-local-variable 'current-input-method current-input-method) + (setq helm-current-prefix-arg nil) + (setq helm-suspend-update-flag nil) + (setq helm-current-buffer (helm--current-buffer)) + (setq helm-buffer-file-name buffer-file-name) + (setq helm-issued-errors nil) + (setq helm-compiled-sources nil) + (setq helm-saved-current-source nil) + (unless (and (or helm-split-window-state + helm--window-side-state) + helm-reuse-last-window-split-state) + (setq helm-split-window-state + (if (or (null split-width-threshold) + (and (integerp split-width-threshold) + (>= split-width-threshold (+ (frame-width) 4)))) + 'vertical 'horizontal)) + (setq helm--window-side-state + (or helm-split-window-default-side 'below))) + ;; Call the init function for sources where appropriate + (helm-funcall-foreach + 'init (and helm-source-filter + (cl-remove-if-not #'(lambda (s) + (member (assoc-default 'name s) + helm-source-filter)) + (helm-get-sources)))) + (setq helm-pattern (or (and helm-maybe-use-default-as-input + (or (if (listp any-default) + (car any-default) any-default) + (with-helm-current-buffer + (thing-at-point 'symbol)))) + "")) + (setq helm-input "") + (clrhash helm-candidate-cache) + (helm-create-helm-buffer) + (helm-clear-visible-mark) + (helm-log-run-hook 'helm-after-initialize-hook) + (cl-loop for s in (helm-get-sources) + for hook = (assoc-default 'after-init-hook s) + when hook do (helm-log-run-hook hook))) + +(defun helm-create-helm-buffer () + "Create and setup `helm-buffer'." + (let ((root-dir default-directory)) + (with-current-buffer (get-buffer-create helm-buffer) + (helm-log "kill local variables: %S" (buffer-local-variables)) + (kill-all-local-variables) + (set (make-local-variable 'inhibit-read-only) t) + (buffer-disable-undo) + (erase-buffer) + (set (make-local-variable 'helm-map) helm-map) + (make-local-variable 'helm-sources) + (set (make-local-variable 'helm-follow-mode) nil) + (set (make-local-variable 'helm-display-function) helm-display-function) + (set (make-local-variable 'helm-selection-point) nil) + (set (make-local-variable 'scroll-margin) + (if helm-display-source-at-screen-top + 0 helm-completion-window-scroll-margin)) + (set (make-local-variable 'default-directory) root-dir) + (set (make-local-variable 'helm-marked-candidates) nil) + (helm-initialize-persistent-action) + (helm-log "helm-display-function = %S" helm-display-function) + (helm-log "helm--local-variables = %S" helm--local-variables) + (cl-loop for (var . val) in helm--local-variables + do (set (make-local-variable var) val) + finally (setq helm--local-variables nil)) + (setq truncate-lines helm-truncate-lines) ; already local. + (setq cursor-type nil) + (setq mode-name "Helm")) + (helm-initialize-overlays helm-buffer) + (get-buffer helm-buffer))) + +(define-minor-mode helm--minor-mode + "[INTERNAL] Enable keymap in helm minibuffer. +This mode have no effect when run outside of helm context. +Please don't use it. + +\\{helm-map}" + :group 'helm + :keymap (and helm-alive-p helm-map) + (unless helm-alive-p (setq helm--minor-mode nil))) + +(defun helm-read-pattern-maybe (any-prompt any-input + any-preselect any-resume any-keymap + any-default any-history) + "Read pattern with prompt ANY-PROMPT and initial input ANY-INPUT. +For ANY-PRESELECT ANY-RESUME ANY-KEYMAP ANY-DEFAULT ANY-HISTORY, See `helm'." + (if (and (helm-resume-p any-resume) + ;; When no source, helm-buffer is empty + ;; or contain non--candidate lines (e.g grep exit status) + (helm-get-current-source)) + (helm-mark-current-line t) + (helm-update any-preselect)) + (with-current-buffer (helm-buffer-get) + (let* ((src (helm-get-current-source)) + (src-keymap (assoc-default 'keymap src)) + (hist (or (and any-history (symbolp any-history) any-history) + ;; Needed for resuming. + (assoc-default 'history src))) + (timer nil) + blink-matching-paren + (first-src (car helm-sources)) + (source-delayed-p (or (assq 'delayed src) + (assq 'delayed (if (symbolp first-src) + (symbol-value first-src) + first-src))))) + ;; Startup with the first keymap found either in current source + ;; or helm arg, otherwise use global value of `helm-map'. + ;; This map will be used as a `minibuffer-local-map'. + ;; Maybe it will be overriden when changing source + ;; by `helm--maybe-update-keymap'. + ;; Note that helm-map have been made buffer-local + ;; in `helm-create-helm-buffer'. + (setq helm-map (or src-keymap any-keymap helm-map)) + (helm-log "helm-get-candidate-number => %S" + (helm-get-candidate-number)) + (helm-log "helm-execute-action-at-once-if-one = %S" + helm-execute-action-at-once-if-one) + (helm-log "helm-quit-if-no-candidate = %S" helm-quit-if-no-candidate) + ;; If source is delayed `helm-execute-action-at-once-if-one' + ;; and `helm-quit-if-no-candidate' are handled after update finish. + (when source-delayed-p + ;; Note that we quickly add the hook now when `helm-update' + ;; is already started, but because source is delayed the hook + ;; should have the time to be passed !!! + ;; the hook will remove itself once done. + (with-helm-after-update-hook (helm-exit-or-quit-maybe))) + ;; Reset `helm-pattern' for non--delayed sources and update + ;; display if no result found with precedent value of `helm-pattern' + ;; unless `helm-quit-if-no-candidate' is non--nil, in this case + ;; Don't force update with an empty pattern. + ;; Reset also `helm-maybe-use-default-as-input' as this checking + ;; happen only on startup. + (when (and helm-maybe-use-default-as-input (not source-delayed-p)) + (setq helm-pattern "") + (setq helm-maybe-use-default-as-input nil) + (and (helm-empty-buffer-p) + (null helm-quit-if-no-candidate) + (helm-force-update))) + ;; Handle `helm-execute-action-at-once-if-one' and + ;; `helm-quit-if-no-candidate' now only for not--delayed sources. + (cond ((and helm-execute-action-at-once-if-one + (not source-delayed-p) + (= (helm-get-candidate-number) 1)) + (ignore)) ; Don't enter the minibuffer loop. + ((and helm-quit-if-no-candidate + (not source-delayed-p) + (= (helm-get-candidate-number) 0)) + (setq helm-quit t) + (and (functionp helm-quit-if-no-candidate) + (funcall helm-quit-if-no-candidate))) + (t ; Enter now minibuffer and wait for input. + (let ((tap (or any-default + (with-helm-current-buffer + (thing-at-point 'symbol))))) + (unwind-protect + (minibuffer-with-setup-hook + #'(lambda () + ;; Start minor-mode with global value of helm-map. + (helm--minor-mode 1) + ;; Now overhide the global value of helm-map with + ;; the local one. + (setq minor-mode-overriding-map-alist + `((helm--minor-mode + . ,(with-helm-buffer helm-map)))) + (setq timer (run-with-idle-timer + (max helm-input-idle-delay 0.001) 'repeat + #'(lambda () + ;; Stop updating when in persistent action + ;; or when `helm-suspend-update-flag' is + ;; non--nil. + (unless (or helm-in-persistent-action + helm-suspend-update-flag) + (save-selected-window + (helm-check-minibuffer-input) + (helm-print-error-messages))))))) + (read-from-minibuffer (or any-prompt "pattern: ") + any-input helm-map + nil hist tap helm-inherit-input-method)) + (when timer (cancel-timer timer) (setq timer nil))))))))) + +(defun helm-exit-or-quit-maybe () + "Exit and run default action if only one candidate, quit if no candidates. +This function is handling `helm-execute-action-at-once-if-one' and +`helm-quit-if-no-candidate' in delayed sources." + (with-helm-window + (cond ((and helm-execute-action-at-once-if-one + (= (helm-get-candidate-number) 1)) + (helm-exit-minibuffer)) + ((and helm-quit-if-no-candidate + (= (helm-get-candidate-number) 0)) + (setq helm-quit t) + (and (functionp helm-quit-if-no-candidate) + (funcall helm-quit-if-no-candidate)) + (keyboard-quit))))) + +(defun helm-toggle-suspend-update () + "Enable or disable update of display in helm. +This can be useful for e.g writing quietly a complex regexp." + (interactive) + (when (setq helm-suspend-update-flag (not helm-suspend-update-flag)) + (helm-kill-async-processes) + (setq helm-pattern "")) + (message (if helm-suspend-update-flag + "Helm update suspended!" + "Helm update reenabled!"))) + +(defadvice tramp-read-passwd (around disable-helm-update) + ;; Suspend update when prompting for a tramp password. + (setq helm-suspend-update-flag t) + (setq overriding-terminal-local-map nil) + (setq helm--reading-passwd-or-string t) + (let (stimers) + (unwind-protect + (progn + (setq stimers (with-timeout-suspend)) + ad-do-it) + (with-timeout-unsuspend stimers) + (setq helm--reading-passwd-or-string nil) + (setq helm-suspend-update-flag nil)))) + +(defun helm--advice-tramp-read-passwd (old--fn &rest args) + ;; Suspend update when prompting for a tramp password. + (setq helm-suspend-update-flag t) + (setq overriding-terminal-local-map nil) + (setq helm--reading-passwd-or-string t) + (unwind-protect + ;; No need to suspend timer in emacs-24.4 + ;; it is fixed upstream. + (apply old--fn args) + (setq helm--reading-passwd-or-string nil) + (setq helm-suspend-update-flag nil))) + +(defun helm--advice-ange-ftp-get-passwd (old--fn &rest args) + ;; Suspend update when prompting for a ange password. + (setq helm-suspend-update-flag t) + (setq overriding-terminal-local-map nil) + (setq helm--reading-passwd-or-string t) + (unwind-protect + (apply old--fn args) + (setq helm--reading-passwd-or-string nil) + (setq helm-suspend-update-flag nil))) + +(defadvice ange-ftp-get-passwd (around disable-helm-update) + ;; Suspend update when prompting for a ange password. + (setq helm-suspend-update-flag t) + (setq overriding-terminal-local-map nil) + (setq helm--reading-passwd-or-string t) + (unwind-protect + ad-do-it + (setq helm--reading-passwd-or-string nil) + (setq helm-suspend-update-flag nil))) + +(defun helm--maybe-update-keymap () + "Handle differents keymaps in multiples sources. + +It will override `helm-map' with the local map of current source. +If no map is found in current source do nothing (keep previous map)." + (with-helm-buffer + (helm-aif (assoc-default 'keymap (helm-get-current-source)) + ;; We need the timer to leave enough time + ;; to helm to setup its buffer when changing source + ;; from a recursive minibuffer. + ;; e.g C-x C-f M-y C-g + ;; => *find-files have now the bindings of *kill-ring. + (run-with-idle-timer + 0.01 nil + (lambda () + (with-current-buffer (window-buffer (minibuffer-window)) + (setq minor-mode-overriding-map-alist `((helm--minor-mode . ,it))))))))) + +;;; Prevent loosing focus when using mouse. +;; +(defvar helm--remap-mouse-mode-map + (let ((map (make-sparse-keymap))) + (cl-loop for k in '([mouse-1] [mouse-2] [mouse-3] + [down-mouse-1] [down-mouse-2] [down-mouse-3] + [drag-mouse-1] [drag-mouse-2] [drag-mouse-3] + [double-mouse-1] [double-mouse-2] [double-mouse-3] + [triple-mouse-1] [triple-mouse-2] [triple-mouse-3]) + do (define-key map k 'undefined)) + map)) + +(define-minor-mode helm--remap-mouse-mode + "[INTERNAL] Prevent escaping helm minibuffer with mouse clicks. +Do nothing when used outside of helm context. + +WARNING: Do not use this mode yourself, it is internal to helm." + :group 'helm + :global t + :keymap helm--remap-mouse-mode-map + (unless helm-alive-p + (setq helm--remap-mouse-mode-map nil))) + +;; Core: clean up + +(defun helm-cleanup () + "Clean up the mess when helm exit or quit." + (helm-log "start cleanup") + (with-current-buffer helm-buffer + ;; bury-buffer from this window. + (bury-buffer) ;[1] + ;; Be sure we call this from helm-buffer. + (helm-funcall-foreach 'cleanup)) + (helm-kill-async-processes) + ;; When running helm from a dedicated frame + ;; with no minibuffer, helm will run in the main frame + ;; which have a minibuffer, so be sure to disable + ;; the `no-other-window' prop there. + (helm-prevent-switching-other-window :enabled nil) + (helm-log-run-hook 'helm-cleanup-hook) + (helm-frame-or-window-configuration 'restore) + ;; [1] now bury-buffer from underlying windows otherwise, + ;; if this window is killed the underlying buffer will + ;; be a helm buffer. + (replace-buffer-in-windows helm-buffer) + (setq helm-alive-p nil) + ;; This is needed in some cases where last input + ;; is yielded infinitely in minibuffer after helm session. + (helm-clean-up-minibuffer)) + +(defun helm-clean-up-minibuffer () + "Remove contents of minibuffer." + (let ((miniwin (minibuffer-window))) + ;; Clean only current minibuffer used by helm. + ;; i.e The precedent one is active. + (unless (minibuffer-window-active-p miniwin) + (with-current-buffer (window-buffer miniwin) + (delete-minibuffer-contents))))) + + +;;; Core: input handling +;; +;; +(defun helm-check-minibuffer-input () + "Check minibuffer content." + (with-helm-quittable + (with-selected-window (or (active-minibuffer-window) + (minibuffer-window)) + (helm-check-new-input (minibuffer-contents))))) + +(defun helm-check-new-input (input) + "Check INPUT string and update the helm buffer if necessary." + ;; First time minibuffer is entered + ;; we check value of `helm-pattern' that have been set + ;; in `helm-initial-setup' when `helm-maybe-use-default-as-input' + ;; is non--nil. After this initial check, reset + ;; `helm-maybe-use-default-as-input' and ignore this. + ;; This happen only when source is `delayed'. + (when helm-maybe-use-default-as-input ; nil when non--delayed. + (setq input helm-pattern) + (with-helm-after-update-hook (setq helm-pattern "")) + (setq helm-maybe-use-default-as-input nil)) + ;; In delayed sources `helm-pattern' have not been resat yet. + (unless (equal input helm-pattern) + (setq helm-pattern input) + (unless (helm-action-window) + (setq helm-input helm-pattern)) + (helm-log "helm-pattern = %S" helm-pattern) + (helm-log "helm-input = %S" helm-input) + (setq helm--in-update t) + (helm-update))) + +(defun helm--reset-update-flag () + (run-with-idle-timer + helm-exit-idle-delay nil + (lambda () (setq helm--in-update nil)))) + +(add-hook 'helm-after-update-hook #'helm--reset-update-flag) + + +;;; Core: source compiler +;; +;; +(defun helm-compile-sources (sources funcs) + "Compile SOURCES with FUNCS. +See `helm-compile-source-functions'. +Helm plug-ins are realized by this function." + (mapcar + (lambda (source) + (cl-loop with src = (if (listp source) source (symbol-value source)) + for noplug = (assoc 'dont-plug src) + for f in funcs + unless (and noplug (memq f (cdr noplug))) + do (setq src (funcall f src)) + finally (cl-return src))) + sources)) + + +;; Core: all candidates + +(defun helm-get-candidates (source) + "Retrieve and return the list of candidates from SOURCE." + (let* (inhibit-quit + (candidate-fn (assoc-default 'candidates source)) + (candidate-proc (assoc-default 'candidates-process source)) + (type-error (lambda () + (error + "`%s' must either be a function, a variable or a list" + (or candidate-fn candidate-proc)))) + (candidates (condition-case-unless-debug err + ;; Process candidates-(process) function + ;; It may return a process or a list of candidates. + (if candidate-proc + ;; Calling `helm-interpret-value' with no + ;; SOURCE arg force the use of `funcall' + ;; and not `helm-funcall-with-source'. + (helm-interpret-value candidate-proc) + (helm-interpret-value candidate-fn source)) + (error (helm-log "Error: %S" err) nil)))) + (when (and (processp candidates) (not candidate-proc)) + (warn "Candidates function `%s' should be called in a `candidates-process' attribute" + candidate-fn)) + (cond ((processp candidates) + ;; Candidates will be filtered later in process filter. + candidates) + ((or (null candidates) + ;; Can happen when the output of a process + ;; is empty, and the candidates function call + ;; something like (split-string (buffer-string) "\n") + ;; which result in a list of one empty string (Issue #938). + ;; e.g (completing-read "test: " '("")) + (equal candidates '(""))) + nil) + ((listp candidates) + ;; Transform candidates with `candidate-transformer' functions if + ;; some, otherwise return candidates. + (helm-transform-candidates candidates source)) + (t (funcall type-error))))) + +(defmacro helm-while-no-input (&rest body) + "Same as `while-no-input' but without testing with `input-pending-p'." + (declare (debug t) (indent 0)) + (let ((catch-sym (make-symbol "input")) + inhibit-quit) + `(with-local-quit + (catch ',catch-sym + (let ((throw-on-input ',catch-sym)) + ,@body))))) + +(defun helm-get-cached-candidates (source) + "Return the cached value of candidates for SOURCE. +Cache the candidates if there is not yet a cached value." + (let* ((name (assoc-default 'name source)) + (candidate-cache (gethash name helm-candidate-cache))) + (helm-aif candidate-cache + (prog1 it (helm-log "Use cached candidates")) + (helm-log "No cached candidates, calculate candidates") + (let ((candidates (helm-get-candidates source))) + (cond ((processp candidates) + (push (cons candidates + (append source + (list (cons 'item-count 0) + (cons 'incomplete-line "")))) + helm-async-processes) + (set-process-filter candidates 'helm-output-filter) + (setq candidates nil)) + ((not (assoc 'volatile source)) + (puthash name candidates helm-candidate-cache))) + candidates)))) + + +;;; Core: candidate transformers +(defun helm-transform-mapcar (function args) + "`mapcar' for candidate-transformer. + +ARGS is (cand1 cand2 ...) or ((disp1 . real1) (disp2 . real2) ...) + +\(helm-transform-mapcar 'upcase '(\"foo\" \"bar\")) +=> (\"FOO\" \"BAR\") +\(helm-transform-mapcar 'upcase '((\"1st\" . \"foo\") (\"2nd\" . \"bar\"))) +=> ((\"1st\" . \"FOO\") (\"2nd\" . \"BAR\")) +" + (cl-loop for arg in args + if (consp arg) + collect (cons (car arg) (funcall function (cdr arg))) + else + collect (funcall function arg))) + +(defun helm-process-candidate-transformer (candidates source) + "Execute `candidate-transformer' function(s) on CANDIDATES in SOURCE." + (helm-aif (assoc-default 'candidate-transformer source) + (helm-composed-funcall-with-source source it candidates) + candidates)) + +(defun helm-process-filtered-candidate-transformer (candidates source) + "Execute `filtered-candidate-transformer' function(s) on CANDIDATES in SOURCE." + (helm-aif (assoc-default 'filtered-candidate-transformer source) + (helm-composed-funcall-with-source source it candidates source) + candidates)) + +(defmacro helm--maybe-process-filter-one-by-one-candidate (candidate source) + "Execute `filter-one-by-one' function(s) on CANDIDATE in SOURCE." + `(helm-aif (assoc-default 'filter-one-by-one ,source) + (if (and (listp it) + (not (functionp it))) ;; Don't treat lambda's as list. + (cl-loop for f in it + do (setq ,candidate (funcall f ,candidate))) + (setq ,candidate (funcall it ,candidate))))) + +(defun helm--initialize-one-by-one-candidates (candidates source) + "Process the CANDIDATES with the `filter-one-by-one' function in SOURCE. +Return CANDIDATES when pattern is empty." + (helm-aif (and (string= helm-pattern "") + (assoc-default 'filter-one-by-one source)) + (cl-loop for cand in candidates + do (helm--maybe-process-filter-one-by-one-candidate cand source) + collect cand) + candidates)) + +(defun helm-process-filtered-candidate-transformer-maybe + (candidates source process-p) + "Execute `filtered-candidate-transformer' function(s) on CANDIDATES in SOURCE. +When PROCESS-P is non-nil execute `filtered-candidate-transformer' +functions if some, otherwise return CANDIDATES." + (if process-p + ;; When no filter return CANDIDATES unmodified. + (helm-process-filtered-candidate-transformer candidates source) + candidates)) + +(defun helm-process-real-to-display (candidates source) + "Execute real-to-display function on all CANDIDATES of SOURCE." + (helm-aif (assoc-default 'real-to-display source) + (setq candidates (helm-funcall-with-source + source 'mapcar + (lambda (cand_) + (if (consp cand_) + ;; override DISPLAY from candidate-transformer + (cons (funcall it (cdr cand_)) (cdr cand_)) + (cons (funcall it cand_) cand_))) + candidates)) + candidates)) + +(defun helm-transform-candidates (candidates source &optional process-p) + "Transform CANDIDATES of SOURCE according to candidate transformers. +When PROCESS-P is non-nil execute the `filtered-candidate-transformer' functions +otherwise only the `candidate-transformer' functions are processed. +When attribute `real-to-display' is present, execute its function on all maybe +filtered CANDIDATES." + (helm-process-real-to-display + (helm-process-filtered-candidate-transformer-maybe + (helm-process-candidate-transformer + (helm--initialize-one-by-one-candidates candidates source) source) + source process-p) + source)) + + +;; Core: narrowing candidates +(defun helm-candidate-number-limit (source) + "Apply candidate-number-limit attribute value. +This overhide variable `helm-candidate-number-limit'. + +e.g: +If \(candidate-number-limit\) is in SOURCE, show all candidates in SOURCE. +If \(candidate-number-limit . 123\) is in SOURCE limit candidate to 123." + (helm-aif (assq 'candidate-number-limit source) + (or (cdr it) 99999999) + (or helm-candidate-number-limit 99999999))) + +(defun helm-candidate-get-display (candidate) + "Get searched display part from CANDIDATE. +CANDIDATE is a string, a symbol, or \(DISPLAY . REAL\) cons cell." + (cond ((car-safe candidate)) + ((symbolp candidate) + (symbol-name candidate)) + ((numberp candidate) + (number-to-string candidate)) + (t candidate))) + +(defun helm-process-pattern-transformer (pattern source) + "Execute pattern-transformer attribute PATTERN function in SOURCE." + (helm-aif (assoc-default 'pattern-transformer source) + (helm-composed-funcall-with-source source it pattern) + pattern)) + +(defun helm-default-match-function (candidate) + "Check if `helm-pattern' match CANDIDATE. +Default function to match candidates according to `helm-pattern'." + (string-match helm-pattern candidate)) + + +;;; Fuzzy matching +;; +;; +(defsubst helm--mapconcat-pattern (pattern) + "Transform string PATTERN in regexp for further fuzzy matching. +e.g helm.el$ + => \"[^h]*h[^e]*e[^l]*l[^m]*m[^.]*[.][^e]*e[^l]*l$\" + ^helm.el$ + => \"helm[.]el$\"." + (let ((ls (split-string-and-unquote pattern ""))) + (if (string= "^" (car ls)) + ;; Exact match. + (mapconcat (lambda (c) + (if (and (string= c "$") + (string-match "$\\'" pattern)) + c (regexp-quote c))) + (cdr ls) "") + ;; Fuzzy match. + (mapconcat (lambda (c) + (if (and (string= c "$") + (string-match "$\\'" pattern)) + c (format "[^%s]*%s" c (regexp-quote c)))) + ls "")))) + +(defvar helm--fuzzy-regexp-cache (make-hash-table :test 'eq)) +(defun helm--fuzzy-match-maybe-set-pattern () + ;; Computing helm-pattern with helm--mapconcat-pattern + ;; is costly, so cache it once time for all and reuse it + ;; until pattern change. + (when helm--in-fuzzy + (let ((fun (if (string-match "\\`\\^" helm-pattern) + #'identity + #'helm--mapconcat-pattern))) + (clrhash helm--fuzzy-regexp-cache) + ;; FIXME: Splitted part are not handled here, + ;; I must compute them in `helm-search-match-part' + ;; when negation and in-buffer are used. + (if (string-match "\\`!" helm-pattern) + (puthash 'helm-pattern + (if (> (length helm-pattern) 1) + (list (funcall fun (substring helm-pattern 1 2)) + (funcall fun (substring helm-pattern 1))) + '("" "")) + helm--fuzzy-regexp-cache) + (puthash 'helm-pattern + (if (> (length helm-pattern) 0) + (list (funcall fun (substring helm-pattern 0 1)) + (funcall fun helm-pattern)) + '("" "")) + helm--fuzzy-regexp-cache))))) + +(defun helm-fuzzy-match (candidate) + "Check if `helm-pattern' fuzzy match CANDIDATE. +This function is used with sources build with `helm-source-sync'." + (unless (string-match " " helm-pattern) + ;; When pattern have one or more spaces, let + ;; match-plugin doing the job with no fuzzy matching.[1] + (let ((regexp (cadr (gethash 'helm-pattern helm--fuzzy-regexp-cache)))) + (if (string-match "\\`!" helm-pattern) + (not (string-match regexp candidate)) + (string-match regexp candidate))))) + +(defun helm-fuzzy-search (pattern) + "Same as `helm-fuzzy-match' but for sources build with `helm-source-in-buffer'." + (unless (string-match " " helm-pattern) + ;; Same as in `helm-fuzzy-match' ref[1]. + (let* ((regexps (gethash 'helm-pattern helm--fuzzy-regexp-cache)) + (partial-regexp (car regexps)) + (regexp (cadr regexps))) + (if (string-match "\\`!" pattern) + ;; Don't try to search here, just return + ;; the position of line and go ahead, + ;; letting `helm-search-match-part' checking if + ;; pattern match against this line. + (prog1 (list (point-at-bol) (point-at-eol)) + (forward-line 1)) + ;; We could use here directly `re-search-forward' + ;; on the regexp produced by `helm--mapconcat-pattern', + ;; but it is very slow because emacs have to do an incredible + ;; amount of loops to match e.g "[^f]*o[^o]..." in the whole buffer, + ;; more the regexp is long more the amount of loops grow. + ;; (Probably leading to a max-lisp-eval-depth error if both + ;; regexp and buffer are too big) + ;; So just search the first bit of pattern e.g "[^f]*f", and + ;; then search the corresponding line with the whole regexp, + ;; which increase dramatically the speed of the search. + (cl-loop while (re-search-forward partial-regexp nil t) + for bol = (point-at-bol) + for eol = (point-at-eol) + if (progn (goto-char bol) + (re-search-forward regexp eol t)) + do (goto-char eol) and return t + else do (goto-char eol) + finally return nil))))) + +(defsubst helm--collect-pairs-in-string (string) + (cl-loop for str on (split-string string "" t) by 'cdr + when (cdr str) + collect (list (car str) (cadr str)))) + +(defun helm-score-candidate-for-pattern (candidate pattern) + "Give a score to CANDIDATE according to PATTERN. +Score is calculated against number of contiguous matches found with PATTERN. +If PATTERN is fully matched in CANDIDATE a maximal score (100) is given. +A bonus of one point is given when PATTERN prefix match CANDIDATE. +Contiguous matches have a coefficient of 2." + (let* ((pat-lookup (helm--collect-pairs-in-string pattern)) + (str-lookup (helm--collect-pairs-in-string candidate)) + (bonus (if (equal (car pat-lookup) (car str-lookup)) 1 0)) + (bonus1 (and (string-match (concat "\\<" (regexp-quote pattern) "\\>") + candidate) + 100))) + (+ bonus (or bonus1 + ;; Give a coefficient of 2 for contiguous matches. + ;; That's mean that "wiaaaki" will not take precedence + ;; on "aaawiki" when matching on "wiki" even if "wiaaaki" + ;; starts by "wi". + (* (length (cl-nintersection + pat-lookup str-lookup :test 'equal)) + 2))))) + +(defun helm-fuzzy-matching-default-sort-fn (candidates _source &optional use-real) + "The transformer for sorting candidates in fuzzy matching. +It is sorting on the display part of by default. + +Sort CANDIDATES according to their score calculated by +`helm-score-candidate-for-pattern'. When two candidates have the +same score sort is made by length. Set USE-REAL to non-nil to +sort on the real part." + (if (string= helm-pattern "") + candidates + (let ((table-scr (make-hash-table :test 'equal))) + (sort candidates + (lambda (s1 s2) + ;; Score and measure the length on real or display part of candidate + ;; according to `use-real'. + (let* ((real-or-disp-fn (if use-real #'cdr #'car)) + (cand1 (if (consp s1) + (funcall real-or-disp-fn s1) + s1)) + (cand2 (if (consp s2) + (funcall real-or-disp-fn s2) + s2)) + (data1 (or (gethash cand1 table-scr) + (puthash cand1 (list (helm-score-candidate-for-pattern + cand1 helm-pattern) + (length cand1)) + table-scr))) + (data2 (or (gethash cand2 table-scr) + (puthash cand2 (list (helm-score-candidate-for-pattern + cand2 helm-pattern) + (length cand2)) + table-scr))) + (len1 (cadr data1)) + (len2 (cadr data2)) + (scr1 (car data1)) + (scr2 (car data2))) + (cond ((= scr1 scr2) + (< len1 len2)) + ((> scr1 scr2))))))))) + +(defun helm-fuzzy-default-highlight-match (candidate) + "The default function to highlight matches in fuzzy matching. +It is meant to use with `filter-one-by-one' slot." + (let* ((pair (and (consp candidate) candidate)) + (display (helm-stringify (if pair (car pair) candidate))) + (real (cdr pair))) + (with-temp-buffer + (insert display) + (goto-char (point-min)) + (if (search-forward helm-pattern nil t) + (add-text-properties + (match-beginning 0) (match-end 0) '(face helm-match)) + (cl-loop with pattern = (if (string-match-p " " helm-pattern) + (split-string helm-pattern) + (split-string helm-pattern "" t)) + for p in pattern + do + (when (search-forward p nil t) + (add-text-properties + (match-beginning 0) (match-end 0) '(face helm-match))))) + (setq display (buffer-string))) + (if real (cons display real) display))) + +(defun helm-fuzzy-highlight-matches (candidates _source) + "The filtered-candidate-transformer function to highlight matches in fuzzy. +See helm-fuzzy-default-highlight-match." + (cl-loop for c in candidates + collect (helm-fuzzy-default-highlight-match c))) + +(defun helm-match-functions (source) + (let ((matchfns (or (assoc-default 'match source) + (assoc-default 'match-strict source) + #'helm-default-match-function))) + (if (and (listp matchfns) (not (functionp matchfns))) + matchfns (list matchfns)))) + +(defun helm-search-functions (source) + (let ((searchfns (assoc-default 'search source))) + (if (and (listp searchfns) (not (functionp searchfns))) + searchfns (list searchfns)))) + +(defmacro helm--accumulate-candidates (candidate newmatches + hash item-count limit source) + "Add CAND into NEWMATCHES and use HASH to uniq NEWMATCHES. +Argument ITEM-COUNT count the matches. +if ITEM-COUNT reaches LIMIT, exit from inner loop." + `(unless (gethash ,candidate ,hash) + (unless (assq 'allow-dups ,source) + (puthash ,candidate t ,hash)) + (helm--maybe-process-filter-one-by-one-candidate ,candidate ,source) + (push ,candidate ,newmatches) + (cl-incf ,item-count) + (when (= ,item-count ,limit) (cl-return)))) + +(defun helm-take-first-elements (seq n) + "Return the N first element of SEQ if SEQ is longer than N. +It is used to narrow down list of candidates to `helm-candidate-number-limit'." + (if (> (length seq) n) (cl-subseq seq 0 n) seq)) + +(cl-defun helm-set-case-fold-search (&optional (pattern helm-pattern)) + "Used to set the value of `case-fold-search' in helm. +Return t or nil depending of value of `helm-case-fold-search' +and `helm-pattern'." + (let ((helm-case-fold-search + (helm-aif (assq 'case-fold-search (helm-get-current-source)) + (cdr it) + helm-case-fold-search)) + ;; Only parse basename for filenames + ;; to avoid setting case sensitivity + ;; when expanded directories contains upcase + ;; characters. + (bn-or-pattern (if (string-match "[~/]*" pattern) + ;; `helm-basename' is not available yet. + (file-name-nondirectory + (directory-file-name pattern)) + pattern))) + (helm-set-case-fold-search-1 bn-or-pattern))) + +(defun helm-set-case-fold-search-1 (pattern) + (cl-case helm-case-fold-search + (smart (let ((case-fold-search nil)) + (if (string-match "[[:upper:]]" pattern) nil t))) + (t helm-case-fold-search))) + +(defun helm-match-from-candidates (cands matchfns match-part-fn limit source) + (let (matches) + (condition-case-unless-debug err + (let ((item-count 0) + (case-fold-search (helm-set-case-fold-search))) + (clrhash helm-match-hash) + (cl-dolist (match matchfns) + (let (newmatches) + (cl-dolist (candidate cands) + (unless (gethash candidate helm-match-hash) + (let ((target (helm-candidate-get-display candidate))) + (when (funcall match + (if match-part-fn + (funcall match-part-fn target) target)) + (helm--accumulate-candidates + candidate newmatches + helm-match-hash item-count limit source))))) + ;; filter-one-by-one may return nil candidates, so delq them if some. + (setq matches (nconc matches (nreverse (delq nil newmatches))))))) + (error (unless (eq (car err) 'invalid-regexp) ; Always ignore regexps errors. + (helm-log-error "helm-match-from-candidates in source `%s': %s %s" + (assoc-default 'name source) (car err) (cdr err))) + (setq matches nil))) + matches)) + +(defun helm-compute-matches (source) + "Start computing candidates in SOURCE." + (save-current-buffer + (let ((matchfns (helm-match-functions source)) + (matchpartfn (assoc-default 'match-part source)) + (helm-source-name (assoc-default 'name source)) + (helm-current-source source) + (limit (helm-candidate-number-limit source)) + (helm-pattern (helm-process-pattern-transformer + helm-pattern source))) + (helm--fuzzy-match-maybe-set-pattern) + ;; If source have a `filtered-candidate-transformer' attr + ;; Filter candidates with this func, otherwise just compute + ;; candidates. + (helm-process-filtered-candidate-transformer + (if (or (equal helm-pattern "") + (equal matchfns '(identity))) + ;; Compute all candidates up to LIMIT. + (helm-take-first-elements + (helm-get-cached-candidates source) limit) + ;; Compute candidates according to pattern with their match fns. + (helm-match-from-candidates + (helm-get-cached-candidates source) matchfns matchpartfn limit source)) + source)))) + +(defun helm-render-source (source matches) + "Display MATCHES from SOURCE according to its settings." + (helm-log "Source name = %S" (assoc-default 'name source)) + (when matches + (helm-insert-header-from-source source) + (if (not (assq 'multiline source)) + (cl-loop for m in matches + for count from 1 + do (helm-insert-match m 'insert source count)) + (let ((start (point)) + (count 0) + separate) + (cl-dolist (match matches) + (cl-incf count) + (if separate + (helm-insert-candidate-separator) + (setq separate t)) + (helm-insert-match match 'insert source count)) + (put-text-property start (point) 'helm-multiline t))))) + +(defmacro helm--maybe-use-while-no-input (&rest body) + "Wrap BODY in `helm-while-no-input' unless initializing a remote connection." + `(progn + (if (and (file-remote-p helm-pattern) + (not (file-remote-p helm-pattern nil t))) + ;; Tramp will ask for passwd, don't use `helm-while-no-input'. + ,@body + (helm-log "Using here `helm-while-no-input'") + (helm-while-no-input ,@body)))) + +(defun helm--compute-sources (src-list) + (cl-loop with matches = (helm--maybe-use-while-no-input + (cl-loop for src in src-list + collect (helm-compute-matches src))) + when (eq matches t) do (setq matches nil) + for src in src-list + for mtc in matches + do (helm-render-source src mtc))) + +(cl-defun helm-process-delayed-sources (delayed-sources &optional preselect source) + "Process helm DELAYED-SOURCES. +Move selection to string or regexp PRESELECT if non--nil. +This function is called in `helm-process-delayed-sources-timer' +when emacs is idle for `helm-idle-delay'." + (with-helm-quittable + (helm-log "Delayed sources = %S" + (mapcar (lambda (s) + (assoc-default 'name s)) + delayed-sources)) + (with-current-buffer (helm-buffer-get) + (save-excursion + (goto-char (point-max)) + (helm--compute-sources delayed-sources) + (when (and (not (helm-empty-buffer-p)) + ;; No selection yet. + (= (overlay-start helm-selection-overlay) + (overlay-end helm-selection-overlay))) + (helm-update-move-first-line 'without-hook))) + (save-excursion + (goto-char (point-min)) + (helm-log-run-hook 'helm-update-hook)) + (setq helm-force-updating-p nil) + (unless (assoc 'candidates-process source) + (helm-display-mode-line (helm-get-current-source)) + (helm-log-run-hook 'helm-after-update-hook)) + (when preselect (helm-preselect preselect source))))) + + +;;; Core: helm-update +;; +(defun helm-update (&optional preselect source) + "Update candidates list in `helm-buffer' according to `helm-pattern'. +Argument PRESELECT is a string or regexp used to move selection to a particular +place once updating is done. It should be used on single source because search +is done on whole `helm-buffer' and not on current source." + (helm-log "Start updating") + (helm-kill-async-processes) + ;; When persistent action have been called + ;; we have two windows even with `helm-full-frame'. + ;; So go back to one window when updating if `helm-full-frame' + ;; is non--nil. + (with-helm-window + (when helm-onewindow-p (delete-other-windows))) + (with-current-buffer (helm-buffer-get) + (set (make-local-variable 'helm-input-local) helm-pattern) + (let (normal-sources + delayed-sources) + (unwind-protect + (progn + ;; Iterate over all the sources + (cl-loop for source in (cl-remove-if-not + 'helm-update-source-p (helm-get-sources)) + if (helm-delayed-source-p source) + ;; Delayed sources just get collected for later + ;; processing + collect source into ds + else + ;; Collect the normal sources + collect source into ns + ;; Export the variables from cl-loop + finally (setq delayed-sources ds + normal-sources ns)) + (erase-buffer) + ;; Render all the sources into the helm buffer after + ;; calculating all candidates. + ;; Candidates must be computed AFTER erasing buffer + ;; even if it cause flickering; Doing so avoid + ;; unexpected results when executing actions. + (helm--compute-sources normal-sources)) + (helm-log "Delayed sources = %S" + (mapcar (lambda (s) (assoc-default 'name s)) + delayed-sources)) + (cond ((and preselect delayed-sources normal-sources) + ;; Preselection run here when there is + ;; normal AND delayed sources. + (helm-log "Update preselect candidate %s" preselect) + (helm-preselect preselect source)) + (delayed-sources ; Preselection and hooks will run later. + (helm-update-move-first-line 'without-hook)) + (t ; No delayed sources, run the hooks now. + (helm-update-move-first-line) + (unless (assoc 'candidates-process source) + (helm-display-mode-line (helm-get-current-source)) + (helm-log-run-hook 'helm-after-update-hook)) + (when preselect + (helm-log "Update preselect candidate %s" preselect) + (helm-preselect preselect source)) + (setq helm-force-updating-p nil))) + (when delayed-sources + ;; Allow giving a value to `delayed' attr from inside source. + ;; Retain the biggest value (the slower) found in DELAYED-SOURCES. + (let ((helm-idle-delay (cl-loop with delay = helm-idle-delay + for s in delayed-sources + for d = (assoc-default 'delayed s) + when d do (setq delay (max delay d)) + finally return delay))) + (run-with-idle-timer + ;; Be sure helm-idle-delay is > + ;; to helm-input-idle-delay + ;; otherwise use value of helm-input-idle-delay + ;; or 0.01 if == to 0. + (max helm-idle-delay helm-input-idle-delay 0.001) nil + 'helm-process-delayed-sources delayed-sources preselect source))) + (helm-log "end update"))))) + +;; Update keymap after updating. +;; Now we run this in post-command-hook, it is +;; probably no more needed in helm-after-update-hook. +;; Leave it commented as a reminder for now. +;; (add-hook 'helm-after-update-hook 'helm--maybe-update-keymap) + +(defun helm-update-source-p (source) + "Whether SOURCE need updating or not." + (let ((len (string-width + (if (or (assoc 'matchplugin source) + (null (assoc 'no-matchplugin source))) + ;; Don't count spaces entered when using + ;; match-plugin. + (replace-regexp-in-string " " "" helm-pattern) + helm-pattern)))) + (and (or (not helm-source-filter) + (member (assoc-default 'name source) helm-source-filter)) + (>= len + (helm-aif (assoc 'requires-pattern source) (or (cdr it) 1) 0)) + ;; These incomplete regexps hang helm forever + ;; so defer update. Maybe replace spaces quoted when using + ;; match-plugin-mode. + (not (member (replace-regexp-in-string "\\s\\ " " " helm-pattern) + helm-update-blacklist-regexps))))) + +(defun helm-delayed-source-p (source) + "Wheter SOURCE is a delayed source or not." + (or (assoc 'delayed source) + (and helm-quick-update + (> (length helm-sources) 1) + (< (window-height (get-buffer-window (current-buffer))) + (line-number-at-pos (point-max)))))) + +(defun helm-update-move-first-line (&optional without-hook) + "Goto first line of `helm-buffer'." + (goto-char (point-min)) + (unless without-hook + (save-excursion (helm-log-run-hook 'helm-update-hook))) + (helm-next-line)) + +(defun helm-force-update (&optional preselect) + "Force recalculation and update of candidates. +The difference with `helm-update' is this function is reevaling +the `init' and `update' attributes functions when present +before updating candidates according to pattern i.e calling `helm-update'. +Selection is preserved to current candidate or moved to PRESELECT +if specified." + (interactive) + (let ((source (helm-get-current-source)) + (selection (helm-get-selection nil t)) + ;; `helm-goto-source' need to have all sources displayed + ;; So disable `helm-quick-update'. + helm-quick-update) + (setq helm-force-updating-p t) + (when source + (mapc 'helm-force-update--reinit + (helm-get-sources))) + (helm-update (or preselect selection) source) + (with-helm-window (recenter)))) + +(defun helm-force-update--reinit (source) + "Reinit SOURCE by calling his update and/or init functions." + (helm-aif (helm-funcall-with-source + source 'helm-candidate-buffer) + (kill-buffer it)) + (cl-dolist (attr '(update init)) + (helm-aif (assoc-default attr source) + (helm-funcall-with-source source it))) + (helm-remove-candidate-cache source)) + +(defun helm-remove-candidate-cache (source) + "Remove SOURCE from `helm-candidate-cache'." + (remhash (assoc-default 'name source) helm-candidate-cache)) + +(defun helm-insert-match (match insert-function source &optional num) + "Insert MATCH into `helm-buffer' with INSERT-FUNCTION for SOURCE. +If MATCH is a list then insert the string intended to appear on the display +and store the real value in a text property." + (let ((start (point-at-bol (point))) + (dispvalue (helm-candidate-get-display match)) + (realvalue (cdr-safe match))) + (when (and (stringp dispvalue) + (not (zerop (length dispvalue)))) + (funcall insert-function dispvalue) + ;; Some sources with candidates-in-buffer have already added + ;; 'helm-realvalue property when creating candidate buffer. + (unless (get-text-property start 'helm-realvalue) + (and realvalue + (put-text-property start (point-at-eol) + 'helm-realvalue realvalue))) + (when num + (put-text-property start (point-at-eol) 'helm-cand-num num)) + (when helm-source-in-each-line-flag + (put-text-property start (point-at-eol) 'helm-source source)) + (funcall insert-function "\n")))) + +(defun helm-insert-header-from-source (source) + "Insert SOURCE name in `helm-buffer' header. +Maybe insert by overlay additional info after source name if SOURCE have +header-name attribute." + (let ((name (assoc-default 'name source))) + (helm-insert-header + name + (helm-aif (assoc-default 'header-name source) + (helm-funcall-with-source source it name))))) + +(defun helm-insert-header (name &optional display-string) + "Insert header of source NAME into the helm buffer. +If DISPLAY-STRING is non--nil and a string, display this additional info +after the source name by overlay." + (unless (bobp) + (let ((start (point))) + (insert "\n") + (put-text-property start (point) 'helm-header-separator t))) + (let ((start (point))) + (insert name) + (put-text-property (point-at-bol) + (point-at-eol) 'helm-header t) + (when display-string + (overlay-put (make-overlay (point-at-bol) (point-at-eol)) + 'display display-string)) + (insert "\n") + (put-text-property start (point) 'face 'helm-source-header))) + +(defun helm-insert-candidate-separator () + "Insert separator of candidates into the helm buffer." + (insert (propertize helm-candidate-separator 'face 'helm-separator)) + (put-text-property (point-at-bol) + (point-at-eol) 'helm-candidate-separator t) + (insert "\n")) + + +;;; Core: async process +;; +(defun helm-output-filter (process output-string) + "The `process-filter' function for helm async sources." + (with-helm-quittable + (helm-output-filter-1 (assoc process helm-async-processes) output-string))) + +(defun helm-output-filter-1 (process-assoc output-string) + (helm-log "output-string = %S" output-string) + (with-current-buffer helm-buffer + (let ((source (cdr process-assoc))) + (save-excursion + (helm-aif (assoc-default 'insertion-marker source) + (goto-char it) + (goto-char (point-max)) + (helm-insert-header-from-source source) + (setcdr process-assoc + (append source `((insertion-marker . ,(point-marker)))))) + (helm-output-filter--process-source + (car process-assoc) output-string source + (helm-candidate-number-limit source)))) + (helm-output-filter--post-process))) + +(defun helm-output-filter--process-source (process output-string source limit) + (cl-dolist (candidate (helm-transform-candidates + (helm-output-filter--collect-candidates + (split-string output-string "\n") + (assoc 'incomplete-line source) + source) + source t)) + (when candidate ; filter-one-by-one may return nil candidates. + (if (assq 'multiline source) + (let ((start (point))) + (helm-insert-candidate-separator) + (helm-insert-match candidate 'insert-before-markers source + (1+ (cdr (assoc 'item-count source)))) + (put-text-property start (point) 'helm-multiline t)) + (helm-insert-match candidate 'insert-before-markers source + (1+ (cdr (assoc 'item-count source))))) + (cl-incf (cdr (assoc 'item-count source))) + (when (>= (assoc-default 'item-count source) limit) + (helm-kill-async-process process) + (cl-return))))) + +(defun helm-output-filter--collect-candidates (lines incomplete-line-info source) + "Collect LINES maybe completing the truncated first and last lines." + ;; The output of process may come in chunks of any size, + ;; so the last line of LINES come truncated, this truncated line is + ;; stored in INCOMPLETE-LINE-INFO and will be concated with the first + ;; incomplete line of next chunk arriving. + ;; INCOMPLETE-LINE-INFO is an attribute of source which is created + ;; with an empty string when the source is computed => (incomplete-line . "") + (helm-log "incomplete-line-info = %S" (cdr incomplete-line-info)) + (butlast + (cl-loop for line in lines + ;; On start `incomplete-line-info' value is empty string. + for newline = (helm-aif (cdr incomplete-line-info) + (prog1 + (concat it line) + (setcdr incomplete-line-info nil)) + line) + do (helm--maybe-process-filter-one-by-one-candidate newline source) + collect newline + ;; Store last incomplete line (last chunk truncated) + ;; until new output arrives. + finally do (setcdr incomplete-line-info line)))) + +(defun helm-output-filter--post-process () + (let ((src (helm-get-current-source))) + (helm-log-run-hook 'helm-update-hook) + (helm-aif (get-buffer-window helm-buffer 'visible) + (with-selected-window it + (helm-skip-noncandidate-line 'next) + (helm-mark-current-line) + (helm-display-mode-line src) + (helm-log-run-hook 'helm-after-update-hook))))) + +(defun helm-process-deferred-sentinel-hook (process event file) + "Defer remote processes in sentinels. +Meant to be called at beginning of a sentinel process function." + (when (and (string= event "finished\n") + (or (file-remote-p file) + ;; `helm-suspend-update-flag' + ;; is non--nil here only during a + ;; running process, this will never be called + ;; when user set it explicitely with `C-!'. + helm-suspend-update-flag)) + (setq helm-suspend-update-flag t) + ;; Kill the process but don't delete entry in + ;; `helm-async-processes'. + (helm-kill-async-process process) + ;; When tramp tries to open the same connection twice in a + ;; short time frame (less than 5s) it throw 'suppress which + ;; call the real-handler on the main "Emacs", so we wait + ;; 5s before updating to avoid this [1], but allowing user to + ;; enter input during this delay. + ;; [1] On last Emacs versions, this is fixed and tramp return + ;; nil in this situation. + ;; Note: It is difficult to have a value < to 5 for + ;; `tramp-connection-min-time-diff', because the process die + ;; when calling too quickly same process. + (run-at-time (or (and (boundp 'tramp-connection-min-time-diff) + tramp-connection-min-time-diff) + 5) + nil #'(lambda () + (when helm-alive-p ; Don't run timer fn after quit. + (setq helm-suspend-update-flag nil) + (helm-check-minibuffer-input)))))) + +(defun helm-kill-async-processes () + "Kill all asynchronous processes registered in `helm-async-processes'." + (while helm-async-processes + (helm-kill-async-process (caar helm-async-processes)) + (setq helm-async-processes (cdr helm-async-processes)))) + +(defun helm-kill-async-process (process) + "Stop output from `helm-output-filter' and kill associated PROCESS." + (set-process-filter process nil) + (delete-process process)) + + +;;; Core: action +;; +(defun helm-execute-selection-action () + "Execute current action and kill the action buffer if present." + (helm-log-run-hook 'helm-before-action-hook) + ;; Position can be different when `helm-current-buffer' + ;; is splitted, so jump to this position before executing action. + (helm-current-position 'restore) + (unwind-protect + (helm-execute-selection-action-1) + (helm-aif (get-buffer helm-action-buffer) + (kill-buffer it)) + (helm-log-run-hook 'helm-after-action-hook))) + +(defun helm-execute-selection-action-1 (&optional + selection action + preserve-saved-action) + "Execute ACTION on current SELECTION. +If PRESERVE-SAVED-ACTION is non--nil save action." + (helm-log "executing action") + (setq action (helm-get-default-action + (or action + helm-saved-action + (if (get-buffer helm-action-buffer) + (helm-get-selection helm-action-buffer) + (helm-get-actions-from-current-source))))) + (let ((source (or helm-saved-current-source + (helm-get-current-source))) + non-essential) + (setq selection (or selection + (helm-get-selection) + (and (assoc 'accept-empty source) ""))) + (unless preserve-saved-action (setq helm-saved-action nil)) + (when (and selection action) + (helm-funcall-with-source + source action + (helm-coerce-selection selection source))))) + +(defun helm-coerce-selection (selection source) + "Apply coerce attribute function to SELECTION in SOURCE. +Coerce source with coerce function." + (helm-aif (assoc-default 'coerce source) + (helm-funcall-with-source source it selection) + selection)) + +(defun helm-get-default-action (action) + "Get the first ACTION value of action list in source." + (if (and (listp action) (not (functionp action))) + (cdar action) + action)) + +(defun helm-select-action () + "Select an action for the currently selected candidate. +If action buffer is selected, back to the helm buffer." + (interactive) + (helm-log-run-hook 'helm-select-action-hook) + (setq helm-saved-selection (helm-get-selection)) + (with-selected-frame (with-helm-window (selected-frame)) + (prog1 + (cond ((get-buffer-window helm-action-buffer 'visible) + (set-window-buffer (get-buffer-window helm-action-buffer) + helm-buffer) + (kill-buffer helm-action-buffer) + (helm-display-mode-line (helm-get-current-source)) + (helm-set-pattern helm-input 'noupdate)) + (helm-saved-selection + (setq helm-saved-current-source (helm-get-current-source)) + (let ((actions (helm-get-actions-from-current-source))) + (if (functionp actions) + (message "Sole action: %s" actions) + (helm-show-action-buffer actions) + ;; Be sure the minibuffer is entirely deleted (#907). + (helm--delete-minibuffer-contents-from "") + ;; Make `helm-pattern' differs from the previous value. + (setq helm-pattern 'dummy) + (helm-check-minibuffer-input)))) + (t (message "No Actions available"))) + (run-hooks 'helm-window-configuration-hook)))) + +(defun helm-show-action-buffer (actions) + (with-current-buffer (get-buffer-create helm-action-buffer) + (erase-buffer) + (buffer-disable-undo) + (set-window-buffer (get-buffer-window helm-buffer) helm-action-buffer) + (set (make-local-variable 'helm-sources) + `(((name . "Actions") + (volatile) + (nomark) + (candidates . ,actions) + (mode-line . ("Action(s)" "TAB:BackToCands RET/f1/f2/fn:NthAct")) + (candidate-transformer + . (lambda (candidates) + (cl-loop for (i . j) in candidates + for count from 1 + collect + (cons (concat (cond ((> count 12) + " ") + ((< count 10) + (format "[f%s] " count)) + (t (format "[f%s] " count))) + (propertize i 'face 'helm-action)) + j)))) + (candidate-number-limit)))) + (set (make-local-variable 'helm-source-filter) nil) + (set (make-local-variable 'helm-selection-overlay) nil) + (helm-initialize-overlays helm-action-buffer))) + + +;; Core: selection + +(defun helm-display-source-at-screen-top-maybe (unit) + "Display source at top of screen when UNIT value is 'source. +With any other value of UNIT return nil." + (when (and helm-display-source-at-screen-top (eq unit 'source)) + (set-window-start (selected-window) + (save-excursion (forward-line -1) (point))))) + +(defun helm-skip-noncandidate-line (direction) + "Skip source header or candidates separator when going in DIRECTION. +Possible value of DIRECTION are 'next or 'previous. +Same as `helm-skip-header-and-separator-line' but ensure +point is moved to the right place when at bop or eob." + (helm-skip-header-and-separator-line direction) + (and (bobp) (forward-line 1)) ; Skip first header. + (and (eobp) (forward-line -1))) ; Avoid last empty line. + +(defun helm-skip-header-and-separator-line (direction) + "Skip source header or candidate separator when going to next/previous line. +Possible value of DIRECTION are 'next or 'previous." + (let ((fn (cl-ecase direction + (next 'eobp) + (previous 'bobp)))) + (while (and (not (funcall fn)) + (or (helm-pos-header-line-p) + (helm-pos-candidate-separator-p))) + (forward-line (if (and (eq direction 'previous) + (not (eq (point-at-bol) (point-min)))) + -1 1))))) + +(defun helm-display-mode-line (source &optional force) + "Setup mode-line and header-line for `helm-buffer'." + (set (make-local-variable 'helm-mode-line-string) + (helm-interpret-value (or (and (listp source) ; Check if source is empty. + (assoc-default 'mode-line source)) + (default-value 'helm-mode-line-string)) + source)) + (let ((follow (and (eq (cdr (assq 'follow source)) 1) "(HF) "))) + ;; Setup mode-line. + (if helm-mode-line-string + (setq mode-line-format + `(" " mode-line-buffer-identification " " + (:eval (format "L%d" (helm-candidate-number-at-point))) + " " ,follow + (:eval (when ,helm--mode-line-display-prefarg + (let ((arg (prefix-numeric-value + (or prefix-arg current-prefix-arg)))) + (unless (= arg 1) + (propertize (format "[prefarg:%s] " arg) + 'face 'helm-prefarg))))) + (:eval (helm-show-candidate-number + (car-safe helm-mode-line-string))) + " " helm--mode-line-string-real " " mode-line-end-spaces) + helm--mode-line-string-real + (substitute-command-keys (if (listp helm-mode-line-string) + (cadr helm-mode-line-string) + helm-mode-line-string))) + (setq mode-line-format (default-value 'mode-line-format))) + ;; Setup header-line. + (when helm-display-header-line + (let* ((hlstr (helm-interpret-value + (and (listp source) + (assoc-default 'header-line source)) + source)) + (hlend (make-string (max 0 (- (window-width) (length hlstr))) ? ))) + (setq header-line-format + (propertize (concat " " hlstr hlend) 'face 'helm-header))))) + (when force (force-mode-line-update))) + +(defun helm-show-candidate-number (&optional name) + "Used to display candidate number in mode-line. +You can specify NAME of candidates e.g \"Buffers\" otherwise +it is \"Candidate\(s\)\" by default." + (when helm-alive-p + (unless (helm-empty-source-p) + (propertize + (format "[%s %s]" + (helm-get-candidate-number 'in-current-source) + (or name "Candidate(s)")) + 'face 'helm-candidate-number)))) + +(cl-defun helm-move-selection-common (&key where direction) + "Move the selection marker to a new position. +Position is determined by WHERE and DIRECTION. +Key arg WHERE can be one of: + - line + - page + - edge + - source +Key arg DIRECTION can be one of: + - previous + - next + - A source or a source name when used with :WHERE 'source." + (let ((move-func (cl-case where + (line (cl-ecase direction + (previous 'helm-move--previous-line-fn) + (next 'helm-move--next-line-fn))) + (page (cl-ecase direction + (previous 'helm-move--previous-page-fn) + (next 'helm-move--next-page-fn))) + (edge (cl-ecase direction + (previous 'helm-move--beginning-of-buffer-fn) + (next 'helm-move--end-of-buffer-fn))) + (source (cl-case direction + (previous 'helm-move--previous-source-fn) + (next 'helm-move--next-source-fn) + (t (lambda () ; A source is passed as DIRECTION arg. + (helm-move--goto-source-fn direction)))))))) + (unless (or (helm-empty-buffer-p (helm-buffer-get)) + (not (helm-window))) + (with-helm-window + (helm-log-run-hook 'helm-move-selection-before-hook) + (funcall move-func) + (and (memq direction '(next previous)) + (helm-skip-noncandidate-line direction)) + (when (helm-pos-multiline-p) + (helm-move--beginning-of-multiline-candidate)) + (helm-display-source-at-screen-top-maybe where) + (when (helm-get-previous-header-pos) + (helm-mark-current-line)) + (helm-display-mode-line (helm-get-current-source)) + (helm-log-run-hook 'helm-move-selection-after-hook))))) + +(defun helm-move--beginning-of-multiline-candidate () + (let ((header-pos (helm-get-previous-header-pos)) + (separator-pos (helm-get-previous-candidate-separator-pos))) + (when header-pos + (goto-char (if (or (null separator-pos) + (< separator-pos header-pos)) + header-pos + separator-pos)) + (forward-line 1)))) + +(defun helm-move--previous-multi-line-fn () + (forward-line -1) + (unless (helm-pos-header-line-p) + (helm-skip-header-and-separator-line 'previous) + (helm-move--beginning-of-multiline-candidate))) + +(defun helm-move--previous-line-fn () + (if (not (helm-pos-multiline-p)) + (forward-line -1) + (helm-move--previous-multi-line-fn)) + (when (and helm-move-to-line-cycle-in-source + (helm-pos-header-line-p)) + (forward-line 1) + (helm-move--end-of-source) + ;; We are at end of helm-buffer + ;; check if last candidate is a multiline candidate + ;; and jump to it + (when (and (eobp) + (save-excursion (forward-line -1) (helm-pos-multiline-p))) + (helm-move--previous-multi-line-fn)))) + +(defun helm-move--next-multi-line-fn () + (let ((header-pos (helm-get-next-header-pos)) + (separator-pos (helm-get-next-candidate-separator-pos))) + (cond ((and separator-pos + (or (null header-pos) (< separator-pos header-pos))) + (goto-char separator-pos)) + (header-pos + (goto-char header-pos))))) + +(defun helm-move--next-line-fn () + (if (not (helm-pos-multiline-p)) + (forward-line 1) + (helm-move--next-multi-line-fn)) + (when (and helm-move-to-line-cycle-in-source + (or (save-excursion (and (helm-pos-multiline-p) + (goto-char (overlay-end + helm-selection-overlay)) + (helm-end-of-source-p t))) + (helm-end-of-source-p t))) + (helm-move--beginning-of-source))) + +(defun helm-move--previous-page-fn () + (condition-case nil + (scroll-down) + (beginning-of-buffer (goto-char (point-min))))) + +(defun helm-move--next-page-fn () + (condition-case nil + (scroll-up) + (end-of-buffer (goto-char (point-max))))) + +(defun helm-move--beginning-of-buffer-fn () + (goto-char (point-min))) + +(defun helm-move--end-of-buffer-fn () + (goto-char (point-max))) + +(defun helm-move--end-of-source () + (goto-char (or (helm-get-next-header-pos) (point-max))) + (when (helm-pos-header-line-p) (forward-line -2))) + +(defun helm-move--beginning-of-source () + (goto-char (helm-get-previous-header-pos)) + (forward-line 1)) + +(defun helm-move--previous-source-fn () + (forward-line -1) + (if (bobp) + (goto-char (point-max)) + (helm-skip-header-and-separator-line 'previous)) + (goto-char (helm-get-previous-header-pos)) + (forward-line 1)) + +(defun helm-move--next-source-fn () + (goto-char (or (helm-get-next-header-pos) (point-min)))) + +(defun helm-move--goto-source-fn (source-or-name) + (goto-char (point-min)) + (let ((name (if (stringp source-or-name) source-or-name + (assoc-default 'name source-or-name)))) + (condition-case err + (while (not (string= name (helm-current-line-contents))) + (goto-char (helm-get-next-header-pos))) + (error (helm-log "%S" err))))) + +(defun helm-candidate-number-at-point () + (with-helm-buffer + (or (get-text-property (point) 'helm-cand-num) 1))) + +(defun helm--next-or-previous-line (direction &optional arg) + ;; Be sure to not use this in non--interactives calls. + (let ((helm-move-to-line-cycle-in-source + (and helm-move-to-line-cycle-in-source arg))) + (if (and arg (> arg 1)) + (cl-loop with pos = (helm-candidate-number-at-point) + with cand-num = (helm-get-candidate-number t) + with iter = (min arg (- cand-num pos)) + for count from 1 + while (<= count iter) + do + (helm-move-selection-common :where 'line :direction direction)) + (helm-move-selection-common :where 'line :direction direction)))) + +(defun helm-previous-line (&optional arg) + "Move selection to the ARG previous line(s). +Same behavior than `helm-next-line' when called with a numeric prefix arg." + (interactive "p") + (helm--next-or-previous-line 'previous arg)) + +(defun helm-next-line (&optional arg) + "Move selection to the next ARG line(s). +When a numeric prefix arg is given and this numeric arg +is > to the number of candidates, move to last candidate of +current source (i.e don't move to next source if some)." + (interactive "p") + (helm--next-or-previous-line 'next arg)) + +(defun helm-previous-page () + "Move selection back with a pageful." + (interactive) + (helm-move-selection-common :where 'page :direction 'previous)) + +(defun helm-next-page () + "Move selection forward with a pageful." + (interactive) + (helm-move-selection-common :where 'page :direction 'next)) + +(defun helm-beginning-of-buffer () + "Move selection at the top." + (interactive) + (helm-move-selection-common :where 'edge :direction 'previous)) + +(defun helm-end-of-buffer () + "Move selection at the bottom." + (interactive) + (helm-move-selection-common :where 'edge :direction 'next)) + +(defun helm-previous-source () + "Move selection to the previous source." + (interactive) + (helm-move-selection-common :where 'source :direction 'previous)) + +(defun helm-next-source () + "Move selection to the next source." + (interactive) + (helm-move-selection-common :where 'source :direction 'next)) + +(defun helm-goto-source (source-or-name) + "Move the selection to the source SOURCE-OR-NAME." + (helm-move-selection-common :where 'source :direction source-or-name)) + +(defun helm--follow-action (arg) + (let ((helm--temp-follow-flag t)) + (when (or (eq last-command 'helm-follow-action-forward) + (eq last-command 'helm-follow-action-backward) + (eq last-command 'helm-execute-persistent-action)) + (if (> arg 0) + (helm-next-line) + (helm-previous-line))) + (helm-execute-persistent-action))) + +(defun helm-follow-action-forward () + "Go to next line and execute persistent action." + (interactive) + (helm--follow-action 1)) + +(defun helm-follow-action-backward () + "Go to previous line and execute persistent action." + (interactive) + (helm--follow-action -1)) + +(defun helm-mark-current-line (&optional resumep) + "Move `helm-selection-overlay' to current line. +Note that this is not related with visibles marks, which are used +to mark candidates." + (with-helm-window + (when resumep + (goto-char helm-selection-point)) + (move-overlay + helm-selection-overlay (point-at-bol) + (if (helm-pos-multiline-p) + (let ((header-pos (helm-get-next-header-pos)) + (separator-pos (helm-get-next-candidate-separator-pos))) + (or (and (null header-pos) separator-pos) + (and header-pos separator-pos + (< separator-pos header-pos) + separator-pos) + header-pos + (point-max))) + (1+ (point-at-eol)))) + (setq helm-selection-point (overlay-start helm-selection-overlay))) + (helm-follow-execute-persistent-action-maybe)) + +(defun helm-confirm-and-exit-minibuffer () + "Maybe ask for confirmation when exiting helm. +It is similar to `minibuffer-complete-and-exit' adapted to helm. +If `minibuffer-completion-confirm' value is 'confirm, +send in minibuffer confirm message and exit on next hit. +If `minibuffer-completion-confirm' value is t, +don't exit and send message 'no match'." + (interactive) + (if (and (helm--updating-p) + (null helm--reading-passwd-or-string)) + (progn (message "[Display not ready]") + (sit-for 0.5) (message nil)) + (let* ((empty-buffer-p (with-current-buffer helm-buffer + (eq (point-min) (point-max)))) + (sel (helm-get-selection)) + (unknown (and (not empty-buffer-p) + (string= (get-text-property + 0 'display + (helm-get-selection nil 'withprop)) + "[?]")))) + (cond ((and (or empty-buffer-p unknown) + (eq minibuffer-completion-confirm 'confirm)) + (setq helm-minibuffer-confirm-state + 'confirm) + (setq minibuffer-completion-confirm nil) + (minibuffer-message " [confirm]")) + ((and (or empty-buffer-p + (unless (if minibuffer-completing-file-name + (and minibuffer-completion-predicate + (funcall minibuffer-completion-predicate sel)) + (and (stringp sel) + ;; SEL may be a cons cell when helm-comp-read + ;; is called directly with a collection composed + ;; of (display . real) and real is a cons cell. + (try-completion sel minibuffer-completion-table + minibuffer-completion-predicate))) + unknown)) + (eq minibuffer-completion-confirm t)) + (minibuffer-message " [No match]")) + (t + (setq helm-minibuffer-confirm-state nil) + (helm-exit-minibuffer)))))) +(add-hook 'helm-after-update-hook 'helm-confirm-and-exit-hook) + +(defun helm-confirm-and-exit-hook () + "Restore `minibuffer-completion-confirm' when helm update." + (unless (or (eq minibuffer-completion-confirm t) + (not helm-minibuffer-confirm-state)) + (setq minibuffer-completion-confirm + helm-minibuffer-confirm-state))) + +(defun helm-read-string (prompt &optional initial-input history + default-value inherit-input-method) + "Same as `read-string' but for reading string from a helm session." + (let ((helm--reading-passwd-or-string t)) + (read-string + prompt initial-input history default-value inherit-input-method))) + +(defun helm--updating-p () + ;; helm timer is between two cycles. + ;; IOW `helm-check-minibuffer-input' haven't yet compared input + ;; and `helm-pattern'. + (or (not (equal (minibuffer-contents) helm-pattern)) + ;; `helm-check-minibuffer-input' have launched `helm-update'. + helm--in-update)) + +(defun helm-maybe-exit-minibuffer () + (interactive) + (if (and (helm--updating-p) + (null helm--reading-passwd-or-string)) + (progn (message "[Display not ready]") + (sit-for 0.5) (message nil)) + (helm-exit-minibuffer))) + +(defun helm-exit-minibuffer () + "Select the current candidate by exiting the minibuffer." + (unless helm-current-prefix-arg + (setq helm-current-prefix-arg current-prefix-arg)) + (setq helm-exit-status 0) + (helm-log-run-hook 'helm-exit-minibuffer-hook) + (exit-minibuffer)) + +(defun helm-keyboard-quit () + "Quit minibuffer in helm. +If action buffer is displayed, kill it." + (interactive) + (when (get-buffer-window helm-action-buffer 'visible) + (kill-buffer helm-action-buffer)) + (setq helm-exit-status 1) + (abort-recursive-edit)) + +(defun helm-get-next-header-pos () + "Return the position of the next header from point." + (next-single-property-change (point) 'helm-header)) + +(defun helm-get-previous-header-pos () + "Return the position of the previous header from point." + (previous-single-property-change (point) 'helm-header)) + +(defun helm-pos-multiline-p () + "Return non-nil if the current position is in the multiline source region." + (get-text-property (point) 'helm-multiline)) + +(defun helm-get-next-candidate-separator-pos () + "Return the position of the next candidate separator from point." + (let ((hp (helm-get-next-header-pos))) + (helm-aif (next-single-property-change (point) 'helm-candidate-separator) + (or + ;; Be sure we don't catch + ;; the separator of next source. + (and hp (< it hp) it) + ;; The separator found is in next source + ;; we are at last cand, so use the header pos. + (and hp (< hp it) hp) + ;; A single source, just try next separator. + it)))) + +(defun helm-get-previous-candidate-separator-pos () + "Return the position of the previous candidate separator from point." + (previous-single-property-change (point) 'helm-candidate-separator)) + +(defun helm-pos-header-line-p () + "Return t if the current line is a header line." + (or (get-text-property (point-at-bol) 'helm-header) + (get-text-property (point-at-bol) 'helm-header-separator))) + +(defun helm-pos-candidate-separator-p () + "Return t if the current line is a candidate separator." + (get-text-property (point-at-bol) 'helm-candidate-separator)) + + +;;; Debugging +;; +;; +(defun helm-debug-output () + "Show all helm-related variables at this time." + (interactive) + (helm-help-internal " *Helm Debug*" 'helm-debug-output-function)) + +(defun helm-debug-output-function (&optional vars) + (message "Calculating all helm-related values...") + (insert "If you debug some variables or forms, set `helm-debug-variables' +to a list of forms.\n\n") + (cl-dolist (v (or vars + helm-debug-variables + (apropos-internal "^helm-" 'boundp))) + (insert "** " + (pp-to-string v) "\n" + (pp-to-string (with-current-buffer helm-buffer (eval v))) "\n")) + (message "Calculating all helm-related values...Done")) + + +;; Core: misc +(defun helm-kill-buffer-hook () + "Remove tick entry from `helm-tick-hash' and remove buffer from +`helm-buffers' when killing a buffer." + (cl-loop for key being the hash-keys in helm-tick-hash + if (string-match (format "^%s/" (regexp-quote (buffer-name))) key) + do (remhash key helm-tick-hash)) + (setq helm-buffers (remove (buffer-name) helm-buffers))) +(add-hook 'kill-buffer-hook 'helm-kill-buffer-hook) + +(defun helm-preselect (candidate-or-regexp &optional source) + "Move `helm-selection-overlay' to CANDIDATE-OR-REGEXP on startup. +Arg CANDIDATE-OR-REGEXP can be a string or a cons cell of two strings. +When it is a cons cell helm will try to jump first to first element of cons cell +and then to second, allowing a finer preselection when possible duplicates are +before the candidate we want to preselect." + (with-helm-window + (when candidate-or-regexp + (if (and helm-force-updating-p source) + (helm-goto-source source) + (goto-char (point-min)) + (forward-line 1)) + (let ((start (point))) + (or + (if (consp candidate-or-regexp) + (and (re-search-forward (car candidate-or-regexp) nil t) + (re-search-forward (cdr candidate-or-regexp) nil t)) + (re-search-forward candidate-or-regexp nil t)) + (goto-char start)))) + (forward-line 0) ; Avoid scrolling right on long lines. + (when (helm-pos-multiline-p) + (helm-move--beginning-of-multiline-candidate)) + (when (helm-pos-header-line-p) (forward-line 1)) + (helm-mark-current-line))) + +(defun helm-delete-current-selection () + "Delete the currently selected item." + (interactive) + (with-helm-window + (cond ((helm-pos-multiline-p) + (helm-aif (helm-get-next-candidate-separator-pos) + (delete-region (point-at-bol) + (1+ (progn (goto-char it) (point-at-eol)))) + ;; last candidate + (goto-char (helm-get-previous-candidate-separator-pos)) + (delete-region (point-at-bol) (point-max))) + (when (helm-end-of-source-p) + (goto-char (or (helm-get-previous-candidate-separator-pos) + (point-min))) + (forward-line 1))) + (t + (delete-region (point-at-bol) (1+ (point-at-eol))) + (when (helm-end-of-source-p t) + (let ((headp (save-excursion + (forward-line -1) + (not (helm-pos-header-line-p))))) + (and headp (forward-line -1)))))) + (unless (helm-end-of-source-p t) + (helm-mark-current-line)))) + +(defun helm-end-of-source-p (&optional at-point) + "Return non--nil if we are at eob or end of source." + (save-excursion + (if (and (helm-pos-multiline-p) (null at-point)) + (null (helm-get-next-candidate-separator-pos)) + (forward-line (if at-point 0 1)) + (or (eq (point-at-bol) (point-at-eol)) + (helm-pos-header-line-p) + (eobp))))) + +(defun helm-edit-current-selection-internal (func) + (with-helm-window + (forward-line 0) + (let ((realvalue (get-text-property (point) 'helm-realvalue)) + (multiline (get-text-property (point) 'helm-multiline))) + (funcall func) + (forward-line 0) + (and realvalue + (put-text-property (point) (point-at-eol) + 'helm-realvalue realvalue)) + (and multiline + (put-text-property (point) (point-at-eol) + 'helm-multiline multiline)) + (helm-mark-current-line)))) + +(defmacro helm-edit-current-selection (&rest forms) + "Evaluate FORMS at current selection in the helm buffer. +Used generally to modify current selection." + (declare (indent 0) (debug t)) + `(helm-edit-current-selection-internal + (lambda () ,@forms))) + +(defun helm-set-pattern (pattern &optional noupdate) + "Set minibuffer contents to PATTERN. +if optional NOUPDATE is non-nil, helm buffer is not changed." + (with-selected-window (or (active-minibuffer-window) (minibuffer-window)) + (delete-minibuffer-contents) + (insert pattern)) + (when noupdate + (setq helm-pattern pattern))) + +(defun helm-minibuffer-completion-contents () + "Return the user input in a minibuffer before point as a string. +That is what completion commands operate on." + (buffer-substring (field-beginning) (point))) + +(defun helm--delete-minibuffer-contents-from (from-str) + ;; Giving an empty string value to FROM-STR delete all. + (require 'helm-utils) + (let ((input (minibuffer-contents))) + (helm-reset-yank-point) + (if (> (length input) 0) + ;; minibuffer is not empty, delete contents from end + ;; of FROM-STR and update. + (helm-set-pattern from-str) + ;; minibuffer is already empty, force update. + (helm-force-update)))) + +(defun helm-delete-minibuffer-contents (&optional arg) + "Delete minibuffer contents. +When `helm-delete-minibuffer-contents-from-point' is non--nil, +delete minibuffer contents from point instead of deleting all. +Giving a prefix arg reverse this behavior. +When at end of minibuffer delete all." + (interactive "P") + (let ((str (if helm-delete-minibuffer-contents-from-point + (if (or arg (eobp)) + "" (helm-minibuffer-completion-contents)) + (if (and arg (not (eobp))) + (helm-minibuffer-completion-contents) "")))) + (helm--delete-minibuffer-contents-from str))) + + +;;; Plugins +;; +;; Built-in plug-in: type +(defun helm-compile-source--type (source) + (helm-aif (assoc-default 'type source) + (append source (assoc-default it helm-type-attributes) nil) + source)) + +;; `define-helm-type-attribute' is public API. + +(defun helm-add-type-attribute (type definition) + (helm-aif (assq type helm-type-attributes) + (setq helm-type-attributes (delete it helm-type-attributes))) + (push (cons type definition) helm-type-attributes)) + +(defun helm-document-type-attribute (type doc) + (add-to-list 'helm-types type t) + (put type 'helm-typeattrdoc + (concat "- " (symbol-name type) "\n\n" doc "\n"))) + +;; Built-in plug-in: dummy +(defun helm-dummy-candidate (_candidate _source) + "Use `helm-pattern' as CANDIDATE in SOURCE." + ;; `source' is defined in filtered-candidate-transformer + (list helm-pattern)) + +(defun helm-compile-source--dummy (source) + (if (assoc 'dummy source) + (progn + (unless (helm-attr-defined + 'filtered-candidate-transformer source) + (helm-attrset 'filtered-candidate-transformer + 'helm-dummy-candidate source)) + (append source + '((candidates "dummy") + (accept-empty) + (match identity) + (volatile)))) + source)) + +;; Built-in plug-in: candidates-in-buffer +(defun helm-candidates-in-buffer (&optional source) + "Get candidates from the candidates buffer according to `helm-pattern'. + +BUFFER is `helm-candidate-buffer' by default. Each +candidate must be placed in one line. This function is meant to +be used in candidates-in-buffer or candidates attribute of an +helm source. Especially fast for many (1000+) candidates. + +eg. + '((name . \"many files\") + (init . (lambda () (with-current-buffer (helm-candidate-buffer 'local) + (insert-many-filenames)))) + (search re-search-forward) ; optional + (candidates-in-buffer) + (type . file)) + ++===============================================================+ +| The new way of making and narrowing candidates: Using buffers | ++===============================================================+ + +By default, `helm' makes candidates by evaluating the +candidates function, then narrows them by `string-match' for each +candidate. + +But this way is very slow for many candidates. The new way is +storing all candidates in a buffer and narrowing them by +`re-search-forward'. Search function is customizable by search +attribute. The important point is that buffer processing is MUCH +FASTER than string list processing and is the Emacs way. + +The init function writes all candidates to a newly-created +candidate buffer. The candidates buffer is created or specified +by `helm-candidate-buffer'. Candidates are stored in a line. + +The candidates function narrows all candidates, IOW creates a +subset of candidates dynamically. It is the task of +`helm-candidates-in-buffer'. As long as +`helm-candidate-buffer' is used,`(candidates-in-buffer)' is +sufficient in most cases. + +Note that `(candidates-in-buffer)' is shortcut of three attributes: + (candidates . helm-candidates-in-buffer) + (volatile) + (match identity) +And `(candidates-in-buffer . func)' is shortcut of three attributes: + (candidates . func) + (volatile) + (match identity) +The expansion is performed in `helm-get-sources'. + +The candidates-in-buffer attribute implies the volatile attribute. +The volatile attribute is needed because `helm-candidates-in-buffer' +creates candidates dynamically and need to be called everytime +`helm-pattern' changes. + +Because `helm-candidates-in-buffer' plays the role of `match' attribute +function, specifying `(match identity)' makes the source slightly faster. + +However if source contain match-part attribute, match is computed only +on part of candidate returned by the call of function provided by this attribute. +The function should have one arg, candidate, and return only +a specific part of candidate. + +To customize `helm-candidates-in-buffer' behavior, use `search', +`get-line' and `match-part' attributes." + (let ((src (or source (helm-get-current-source)))) + (helm-candidates-in-buffer-1 + (helm-candidate-buffer) + helm-pattern + (or (assoc-default 'get-line src) + #'buffer-substring-no-properties) + (or (assoc-default 'search src) + '(helm-candidates-in-buffer-search-default-fn)) + (helm-candidate-number-limit src) + (helm-attr 'match-part) + src))) + +(defun helm-candidates-in-buffer-search-default-fn (pattern) + "Search PATTERN with `re-search-forward' with bound and noerror args." + (condition-case _err + (re-search-forward pattern nil t) + (invalid-regexp nil))) + +(defun helm-candidates-in-buffer-1 (buffer pattern get-line-fn + search-fns limit + match-part-fn source) + "Return the list of candidates inserted in BUFFER matching PATTERN." + ;; buffer == nil when candidates buffer does not exist. + (when buffer + (with-current-buffer buffer + (let ((inhibit-point-motion-hooks t) + (start-point (1- (point-min)))) + (goto-char start-point) + (if (string= pattern "") + (helm-initial-candidates-from-candidate-buffer + get-line-fn limit) + (helm-search-from-candidate-buffer + pattern get-line-fn search-fns limit + start-point match-part-fn source)))))) + +(defun helm-search-from-candidate-buffer (pattern get-line-fn search-fns + limit start-point match-part-fn source) + (let (buffer-read-only + matches + newmatches + (case-fold-search (helm-set-case-fold-search))) + (helm--search-from-candidate-buffer-1 + (lambda () + (clrhash helm-cib-hash) + (cl-dolist (searcher search-fns) + (goto-char start-point) + (setq newmatches nil) + (cl-loop with pos-lst + with item-count = 0 + while (and (setq pos-lst (funcall searcher pattern)) + (not (eobp))) + for cand = (apply get-line-fn + (if (and pos-lst (listp pos-lst)) + pos-lst + (list (point-at-bol) (point-at-eol)))) + when (and (not (gethash cand helm-cib-hash)) + (or + ;; Always collect when cand is matched by searcher funcs + ;; and match-part attr is not present. + (and (not match-part-fn) + (not (consp pos-lst))) + ;; If match-part attr is present, or if SEARCHER fn + ;; returns a cons cell, collect PATTERN only if it + ;; match the part of CAND specified by the match-part func. + (helm-search-match-part cand pattern (or match-part-fn #'identity)))) + do (helm--accumulate-candidates + cand newmatches helm-cib-hash item-count limit source)) + (setq matches (append matches (nreverse newmatches)))) + (delq nil matches))))) + +(defun helm-search-match-part (candidate pattern match-part-fn) + "Match PATTERN only on part of CANDIDATE returned by MATCH-PART-FN. +Because `helm-search-match-part' maybe called even if unspecified +in source (negation), MATCH-PART-FN default to `identity' to match whole candidate. +When using fuzzy matching and negation (i.e \"!\"), this function is always called." + (let ((part (funcall match-part-fn candidate)) + (fuzzy-regexp (cadr (gethash 'helm-pattern helm--fuzzy-regexp-cache)))) + (if (string-match " " pattern) + (cl-loop for i in (split-string pattern) always + (if (string-match "\\`!" i) + (not (string-match (substring i 1) part)) + (string-match i part))) + (if (string-match "\\`!" pattern) + (not (string-match (if helm--in-fuzzy + ;; Fuzzy regexp have already been + ;; computed with substring 1. + fuzzy-regexp + (substring 1 pattern)) + part)) + (string-match (if helm--in-fuzzy fuzzy-regexp pattern) + part))))) + +(defun helm-initial-candidates-from-candidate-buffer (get-line-fn limit) + (delq nil (cl-loop for i from 1 to limit + until (eobp) + collect (funcall get-line-fn + (point-at-bol) (point-at-eol)) + do (forward-line 1)))) + +(defun helm--search-from-candidate-buffer-1 (search-fn) + ;; Previously we were adding a newline at bob and at eol + ;; and removing these newlines afterward, it seems it is no more + ;; needed, thus when searching for empty line ("^$") + ;; it was adding the first line as a matched line + ;; which is wrong. + (unwind-protect + (funcall search-fn) + (set-buffer-modified-p nil))) + +(defun helm-candidate-buffer (&optional create-or-buffer) + "Register and return a buffer containing candidates of current source. +`helm-candidate-buffer' searches buffer-local candidates buffer first, +then global candidates buffer. + +Acceptable values of CREATE-OR-BUFFER: + +- nil (omit) + Only return the candidates buffer. +- a buffer + Register a buffer as a candidates buffer. +- 'global + Create a new global candidates buffer, + named \" *helm candidates:SOURCE*\". +- other non-nil value + Create a new local candidates buffer, + named \" *helm candidates:SOURCE*HELM-CURRENT-BUFFER\"." + (let* ((global-bname (format " *helm candidates:%s*" + helm-source-name)) + (local-bname (format " *helm candidates:%s*%s" + helm-source-name + (buffer-name helm-current-buffer))) + (register-func #'(lambda () + (setq helm-candidate-buffer-alist + (cons (cons helm-source-name create-or-buffer) + (delete (assoc helm-source-name + helm-candidate-buffer-alist) + helm-candidate-buffer-alist))))) + (kill-buffers-func #'(lambda () + (cl-loop for b in (buffer-list) + if (string-match (format "^%s" (regexp-quote global-bname)) + (buffer-name b)) + do (kill-buffer b)))) + (create-func #'(lambda () + (with-current-buffer + (get-buffer-create (if (eq create-or-buffer 'global) + global-bname + local-bname)) + (buffer-disable-undo) + (erase-buffer) + (font-lock-mode -1)))) + (return-func #'(lambda () + (or (get-buffer local-bname) + (get-buffer global-bname) + (helm-aif (assoc-default helm-source-name + helm-candidate-buffer-alist) + (and (buffer-live-p it) it)))))) + (when create-or-buffer + (funcall register-func) + (unless (bufferp create-or-buffer) + (and (eq create-or-buffer 'global) (funcall kill-buffers-func)) + (funcall create-func))) + (funcall return-func))) + +(defun helm-init-candidates-in-buffer (buffer data) + "Register BUFFER with DATA for a helm candidates-in-buffer session. +Arg BUFFER can be a string, a buffer object (bufferp), or a symbol, +either 'local or 'global which is passed to `helm-candidate-buffer'. +Arg DATA can be either a list or a plain string. +Returns the resulting buffer." + (declare (indent 1)) + (let ((buf (helm-candidate-buffer + (if (or (stringp buffer) + (bufferp buffer)) + (get-buffer-create buffer) + buffer)))) ; a symbol. + (with-current-buffer buf + (erase-buffer) + (if (listp data) + (insert (mapconcat (lambda (i) + (cond ((symbolp i) (symbol-name i)) + ((numberp i) (number-to-string i)) + (t i))) + data "\n")) + (and (stringp data) (insert data)))) + buf)) + +(defun helm-compile-source--candidates-in-buffer (source) + (helm-aif (assoc 'candidates-in-buffer source) + (append source + `((candidates . ,(or (cdr it) + (lambda () + (helm-candidates-in-buffer source)))) + (volatile) (match identity))) + source)) + + +;;; Resplit helm window +;; +;; +(defun helm-toggle-resplit-window () + "Toggle resplit helm window, vertically or horizontally." + (interactive) + (when helm-prevent-escaping-from-minibuffer + (helm-prevent-switching-other-window :enabled nil)) + (unwind-protect + (with-helm-window + (if (or helm-full-frame (one-window-p t)) + (message "Error: Attempt to resplit a single window") + (let ((before-height (window-height))) + (delete-window) + (set-window-buffer + (select-window + (if (= (window-height) before-height) ; initial split was horizontal. + ;; Split window vertically with `helm-buffer' placed + ;; on the good side according to actual value of + ;; `helm-split-window-default-side'. + (prog1 + (cond ((or (eq helm-split-window-default-side 'above) + (eq helm-split-window-default-side 'left)) + (split-window + (selected-window) nil 'above)) + (t (split-window-vertically))) + (setq helm-split-window-state 'vertical)) + ;; Split window vertically, same comment as above. + (setq helm-split-window-state 'horizontal) + (cond ((or (eq helm-split-window-default-side 'left) + (eq helm-split-window-default-side 'above)) + (split-window (selected-window) nil 'left)) + (t (split-window-horizontally))))) + helm-buffer))) + (setq helm--window-side-state (helm--get-window-side-state))) + (when helm-prevent-escaping-from-minibuffer + (helm-prevent-switching-other-window :enabled t)))) + +;; Utility: Resize helm window. +(defun helm-enlarge-window-1 (n) + "Enlarge or narrow helm window. +If N is positive enlarge, if negative narrow." + (unless helm-full-frame + (let ((horizontal-p (eq helm-split-window-state 'horizontal))) + (with-helm-window + (enlarge-window n horizontal-p))))) + +(defun helm-narrow-window () + "Narrow helm window." + (interactive) + (helm-enlarge-window-1 -1)) + +(defun helm-enlarge-window () + "Enlarge helm window." + (interactive) + (helm-enlarge-window-1 1)) + +(defun helm-swap-windows () + "Swap window holding `helm-buffer' with other window." + (interactive) + (if (and helm-full-frame (one-window-p t)) + (error "Error: Can't swap windows in a single window") + (let* ((w1 (helm-window)) + (split-state (eq helm-split-window-state 'horizontal)) + (w1size (window-total-size w1 split-state)) + (b1 (window-buffer w1)) ; helm-buffer + (s1 (window-start w1)) + (cur-frame (window-frame w1)) + (w2 (with-selected-window (helm-window) + ;; Don't try to display helm-buffer + ;; in a dedicated window. + (get-window-with-predicate + (lambda (w) (not (window-dedicated-p w))) + 1 cur-frame))) + (w2size (window-total-size w2 split-state)) + (b2 (window-buffer w2)) ; probably helm-current-buffer + (s2 (window-start w2)) + resize) + (with-selected-frame (window-frame w1) + (helm-replace-buffer-in-window w1 b1 b2) + (helm-replace-buffer-in-window w2 b2 b1) + (setq resize + (cond ( ;; helm-window is smaller than other window. + (< w1size w2size) + (- (- (max w2size w1size) + (min w2size w1size)))) + ( ;; helm-window is larger than other window. + (> w1size w2size) + (- (max w2size w1size) + (min w2size w1size))) + ( ;; windows have probably same size. + t nil))) + ;; Maybe resize the window holding helm-buffer. + (and resize (window-resize w2 resize split-state)) + (set-window-start w1 s2 t) + (set-window-start w2 s1 t)) + (setq helm--window-side-state (helm--get-window-side-state))))) + +(defun helm--get-window-side-state () + "Return the position of `helm-window' from `helm-current-buffer'. +Possible values are 'left 'right 'below or 'above." + (let ((side-list '(left right below above))) + (cl-loop for side in side-list + thereis (and (equal (helm-window) + (window-in-direction + side (get-buffer-window helm-current-buffer t) + t)) + side)))) + +(defun helm-replace-buffer-in-window (window buffer1 buffer2) + "Replace BUFFER1 by BUFFER2 in WINDOW registering BUFFER1." + (when (get-buffer-window buffer1) + (unrecord-window-buffer window buffer1) + (set-window-buffer window buffer2))) + +;; Utility: select another action by key +(defun helm-select-nth-action (n) + "Select the N nth action for the currently selected candidate." + (setq helm-saved-selection (helm-get-selection)) + (unless helm-saved-selection + (error "Nothing is selected")) + (setq helm-saved-action + (helm-get-nth-action + n + (if (get-buffer-window helm-action-buffer 'visible) + (assoc-default 'candidates (helm-get-current-source)) + (helm-get-actions-from-current-source)))) + (helm-maybe-exit-minibuffer)) + +(defun helm-get-nth-action (n action) + (cond ((and (zerop n) (functionp action)) + action) + ((listp action) + (or (cdr (elt action n)) + (error "No such action"))) + ((and (functionp action) (< 0 n)) + (error "Sole action")) + (t + (error "Error in `helm-select-nth-action'")))) + +;; Utility: Persistent Action +(defmacro with-helm-display-same-window (&rest body) + "Execute BODY in the window used for persistent action. +Make `pop-to-buffer' and `display-buffer' display in the same window." + (declare (indent 0) (debug t)) + `(let ((display-buffer-function 'helm-persistent-action-display-buffer)) + ,@body)) + +(defun helm-initialize-persistent-action () + (set (make-local-variable 'helm-persistent-action-display-window) nil)) + +(cl-defun helm-execute-persistent-action + (&optional (attr 'persistent-action) split-onewindow) + "Perform the associated action ATTR without quitting helm. +ATTR default is 'persistent-action', but it can be anything else. +In this case you have to add this new attribute to your source. + +When `helm-full-frame' or SPLIT-ONEWINDOW are non--nil, +and `helm-buffer' is displayed in only one window, +the helm window is splitted to display +`helm-select-persistent-action-window' in other window +and keep its visibility." + (interactive) + (helm-log "executing persistent-action") + (let* ((attr-val (assoc-default attr (helm-get-current-source))) + ;; If attr value is a cons, use its car as persistent function + ;; and its car to decide if helm window should be splitted. + (fn (if (and (consp attr-val) + ;; maybe a lambda. + (not (functionp attr-val))) + (car attr-val) attr-val)) + (no-split (and (consp attr-val) + (not (functionp attr-val)) + (cdr attr-val)))) + (with-helm-window + (save-selected-window + (if no-split + (helm-select-persistent-action-window) + (helm-select-persistent-action-window + (or split-onewindow helm-onewindow-p))) + (helm-log "current-buffer = %S" (current-buffer)) + (let ((helm-in-persistent-action t)) + (with-helm-display-same-window + (helm-execute-selection-action-1 + nil (or fn (helm-get-actions-from-current-source)) t) + (helm-log-run-hook 'helm-after-persistent-action-hook)) + ;; A typical case is when a persistent action delete + ;; the buffer already displayed in + ;; `helm-persistent-action-display-window' and `helm-full-frame' + ;; is enabled, we end up with the `helm-buffer' + ;; displayed in two windows. + (when (and helm-onewindow-p + (> (length (window-list)) 1) + (equal (buffer-name + (window-buffer + helm-persistent-action-display-window)) + (helm-buffer-get))) + (delete-other-windows))))))) + +(defun helm-persistent-action-display-window (&optional split-onewindow) + "Return the window that will be used for persistent action. +If SPLIT-ONEWINDOW is non--nil window will be splitted in persistent action." + (with-helm-window + (setq helm-persistent-action-display-window + (cond ((and (window-live-p helm-persistent-action-display-window) + (not (member helm-persistent-action-display-window + (get-buffer-window-list helm-buffer)))) + helm-persistent-action-display-window) + (split-onewindow (split-window)) + ((get-buffer-window helm-current-buffer)) + (t (next-window (selected-window) 1)))))) + +(defun helm-select-persistent-action-window (&optional split-onewindow) + "Select the window that will be used for persistent action. +See `helm-persistent-action-display-window' for how to use SPLIT-ONEWINDOW." + (select-window (get-buffer-window (helm-buffer-get))) + (select-window + (setq minibuffer-scroll-window + (helm-persistent-action-display-window split-onewindow)))) + +(defun helm-persistent-action-display-buffer (buf &optional action) + "Make `pop-to-buffer' and `display-buffer' display in the same window. +If `helm-persistent-action-use-special-display' is non-nil and +BUF is to be displayed by `special-display-function', use it. +Otherwise ignores `special-display-buffer-names' and `special-display-regexps'. +Argument ACTION if present will be used as second argument of `display-buffer'." + (let* ((name (buffer-name buf)) + display-buffer-function pop-up-windows pop-up-frames + ;; Disable `special-display-regexps' and `special-display-buffer-names' + ;; unless `helm-persistent-action-use-special-display' is non--nil. + (special-display-buffer-names + (and helm-persistent-action-use-special-display + special-display-buffer-names)) + (special-display-regexps + (and helm-persistent-action-use-special-display + special-display-regexps)) + (same-window-regexps + (unless (and helm-persistent-action-use-special-display + (or (member name + (mapcar (lambda (x) (or (car-safe x) x)) + special-display-buffer-names)) + (cl-loop for x in special-display-regexps + thereis (string-match (or (car-safe x) x) + name)))) + '(".")))) + ;; Don't loose minibuffer when displaying persistent window in + ;; another frame. + ;; This happen when the displayed persistent buffer-name is one of + ;; `special-display-buffer-names' or match `special-display-regexps' + ;; and `helm-persistent-action-use-special-display' is enabled. + (with-selected-window (if (or special-display-regexps + special-display-buffer-names) + (minibuffer-window) + (selected-window)) + ;; Be sure window of BUF is not dedicated. + (set-window-dedicated-p (get-buffer-window buf) nil) + (display-buffer buf action)))) + +;; scroll-other-window(-down)? for persistent-action +(defun helm-other-window-base (command &optional scroll-amount) + (setq scroll-amount (unless (eq scroll-amount 'noscroll) + helm-scroll-amount)) + (with-selected-window (helm-persistent-action-display-window) + (funcall command scroll-amount))) + +(defun helm-scroll-other-window () + "Scroll other window (not *Helm* window) upward." + (interactive) + (helm-other-window-base 'scroll-up)) + +(defun helm-scroll-other-window-down () + "Scroll other window (not *Helm* window) downward." + (interactive) + (helm-other-window-base 'scroll-down)) + +(defun helm-recenter-top-bottom-other-window () + "`recenter-top-bottom' in other window (not *Helm* window)." + (interactive) + (helm-other-window-base 'recenter-top-bottom 'noscroll)) + +(defun helm-reposition-window-other-window () + "`helm-reposition-window' in other window (not *Helm* window)." + (interactive) + (helm-other-window-base 'reposition-window 'noscroll)) + + + +;; Utility: Visible Mark + +(defun helm-clear-visible-mark () + (with-current-buffer (helm-buffer-get) + (mapc 'delete-overlay helm-visible-mark-overlays) + (set (make-local-variable 'helm-visible-mark-overlays) nil))) + +(defun helm-this-visible-mark () + (cl-loop for o in helm-visible-mark-overlays + when (equal (point-at-bol) (overlay-start o)) + return o)) + +(defun helm-delete-visible-mark (overlay) + (setq helm-marked-candidates + (remove + (cons (helm-get-current-source) (helm-get-selection)) + helm-marked-candidates)) + (delete-overlay overlay) + (setq helm-visible-mark-overlays + (delq overlay helm-visible-mark-overlays))) + +(defun helm-make-visible-mark () + (let ((o (make-overlay (point-at-bol) + (if (helm-pos-multiline-p) + (or (helm-get-next-candidate-separator-pos) + (point-max)) + (1+ (point-at-eol)))))) + (overlay-put o 'priority 0) + (overlay-put o 'face 'helm-visible-mark) + (overlay-put o 'source (assoc-default 'name (helm-get-current-source))) + (overlay-put o 'string (buffer-substring (overlay-start o) (overlay-end o))) + (overlay-put o 'real (helm-get-selection)) + (add-to-list 'helm-visible-mark-overlays o)) + (push (cons (helm-get-current-source) (helm-get-selection)) + helm-marked-candidates)) + +(defun helm-toggle-visible-mark () + "Toggle helm visible mark at point." + (interactive) + (with-helm-window + (let ((nomark (assq 'nomark (helm-get-current-source)))) + (if nomark + (message "Marking not allowed in this source") + (helm-aif (helm-this-visible-mark) + (helm-delete-visible-mark it) + (helm-make-visible-mark)) + (unless (helm-end-of-source-p) + (helm-next-line)))))) + +(defun helm-mark-all () + "Mark all visible unmarked candidates in current source." + (interactive) + (require 'helm-files) + (with-helm-window + (let ((nomark (assq 'nomark (helm-get-current-source))) + (follow (if helm-follow-mode 1 -1))) + (helm-follow-mode -1) + (unwind-protect + (if nomark + (message "Marking not allowed in this source") + (save-excursion + (goto-char (helm-get-previous-header-pos)) + (helm-next-line) + (let* ((next-head (helm-get-next-header-pos)) + (end (and next-head + (save-excursion + (goto-char next-head) + (forward-line -1) + (point)))) + (maxpoint (or end (point-max)))) + (while (< (point) maxpoint) + (helm-mark-current-line) + (let* ((prefix (get-text-property (point-at-bol) 'display)) + (cand (helm-get-selection)) + (bn (and (helm-file-completion-source-p) + (helm-basename cand))) + (src-name (assoc-default 'name + (helm-get-current-source)))) + (when (and (not (helm-this-visible-mark)) + (not (or (string= prefix "[?]") + (string= prefix "[@]")))) + ;; Don't mark possibles directories ending with . or .. + ;; autosave files/links and non--existent file. + (unless + (and (or (helm-file-completion-source-p) + (string= + src-name "Files from Current Directory")) + (or (string-match + "^[.]?#.*#?$\\|[^#]*[.]\\{1,2\\}$" bn) + ;; We need to test here when not using + ;; a transformer that tag prefix + ;; (i.e on tramp). + (not (file-exists-p cand)))) + (helm-make-visible-mark)))) + (if (helm-pos-multiline-p) + (progn + (goto-char + (or (helm-get-next-candidate-separator-pos) + (point-max))) + (forward-line 1)) + (forward-line 1)) + (end-of-line)))) + (helm-mark-current-line) + (message "%s candidates marked" (length helm-marked-candidates))) + (helm-follow-mode follow) (message nil))))) + +(defun helm-unmark-all () + "Unmark all candidates in all sources of current helm session." + (interactive) + (with-helm-window + (let ((len (length helm-marked-candidates))) + (save-excursion + (helm-clear-visible-mark)) + (setq helm-marked-candidates nil) + (helm-mark-current-line) + (message "%s candidates unmarked" len)))) + +(defun helm-toggle-all-marks () + "Toggle all marks. +Mark all visible candidates of current source or unmark all candidates +visible or invisible in all sources of current helm session" + (interactive) + (let ((marked (helm-marked-candidates))) + (if (and (>= (length marked) 1) + (with-helm-window helm-visible-mark-overlays)) + (helm-unmark-all) + (helm-mark-all)))) + +(cl-defun helm-marked-candidates (&key with-wildcard) + "Return marked candidates of current source if any. +Otherwise one element list of current selection. +When key WITH-WILDCARD is specified try to expand a wilcard if some." + (with-current-buffer helm-buffer + (cl-loop with current-src = (helm-get-current-source) + for (source . real) in + (or (reverse helm-marked-candidates) + (list (cons current-src (helm-get-selection)))) + when (equal (assoc 'name current-src) + (assoc 'name source)) + ;; When real is a normal filename without wildcard + ;; file-expand-wildcards returns a list of one file. + ;; When real is a non--existent file it return nil. + append (let* ((elm (helm-coerce-selection real source)) + (c (and with-wildcard + (condition-case nil + (helm-file-expand-wildcards elm t) + (error nil))))) + (or c (list elm))) + into cands + finally do (prog1 (cl-return cands) + (helm-log "Marked candidates = %S" cands))))) + +(defun helm-file-expand-wildcards (pattern &optional full) + "Same as `file-expand-wildcards' but allow recursion. +Recursion happen when PATTERN starts with two stars. +Directories expansion is not supported." + (require 'helm-utils) + (let ((bn (helm-basename pattern))) + (if (and helm-file-globstar + (string-match "\\`\\*\\{2\\}\\(.*\\)" bn)) + (helm-walk-directory (helm-basedir pattern) + :path (cl-case full + (full 'full) + (relative 'relative) + ((basename nil) 'basename) + (t 'full)) + :directories nil + :match (wildcard-to-regexp bn) + :skip-subdirs t) + (file-expand-wildcards pattern full)))) + +(defun helm-current-source-name= (name) + (save-excursion + (goto-char (helm-get-previous-header-pos)) + (equal name (helm-current-line-contents)))) + +(defun helm-revive-visible-mark () + "Restore marked candidates when helm update display." + (with-current-buffer helm-buffer + (cl-dolist (o helm-visible-mark-overlays) + (goto-char (point-min)) + (while (and (search-forward (overlay-get o 'string) nil t) + (helm-current-source-name= (overlay-get o 'source))) + ;; Calculate real value of candidate. + ;; It can be nil if candidate have only a display value. + (let ((real (get-text-property (point-at-bol 0) 'helm-realvalue))) + (if real + ;; Check if real value of current candidate is the same + ;; than the one stored in overlay. + ;; This is needed when some cands have same display names. + ;; Using equal allow testing any type of value for real cand. + ;; Issue (#706). + (and (equal (overlay-get o 'real) real) + (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0)))) + (move-overlay o (point-at-bol 0) (1+ (point-at-eol 0))))))))) +(add-hook 'helm-update-hook 'helm-revive-visible-mark) + +(defun helm-next-point-in-list (curpos points &optional prev) + (cond + ;; rule out special cases. + ((null points) curpos) + ((and prev (<= curpos (car points))) + (nth (1- (length points)) points)) + ((< (car (last points)) curpos) + (if prev (car (last points)) (nth 0 points))) + ((and (not prev) (>= curpos (car (last points)))) + (nth 0 points)) + (t + (nth (if prev + (cl-loop for pt in points + for i from 0 + if (<= curpos pt) return (1- i)) + (cl-loop for pt in points + for i from 0 + if (< curpos pt) return i)) + points)))) + +(defun helm-next-visible-mark (&optional prev) + "Move next helm visible mark. +If PREV is non-nil move to precedent." + (interactive) + (with-helm-window + (ignore-errors + (goto-char (helm-next-point-in-list + (point) + (sort (mapcar 'overlay-start helm-visible-mark-overlays) '<) + prev))) + (helm-mark-current-line))) + +(defun helm-prev-visible-mark () + "Move previous helm visible mark." + (interactive) + (helm-next-visible-mark t)) + +;;; Utility: Selection Paste +;; +(defun helm-yank-selection (arg) + "Set minibuffer contents to current display selection. +With a prefix arg set to real value of current selection." + (interactive "P") + (let ((str (helm-get-selection nil (not arg)))) + (kill-new str) + (helm-set-pattern str))) + +(defun helm-kill-selection-and-quit (arg) + "Store display value of current selection to kill ring. +With a prefix arg set to real value of current selection. +Display value is what you see in `helm-buffer' and real value +is what is used to perform actions." + (interactive "P") + (helm-run-after-quit + (lambda (sel) + (kill-new sel) + (message "Killed: %s" sel)) + (helm-get-selection nil (not arg)))) + +(defun helm-copy-to-buffer () + "Copy selection or marked candidates to `helm-current-buffer'." + (interactive) + (with-helm-buffer + (cl-loop for cand in (helm-marked-candidates) + do (with-helm-current-buffer + (insert cand "\n"))))) + + +;;; Follow-mode: Automatical execution of persistent-action +;; +;; +(defun helm-follow-mode (&optional arg) + "Execute persistent action everytime the cursor is moved when enabled. +The mode is enabled for the current source only, you will have to turn it +on again when you go to next source if you want it there also. +This mode can be enabled or disabled interactively at anytime during +helm session or enabled specifically by source by adding the `follow' +attribute to this source. +Even when the attribute `follow' exists in source, it is still possible +to disable/enable this mode interactively. +Note that when you disable it interactively and `follow' attribute exists, +`helm-follow-mode' will be disabled on next helm session even if `follow' +attribute is specified in source. To avoid this set your `follow' attribute +in source in `helm-before-initialize-hook'. + +e.g: + +\(add-hook 'helm-before-initialize-hook + #'(lambda () (helm-attrset 'follow 1 helm-source-buffers-list))) + +This will enable `helm-follow-mode' automatically in `helm-source-buffers-list'." + (interactive "p") + (with-current-buffer helm-buffer + (let* ((src (helm-get-current-source)) + (name (assoc-default 'name src)) + (sym (cl-loop for s in helm-sources + for sname = (and (symbolp s) + (assoc-default + 'name (symbol-value s))) + thereis (and sname (string= sname name) s))) + (fol-attr (assq 'follow src)) + (enabled (or + ;; If `helm-follow-mode' is called with a negative + ;; ARG, assume follow is already enabled. + ;; i.e turn it off now. + (< arg 0) + (eq (cdr fol-attr) 1) + helm-follow-mode))) + (if src + (progn + (if (eq (cdr fol-attr) 'never) + (message "helm-follow-mode not allowed in this source") + ;; Make follow attr persistent for this emacs session. + (helm-attrset 'follow (if enabled -1 1) src) + (setq helm-follow-mode (not enabled)) + (message "helm-follow-mode is %s" + (if helm-follow-mode + "enabled" "disabled")) + (helm-display-mode-line src)) + (unless helm-follow-mode-persistent + (and sym (set sym (remove (assq 'follow src) src))))) + (message "Not enough candidates for helm-follow-mode"))))) + +(defvar helm-follow-input-idle-delay nil + "`helm-follow-mode' will execute its persistent action after this delay. +Note that if the `follow-delay' attr is present in source, +it will take precedence on this.") +(defun helm-follow-execute-persistent-action-maybe () + "Execute persistent action in mode `helm-follow-mode'. +This happen after `helm-input-idle-delay' secs." + (let ((src (helm-get-current-source))) + (and (not (get-buffer-window helm-action-buffer 'visible)) + (eq (assoc-default 'follow src) 1) + (sit-for (or (assoc-default 'follow-delay src) + helm-follow-input-idle-delay + (and helm-input-idle-delay + (max helm-input-idle-delay 0.01)))) + (helm-window) + (helm-get-selection) + (save-excursion + (helm-execute-persistent-action))))) + + +;;; Auto-resize mode +;; +(defun helm--autoresize-hook (&optional max-height min-height) + (with-helm-window + (fit-window-to-buffer nil + (/ (* (frame-height) + (or max-height helm-autoresize-max-height)) + 100) + (/ (* (frame-height) + (or min-height helm-autoresize-min-height)) + 100)))) + +(define-minor-mode helm-autoresize-mode + "Auto resize helm window when enabled. +Helm window is resized according to values of `helm-autoresize-max-height' +and `helm-autoresize-min-height'. +Note that when this mode is enabled, helm behave like when +`helm-always-two-windows' is enabled. + +See `fit-window-to-buffer' for more infos." + :group 'helm + :global t + (if helm-autoresize-mode + (progn (add-hook 'helm-after-update-hook 'helm--autoresize-hook) + (add-hook 'helm-window-configuration-hook 'helm--autoresize-hook)) + (remove-hook 'helm-after-update-hook 'helm--autoresize-hook) + (remove-hook 'helm-window-configuration-hook 'helm--autoresize-hook))) + + +(provide 'helm) + +;; Local Variables: +;; byte-compile-warnings: (not cl-functions obsolete) +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; helm.el ends here diff --git a/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-autoloads.el b/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-autoloads.el deleted file mode 100644 index 4659f89..0000000 --- a/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-autoloads.el +++ /dev/null @@ -1,27 +0,0 @@ -;;; helm-projectile-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "helm-projectile" "helm-projectile.el" (21570 -;;;;;; 23307 0 0)) -;;; Generated autoloads from helm-projectile.el - -(autoload 'helm-projectile "helm-projectile" "\ -Use projectile with Helm instead of ido. - -With a prefix ARG invalidates the cache first. -If invoked outside of a project, displays a list of known projects to jump. - -\(fn &optional ARG)" t nil) - -(eval-after-load 'projectile '(progn (define-key projectile-command-map (kbd "h") 'helm-projectile))) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; helm-projectile-autoloads.el ends here diff --git a/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-pkg.el b/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-pkg.el deleted file mode 100644 index 92551f8..0000000 --- a/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "helm-projectile" "20141017.246" "Helm integration for Projectile" '((helm "1.4.0") (projectile "0.11.0") (cl-lib "0.3")) :url "https://github.com/bbatsov/projectile" :keywords '("project" "convenience")) diff --git a/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile.el b/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile.el deleted file mode 100644 index 9e0849e..0000000 --- a/emacs.d/elpa/helm-projectile-20141017.246/helm-projectile.el +++ /dev/null @@ -1,455 +0,0 @@ -;;; helm-projectile.el --- Helm integration for Projectile - -;; Copyright (C) 2011-2013 Bozhidar Batsov - -;; Author: Bozhidar Batsov -;; URL: https://github.com/bbatsov/projectile -;; Created: 2011-31-07 -;; Keywords: project, convenience -;; Version: 20141017.246 -;; X-Original-Version: 0.11.0 -;; Package-Requires: ((helm "1.4.0") (projectile "0.11.0") (cl-lib "0.3")) - -;; This file is NOT part of GNU Emacs. - -;;; License: - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: -;; -;; This library provides easy project management and navigation. The -;; concept of a project is pretty basic - just a folder containing -;; special file. Currently git, mercurial and bazaar repos are -;; considered projects by default. If you want to mark a folder -;; manually as a project just create an empty .projectile file in -;; it. See the README for more details. -;; -;;; Code: - -(require 'projectile) -(require 'helm-config) -(require 'helm-locate) -(require 'helm-buffers) -(require 'helm-files) -(require 'cl-lib) - -(declare-function eshell "eshell") - -(defgroup helm-projectile nil - "Helm support for projectile." - :prefix "helm-projectile-" - :group 'projectile - :link `(url-link :tag "helm-projectile homepage" "https://github.com/bbatsov/projectile")) - -(defvar helm-projectile-current-project-root) - -(defun helm-projectile-coerce-file (candidate) - (with-current-buffer (helm-candidate-buffer) - (expand-file-name candidate helm-projectile-current-project-root))) - -(defmacro helm-projectile-define-key (keymap key def &rest bindings) - "In KEYMAP, define key sequence KEY1 as DEF1, KEY2 as DEF2 ..." - (declare (indent defun)) - (let ((ret '(progn))) - (while key - (add-to-list - 'ret - `(define-key ,keymap ,key - (lambda () - (interactive) - (helm-quit-and-execute-action ,def))) - 'append) - (setq key (pop bindings) - def (pop bindings))) - ret)) - -(defun helm-projectile-vc (dir) - "A Helm action for jumping to project root using `vc-dir' or Magit. -DIR is a directory to be switched" - (let ((projectile-require-project-root nil)) - (cond - ((and (eq (projectile-project-vcs dir) 'git) (fboundp 'magit-status)) - (magit-status dir)) - (t (vc-dir dir))))) - -(defun helm-projectile-compile-project (dir) - "A Helm action for compile a project. -DIR is the project root." - (let ((helm--reading-passwd-or-string t) - (default-directory dir)) - (projectile-compile-project helm-current-prefix-arg dir))) - -(defun helm-projectile-remove-known-project (_ignore) - "Delete selected projects. -_IGNORE means the argument does not matter. -It is there because Helm requires it." - (let* ((projects (helm-marked-candidates :with-wildcard t)) - (len (length projects))) - (with-helm-display-marked-candidates - helm-marked-buffer-name - projects - (if (not (y-or-n-p (format "Delete *%s Projects(s)" len))) - (message "(No deletion performed)") - (progn - (mapc (lambda (p) - (delete p projectile-known-projects)) - projects) - (projectile-save-known-projects)) - (message "%s Projects(s) deleted" len))))) - -(defvar helm-source-projectile-projects - `((name . "Projectile projects") - (candidates . (lambda () - (if (projectile-project-p) - (cons (abbreviate-file-name (projectile-project-root)) - (projectile-relevant-known-projects)) - projectile-known-projects))) - (keymap . ,(let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (helm-projectile-define-key map - (kbd "C-d") 'dired - (kbd "M-g") 'helm-projectile-vc - (kbd "M-e") 'helm-projectile-switch-to-eshell - (kbd "C-s") 'helm-find-files-grep - (kbd "C-c") 'helm-projectile-compile-project - (kbd "M-D") 'helm-projectile-remove-known-project) - map)) - (action . (("Switch to project" . - (lambda (project) - (let ((projectile-completion-system 'helm)) - (projectile-switch-project-by-name project)))) - ("Open Dired in project's directory `C-d'" . dired) - ("Open project root in vc-dir or magit `M-g'" . - helm-projectile-vc) - ("Switch to Eshell `M-e'" . helm-projectile-switch-to-eshell) - ("Grep in projects `C-s'. With C-u, recurse" . helm-find-files-grep) - ("Compile project `C-c'. With C-u, new compile command" - . helm-projectile-compile-project) - ("Remove project(s) `M-D'" . helm-projectile-remove-known-project)))) - "Helm source for known projectile projects.") - -(defun helm-projectile-init-buffer-with-files (project-root files) - (with-current-buffer (helm-candidate-buffer project-root) - (set (make-local-variable 'helm-projectile-current-project-root) - project-root) - (dolist (file files) - (insert (concat file "\n"))))) - -(defvar helm-projectile-find-file-map - (let ((map (copy-keymap helm-find-files-map))) - (define-key map (kbd "") 'helm-previous-source) - (define-key map (kbd "") 'helm-next-source) - (helm-projectile-define-key map - (kbd "M-e") 'helm-projectile-switch-to-eshell - (kbd "M-.") 'helm-projectile-ff-etags-select-action - (kbd "M-!") 'helm-projectile-find-files-eshell-command-on-file-action) - map)) - -(define-key helm-etags-map (kbd "C-c p f") (lambda () - (interactive) - (helm-run-after-quit 'helm-projectile-find-file nil))) - -(defun helm-projectile-find-files-eshell-command-on-file-action (_candidate) - (interactive) - (let* ((helm-ff-default-directory (file-name-directory _candidate))) - (helm-find-files-eshell-command-on-file _candidate))) - -(defun helm-projectile-ff-etags-select-action (_candidate) - (interactive) - (let* ((helm-ff-default-directory (file-name-directory _candidate))) - (helm-ff-etags-select _candidate))) - -(defun helm-projectile-switch-to-eshell (dir) - (interactive) - (let* ((helm-ff-default-directory (file-name-directory dir))) - (helm-ff-switch-to-eshell dir))) - -(defvar helm-projectile-file-actions - (helm-make-actions - "Find File" 'helm-find-file-or-marked - "Find file in Dired" 'helm-point-file-in-dired - (lambda () (and (locate-library "elscreen") "Find file in Elscreen")) - 'helm-elscreen-find-file - "View file" 'view-file - "Checksum File" 'helm-ff-checksum - "Query replace on marked" 'helm-ff-query-replace-on-marked - "Serial rename files" 'helm-ff-serial-rename - "Serial rename by symlinking files" 'helm-ff-serial-rename-by-symlink - "Serial rename by copying files" 'helm-ff-serial-rename-by-copying - "Open file with default tool" 'helm-open-file-with-default-tool - "Find file in hex dump" 'hexl-find-file - "Insert as org link `C-c @'" 'helm-files-insert-as-org-link - "Open file externally `C-c C-x, C-u to choose'" 'helm-open-file-externally - "Grep File(s) `C-s, C-u Recurse'" 'helm-find-files-grep - "Zgrep File(s) `M-g z, C-u Recurse'" 'helm-ff-zgrep - "Switch to Eshell `M-e'" 'helm-projectile-switch-to-eshell - "Etags `M-., C-u reload tag file'" 'helm-projectile-ff-etags-select-action - "Eshell command on file(s) `M-!, C-u take all marked as arguments.'" 'helm-projectile-find-files-eshell-command-on-file-action - "Find file as root `C-c r'" 'helm-find-file-as-root - "Ediff File `C-='" 'helm-find-files-ediff-files - "Ediff Merge File `C-c ='" 'helm-find-files-ediff-merge-files - "Delete File(s) `M-D'" 'helm-delete-marked-files - "Copy file(s) `M-C, C-u to follow'" 'helm-find-files-copy - "Rename file(s) `M-R, C-u to follow'" 'helm-find-files-rename - "Symlink files(s) `M-S, C-u to follow'" 'helm-find-files-symlink - "Relsymlink file(s) `C-u to follow'" 'helm-find-files-relsymlink - "Hardlink file(s) `M-H, C-u to follow'" 'helm-find-files-hardlink - "Find file other window `C-c o'" 'find-file-other-window - "Switch to history `M-p'" 'helm-find-files-switch-to-hist - "Find file other frame `C-c C-o'" 'find-file-other-frame - "Print File `C-c p, C-u to refresh'" 'helm-ff-print - "Locate `C-x C-f, C-u to specify locate db'" 'helm-ff-locate) - "Action for files.") - -(defvar helm-source-projectile-files-dwim-list - `((name . "Projectile Files") - (init . (lambda () - (let* ((project-files (projectile-current-project-files)) - (files (projectile-select-files project-files))) - (cond - ((= (length files) 1) - (find-file (expand-file-name (car files) (projectile-project-root))) - (helm-exit-minibuffer)) - ((> (length files) 1) - (helm-projectile-init-buffer-with-files (projectile-project-root) - files)) - (t - (helm-projectile-init-buffer-with-files (projectile-project-root) - project-files)))))) - (coerce . helm-projectile-coerce-file) - (candidates-in-buffer) - (keymap . ,(let ((map (copy-keymap helm-find-files-map))) - (define-key map (kbd "") 'helm-previous-source) - (define-key map (kbd "") 'helm-next-source) - map)) - (help-message . helm-find-file-help-message) - (mode-line . helm-ff-mode-line-string) - (type . file) - (action . ,helm-projectile-file-actions)) - "Helm source definition for Projectile files") - -(defvar helm-source-projectile-files-list - `((name . "Projectile Files") - (init . (lambda () - (helm-projectile-init-buffer-with-files (projectile-project-root) - (projectile-current-project-files)))) - (coerce . helm-projectile-coerce-file) - (candidates-in-buffer) - (keymap . ,helm-projectile-find-file-map) - (help-message . helm-find-file-help-message) - (mode-line . helm-ff-mode-line-string) - (type . file) - (action . ,helm-projectile-file-actions)) - "Helm source definition for Projectile files") - -(defun helm-projectile-dired-find-dir (dir) - "Jump to a selected directory DIR from helm-projectile." - (dired (expand-file-name dir (projectile-project-root))) - (run-hooks 'projectile-find-dir-hook)) - -(defun helm-projectile-dired-find-dir-other-window (dir) - "Jump to a selected directory DIR from helm-projectile." - (dired-other-window (expand-file-name dir (projectile-project-root))) - (run-hooks 'projectile-find-dir-hook)) - -(defvar helm-source-projectile-directories-list - `((name . "Projectile Directories") - (candidates . (lambda () - (if projectile-find-dir-includes-top-level - (append '("./") (projectile-current-project-dirs)) - (projectile-current-project-dirs)))) - (keymap . ,(let ((map (make-sparse-keymap))) - (set-keymap-parent map helm-map) - (helm-projectile-define-key map - (kbd "C-c o") 'helm-projectile-dired-find-dir-other-window - (kbd "M-e") 'helm-projectile-switch-to-eshell - (kbd "C-s") 'helm-find-files-grep) - map)) - (action . (("Open Dired" . helm-projectile-dired-find-dir) - ("Open Dired in other window`C-c o'" . helm-projectile-dired-find-dir) - ("Switch to Eshell `M-e'" . helm-projectile-switch-to-eshell) - ("Grep in projects `C-s C-u Recurse'" . helm-find-files-grep)))) - "Helm source for listing project directories") - -(defvar helm-source-projectile-buffers-list - `((name . "Projectile Buffers") - (init . (lambda () - ;; Issue #51 Create the list before `helm-buffer' creation. - (setq helm-projectile-buffers-list-cache (projectile-project-buffer-names)) - (let ((result (cl-loop for b in helm-projectile-buffers-list-cache - maximize (length b) into len-buf - maximize (length (with-current-buffer b - (symbol-name major-mode))) - into len-mode - finally return (cons len-buf len-mode)))) - (unless helm-buffer-max-length - (setq helm-buffer-max-length (car result))) - (unless helm-buffer-max-len-mode - ;; If a new buffer is longer that this value - ;; this value will be updated - (setq helm-buffer-max-len-mode (cdr result)))))) - (candidates . helm-projectile-buffers-list-cache) - (type . buffer) - (match helm-buffers-list--match-fn) - (persistent-action . helm-buffers-list-persistent-action) - (keymap . ,helm-buffer-map) - (volatile) - (no-delay-on-input) - (mode-line . helm-buffer-mode-line-string) - (persistent-help - . "Show this buffer / C-u \\[helm-execute-persistent-action]: Kill this buffer"))) - -(defvar helm-source-projectile-recentf-list - `((name . "Projectile Recent Files") - ;; Needed for filenames with capitals letters. - (init . (lambda () - (helm-projectile-init-buffer-with-files (projectile-project-root) - (projectile-recentf-files)))) - (coerce . helm-projectile-coerce-file) - (candidates-in-buffer) - (keymap . ,helm-generic-files-map) - (help-message . helm-find-file-help-message) - (mode-line . helm-ff-mode-line-string) - (type . file) - (action . ,(cdr (helm-get-actions-from-type - helm-source-locate)))) - "Helm source definition.") - -(defcustom helm-projectile-sources-list - '(helm-source-projectile-projects - helm-source-projectile-buffers-list - helm-source-projectile-recentf-list - helm-source-projectile-files-list - helm-source-projectile-directories-list - ) - "Default sources for `helm-projectile'." - :group 'helm-projectile) - - -(defmacro helm-projectile-command (command source prompt) - "Template for generic helm-projectile commands. -COMMAND is a command name to be appended with \"helm-projectile\" prefix. -SOURCE is a Helm source that should be Projectile specific. -PROMPT is a string for displaying as a prompt." - `(defun ,(intern (concat "helm-projectile-" command)) (&optional arg) - "Use projectile with Helm for finding files in project - -With a prefix ARG invalidates the cache first." - (interactive "P") - (if (projectile-project-p) - (projectile-maybe-invalidate-cache arg)) - (let ((helm-ff-transformer-show-only-basename nil)) - (helm :sources ,source - :buffer "*helm projectile*" - :prompt (projectile-prepend-project-name ,prompt))))) - -(helm-projectile-command "switch-project" 'helm-source-projectile-projects "Switch to project: ") -(helm-projectile-command "find-file" 'helm-source-projectile-files-list "Find file: ") -(helm-projectile-command "find-file-dwim" 'helm-source-projectile-files-dwim-list "Find file: ") -(helm-projectile-command "find-dir" 'helm-source-projectile-directories-list "Find dir: ") -(helm-projectile-command "recentf" 'helm-source-projectile-recentf-list "Recently visited file: ") -(helm-projectile-command "switch-to-buffer" 'helm-source-projectile-buffers-list "Switch to buffer: ") - -(defun helm-projectile-find-other-file (&optional flex-matching) - "Switch between files with the same name but different extensions using Helm. -With FLEX-MATCHING, match any file that contains the base name of current file. -Other file extensions can be customized with the variable `projectile-other-file-alist'." - (interactive "P") - (-if-let (other-files (projectile-get-other-files (buffer-file-name) - (projectile-current-project-files) - flex-matching)) - (if (= (length other-files) 1) - (find-file (expand-file-name (car other-files) (projectile-project-root))) - (progn - (let* ((helm-ff-transformer-show-only-basename nil)) - (helm :sources `((name . "Projectile Other Files") - (init . (lambda () - (helm-projectile-init-buffer-with-files (projectile-project-root) - other-files))) - (coerce . helm-projectile-coerce-file) - (candidates-in-buffer) - (keymap . ,(let ((map (copy-keymap helm-find-files-map))) - (define-key map (kbd "") 'helm-previous-source) - (define-key map (kbd "") 'helm-next-source) - map)) - (help-message . helm-find-file-help-message) - (mode-line . helm-ff-mode-line-string) - (type . file) - (action . ,helm-projectile-file-actions)) - :buffer "*helm projectile*" - :prompt (projectile-prepend-project-name "Find other file: "))))) - (error "No other file found"))) - -(defun helm-projectile-on () - "Turn on helm-projectile key bindings." - (interactive) - (message "Turn on helm-projectile key bindings") - (helm-projectile-toggle 1)) - -(defun helm-projectile-off () - "Turn off helm-projectile key bindings." - (interactive) - (message "Turn off helm-projectile key bindings") - (helm-projectile-toggle -1)) - -(defun helm-projectile-toggle (toggle) - "Toggle Helm version of Projectile commands." - (if (> toggle 0) - (progn - (define-key projectile-command-map (kbd "a") 'helm-projectile-find-other-file) - (define-key projectile-command-map (kbd "f") 'helm-projectile-find-file) - (define-key projectile-command-map (kbd "g") 'helm-projectile-find-file-dwim) - (define-key projectile-command-map (kbd "d") 'helm-projectile-find-dir) - (define-key projectile-command-map (kbd "p") 'helm-projectile-switch-project) - (define-key projectile-command-map (kbd "e") 'helm-projectile-recentf) - (define-key projectile-command-map (kbd "b") 'helm-projectile-switch-to-buffer)) - (progn - (define-key projectile-command-map (kbd "a") 'projectile-find-other-file) - (define-key projectile-command-map (kbd "f") 'projectile-find-file) - (define-key projectile-command-map (kbd "g") 'helm-projectile-find-file-dwim) - (define-key projectile-command-map (kbd "d") 'projectile-find-dir) - (define-key projectile-command-map (kbd "p") 'projectile-switch-project) - (define-key projectile-command-map (kbd "e") 'projectile-recentf) - (define-key projectile-command-map (kbd "b") 'projectile-switch-to-buffer)))) - -;;;###autoload -(defun helm-projectile (&optional arg) - "Use projectile with Helm instead of ido. - -With a prefix ARG invalidates the cache first. -If invoked outside of a project, displays a list of known projects to jump." - (interactive "P") - (if (projectile-project-p) - (projectile-maybe-invalidate-cache arg)) - (let ((helm-ff-transformer-show-only-basename nil) - (src (if (projectile-project-p) - helm-projectile-sources-list - helm-source-projectile-projects))) - (helm :sources src - :buffer "*helm projectile*" - :prompt (projectile-prepend-project-name (if (projectile-project-p) - "pattern: " - "Switch to project: "))))) - -;;;###autoload -(eval-after-load 'projectile - '(progn - (define-key projectile-command-map (kbd "h") 'helm-projectile))) - -(provide 'helm-projectile) - -;;; helm-projectile.el ends here diff --git a/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-autoloads.el b/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-autoloads.el new file mode 100644 index 0000000..fa29c1f --- /dev/null +++ b/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-autoloads.el @@ -0,0 +1,70 @@ +;;; helm-projectile-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "helm-projectile" "helm-projectile.el" (21837 +;;;;;; 24207 0 0)) +;;; Generated autoloads from helm-projectile.el + +(defvar helm-projectile-fuzzy-match t "\ +Enable fuzzy matching for Helm Projectile commands. +This needs to be set before loading helm-projectile.") + +(custom-autoload 'helm-projectile-fuzzy-match "helm-projectile" t) + +(autoload 'helm-projectile-find-file-dwim "helm-projectile" "\ +Find file at point based on context. + +\(fn)" t nil) + +(autoload 'helm-projectile-find-other-file "helm-projectile" "\ +Switch between files with the same name but different extensions using Helm. +With FLEX-MATCHING, match any file that contains the base name of current file. +Other file extensions can be customized with the variable `projectile-other-file-alist'. + +\(fn &optional FLEX-MATCHING)" t nil) + +(autoload 'helm-projectile-on "helm-projectile" "\ +Turn on helm-projectile key bindings. + +\(fn)" t nil) + +(autoload 'helm-projectile-off "helm-projectile" "\ +Turn off helm-projectile key bindings. + +\(fn)" t nil) + +(autoload 'helm-projectile-grep "helm-projectile" "\ +Helm version of projectile-grep. + +\(fn)" t nil) + +(autoload 'helm-projectile-ack "helm-projectile" "\ +Helm version of projectile-ack. + +\(fn)" t nil) + +(autoload 'helm-projectile-ag "helm-projectile" "\ +Helm version of projectile-ag. + +\(fn &optional OPTIONS)" t nil) + +(autoload 'helm-projectile "helm-projectile" "\ +Use projectile with Helm instead of ido. + +With a prefix ARG invalidates the cache first. +If invoked outside of a project, displays a list of known projects to jump. + +\(fn &optional ARG)" t nil) + +(eval-after-load 'projectile '(progn (define-key projectile-command-map (kbd "h") 'helm-projectile))) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; helm-projectile-autoloads.el ends here diff --git a/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-pkg.el b/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-pkg.el new file mode 100644 index 0000000..fb30c47 --- /dev/null +++ b/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile-pkg.el @@ -0,0 +1 @@ +(define-package "helm-projectile" "20150427.2348" "Helm integration for Projectile" '((helm "1.4.0") (projectile "0.12.0") (dash "1.5.0") (cl-lib "0.3")) :url "https://github.com/bbatsov/projectile" :keywords '("project" "convenience")) diff --git a/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile.el b/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile.el new file mode 100644 index 0000000..7de8b85 --- /dev/null +++ b/emacs.d/elpa/helm-projectile-20150427.2348/helm-projectile.el @@ -0,0 +1,842 @@ +;;; helm-projectile.el --- Helm integration for Projectile + +;; Copyright (C) 2011-2015 Bozhidar Batsov + +;; Author: Bozhidar Batsov +;; URL: https://github.com/bbatsov/projectile +;; Package-Version: 20150427.2348 +;; Created: 2011-31-07 +;; Keywords: project, convenience +;; Version: 0.12.0 +;; Package-Requires: ((helm "1.4.0") (projectile "0.12.0") (dash "1.5.0") (cl-lib "0.3")) + +;; This file is NOT part of GNU Emacs. + +;;; License: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: +;; +;; This library provides easy project management and navigation. The +;; concept of a project is pretty basic - just a folder containing +;; special file. Currently git, mercurial and bazaar repos are +;; considered projects by default. If you want to mark a folder +;; manually as a project just create an empty .projectile file in +;; it. See the README for more details. +;; +;;; Code: + +(require 'projectile) +(require 'helm-locate) +(require 'helm-buffers) +(require 'helm-files) +(require 'cl-lib) + +(declare-function eshell "eshell") +(declare-function helm-do-ag "helm-ag") +(defvar helm-ag-base-command) + +(defgroup helm-projectile nil + "Helm support for projectile." + :prefix "helm-projectile-" + :group 'projectile + :link `(url-link :tag "helm-projectile homepage" "https://github.com/bbatsov/projectile")) + +(defvar helm-projectile-current-project-root) + +;;;###autoload +(defcustom helm-projectile-fuzzy-match t + "Enable fuzzy matching for Helm Projectile commands. +This needs to be set before loading helm-projectile." + :group 'helm-projectile + :type 'boolean) + +(defun helm-projectile-coerce-file (candidate) + (with-current-buffer (helm-candidate-buffer) + (expand-file-name candidate (projectile-project-root)))) + +(defmacro helm-projectile-define-key (keymap key def &rest bindings) + "In KEYMAP, define key sequence KEY1 as DEF1, KEY2 as DEF2 ..." + (declare (indent defun)) + (let ((ret '(progn))) + (while key + (push + `(define-key ,keymap ,key + (lambda () + (interactive) + (helm-quit-and-execute-action ,def))) + ret) + (setq key (pop bindings) + def (pop bindings))) + (reverse ret))) + +(defun helm-projectile-hack-actions (actions &rest prescription) + "Given a Helm action list and a prescription, return a hacked +Helm action list, after applying the PRESCRIPTION. + +The Helm action list ACTIONS is of the form: + +\(\(DESCRIPTION1 . FUNCTION1\) + \(DESCRIPTION2 . FUNCTION2\) + ... + \(DESCRIPTIONn . FUNCTIONn\)\) + +PRESCRIPTION is in the form: + +\(INSTRUCTION1 INSTRUCTION2 ... INSTRUCTIONn\) + +If an INSTRUCTION is a symbol, the action with function name +INSTRUCTION is deleted. + +If an INSTRUCTION is of the form \(FUNCTION1 . FUNCTION2\), the +action with function name FUNCTION1 will change it's function to +FUNCTION2. + +If an INSTRUCTION is of the form \(FUNCTION . DESCRIPTION\), and +if an action with function name FUNCTION exists in the original +Helm action list, the action in the Helm action list, with +function name FUNCTION will change it's description to +DESCRIPTION. Otherwise, (FUNCTION . DESCRIPTION) will be added to +the action list. + +Please check out how `helm-projectile-file-actions' is defined +for an example of how this function is being used." + (let* ((to-delete (cl-remove-if (lambda (entry) (listp entry)) prescription)) + (actions (cl-delete-if (lambda (action) (memq (cdr action) to-delete)) + (copy-alist actions))) + new) + (cl-dolist (action actions) + (when (setq new (cdr (assq (cdr action) prescription))) + (if (stringp new) + (setcar action new) + (setcdr action new)))) + ;; Add new actions from PRESCRIPTION + (setq new nil) + (cl-dolist (instruction prescription) + (when (and (listp instruction) + (null (rassq (car instruction) actions)) + (symbolp (car instruction)) (stringp (cdr instruction))) + (push (cons (cdr instruction) (car instruction)) new))) + (append actions (nreverse new)))) + +(defun helm-projectile-vc (dir) + "A Helm action for jumping to project root using `vc-dir' or Magit. +DIR is a directory to be switched" + (let ((projectile-require-project-root nil)) + (projectile-vc dir))) + +(defun helm-projectile-compile-project (dir) + "A Helm action for compile a project. +DIR is the project root." + (let ((helm--reading-passwd-or-string t) + (default-directory dir)) + (projectile-compile-project helm-current-prefix-arg dir))) + +(defun helm-projectile-remove-known-project (_ignore) + "Delete selected projects. +_IGNORE means the argument does not matter. +It is there because Helm requires it." + (let* ((projects (helm-marked-candidates :with-wildcard t)) + (len (length projects))) + (with-helm-display-marked-candidates + helm-marked-buffer-name + projects + (if (not (y-or-n-p (format "Delete *%s projects(s)" len))) + (message "(No deletion performed)") + (progn + (mapc (lambda (p) + (delete p projectile-known-projects)) + projects) + (projectile-save-known-projects)) + (message "%s projects(s) deleted" len))))) + +(defvar helm-source-projectile-projects + (helm-build-in-buffer-source "Projectile projects" + :data (lambda () + (if (projectile-project-p) + (cons (abbreviate-file-name (projectile-project-root)) + (projectile-relevant-known-projects)) + projectile-known-projects)) + :fuzzy-match helm-projectile-fuzzy-match + :keymap (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (helm-projectile-define-key map + (kbd "C-d") 'dired + (kbd "M-g") 'helm-projectile-vc + (kbd "M-e") 'helm-projectile-switch-to-eshell + (kbd "C-s") 'helm-find-files-grep + (kbd "M-c") 'helm-projectile-compile-project + (kbd "M-D") 'helm-projectile-remove-known-project) + map) + :mode-line helm-ff-mode-line-string + :action '(("Switch to project" . + (lambda (project) + (let ((projectile-completion-system 'helm)) + (projectile-switch-project-by-name project)))) + ("Open Dired in project's directory `C-d'" . dired) + ("Open project root in vc-dir or magit `M-g'" . helm-projectile-vc) + ("Switch to Eshell `M-e'" . helm-projectile-switch-to-eshell) + ("Grep in projects `C-s'. With C-u, recurse" . helm-find-files-grep) + ("Compile project `M-c'. With C-u, new compile command" + . helm-projectile-compile-project) + ("Remove project(s) `M-D'" . helm-projectile-remove-known-project))) + "Helm source for known projectile projects.") + +(define-key helm-etags-map (kbd "C-c p f") (lambda () + (interactive) + (helm-run-after-quit 'helm-projectile-find-file nil))) + +(defun helm-projectile-find-files-eshell-command-on-file-action (_candidate) + (interactive) + (let* ((helm-ff-default-directory (file-name-directory _candidate))) + (helm-find-files-eshell-command-on-file _candidate))) + +(defun helm-projectile-ff-etags-select-action (_candidate) + (interactive) + (let* ((helm-ff-default-directory (file-name-directory _candidate))) + (helm-ff-etags-select _candidate))) + +(defun helm-projectile-switch-to-eshell (dir) + (interactive) + (let* ((projectile-require-project-root nil) + (helm-ff-default-directory (file-name-directory (projectile-expand-root dir)))) + (helm-ff-switch-to-eshell dir))) + +(defun helm-projectile-files-in-current-dired-buffer () + "Return a list of files (only) in the current dired buffer." + (let (flist) + (cl-flet ((fpush (fname) (push fname flist))) + (save-excursion + (let (file buffer-read-only) + (goto-char (point-min)) + (while (not (eobp)) + (save-excursion + (and (not (eolp)) + (setq file (dired-get-filename t t)) ; nil on non-file + (progn (end-of-line) + (funcall #'fpush file)))) + (forward-line 1))))) + (mapcar 'file-truename (nreverse flist)))) + +(defun helm-projectile-all-dired-buffers () + "Get all current Dired buffers." + (mapcar (lambda (b) + (with-current-buffer b (buffer-name))) + (-filter (lambda (b) + (with-current-buffer b + (and (eq major-mode 'dired-mode) + (buffer-name)))) + (buffer-list)))) + +(defvar helm-projectile-virtual-dired-remote-enable nil + "Enable virtual Dired manager in remote host. Disabled by default.") + +(defun helm-projectile-dired-files-new-action (candidate) + "Create a Dired buffer from chosen files. +CANDIDATE is the selected file, but choose the marked files if available." + (if (and (file-remote-p (projectile-project-root)) + (not helm-projectile-virtual-dired-remote-enable)) + (message "Virtual Dired manager is disabled in remote host. Enable with %s." + (propertize "helm-projectile-virtual-dired-remote-enable" 'face 'font-lock-keyword-face)) + (let ((new-name (completing-read "Select or enter a new buffer name: " + (helm-projectile-all-dired-buffers))) + (helm--reading-passwd-or-string t) + (files (-filter (lambda (f) + (not (string= f ""))) + (mapcar (lambda (file) + (replace-regexp-in-string (projectile-project-root) "" file)) + (helm-marked-candidates :with-wildcard t)))) + (default-directory (projectile-project-root))) + ;; create a unique buffer that is unique to any directory in default-directory + ;; or opened buffer; when Dired is passed with a non-existence directory name, + ;; it only creates a buffer and insert everything. If a new name user supplied + ;; exists as default-directory, Dired throws error when insert anything that + ;; does not exist in current directory. + (with-current-buffer (dired (cons (make-temp-name new-name) + (if files + files + (list candidate)))) + (when (get-buffer new-name) + (kill-buffer new-name)) + (rename-buffer new-name))))) + +(defun helm-projectile-dired-files-add-action (candidate) + "Add files to a Dired buffer. +CANDIDATE is the selected file. Used when no file is explicitly marked." + (if (and (file-remote-p (projectile-project-root)) + (not helm-projectile-virtual-dired-remote-enable)) + (message "Virtual Dired manager is disabled in remote host. Enable with %s." + (propertize "helm-projectile-virtual-dired-remote-enable" 'face 'font-lock-keyword-face)) + (if (eq (with-helm-current-buffer major-mode) 'dired-mode) + (let* ((helm--reading-passwd-or-string t) + (root (projectile-project-root)) ; store root for later use + (dired-buffer-name (or (and (eq major-mode 'dired-mode) (buffer-name)) + (completing-read "Select a Dired buffer:" + (helm-projectile-all-dired-buffers)))) + (dired-files (with-current-buffer dired-buffer-name + (helm-projectile-files-in-current-dired-buffer))) + (marked-files (helm-marked-candidates :with-wildcard t)) + (files (sort (mapcar (lambda (file) + (replace-regexp-in-string (projectile-project-root) "" file)) + (cl-nunion (if marked-files + marked-files + (list candidate)) + dired-files + :test #'string-equal)) + 'string-lessp))) + (kill-buffer dired-buffer-name) + ;; Rebind default-directory because after killing a buffer, we + ;; could be in any buffer and default-directory is set to that + ;; random buffer + ;; + ;; Also use saved root directory, because after killing a buffer, + ;; we could be outside of current project + (let ((default-directory root)) + (with-current-buffer (dired (cons (make-temp-name dired-buffer-name) + (if files + (mapcar (lambda (file) + (replace-regexp-in-string root "" file)) + files) + (list candidate)))) + (rename-buffer dired-buffer-name)))) + (error "You're not in a Dired buffer to add.")))) + +(defun helm-projectile-dired-files-delete-action (candidate) + "Delete selected entries from a Dired buffer. +CANDIDATE is the selected file. Used when no file is explicitly marked." + (if (and (file-remote-p (projectile-project-root)) + (not helm-projectile-virtual-dired-remote-enable)) + (message "Virtual Dired manager is disabled in remote host. Enable with %s." + (propertize "helm-projectile-virtual-dired-remote-enable" 'face 'font-lock-keyword-face)) + (let* ((helm--reading-passwd-or-string t) + (root (projectile-project-root)) + (dired-buffer-name (with-helm-current-buffer (buffer-name))) + (dired-files (with-current-buffer dired-buffer-name + (helm-projectile-files-in-current-dired-buffer))) + (files (sort (cl-set-exclusive-or (helm-marked-candidates :with-wildcard t) + dired-files + :test #'string-equal) #'string-lessp))) + (kill-buffer dired-buffer-name) + ;; similar reason to `helm-projectile-dired-files-add-action' + (let ((default-directory root)) + (with-current-buffer (dired (cons (make-temp-name dired-buffer-name) + (if files + (mapcar (lambda (file) + (replace-regexp-in-string root "" file)) + files) + (list candidate)))) + (rename-buffer dired-buffer-name)))))) + +(defvar helm-projectile-find-file-map + (let ((map (copy-keymap helm-find-files-map))) + (helm-projectile-define-key map + (kbd "C-c f") 'helm-projectile-dired-files-new-action + (kbd "C-c a") 'helm-projectile-dired-files-add-action + (kbd "M-e") 'helm-projectile-switch-to-eshell + (kbd "M-.") 'helm-projectile-ff-etags-select-action + (kbd "M-!") 'helm-projectile-find-files-eshell-command-on-file-action) + (define-key map (kbd "") 'helm-previous-source) + (define-key map (kbd "") 'helm-next-source) + map) + "Mapping for file commands in Helm Projectile.") + +(defvar helm-projectile-file-actions + (helm-projectile-hack-actions + (cdr (assq 'action (or helm-source-find-files + (helm-make-source "Find files" 'helm-source-ffiles)))) + ;; Delete these actions + 'helm-ff-browse-project + 'helm-insert-file-name-completion-at-point + 'helm-ff-find-sh-command + 'helm-ff-cache-add-file + ;; Substitute these actions + '(helm-ff-switch-to-eshell . helm-projectile-switch-to-eshell) + '(helm-ff-etags-select . helm-projectile-ff-etags-select-action) + '(helm-find-files-eshell-command-on-file + . helm-projectile-find-files-eshell-command-on-file-action) + ;; Change action descriptions + '(helm-find-file-as-root . "Find file as root `C-c r'") + ;; New actions + '(helm-projectile-dired-files-new-action + . "Create Dired buffer from files `C-c f'") + '(helm-projectile-dired-files-add-action + . "Add files to Dired buffer `C-c a'")) + "Action for files.") + +(defun helm-projectile-build-dwim-source (candidates) + "Dynamically build a Helm source definition for Projectile files based on context with CANDIDATES." + "" + (helm-build-in-buffer-source "Projectile files" + :data candidates + :fuzzy-match helm-projectile-fuzzy-match + :coerce 'helm-projectile-coerce-file + :action-transformer 'helm-find-files-action-transformer + :keymap helm-projectile-find-file-map + :help-message helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action helm-projectile-file-actions)) + +(defvar helm-source-projectile-files-list + (helm-build-in-buffer-source "Projectile files" + :data (lambda () + (condition-case nil + (projectile-current-project-files) + (error nil))) + :fuzzy-match helm-projectile-fuzzy-match + :coerce 'helm-projectile-coerce-file + :keymap helm-projectile-find-file-map + :help-message 'helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action helm-projectile-file-actions + ) + "Helm source definition for Projectile files.") + +(defvar helm-source-projectile-files-in-all-projects-list + (helm-build-in-buffer-source "Projectile files in all Projects" + :data (lambda () + (condition-case nil + (let ((projectile-require-project-root nil)) + (projectile-all-project-files)) + (error nil))) + :coerce 'helm-projectile-coerce-file + :keymap helm-find-files-map + :help-message 'helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action helm-projectile-file-actions + ) + "Helm source definition for all Projectile files in all projects.") + +(defvar helm-projectile-dired-file-actions + (helm-projectile-hack-actions + helm-projectile-file-actions + ;; New actions + '(helm-projectile-dired-files-delete-action . "Remove entry(s) from Dired buffer `C-c d'"))) + +(defvar helm-source-projectile-dired-files-list + (helm-build-in-buffer-source "Projectile files in current Dired buffer" + :data (lambda () + (condition-case nil + (if (and (file-remote-p (projectile-project-root)) + (not helm-projectile-virtual-dired-remote-enable)) + nil + (let ((default-directory (projectile-project-root))) + (when (eq major-mode 'dired-mode) + (mapcar (lambda (file) + (replace-regexp-in-string default-directory "" file)) + (helm-projectile-files-in-current-dired-buffer))))) + (error nil))) + :coerce 'helm-projectile-coerce-file + :filter-one-by-one (lambda (file) + (let ((default-directory (projectile-project-root))) + (helm-ff-filter-candidate-one-by-one file))) + :action-transformer 'helm-find-files-action-transformer + :keymap (let ((map (copy-keymap helm-projectile-find-file-map))) + (helm-projectile-define-key map + (kbd "C-c d") 'helm-projectile-dired-files-delete-action) + map) + :help-message 'helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action helm-projectile-dired-file-actions) + "Helm source definition for Projectile delete files.") + +(defun helm-projectile-dired-find-dir (dir) + "Jump to a selected directory DIR from helm-projectile." + (dired (expand-file-name dir (projectile-project-root))) + (run-hooks 'projectile-find-dir-hook)) + +(defun helm-projectile-dired-find-dir-other-window (dir) + "Jump to a selected directory DIR from helm-projectile." + (dired-other-window (expand-file-name dir (projectile-project-root))) + (run-hooks 'projectile-find-dir-hook)) + +(defvar helm-source-projectile-directories-list + (helm-build-in-buffer-source "Projectile directories" + :data (lambda () + (condition-case nil + (if projectile-find-dir-includes-top-level + (append '("./") (projectile-current-project-dirs)) + (projectile-current-project-dirs)) + (error nil))) + :fuzzy-match helm-projectile-fuzzy-match + :coerce 'helm-projectile-coerce-file + :action-transformer 'helm-find-files-action-transformer + :keymap (let ((map (make-sparse-keymap))) + (set-keymap-parent map helm-map) + (helm-projectile-define-key map + (kbd "") 'helm-previous-source + (kbd "") 'helm-next-source + (kbd "C-c o") 'helm-projectile-dired-find-dir-other-window + (kbd "M-e") 'helm-projectile-switch-to-eshell + (kbd "C-c f") 'helm-projectile-dired-files-new-action + (kbd "C-c a") 'helm-projectile-dired-files-add-action + (kbd "C-s") 'helm-find-files-grep) + map) + :help-message 'helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action '(("Open Dired" . helm-projectile-dired-find-dir) + ("Open Dired in other window `C-c o'" . helm-projectile-dired-find-dir) + ("Switch to Eshell `M-e'" . helm-projectile-switch-to-eshell) + ("Grep in projects `C-s C-u Recurse'" . helm-find-files-grep) + ("Create Dired buffer from files `C-c f'" . helm-projectile-dired-files-new-action) + ("Add files to Dired buffer `C-c a'" . helm-projectile-dired-files-add-action))) + "Helm source for listing project directories.") + +(defclass helm-source-projectile-buffer (helm-source-sync helm-type-buffer) + ((init :initform (lambda () + ;; Issue #51 Create the list before `helm-buffer' creation. + (setq helm-buffers-list-cache (projectile-project-buffer-names)) + (let ((result (cl-loop for b in helm-buffers-list-cache + maximize (length b) into len-buf + maximize (length (with-current-buffer b + (symbol-name major-mode))) + into len-mode + finally return (cons len-buf len-mode)))) + (unless helm-buffer-max-length + (setq helm-buffer-max-length (car result))) + (unless helm-buffer-max-len-mode + ;; If a new buffer is longer that this value + ;; this value will be updated + (setq helm-buffer-max-len-mode (cdr result)))))) + (candidates :initform helm-buffers-list-cache) + (matchplugin :initform nil) + (match :initform 'helm-buffers-match-function) + (persistent-action :initform 'helm-buffers-list-persistent-action) + (keymap :initform helm-buffer-map) + (volatile :initform t) + (mode-line :initform helm-buffer-mode-line-string) + (persistent-help + :initform + "Show this buffer / C-u \\[helm-execute-persistent-action]: Kill this buffer"))) + +(defvar helm-source-projectile-buffers-list (helm-make-source "Project buffers" 'helm-source-projectile-buffer)) + +(defvar helm-source-projectile-recentf-list + (helm-build-in-buffer-source "Projectile recent files" + :data (lambda () + (condition-case nil + (projectile-recentf-files) + (error nil))) + :fuzzy-match helm-projectile-fuzzy-match + :coerce 'helm-projectile-coerce-file + :keymap helm-projectile-find-file-map + :help-message 'helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action helm-projectile-file-actions + ) + "Helm source definition for recent files in current project.") + +(defvar helm-source-projectile-files-and-dired-list + '(helm-source-projectile-dired-files-list + helm-source-projectile-files-list)) + +(defvar helm-source-projectile-directories-and-dired-list + '(helm-source-projectile-dired-files-list + helm-source-projectile-directories-list)) + +(defcustom helm-projectile-sources-list + '(helm-source-projectile-buffers-list + helm-source-projectile-files-list + helm-source-projectile-projects + ) + "Default sources for `helm-projectile'." + :group 'helm-projectile) + +(defmacro helm-projectile-command (command source prompt &optional not-require-root) + "Template for generic helm-projectile commands. +COMMAND is a command name to be appended with \"helm-projectile\" prefix. +SOURCE is a Helm source that should be Projectile specific. +PROMPT is a string for displaying as a prompt. +NOT-REQUIRE-ROOT specifies the command doesn't need to be used in a +project root." + `(defun ,(intern (concat "helm-projectile-" command)) (&optional arg) + "Use projectile with Helm for finding files in project + +With a prefix ARG invalidates the cache first." + (interactive "P") + (if (projectile-project-p) + (projectile-maybe-invalidate-cache arg) + (unless ,not-require-root + (error "You're not in a project"))) + (let ((helm-ff-transformer-show-only-basename nil) + ;; for consistency, we should just let Projectile take care of ignored files + (helm-boring-file-regexp-list nil)) + (helm :sources ,source + :buffer "*helm projectile*" + :prompt (projectile-prepend-project-name ,prompt))))) + +(helm-projectile-command "switch-project" 'helm-source-projectile-projects "Switch to project: " t) +(helm-projectile-command "find-file" helm-source-projectile-files-and-dired-list "Find file: ") +(helm-projectile-command "find-file-in-known-projects" 'helm-source-projectile-files-in-all-projects-list "Find file in projects: ") +(helm-projectile-command "find-dir" helm-source-projectile-directories-and-dired-list "Find dir: ") +(helm-projectile-command "recentf" 'helm-source-projectile-recentf-list "Recently visited file: ") +(helm-projectile-command "switch-to-buffer" 'helm-source-projectile-buffers-list "Switch to buffer: ") + +;;;###autoload +(defun helm-projectile-find-file-dwim () + "Find file at point based on context." + (interactive) + (let* ((project-files (projectile-current-project-files)) + (files (projectile-select-files project-files))) + (if (= (length files) 1) + (find-file (expand-file-name (car files) (projectile-project-root))) + (helm :sources (helm-projectile-build-dwim-source (if (> (length files) 1) + files + project-files)) + :buffer "*helm projectile*" + :prompt (projectile-prepend-project-name "Find file: "))))) + +;;;###autoload +(defun helm-projectile-find-other-file (&optional flex-matching) + "Switch between files with the same name but different extensions using Helm. +With FLEX-MATCHING, match any file that contains the base name of current file. +Other file extensions can be customized with the variable `projectile-other-file-alist'." + (interactive "P") + (-if-let (other-files (projectile-get-other-files (buffer-file-name) + (projectile-current-project-files) + flex-matching)) + (if (= (length other-files) 1) + (find-file (expand-file-name (car other-files) (projectile-project-root))) + (progn + (let* ((helm-ff-transformer-show-only-basename nil)) + (helm :sources (helm-build-in-buffer-source "Projectile other files" + :data other-files + :coerce 'helm-projectile-coerce-file + :keymap (let ((map (copy-keymap helm-find-files-map))) + (define-key map (kbd "") 'helm-previous-source) + (define-key map (kbd "") 'helm-next-source) + map) + :help-message helm-ff-help-message + :mode-line helm-ff-mode-line-string + :action helm-projectile-file-actions) + :buffer "*helm projectile*" + :prompt (projectile-prepend-project-name "Find other file: "))))) + (error "No other file found"))) + +(defun helm-projectile-grep-or-ack (&optional use-ack-p ack-ignored-pattern ack-executable) + "Perform helm-grep at project root. +USE-ACK-P indicates whether to use ack or not. +ACK-IGNORED-PATTERN is a file regex to exclude from searching. +ACK-EXECUTABLE is the actual ack binary name. +It is usually \"ack\" or \"ack-grep\". +If it is nil, or ack/ack-grep not found then use default grep command." + (let* ((default-directory (projectile-project-root)) + (helm-ff-default-directory (projectile-project-root)) + (follow (and helm-follow-mode-persistent + (assoc-default 'follow helm-source-grep))) + (helm-grep-in-recurse t) + (grep-find-ignored-files (-union (projectile-ignored-files-rel) grep-find-ignored-files)) + (grep-find-ignored-directories (-union (projectile-ignored-directories-rel) grep-find-ignored-directories)) + (helm-grep-default-command (if use-ack-p + (concat ack-executable " -H --no-group --no-color " ack-ignored-pattern " %p %f") + "grep -a -r %e -n%cH -e %p %f .")) + (helm-grep-default-recurse-command helm-grep-default-command) + (helm-source-grep + (helm-build-async-source + (capitalize (helm-grep-command t)) + :header-name (lambda (name) + (let ((name (if use-ack-p + "Helm Projectile Ack" + "Helm Projectile Grep"))) + (concat name " " "(C-c ? Help)"))) + :candidates-process 'helm-grep-collect-candidates + :filter-one-by-one 'helm-grep-filter-one-by-one + :candidate-number-limit 9999 + :nohighlight t + :mode-line helm-grep-mode-line-string + ;; We need to specify keymap here and as :keymap arg [1] + ;; to make it available in further resuming. + :keymap helm-grep-map + :history 'helm-grep-history + :action (helm-make-actions + "Find file" 'helm-grep-action + "Find file other frame" 'helm-grep-other-frame + (lambda () (and (locate-library "elscreen") + "Find file in Elscreen")) + 'helm-grep-jump-elscreen + "Save results in grep buffer" 'helm-grep-save-results + "Find file other window" 'helm-grep-other-window) + :persistent-action 'helm-grep-persistent-action + :persistent-help "Jump to line (`C-u' Record in mark ring)" + :requires-pattern 2))) + (helm + :sources 'helm-source-grep + :input (if (region-active-p) + (buffer-substring-no-properties (region-beginning) (region-end)) + (thing-at-point 'symbol)) + :buffer (format "*helm %s*" (if use-ack-p + "ack" + "grep")) + :default-directory (projectile-project-root) + :keymap helm-grep-map + :history 'helm-grep-history + :truncate-lines t))) + +;;;###autoload +(defun helm-projectile-on () + "Turn on helm-projectile key bindings." + (interactive) + (message "Turn on helm-projectile key bindings") + (helm-projectile-toggle 1)) + +;;;###autoload +(defun helm-projectile-off () + "Turn off helm-projectile key bindings." + (interactive) + (message "Turn off helm-projectile key bindings") + (helm-projectile-toggle -1)) + +;;;###autoload +(defun helm-projectile-grep () + "Helm version of projectile-grep." + (interactive) + (if (projectile-project-p) + (funcall'run-with-timer 0.01 nil + #'helm-projectile-grep-or-ack nil) + (error "You're not in a project"))) + +;;;###autoload +(defun helm-projectile-ack () + "Helm version of projectile-ack." + (interactive) + (if (projectile-project-p) + (let ((ack-ignored (mapconcat + 'identity + (-union (-map (lambda (path) + (concat "--ignore-dir=" (file-name-nondirectory (directory-file-name path)))) + projectile-globally-ignored-directories) + (-map (lambda (path) + (concat "--ignore-file=match:" (shell-quote-argument path))) + projectile-globally-ignored-files)) " ")) + (helm-ack-grep-executable (cond + ((executable-find "ack") "ack") + ((executable-find "ack-grep") "ack-grep") + (t (error "ack or ack-grep is not available."))))) + (funcall 'run-with-timer 0.01 nil + #'helm-projectile-grep-or-ack t ack-ignored helm-ack-grep-executable)) + (error "You're not in a project"))) + +;;;###autoload +(defun helm-projectile-ag (&optional options) + "Helm version of projectile-ag." + (interactive (if current-prefix-arg (list (read-string "option: " "" 'helm-ag-command-history)))) + (unless (executable-find "ag") + (error "ag not available")) + (if (require 'helm-ag nil 'noerror) + (if (projectile-project-p) + (let* ((grep-find-ignored-files (-union projectile-globally-ignored-files grep-find-ignored-files)) + (grep-find-ignored-directories (-union projectile-globally-ignored-directories grep-find-ignored-directories)) + (ignored (mapconcat (lambda (i) + (concat "--ignore " i)) + (append grep-find-ignored-files grep-find-ignored-directories) + " ")) + (helm-ag-command-option options) + (helm-ag-base-command (concat helm-ag-base-command " " ignored))) + (helm-do-ag (projectile-project-root))) + (error "You're not in a project")) + (error "helm-ag not available"))) + +(defun helm-projectile-commander-bindings () + (def-projectile-commander-method ?a + "Run ack on project." + (call-interactively 'helm-projectile-ack)) + + (def-projectile-commander-method ?A + "Find ag on project." + (call-interactively 'helm-projectile-ag)) + + (def-projectile-commander-method ?f + "Find file in project." + (helm-projectile-find-file)) + + (def-projectile-commander-method ?b + "Switch to project buffer." + (helm-projectile-switch-to-buffer)) + + (def-projectile-commander-method ?d + "Find directory in project." + (helm-projectile-find-dir)) + + (def-projectile-commander-method ?g + "Run grep on project." + (helm-projectile-grep)) + + (def-projectile-commander-method ?s + "Switch project." + (helm-projectile-switch-project)) + + (def-projectile-commander-method ?e + "Find recently visited file in project." + (helm-projectile-recentf))) + +(defun helm-projectile-toggle (toggle) + "Toggle Helm version of Projectile commands." + (if (> toggle 0) + (progn + (setq projectile-switch-project-action 'helm-projectile-find-file) + (define-key projectile-command-map (kbd "a") 'helm-projectile-find-other-file) + (define-key projectile-command-map (kbd "f") 'helm-projectile-find-file) + (define-key projectile-command-map (kbd "F") 'helm-projectile-find-file-in-known-projects) + (define-key projectile-command-map (kbd "g") 'helm-projectile-find-file-dwim) + (define-key projectile-command-map (kbd "d") 'helm-projectile-find-dir) + (define-key projectile-command-map (kbd "p") 'helm-projectile-switch-project) + (define-key projectile-command-map (kbd "e") 'helm-projectile-recentf) + (define-key projectile-command-map (kbd "b") 'helm-projectile-switch-to-buffer) + (define-key projectile-command-map (kbd "s g") 'helm-projectile-grep) + (define-key projectile-command-map (kbd "s a") 'helm-projectile-ack) + (define-key projectile-command-map (kbd "s s") 'helm-projectile-ag) + (helm-projectile-commander-bindings)) + (progn + (setq projectile-switch-project-action 'projectile-find-file) + (define-key projectile-command-map (kbd "a") 'projectile-find-other-file) + (define-key projectile-command-map (kbd "f") 'projectile-find-file) + (define-key projectile-command-map (kbd "F") 'projectile-find-file-in-known-projects) + (define-key projectile-command-map (kbd "g") 'helm-projectile-find-file-dwim) + (define-key projectile-command-map (kbd "d") 'projectile-find-dir) + (define-key projectile-command-map (kbd "p") 'projectile-switch-project) + (define-key projectile-command-map (kbd "e") 'projectile-recentf) + (define-key projectile-command-map (kbd "b") 'projectile-switch-to-buffer) + (define-key projectile-command-map (kbd "s g") 'projectile-grep) + (define-key projectile-command-map (kbd "s s") 'projectile-ag) + (projectile-commander-bindings)))) + +;;;###autoload +(defun helm-projectile (&optional arg) + "Use projectile with Helm instead of ido. + +With a prefix ARG invalidates the cache first. +If invoked outside of a project, displays a list of known projects to jump." + (interactive "P") + (if (projectile-project-p) + (projectile-maybe-invalidate-cache arg)) + (let ((helm-ff-transformer-show-only-basename nil) + (src (if (projectile-project-p) + helm-projectile-sources-list + helm-source-projectile-projects))) + (helm :sources src + :buffer "*helm projectile*" + :prompt (projectile-prepend-project-name (if (projectile-project-p) + "pattern: " + "Switch to project: "))))) + +;;;###autoload +(eval-after-load 'projectile + '(progn + (define-key projectile-command-map (kbd "h") 'helm-projectile))) + +(provide 'helm-projectile) + +;;; helm-projectile.el ends here diff --git a/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-autoloads.el b/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-autoloads.el deleted file mode 100644 index d361a8a..0000000 --- a/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-autoloads.el +++ /dev/null @@ -1,36 +0,0 @@ -;;; highlight-indentation-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "highlight-indentation" "highlight-indentation.el" -;;;;;; (21570 28044 0 0)) -;;; Generated autoloads from highlight-indentation.el - -(autoload 'highlight-indentation-mode "highlight-indentation" "\ -Highlight indentation minor mode highlights indentation based -on spaces - -\(fn &optional ARG)" t nil) - -(autoload 'highlight-indentation-set-offset "highlight-indentation" "\ -Set indentation offset localy in buffer, will prevent -highlight-indentation from trying to guess indentation offset -from major mode - -\(fn OFFSET)" t nil) - -(autoload 'highlight-indentation-current-column-mode "highlight-indentation" "\ -Hilight Indentation minor mode displays -a vertical bar corresponding to the indentation of the current line - -\(fn &optional ARG)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; highlight-indentation-autoloads.el ends here diff --git a/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-pkg.el b/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-pkg.el deleted file mode 100644 index bcfdba9..0000000 --- a/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "highlight-indentation" "20131207.835" "Minor modes for highlighting indentation" 'nil :url "https://github.com/antonj/Highlight-Indentation-for-Emacs") diff --git a/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation.el b/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation.el deleted file mode 100644 index 3cd8328..0000000 --- a/emacs.d/elpa/highlight-indentation-20131207.835/highlight-indentation.el +++ /dev/null @@ -1,156 +0,0 @@ -;;; highlight-indentation.el --- Minor modes for highlighting indentation -;; Author: Anton Johansson - http://antonj.se -;; Created: Dec 15 23:42:04 2010 -;; Version: 20131207.835 -;; X-Original-Version: 0.6.0 -;; URL: https://github.com/antonj/Highlight-Indentation-for-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 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. -;; -;;; Commentary: -;; Customize `highlight-indentation-face', and -;; `highlight-indentation-current-column-face' to suit your theme. - -;;; Code: - -(defgroup highlight-indentation nil - "Highlight Indentation" - :prefix "highlight-indentation-" - :group 'basic-faces) - -(defface highlight-indentation-face - ;; Fringe has non intrusive color in most color-themes - '((t :inherit fringe)) - "Basic face for highlighting indentation guides." - :group 'highlight-indentation) - -(defcustom highlight-indentation-offset 4 - "Default indentation offset, used if no other can be found from - major mode. This value is always used by - `highlight-indentation-mode' if set buffer local. Set buffer - local with `highlight-indentation-set-offset'" - :group 'highlight-indentation) - -(defvar highlight-indentation-current-regex nil) - -;;;###autoload -(define-minor-mode highlight-indentation-mode - "Highlight indentation minor mode highlights indentation based -on spaces" - :lighter " ||" - (when highlight-indentation-current-regex ;; OFF - (font-lock-remove-keywords nil `((,highlight-indentation-current-regex - (1 'highlight-indentation-face))))) - - (set (make-local-variable 'highlight-indentation-current-regex) nil) - - (when highlight-indentation-mode ;; ON - (when (not (local-variable-p 'highlight-indentation-offset)) - (set (make-local-variable 'highlight-indentation-offset) - ;; Set indentation offset from highlight-indentation-offset if set, otherwise - ;; according to major mode - (cond ((and (eq major-mode 'python-mode) (boundp 'python-indent)) - python-indent) - ((and (eq major-mode 'python-mode) (boundp 'py-indent-offset)) - py-indent-offset) - ((and (eq major-mode 'python-mode) (boundp 'python-indent-offset)) - python-indent-offset) - ((eq major-mode 'ruby-mode) - ruby-indent-level) - ((and (eq major-mode 'scala-mode) (boundp 'scala-indent:step)) - scala-indent:step) - ((and (eq major-mode 'scala-mode) (boundp 'scala-mode-indent:step)) - scala-mode-indent:step) - ((or (eq major-mode 'scss-mode) (eq major-mode 'css-mode)) - css-indent-offset) - ((eq major-mode 'nxml-mode) - nxml-child-indent) - ((eq major-mode 'coffee-mode) - coffee-tab-width) - ((eq major-mode 'js-mode) - js-indent-level) - ((eq major-mode 'js2-mode) - js2-basic-offset) - ((local-variable-p 'c-basic-offset) - c-basic-offset) - (t - (default-value 'highlight-indentation-offset))))) - (set (make-local-variable 'highlight-indentation-current-regex) - (format "\\( \\) \\{%s\\}" (- highlight-indentation-offset 1))) - (font-lock-add-keywords nil `((,highlight-indentation-current-regex - (1 'highlight-indentation-face))))) - (font-lock-fontify-buffer)) - -;;;###autoload -(defun highlight-indentation-set-offset (offset) - "Set indentation offset localy in buffer, will prevent -highlight-indentation from trying to guess indentation offset -from major mode" - (interactive - (if (and current-prefix-arg (not (consp current-prefix-arg))) - (list (prefix-numeric-value current-prefix-arg)) - (list (read-number "Indentation offset: ")))) - (set (make-local-variable 'highlight-indentation-offset) offset) - (when highlight-indentation-mode - (highlight-indentation-mode))) - - -;;; -;;; Copyright (C) Kresten Krab Thorup -;;; Available under Apache License, Version 2. -;;; -;;; This minor mode will highlight the indentation of the current line -;;; as a vertical bar (grey background color) aligned with the column of the -;;; first character of the current line. -;;; -(defface highlight-indentation-current-column-face - ;; Fringe has non intrusive color in most color-themes - '((t :inherit fringe)) - "Basic face for highlighting indentation guides." - :group 'highlight-indentation) - -;; used to hold the last regex we installed -(defvar highlight-indentation-current-column-regex nil) - -;;;###autoload -(define-minor-mode - highlight-indentation-current-column-mode - "Hilight Indentation minor mode displays -a vertical bar corresponding to the indentation of the current line" - :lighter " |" - - (when highlight-indentation-current-column-regex - (font-lock-remove-keywords nil highlight-indentation-current-column-regex)) - - (set (make-local-variable 'highlight-indentation-current-column-regex) nil) - (cond (highlight-indentation-current-column-mode - (add-hook 'post-command-hook 'highlight-indentation-current-column-post-command-hook nil t)) - (t - (remove-hook 'post-command-hook 'highlight-indentation-current-column-post-command-hook t) - - (font-lock-fontify-buffer)))) - -(defun highlight-indentation-current-column-post-command-hook () - "This hook runs after every keystroke" - (when highlight-indentation-current-column-regex - (font-lock-remove-keywords nil highlight-indentation-current-column-regex)) - (let ((indent (save-excursion (back-to-indentation) (current-column)))) - (when (and highlight-indentation-current-column-mode - (> indent 1)) - (let* ((re (format "^ \\{%d\\}\\( \\)" indent)) - (arg `((,re (1 'highlight-indentation-current-column-face prepend))))) - (set (make-local-variable 'highlight-indentation-current-column-regex) arg) - (font-lock-add-keywords nil arg)))) - (font-lock-fontify-buffer)) - -(provide 'highlight-indentation) - -;;; highlight-indentation.el ends here diff --git a/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-autoloads.el b/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-autoloads.el new file mode 100644 index 0000000..b5f1dce --- /dev/null +++ b/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-autoloads.el @@ -0,0 +1,35 @@ +;;; highlight-indentation-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "highlight-indentation" "highlight-indentation.el" +;;;;;; (21837 24207 0 0)) +;;; Generated autoloads from highlight-indentation.el + +(autoload 'highlight-indentation-mode "highlight-indentation" "\ +Highlight indentation minor mode highlights indentation based on spaces + +\(fn &optional ARG)" t nil) + +(autoload 'highlight-indentation-set-offset "highlight-indentation" "\ +Set indentation offset localy in buffer, will prevent +highlight-indentation from trying to guess indentation offset +from major mode + +\(fn OFFSET)" t nil) + +(autoload 'highlight-indentation-current-column-mode "highlight-indentation" "\ +Hilight Indentation minor mode displays a vertical bar +corresponding to the indentation of the current line + +\(fn &optional ARG)" t nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; highlight-indentation-autoloads.el ends here diff --git a/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-pkg.el b/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-pkg.el new file mode 100644 index 0000000..8c5a634 --- /dev/null +++ b/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation-pkg.el @@ -0,0 +1 @@ +(define-package "highlight-indentation" "20150307.208" "Minor modes for highlighting indentation" 'nil :url "https://github.com/antonj/Highlight-Indentation-for-Emacs") diff --git a/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation.el b/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation.el new file mode 100644 index 0000000..b26d718 --- /dev/null +++ b/emacs.d/elpa/highlight-indentation-20150307.208/highlight-indentation.el @@ -0,0 +1,244 @@ +;;; highlight-indentation.el --- Minor modes for highlighting indentation +;; Author: Anton Johansson - http://antonj.se +;; Created: Dec 15 23:42:04 2010 +;; Version: 0.7.0 +;; Package-Version: 20150307.208 +;; URL: https://github.com/antonj/Highlight-Indentation-for-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 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. +;; +;;; Commentary: +;; Customize `highlight-indentation-face', and +;; `highlight-indentation-current-column-face' to suit your theme. + +;;; Code: + +(defgroup highlight-indentation nil + "Highlight Indentation" + :prefix "highlight-indentation-" + :group 'basic-faces) + +(defface highlight-indentation-face + ;; Fringe has non intrusive color in most color-themes + '((t :inherit fringe)) + "Basic face for highlighting indentation guides." + :group 'highlight-indentation) + +(defcustom highlight-indentation-offset 4 + "Default indentation offset, used if no other can be found from + major mode. This value is always used by + `highlight-indentation-mode' if set buffer local. Set buffer + local with `highlight-indentation-set-offset'" + :group 'highlight-indentation) + +(defconst highlight-indentation-hooks + '((after-change-functions (lambda (start end length) + (highlight-indentation-redraw-region + start end + 'highlight-indentation-overlay + 'highlight-indentation-put-overlays-region)) + t t) + (window-scroll-functions (lambda (win start) + (highlight-indentation-redraw-window + win + 'highlight-indentation-overlay + 'highlight-indentation-put-overlays-region + start)) + nil t))) + +(defun highlight-indentation-get-buffer-windows (&optional all-frames) + "Return a list of windows displaying the current buffer." + (get-buffer-window-list (current-buffer) 'no-minibuf all-frames)) + +(defun highlight-indentation-delete-overlays-buffer (overlay) + "Delete all overlays in the current buffer." + (save-restriction + (widen) + (highlight-indentation-delete-overlays-region (point-min) (point-max) overlay))) + +(defun highlight-indentation-delete-overlays-region (start end overlay) + "Delete overlays between START and END." + (mapc #'(lambda (o) + (if (overlay-get o overlay) (delete-overlay o))) + (overlays-in start end))) + +(defun highlight-indentation-redraw-window (win overlay func &optional start) + "Redraw win starting from START." + (highlight-indentation-redraw-region (or start (window-start win)) (window-end win t) overlay func)) + +(defun highlight-indentation-redraw-region (start end overlay func) + "Erease and read overlays between START and END." + (save-match-data + (save-excursion + (let ((inhibit-point-motion-hooks t) + (end (save-excursion (goto-char end) (line-beginning-position 2)))) + (highlight-indentation-delete-overlays-region start end overlay) + (funcall func start end overlay))))) + +(defun highlight-indentation-redraw-all-windows (overlay func &optional all-frames) + "Redraw the all windows showing the current buffer." + (dolist (win (highlight-indentation-get-buffer-windows all-frames)) + (highlight-indentation-redraw-window win overlay func))) + +(defun highlight-indentation-put-overlays-region (start end overlay) + "Place overlays between START and END." + (goto-char start) + (let (o ;; overlay + (last-indent 0) + (pos start)) + (while (< pos end) + (beginning-of-line) + (while (and (integerp (char-after)) + (not (= 10 (char-after))) ;; newline + (= 32 (char-after))) ;; space + (when (= 0 (% (current-column) highlight-indentation-offset)) + (setq pos (point) + last-indent pos + o (make-overlay pos (+ pos 1))) + (overlay-put o overlay t) + (overlay-put o 'priority highlight-indentation-overlay-priority) + (overlay-put o 'face 'highlight-indentation-face)) + (forward-char)) + (forward-line) ;; Next line + (setq pos (point))))) + +(defun highlight-indentation-guess-offset () + "Get indentation offset of current buffer" + (cond ((and (eq major-mode 'python-mode) (boundp 'python-indent)) + python-indent) + ((and (eq major-mode 'python-mode) (boundp 'py-indent-offset)) + py-indent-offset) + ((and (eq major-mode 'python-mode) (boundp 'python-indent-offset)) + python-indent-offset) + ((eq major-mode 'ruby-mode) + ruby-indent-level) + ((and (eq major-mode 'scala-mode) (boundp 'scala-indent:step)) + scala-indent:step) + ((and (eq major-mode 'scala-mode) (boundp 'scala-mode-indent:step)) + scala-mode-indent:step) + ((or (eq major-mode 'scss-mode) (eq major-mode 'css-mode)) + css-indent-offset) + ((eq major-mode 'nxml-mode) + nxml-child-indent) + ((eq major-mode 'coffee-mode) + coffee-tab-width) + ((eq major-mode 'js-mode) + js-indent-level) + ((eq major-mode 'js2-mode) + js2-basic-offset) + ((and (fboundp 'derived-mode-class) (eq (derived-mode-class major-mode) 'sws-mode)) + sws-tab-width) + ((eq major-mode 'web-mode) + web-mode-html-offset) ; other similar vars: web-mode-{css-indent,scripts}-offset + ((local-variable-p 'c-basic-offset) + c-basic-offset) + (t + (default-value 'highlight-indentation-offset)))) + +;;;###autoload +(define-minor-mode highlight-indentation-mode + "Highlight indentation minor mode highlights indentation based on spaces" + :lighter " ||" + (when (not highlight-indentation-mode) ;; OFF + (highlight-indentation-delete-overlays-buffer 'highlight-indentation-overlay) + (dolist (hook highlight-indentation-hooks) + (remove-hook (car hook) (nth 1 hook) (nth 3 hook)))) + + (when highlight-indentation-mode ;; ON + (when (not (local-variable-p 'highlight-indentation-offset)) + (set (make-local-variable 'highlight-indentation-offset) + (highlight-indentation-guess-offset))) + + ;; Setup hooks + (dolist (hook highlight-indentation-hooks) + (apply 'add-hook hook)) + (highlight-indentation-redraw-all-windows 'highlight-indentation-overlay + 'highlight-indentation-put-overlays-region))) + +;;;###autoload +(defun highlight-indentation-set-offset (offset) + "Set indentation offset localy in buffer, will prevent +highlight-indentation from trying to guess indentation offset +from major mode" + (interactive + (if (and current-prefix-arg (not (consp current-prefix-arg))) + (list (prefix-numeric-value current-prefix-arg)) + (list (read-number "Indentation offset: ")))) + (set (make-local-variable 'highlight-indentation-offset) offset) + (when highlight-indentation-mode + (highlight-indentation-mode))) + +;;; This minor mode will highlight the indentation of the current line +;;; as a vertical bar (grey background color) aligned with the column of the +;;; first character of the current line. +(defface highlight-indentation-current-column-face + ;; Fringe has non intrusive color in most color-themes + '((t (:background "black"))) + "Basic face for highlighting indentation guides." + :group 'highlight-indentation) + +(defvar highlight-indentation-overlay-priority 1) +(defvar highlight-indentation-current-column-overlay-priority 2) + +(defconst highlight-indentation-current-column-hooks + '((post-command-hook (lambda () + (highlight-indentation-redraw-all-windows 'highlight-indentation-current-column-overlay + 'highlight-indentation-current-column-put-overlays-region)) nil t))) + +(defun highlight-indentation-current-column-put-overlays-region (start end overlay) + "Place overlays between START and END." + (let (o ;; overlay + (last-indent 0) + (indent (save-excursion (back-to-indentation) (current-column))) + (pos start)) + (goto-char start) + ;; (message "doing it %d" indent) + (while (< pos end) + (beginning-of-line) + (while (and (integerp (char-after)) + (not (= 10 (char-after))) ;; newline + (= 32 (char-after))) ;; space + (when (= (current-column) indent) + (setq pos (point) + last-indent pos + o (make-overlay pos (+ pos 1))) + (overlay-put o overlay t) + (overlay-put o 'priority highlight-indentation-current-column-overlay-priority) + (overlay-put o 'face 'highlight-indentation-current-column-face)) + (forward-char)) + (forward-line) ;; Next line + (setq pos (point))))) + +;;;###autoload +(define-minor-mode highlight-indentation-current-column-mode + "Hilight Indentation minor mode displays a vertical bar +corresponding to the indentation of the current line" + :lighter " |" + + (when (not highlight-indentation-current-column-mode) ;; OFF + (highlight-indentation-delete-overlays-buffer 'highlight-indentation-current-column-overlay) + (dolist (hook highlight-indentation-current-column-hooks) + (remove-hook (car hook) (nth 1 hook) (nth 3 hook)))) + + (when highlight-indentation-current-column-mode ;; ON + (when (not (local-variable-p 'highlight-indentation-offset)) + (set (make-local-variable 'highlight-indentation-offset) + (highlight-indentation-guess-offset))) + + ;; Setup hooks + (dolist (hook highlight-indentation-current-column-hooks) + (apply 'add-hook hook)) + (highlight-indentation-redraw-all-windows 'highlight-indentation-current-column-overlay + 'highlight-indentation-current-column-put-overlays-region))) + +(provide 'highlight-indentation) + +;;; highlight-indentation.el ends here diff --git a/emacs.d/elpa/idomenu-20111122.1048/idomenu-autoloads.el b/emacs.d/elpa/idomenu-20111122.1048/idomenu-autoloads.el deleted file mode 100644 index 8078e24..0000000 --- a/emacs.d/elpa/idomenu-20111122.1048/idomenu-autoloads.el +++ /dev/null @@ -1,21 +0,0 @@ -;;; idomenu-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "idomenu" "idomenu.el" (21570 28044 0 0)) -;;; Generated autoloads from idomenu.el - -(autoload 'idomenu "idomenu" "\ -Switch to a buffer-local tag from Imenu via Ido. - -\(fn)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; idomenu-autoloads.el ends here diff --git a/emacs.d/elpa/idomenu-20111122.1048/idomenu-pkg.el b/emacs.d/elpa/idomenu-20111122.1048/idomenu-pkg.el deleted file mode 100644 index 812a2b0..0000000 --- a/emacs.d/elpa/idomenu-20111122.1048/idomenu-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "idomenu" "20111122.1048" "imenu tag selection a la ido" 'nil) diff --git a/emacs.d/elpa/idomenu-20111122.1048/idomenu.el b/emacs.d/elpa/idomenu-20111122.1048/idomenu.el deleted file mode 100644 index 380d115..0000000 --- a/emacs.d/elpa/idomenu-20111122.1048/idomenu.el +++ /dev/null @@ -1,83 +0,0 @@ -;;; idomenu.el --- imenu tag selection a la ido -;; -;; Copyright (C) 2010 Georg Brandl -;; -;; Author: Georg Brandl -;; Version: 20111122.1048 -;; X-Original-Version: 0.1 -;; -;; 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 -;; of the License, or (at your option) any later version. -;; -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . -;; -;;; Commentary: -;; -;; This package provides the `idomenu' command for selecting an imenu tag using -;; ido completion. The buffer needs to have support for imenu already enabled. -;; -;; Add something like the following to your .emacs: -;; -;; (autoload 'idomenu "idomenu" nil t) -;; -;;; Code: - -(require 'ido) -(require 'imenu) - -(defun idomenu--guess-default (index-alist symbol) - "Guess a default choice from the given symbol." - (catch 'found - (let ((regex (concat "\\_<" (regexp-quote symbol) "\\_>"))) - (dolist (item index-alist) - (if (string-match regex (car item)) (throw 'found (car item))))))) - -(defun idomenu--read (index-alist &optional prompt guess) - "Read a choice from an Imenu alist via Ido." - (let* ((symatpt (thing-at-point 'symbol)) - (default (and guess symatpt (idomenu--guess-default index-alist symatpt))) - (names (mapcar 'car index-alist)) - (name (ido-completing-read (or prompt "imenu ") names - nil t nil nil default)) - (choice (assoc name index-alist))) - (if (imenu--subalist-p choice) - (idomenu--read (cdr choice) prompt nil) - choice))) - -(defun idomenu--trim (str) - "Trim leading and tailing whitespace from STR." - (let ((s (if (symbolp str) (symbol-name str) str))) - (replace-regexp-in-string "\\(^[[:space:]\n]*\\|[[:space:]\n]*$\\)" "" s))) - -(defun idomenu--trim-alist (index-alist) - "There must be a better way to apply a function to all cars of an alist" - (mapcar (lambda (pair) (cons (idomenu--trim (car pair)) (cdr pair))) - index-alist)) - -;;;###autoload -(defun idomenu () - "Switch to a buffer-local tag from Imenu via Ido." - (interactive) - ;; ido initialization - (ido-init-completion-maps) - (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) - (add-hook 'choose-completion-string-functions 'ido-choose-completion-string) - (add-hook 'kill-emacs-hook 'ido-kill-emacs-hook) - ;; set up ido completion list - (let ((index-alist (cdr (imenu--make-index-alist)))) - (if (equal index-alist '(nil)) - (message "No imenu tags in buffer") - (imenu (idomenu--read (idomenu--trim-alist index-alist) nil t))))) - -(provide 'idomenu) -;;; idomenu.el ends here diff --git a/emacs.d/elpa/idomenu-20141123.1320/idomenu-autoloads.el b/emacs.d/elpa/idomenu-20141123.1320/idomenu-autoloads.el new file mode 100644 index 0000000..3dd6a9e --- /dev/null +++ b/emacs.d/elpa/idomenu-20141123.1320/idomenu-autoloads.el @@ -0,0 +1,21 @@ +;;; idomenu-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "idomenu" "idomenu.el" (21837 24207 0 0)) +;;; Generated autoloads from idomenu.el + +(autoload 'idomenu "idomenu" "\ +Switch to a buffer-local tag from Imenu via Ido. + +\(fn)" t nil) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; idomenu-autoloads.el ends here diff --git a/emacs.d/elpa/idomenu-20141123.1320/idomenu-pkg.el b/emacs.d/elpa/idomenu-20141123.1320/idomenu-pkg.el new file mode 100644 index 0000000..176593d --- /dev/null +++ b/emacs.d/elpa/idomenu-20141123.1320/idomenu-pkg.el @@ -0,0 +1 @@ +(define-package "idomenu" "20141123.1320" "imenu tag selection a la ido" 'nil) diff --git a/emacs.d/elpa/idomenu-20141123.1320/idomenu.el b/emacs.d/elpa/idomenu-20141123.1320/idomenu.el new file mode 100644 index 0000000..71aee83 --- /dev/null +++ b/emacs.d/elpa/idomenu-20141123.1320/idomenu.el @@ -0,0 +1,83 @@ +;;; idomenu.el --- imenu tag selection a la ido +;; +;; Copyright (C) 2010 Georg Brandl +;; +;; Author: Georg Brandl +;; Version: 0.1 +;; Package-Version: 20141123.1320 +;; +;; 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 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;; +;; This package provides the `idomenu' command for selecting an imenu tag using +;; ido completion. The buffer needs to have support for imenu already enabled. +;; +;; Add something like the following to your .emacs: +;; +;; (autoload 'idomenu "idomenu" nil t) +;; +;;; Code: + +(require 'ido) +(require 'imenu) + +(defun idomenu--guess-default (index-alist symbol) + "Guess a default choice from the given symbol." + (catch 'found + (let ((regex (concat "\\_<" (regexp-quote symbol) "\\_>"))) + (dolist (item index-alist) + (if (string-match regex (car item)) (throw 'found (car item))))))) + +(defun idomenu--read (index-alist &optional prompt guess) + "Read a choice from an Imenu alist via Ido." + (let* ((symatpt (thing-at-point 'symbol)) + (default (and guess symatpt (idomenu--guess-default index-alist symatpt))) + (names (mapcar 'car index-alist)) + (name (ido-completing-read (or prompt "imenu ") names + nil t nil nil default)) + (choice (assoc name index-alist))) + (if (imenu--subalist-p choice) + (idomenu--read (cdr choice) prompt nil) + choice))) + +(defun idomenu--trim (str) + "Trim leading and tailing whitespace from STR." + (let ((s (if (symbolp str) (symbol-name str) str))) + (replace-regexp-in-string "\\(^[[:space:]\n]*\\|[[:space:]\n]*$\\)" "" s))) + +(defun idomenu--trim-alist (index-alist) + "There must be a better way to apply a function to all cars of an alist" + (mapcar (lambda (pair) (cons (idomenu--trim (car pair)) (cdr pair))) + index-alist)) + +;;;###autoload +(defun idomenu () + "Switch to a buffer-local tag from Imenu via Ido." + (interactive) + ;; ido initialization + (ido-init-completion-maps) + (add-hook 'minibuffer-setup-hook 'ido-minibuffer-setup) + (add-hook 'choose-completion-string-functions 'ido-choose-completion-string) + (add-hook 'kill-emacs-hook 'ido-kill-emacs-hook) + ;; set up ido completion list + (let ((index-alist (cdr (imenu--make-index-alist)))) + (if (equal index-alist '(nil)) + (message "No imenu tags in buffer") + (imenu (idomenu--read (idomenu--trim-alist index-alist) nil t))))) + +(provide 'idomenu) +;;; idomenu.el ends here diff --git a/emacs.d/elpa/jedi-20140321.1323/Makefile b/emacs.d/elpa/jedi-20140321.1323/Makefile deleted file mode 100644 index 8499d32..0000000 --- a/emacs.d/elpa/jedi-20140321.1323/Makefile +++ /dev/null @@ -1,201 +0,0 @@ -ENV = env - -VIRTUALENV_SYSTEM_SITE_PACKAGES ?= true -VIRTUALENV = \ - VIRTUALENV_SYSTEM_SITE_PACKAGES=$(VIRTUALENV_SYSTEM_SITE_PACKAGES) \ - virtualenv --python=$(PYTHON) -PIP_INSTALL = $(ENV)/$(BINDIR)/pip install -JEDI_DEV_URL = https://github.com/davidhalter/jedi/archive/dev.zip - -PYTHON ?= python -CASK ?= cask -export EMACS ?= emacs - -BINDIR ?= bin - -ELPA_DIR = \ - .cask/$(shell ${EMACS} -Q --batch --eval '(princ emacs-version)')/elpa -# See: cask-elpa-dir - -VIRTUAL_EMACS = ${CASK} exec ${EMACS} -Q \ ---eval "(setq python-environment--verbose t)" \ ---eval "(setq jedi:environment-root \"$(PWD)/$(ENV)\")" - -.PHONY : test test-1 tryout clean-elpa requirements env clean-env clean \ - print-deps travis-ci doc - -TEST_DEPS = elpa env -test: ${TEST_DEPS} - ${MAKE} test-1 - -test-1: - ${VIRTUAL_EMACS} -batch \ - -L . -l test-jedi.el -f ert-run-tests-batch-and-exit - tox - -compile: elpa clean-elc - ${VIRTUAL_EMACS} -batch \ - -L . -f batch-byte-compile *.el - -clean-elc: - rm -rf *.elc - -tryout: compile env - ${VIRTUAL_EMACS} -L . -l tryout-jedi.el - -doc: elpa - make -C doc html - -ensure-git: - test -d .git # Running task that can be run only in git repository - -elpa: ${ELPA_DIR} -${ELPA_DIR}: Cask - ${CASK} install - test -d $@ - touch $@ - - -clean-elpa: - rm -rf ${ELPA_DIR} - -requirements: - @echo "**************************************************************" - @echo " ERROR: \"make requirements\" is obsolete!" - @echo " Please run \"M-x jedi:install-server\" inside of your Emacs." - @echo " * If you are using el-get, please update it first." - @echo " See also: https://github.com/dimitri/el-get/pull/1603" - @echo "**************************************************************" - @exit 1 - -install-jedi-dev: - ${PIP_INSTALL} --upgrade ${JEDI_DEV_URL} - -env: $(ENV)/$(BINDIR)/jediepcserver -$(ENV)/$(BINDIR)/jediepcserver: ${ELPA_DIR} jediepcserver.py setup.py - ${VIRTUAL_EMACS} -batch -l jedi.el -f "jedi:install-server-block" - test -f $@ - -clean-env: - rm -rf $(ENV) - -clean-el: clean-elpa clean-elc -clean: clean-env clean-el - rm -rf .cask - -print-deps: elpa env - @echo "----------------------- Dependencies -----------------------" - $(EMACS) --version - ${VIRTUAL_EMACS} -batch -l jedi.el -f jedi:print-jedi-version - ls -d $(ENV)/*/python*/site-packages/*egg-info - @echo "------------------------------------------------------------" - -before-test: ${TEST_DEPS} - tox --notest - -travis-ci: print-deps test - test ! -d ~/.emacs.d/.python-environments - - - -# Run test against Emacs listed in ${EMACS_LIST}. -# This is for running tests for multiple Emacs versions. -# This is not used in Travis CI. Usage:: -# -# make EMACS_LIST="emacs emacs-snapshot emacs23" test-all -# -# See: http://stackoverflow.com/a/12110773/727827 -# -# Use ${MET_MAKEFLAGS} to do the tests in parallel. -# -# MET_MAKEFLAGS=-j4 - -JOBS := $(addprefix job-,${EMACS_LIST}) -.PHONY: ${JOBS} - -${JOBS}: job-%: - ${MAKE} EMACS=$* clean-elc elpa - ${MAKE} EMACS=$* ${MET_MAKEFLAGS} test-1 - -test-all: env ${JOBS} - - - -### Packaging -# -# Create dist/${PACKAGE}-${VERSION}.tar.gz ready for distribution. -# -# See: (info "(elisp) Multi-file Packages") -PACKAGE = jedi -VERSION = $(shell grep ';; Version:' jedi.el | sed 's/^.* \([0-9].*\)$$/\1/') -DIST_FILES = jedi-pkg.el jedi.el jediepcserver.py \ - Makefile tryout-jedi.el - -.PHONY: dist ${PACKAGE}-${VERSION}.tar.gz ${PACKAGE}-${VERSION} \ - clean-dist clean-dist-all - -dist: clean-dist - ${MAKE} dist-1 - -dist-1: dist/${PACKAGE}-${VERSION}.tar dist/${PACKAGE}-${VERSION}.tar.gz - -dist/${PACKAGE}-${VERSION}.tar: ${PACKAGE}-${VERSION}.tar -${PACKAGE}-${VERSION}.tar: ${PACKAGE}-${VERSION} - tar --directory dist -cvf dist/$@ $< - -dist/${PACKAGE}-${VERSION}.tar.gz: ${PACKAGE}-${VERSION}.tar.gz -${PACKAGE}-${VERSION}.tar.gz: ${PACKAGE}-${VERSION} - tar --directory dist -cvzf dist/$@ $< - -${PACKAGE}-${VERSION}: dist/${PACKAGE}-${VERSION} -dist/${PACKAGE}-${VERSION}: - mkdir -p $@ - cp -v ${DIST_FILES} $@ - -clean-dist: - rm -rf dist/${PACKAGE}-${VERSION}* - -clean-dist-all: - rm -rf dist - - - -### Package installation -PACKAGE_USER_DIR = -TEST_PACKAGE_DIR = dist/test - -install-dist: - test -d '${PACKAGE_USER_DIR}' - ${EMACS} --batch -Q \ - -l package \ - --eval " \ - (add-to-list 'package-archives \ - '(\"marmalade\" . \"http://marmalade-repo.org/packages/\") t)" \ - --eval '(setq package-user-dir "${PWD}/${PACKAGE_USER_DIR}")' \ - --eval '(package-list-packages)' \ - --eval '(package-install-file "${PWD}/dist/${PACKAGE}-${VERSION}.tar")' - -test-install: dist/${PACKAGE}-${VERSION}.tar - rm -rf ${TEST_PACKAGE_DIR} - mkdir -p ${TEST_PACKAGE_DIR} - ${MAKE} install-dist PACKAGE_USER_DIR=${TEST_PACKAGE_DIR} - -test-install-requirement: test-install - ${MAKE} --directory ${TEST_PACKAGE_DIR}/${PACKAGE}-${VERSION} \ - requirements - - - -### GH pages -MAKE_GH_PAGES = $(MAKE) --directory doc --file gh-pages.mk - -gh-pages-latest: - $(MAKE_GH_PAGES) - -# Publish released documentation. This task can be run only when the -# current revision has tag (i.e., released). -gh-pages-released: - # Make sure it's on tag - git describe --tags --dirty | grep -v - - # Run doc/gh-pages.mk - $(MAKE_GH_PAGES) DOC_VER=released diff --git a/emacs.d/elpa/jedi-20140321.1323/jedi-autoloads.el b/emacs.d/elpa/jedi-20140321.1323/jedi-autoloads.el deleted file mode 100644 index b358ba1..0000000 --- a/emacs.d/elpa/jedi-20140321.1323/jedi-autoloads.el +++ /dev/null @@ -1,125 +0,0 @@ -;;; jedi-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "jedi" "jedi.el" (21571 44958 0 0)) -;;; Generated autoloads from jedi.el - -(autoload 'jedi:start-dedicated-server "jedi" "\ -Start Jedi server dedicated to this buffer. -This is useful, for example, when you want to use different -`sys.path' for some buffer. When invoked as an interactive -command, it asks you how to start the Jedi server. You can edit -the command in minibuffer to specify the way Jedi server run. - -If you want to setup how Jedi server is started programmatically -per-buffer/per-project basis, make `jedi:server-command' and -`jedi:server-args' buffer local and set it in `python-mode-hook'. -See also: `jedi:server-args'. - -\(fn COMMAND)" t nil) - -(autoload 'jedi:complete "jedi" "\ -Complete code at point. - -\(fn &key (expand ac-expand-on-auto-complete))" t nil) - -(autoload 'jedi:ac-setup "jedi" "\ -Add Jedi AC sources to `ac-sources'. - -If auto-completion is all you need, you can call this function instead -of `jedi:setup', like this:: - - (add-hook 'python-mode-hook 'jedi:ac-setup) - -Note that this function calls `auto-complete-mode' if it is not -already enabled, for people who don't call `global-auto-complete-mode' -in their Emacs configuration. - -\(fn)" t nil) - -(autoload 'helm-jedi-related-names "jedi" "\ -Find related names of the object at point using `helm' interface. - -\(fn)" t nil) - -(autoload 'anything-jedi-related-names "jedi" "\ -Find related names of the object at point using `anything' interface. - -\(fn)" t nil) - -(autoload 'jedi:setup "jedi" "\ -Fully setup jedi.el for current buffer. -It setups `ac-sources' (calls `jedi:ac-setup') and turns -`jedi-mode' on. - -This function is intended to be called from `python-mode-hook', -like this:: - - (add-hook 'python-mode-hook 'jedi:setup) - -You can also call this function as a command, to quickly test -what jedi can do. - -\(fn)" t nil) - -(autoload 'jedi:install-server "jedi" "\ -This command installs Jedi server script jediepcserver.py in a -Python environment dedicated to Emacs. By default, the -environment is at ``~/.emacs.d/.python-environments/default/``. -This environment is automatically created by ``virtualenv`` if it -does not exist. - -Run this command (i.e., type ``M-x jedi:install-server RET``) -whenever Jedi.el shows a message to do so. It is a good idea to -run this every time after you update Jedi.el to sync version of -Python modules used by Jedi.el and Jedi.el itself. - -You can modify the location of the environment by changing -`jedi:environment-root' and/or `python-environment-directory'. More -specifically, Jedi.el will install Python modules under the directory -``PYTHON-ENVIRONMENT-DIRECTORY/JEDI:ENVIRONMENT-ROOT``. Note that you -need command line program ``virtualenv``. If you have the command in -an unusual location, use `python-environment-virtualenv' to specify the -location. - -.. NOTE:: jediepcserver.py is installed in a virtual environment but it - does not mean Jedi.el cannot recognize the modules in virtual - environment you are using for your Python development. Jedi - EPC server recognize the virtualenv it is in (i.e., the - environment variable ``VIRTUAL_ENV`` in your Emacs) and then - add modules in that environment to its ``sys.path``. You can - also add ``--virtual-env PATH/TO/ENV`` to `jedi:server-args' - to include modules of virtual environment even you launch - Emacs outside of the virtual environment. - -.. NOTE:: It is highly recommended to use this command to install - Python modules for Jedi.el. You still can install Python - modules used by Jedi.el manually. However, you are then - responsible for keeping Jedi.el and Python modules compatible. - -See also: - -- https://github.com/tkf/emacs-jedi/pull/72 -- https://github.com/tkf/emacs-jedi/issues/140#issuecomment-37358527 - -\(fn)" t nil) - -(autoload 'jedi:install-server-block "jedi" "\ -Blocking version `jedi:install-server'. - -\(fn)" nil nil) - -;;;*** - -;;;### (autoloads nil nil ("jedi-pkg.el") (21571 44958 323059 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; jedi-autoloads.el ends here diff --git a/emacs.d/elpa/jedi-20140321.1323/jedi-pkg.el b/emacs.d/elpa/jedi-20140321.1323/jedi-pkg.el deleted file mode 100644 index 8a82be7..0000000 --- a/emacs.d/elpa/jedi-20140321.1323/jedi-pkg.el +++ /dev/null @@ -1,7 +0,0 @@ -(define-package "jedi" "20140321.1323" "Python auto-completion for Emacs" - '((epc "0.1.0") - (auto-complete "1.4") - (python-environment "0.0.2"))) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/jedi-20140321.1323/jedi.el b/emacs.d/elpa/jedi-20140321.1323/jedi.el deleted file mode 100644 index 3cba7bd..0000000 --- a/emacs.d/elpa/jedi-20140321.1323/jedi.el +++ /dev/null @@ -1,1352 +0,0 @@ -;;; jedi.el --- a Python auto-completion for Emacs - -;; Copyright (C) 2012 Takafumi Arakaki - -;; Author: Takafumi Arakaki -;; Package-Requires: ((epc "0.1.0") (auto-complete "1.4") (python-environment "0.0.2")) -;; Version: 0.2.0alpha2 - -;; This file is NOT part of GNU Emacs. - -;; jedi.el is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; jedi.el is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with jedi.el. -;; If not, see . - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) -(require 'ring) - -(require 'epc) -(require 'auto-complete) -(require 'python-environment) -(declare-function pos-tip-show "pos-tip") - - -(defgroup jedi nil - "Auto-completion for Python." - :group 'completion - :prefix "jedi:") - -(defconst jedi:version "0.2.0alpha2") - -(defvar jedi:source-dir (if load-file-name - (file-name-directory load-file-name) - default-directory)) - -(defvar jedi:epc nil) -(make-variable-buffer-local 'jedi:epc) - -(defvar jedi:server-script - (convert-standard-filename - (expand-file-name "jediepcserver.py" jedi:source-dir)) - "Full path to Jedi server script file ``jediepcserver.py``.") - - -;;; Configuration variables - -(defcustom jedi:environment-root nil - "Name of Python environment to use. -If it is nil, `python-environment-default-root-name' is used. - -You can specify a full path instead of a name (relative path). -In that case, `python-environment-directory' is ignored and -Python virtual environment is created at the specified path." - :group 'jedi) - -(defcustom jedi:environment-virtualenv nil - "``virtualenv`` command to use. A list of string. -If it is nil, `python-environment-virtualenv' is used instead. - -You must set non-`nil' value to `jedi:environment-root' in order -to make this setting work." - :group 'jedi) - -(defun jedi:-env-server-command () - (let* ((getbin (lambda (x) (python-environment-bin x jedi:environment-root))) - (script (or (funcall getbin "jediepcserver") - (funcall getbin "jediepcserver.py")))) - (when script - (list script)))) - -(defcustom jedi:server-command - (or (jedi:-env-server-command) - (list "python" jedi:server-script)) - "Command used to run Jedi server. - -.. NOTE:: - - If you used `jedi:install-server' (recommended) to install - Python server jediepcserver.py, you don't need to mess around - with jediepcserver.py. Jedi.el handles everything - automatically. - -If you install Python server jediepcserver.py using -`jedi:install-server' command, `jedi:server-command' should be -automatically set to:: - - '(\"~/.emacs.d/.python-environments/default/bin/jediepcserver.py\") - -Otherwise, it is set to:: - - '(\"python\" \"JEDI:SOURCE-DIR/jediepcserver.py\") - -.. NOTE:: If you installed jediepcserver.py manually, then you - have to set `jedi:server-command' appropriately. - - If you can run ``jediepcserver.py --help`` in your shell, then - you can simply set:: - - (setq jedi:server-command '(\"jediepcserver.py\")) - - Otherwise, you need to find where you installed - jediepcserver.py then set the path directly:: - - (setq jedi:server-command '(\"PATH/TO/jediepcserver.py\")) - -If you want to use a specific version of Python, setup -`jedi:environment-virtualenv' variable appropriately and -reinstall jediepcserver.py. - -If you want to pass some arguments to the Jedi server command, -use `jedi:server-args' instead of appending them -`jedi:server-command'." - :group 'jedi) - -(defcustom jedi:server-args nil - "Command line arguments to be appended to `jedi:server-command'. - -If you want to add some special `sys.path' when starting Jedi -server, do something like this:: - - (setq jedi:server-args - '(\"--sys-path\" \"MY/SPECIAL/PATH\" - \"--sys-path\" \"MY/OTHER/SPECIAL/PATH\")) - -If you want to include some virtualenv, do something like the -following. Note that actual environment variable ``VIRTUAL_ENV`` -is treated automatically so you don't need to pass it. Also, -you need to start Jedi EPC server with the same python version -that you use for the virtualenv.:: - - (setq jedi:server-args - '(\"--virtual-env\" \"SOME/VIRTUAL_ENV_1\" - \"--virtual-env\" \"SOME/VIRTUAL_ENV_2\")) - -To see what other arguments Jedi server can take, execute the -following command:: - - python jediepcserver.py --help - - -**Advanced usage** - -Sometimes you want to configure how Jedi server is started per -buffer. To do that, you should make this variable buffer local -in `python-mode-hook' and set it to some buffer specific variable, -like this:: - - (defun my-jedi-server-setup () - (let ((cmds (GET-SOME-PROJECT-SPECIFIC-COMMAND)) - (args (GET-SOME-PROJECT-SPECIFIC-ARGS))) - (when cmds (set (make-local-variable 'jedi:server-command) cmds)) - (when args (set (make-local-variable 'jedi:server-args) args)))) - - (add-hook 'python-mode-hook 'my-jedi-server-setup) - -Note that Jedi server run by the same command is pooled. So, -there is only one Jedi server for the same set of command. If -you want to check how many EPC servers are running, use the EPC -GUI: M-x `epc:controller'. You will see a table of EPC connections -for Jedi.el and other EPC applications. - -If you want to start a new ad-hoc server for the current buffer, -use the command `jedi:start-dedicated-server'." - :group 'jedi) - -(defcustom jedi:complete-on-dot nil - "Non-`nil' means automatically start completion after inserting a dot. -To make this option work, you need to use `jedi:setup' instead of -`jedi:ac-setup' to start Jedi." - :group 'jedi) - -(defcustom jedi:tooltip-method '(pos-tip popup) - "Configuration for `jedi:tooltip-show'. -This is a list which may contain symbol(s) `pos-tip' and/or -`popup'. It determines tooltip method to use. Setting this -value to nil means to use minibuffer instead of tooltip." - :group 'jedi) - -(defcustom jedi:get-in-function-call-timeout 3000 - "Cancel request to server for call signature after this period -specified in in millisecond." - :group 'jedi) - -(defcustom jedi:get-in-function-call-delay 1000 - "How long Jedi should wait before showing call signature -tooltip in millisecond." - :group 'jedi) - -(defcustom jedi:goto-definition-config - '((nil nil nil) - (t nil nil) - (nil definition nil) - (t definition nil) - (nil nil t ) - (t nil t ) - (nil definition t ) - (t definition t )) - "Configure how prefix argument modifies `jedi:goto-definition' behavior. - -Each element of the list is arguments (list) passed to -`jedi:goto-definition'. Note that this variable has no effect on -`jedi:goto-definition' when it is used as a lisp function - -The following setting is default (last parts are omitted). -Nth element is used as the argument when N universal prefix -arguments (``C-u``) are given.:: - - (setq jedi:goto-definition-config - '((nil nil nil) ; C-. - (t nil nil) ; C-u C-. - (nil definition nil) ; C-u C-u C-. - (t definition nil) ; C-u C-u C-u C-. - ...)) - -For example, if you want to follow \"substitution path\" by default, -use the setting like this:: - - (setq jedi:goto-definition-config - '((nil definition nil) - (t definition nil) - (nil nil nil) - (t nil nil) - (nil definition t ) - (t definition t ) - (nil nil t ) - (t nil t ))) - -You can rearrange the order to have most useful sets of arguments -at the top." - :group 'jedi) - -(defcustom jedi:doc-mode 'rst-mode - "Major mode to use when showing document." - :group 'jedi) - -(defcustom jedi:doc-hook '(view-mode) - "The hook that's run after showing a document." - :type 'hook - :group 'jedi) - -(defcustom jedi:doc-display-buffer 'display-buffer - "A function to be called with a buffer to show document." - :group 'jedi) - -(defcustom jedi:install-imenu nil - "[EXPERIMENTAL] If `t', use Jedi to create `imenu' index. -To use this feature, you need to install the developmental -version (\"dev\" branch) of Jedi." - :group 'jedi) - -(defcustom jedi:imenu-create-index-function 'jedi:create-nested-imenu-index - "`imenu-create-index-function' for Jedi.el. -It must be a function that takes no argument and return an object -described in `imenu--index-alist'. -This can be set to `jedi:create-flat-imenu-index'. -Default is `jedi:create-nested-imenu-index'." - :group 'jedi) - -(make-obsolete-variable 'jedi:setup-keys nil "0.1.3") -(defcustom jedi:setup-keys nil - "Setup recommended keybinds. - -.. warning:: Use of this value is obsolete now. As of 0.1.3, - jedi.el has default keybinds, which are different than these. See also - `jedi-mode'. - -.. admonition:: Default keybinds - - ```` : = `jedi:key-complete' - Complete code at point. (`jedi:complete') - - ``C-.`` : = `jedi:key-goto-definition' - Goto the definition of the object at point. (`jedi:goto-definition') - - ``C-c d`` : = `jedi:key-show-doc' - Show the documentation of the object at point. (`jedi:show-doc') - - ``C-c r`` : = `jedi:key-related-names' - Find related names of the object at point. - (`helm-jedi-related-names' / `anything-jedi-related-names') - -When `jedi:setup-keys' is non-`nil', recommended keybinds are set -in `jedi-mode-map' when **loading** jedi.el. Therefore, you must -set this value before jedi.el is loaded. As recommended usage of -jedi.el is to call `jedi:setup' via `python-mode-hook' where -`jedi:setup' is autloaded, setting `jedi:setup-keys' to `t' in -you emacs setup (e.g., ``.emacs.d/init.el``) works fine.:: - - (setq jedi:setup-keys t) - (add-hook 'python-mode-hook 'jedi:setup) - -If you want to require jedi.el explicitly when loading Emacs, -make sure to set `jedi:setup-keys' before loading jedi.el:: - - (setq jedi:setup-keys t) - (require 'jedi) - -Byte compiler warns about unbound variable if you set -`jedi:setup-keys' before loading jedi.el. The proper way to -suppress this warning is the following:: - - (eval-when-compile (require 'jedi nil t)) - (setq jedi:setup-keys t) - -You can change these keybinds by changing `jedi:key-complete', -`jedi:key-goto-definition', `jedi:key-show-doc', and -`jedi:key-related-names'. For example, default keybind for -ropemacs's `rope-show-doc' is same as `jedi:show-doc'. You can -avoid collision by something like this:: - - (setq jedi:key-show-doc (kbd \"C-c D\"))" - :group 'jedi) - -(defcustom jedi:key-complete (kbd "") - "Keybind for command `jedi:complete'." - :group 'jedi) - -(defcustom jedi:key-goto-definition (kbd "C-.") - "Keybind for command `jedi:goto-definition'." - :group 'jedi) - -(defcustom jedi:key-show-doc (kbd "C-c d") - "Keybind for command `jedi:show-doc'." - :group 'jedi) - -(defcustom jedi:key-related-names (kbd "C-c r") - "Keybind for command `helm-jedi-related-names' or -`anything-jedi-related-names'." - :group 'jedi) - -(defcustom jedi:key-goto-definition-pop-marker (kbd "C-,") - "Keybind for command `jedi:goto-definition-pop-marker'." - :group 'jedi) - -(defcustom jedi:use-shortcuts nil - "If non-`nil', enable the following shortcuts: - -| ``M-.`` `jedi:goto-definition' -| ``M-,`` `jedi:goto-definition-pop-marker' -" - :group 'jedi) - -(defcustom jedi:import-python-el-settings t - "Automatically import setting from python.el variables." - :group 'jedi) - -(defcustom jedi:goto-definition-marker-ring-length 16 - "Length of marker ring to store `jedi:goto-definition' call positions" - :group 'jedi) - - -;;; Internal variables - -(defvar jedi:get-in-function-call--d nil - "Bounded to deferred object while requesting get-in-function-call.") - -(defvar jedi:defined-names--singleton-d nil - "Bounded to deferred object while requesting defined_names.") - - -;;; Jedi mode - -(defvar jedi-mode-map (make-sparse-keymap)) - -(defun jedi:handle-post-command () - (jedi:get-in-function-call-when-idle)) - -(define-minor-mode jedi-mode - "Jedi mode. -When `jedi-mode' is on, call signature is automatically shown as -toolitp when inside of function call. - -\\{jedi-mode-map}" - :keymap jedi-mode-map - :group 'jedi - (let ((map jedi-mode-map)) - (when jedi:use-shortcuts - (define-key map (kbd "M-.") 'jedi:goto-definition) - (define-key map (kbd "M-,") 'jedi:goto-definition-pop-marker)) - (if jedi:complete-on-dot - (define-key map "." 'jedi:dot-complete) - (define-key map "." nil))) - (if jedi-mode - (progn - (when jedi:install-imenu - (add-hook 'after-change-functions 'jedi:after-change-handler nil t) - (jedi:defined-names-deferred) - (setq imenu-create-index-function jedi:imenu-create-index-function)) - (add-hook 'post-command-hook 'jedi:handle-post-command nil t) - (add-hook 'kill-buffer-hook 'jedi:server-pool--gc-when-idle nil t)) - (remove-hook 'post-command-hook 'jedi:handle-post-command t) - (remove-hook 'after-change-functions 'jedi:after-change-handler t) - (remove-hook 'kill-buffer-hook 'jedi:server-pool--gc-when-idle t) - (jedi:server-pool--gc-when-idle))) - -;; Define keybinds. -;; See: https://github.com/tkf/emacs-jedi/issues/47 -(let ((map jedi-mode-map)) - (define-key map (kbd "") 'jedi:complete) - (define-key map (kbd "C-c ?") 'jedi:show-doc) - (define-key map (kbd "C-c .") 'jedi:goto-definition) - (define-key map (kbd "C-c ,") 'jedi:goto-definition-pop-marker) - (let ((command (cond - ((featurep 'helm) 'helm-jedi-related-names) - ((featurep 'anything) 'anything-jedi-related-names) - ((locate-library "helm") 'helm-jedi-related-names) - ((locate-library "anything") 'anything-jedi-related-names)))) - (when command - (define-key map (kbd "C-c /") command)))) - -(when jedi:setup-keys - (let ((map jedi-mode-map)) - (define-key map jedi:key-complete 'jedi:complete) - (define-key map jedi:key-goto-definition 'jedi:goto-definition) - (define-key map jedi:key-show-doc 'jedi:show-doc) - (define-key map jedi:key-goto-definition-pop-marker - 'jedi:goto-definition-pop-marker) - (let ((command (cond - ((featurep 'helm) 'helm-jedi-related-names) - ((featurep 'anything) 'anything-jedi-related-names)))) - (when command - (define-key map jedi:key-related-names command))))) - - -;;; EPC utils - -(defun jedi:epc--live-p (mngr) - "Return non-nil when MNGR is an EPC manager object with a live -connection." - (let ((proc (ignore-errors - (epc:connection-process (epc:manager-connection mngr))))) - (and (processp proc) - ;; Same as `process-live-p' in Emacs >= 24: - (memq (process-status proc) '(run open listen connect stop))))) - -(defmacro jedi:-with-run-on-error (body &rest run-on-error) - (declare (indent 1)) - `(let ((something-happened t)) - (unwind-protect - (prog1 ,body - (setq something-happened nil)) - (when something-happened - ,@run-on-error)))) - -(defun jedi:epc--start-epc (server-prog server-args) - "Same as `epc:start-epc', but set query-on-exit flag for -associated processes to nil." - (let ((mngr (jedi:-with-run-on-error - (epc:start-epc server-prog server-args) - (display-warning 'jedi "\ -Failed to start Jedi EPC server. -*** You may need to run \"M-x jedi:install-server\". *** -This could solve the problem especially if you haven't run the command yet -since Jedi.el installation or update and if the server complains about -Python module imports." :error)))) - (set-process-query-on-exit-flag (epc:connection-process - (epc:manager-connection mngr)) - nil) - (set-process-query-on-exit-flag (epc:manager-server-process mngr) nil) - mngr)) - - -;;; Server pool - -(defvar jedi:server-pool--table (make-hash-table :test 'equal) - "A hash table that holds a pool of EPC server instances.") - -(defun jedi:server-pool--start (command) - "Get an EPC server instance from server pool by COMMAND as a -key, or start new one if there is none." - (let ((cached (gethash command jedi:server-pool--table))) - (if (and cached (jedi:epc--live-p cached)) - cached - (let* ((default-directory "/") - (mngr (jedi:epc--start-epc (car command) (cdr command)))) - (puthash command mngr jedi:server-pool--table) - (jedi:server-pool--gc-when-idle) - mngr)))) - -(defun jedi:-get-servers-in-use () - "Return a list of non-nil `jedi:epc' in all buffers." - (loop with mngr-list - for buffer in (buffer-list) - for mngr = (with-current-buffer buffer jedi:epc) - when (and mngr (not (memq mngr mngr-list))) - collect mngr into mngr-list - finally return mngr-list)) - -(defvar jedi:server-pool--gc-timer nil) - -(defun jedi:server-pool--gc () - "Stop unused servers." - (let ((servers-in-use (jedi:-get-servers-in-use))) - (maphash - (lambda (key mngr) - (unless (memq mngr servers-in-use) - (remhash key jedi:server-pool--table) - (epc:stop-epc mngr))) - jedi:server-pool--table)) - ;; Clear timer so that GC is started next time - ;; `jedi:server-pool--gc-when-idle' is called. - (setq jedi:server-pool--gc-timer nil)) - -(defun jedi:server-pool--gc-when-idle () - "Run `jedi:server-pool--gc' when idle." - (unless jedi:server-pool--gc-timer - (setq jedi:server-pool--gc-timer - (run-with-idle-timer 10 nil 'jedi:server-pool--gc)))) - - -;;; Server management - -(defun jedi:start-server () - (if (jedi:epc--live-p jedi:epc) - (message "Jedi server is already started!") - (setq jedi:epc (jedi:server-pool--start - (append jedi:server-command jedi:server-args)))) - jedi:epc) - -(defun jedi:stop-server () - "Stop Jedi server. Use this command when you want to restart -Jedi server (e.g., when you changed `jedi:server-command' or -`jedi:server-args'). Jedi srever will be restarted automatically -later when it is needed." - (interactive) - (if jedi:epc - (epc:stop-epc jedi:epc) - (message "Jedi server is already killed.")) - (setq jedi:epc nil) - ;; It could be non-nil due to some error. Rescue it in that case. - (setq jedi:get-in-function-call--d nil) - (setq jedi:defined-names--singleton-d nil)) - -(defun jedi:get-epc () - (if (jedi:epc--live-p jedi:epc) - jedi:epc - (jedi:start-server))) - -;;;###autoload -(defun jedi:start-dedicated-server (command) - "Start Jedi server dedicated to this buffer. -This is useful, for example, when you want to use different -`sys.path' for some buffer. When invoked as an interactive -command, it asks you how to start the Jedi server. You can edit -the command in minibuffer to specify the way Jedi server run. - -If you want to setup how Jedi server is started programmatically -per-buffer/per-project basis, make `jedi:server-command' and -`jedi:server-args' buffer local and set it in `python-mode-hook'. -See also: `jedi:server-args'." - (interactive - (list (split-string-and-unquote - (read-string "Run Jedi server: " - (mapconcat - #'identity - (append jedi:server-command - jedi:server-args) - " "))))) - ;; Reset `jedi:epc' so that a new server is created when COMMAND is - ;; new. If it is already in the server pool, the server instance - ;; already in the pool is picked up by `jedi:start-server'. - (setq jedi:epc nil) - ;; Set `jedi:server-command', so that this command is used - ;; when restarting EPC server of this buffer. - (set (make-local-variable 'jedi:server-command) command) - (set (make-local-variable 'jedi:server-args) nil) - (jedi:start-server)) - -(defun jedi:-buffer-file-name () - "Return `buffer-file-name' without text properties. -See: https://github.com/tkf/emacs-jedi/issues/54" - (when (stringp buffer-file-name) - (substring-no-properties buffer-file-name))) - -(defun jedi:call-deferred (method-name) - "Call ``Script(...).METHOD-NAME`` and return a deferred object." - (let ((source (buffer-substring-no-properties (point-min) (point-max))) - (line (count-lines (point-min) (min (1+ (point)) (point-max)))) - (column (current-column)) - (source-path (jedi:-buffer-file-name))) - (epc:call-deferred (jedi:get-epc) - method-name - (list source line column source-path)))) - - -;;; Completion - -(defvar jedi:complete-reply nil - "Last reply to `jedi:complete-request'.") - -(defvar jedi:complete-request-point 0 - ;; It is passed to `=', so do not initialize this value by `nil'. - "The point where `jedi:complete-request' is called.") - -(defun jedi:complete-request () - "Request ``Script(...).complete`` and return a deferred object. -`jedi:complete-reply' is set to the reply sent from the server." - (setq jedi:complete-request-point (point)) - (deferred:nextc (jedi:call-deferred 'complete) - (lambda (reply) - (setq jedi:complete-reply reply)))) - -;;;###autoload -(defun* jedi:complete (&key (expand ac-expand-on-auto-complete)) - "Complete code at point." - (interactive) - (lexical-let ((expand expand)) - (deferred:nextc (jedi:complete-request) - (lambda () - (let ((ac-expand-on-auto-complete expand)) - (ac-start :triggered 'command)))))) -;; Calling `auto-complete' or `ac-update-greedy' instead of `ac-start' -;; here did not work. - -(defun jedi:dot-complete () - "Insert dot and complete code at point." - (interactive) - (insert ".") - (unless (or (ac-cursor-on-diable-face-p) - ;; don't complete if the dot is immediately after int literal - (looking-back "\\(\\`\\|[^._[:alnum:]]\\)[0-9]+\\.")) - (jedi:complete :expand nil))) - - -;;; AC source - -(defun jedi:ac-direct-matches () - (mapcar - (lambda (x) - (destructuring-bind (&key word doc description symbol) - x - (popup-make-item word - :symbol symbol - :document (unless (equal doc "") doc) - :summary description))) - jedi:complete-reply)) - -(defun jedi:ac-direct-prefix () - (or (ac-prefix-default) - (when (= jedi:complete-request-point (point)) - jedi:complete-request-point))) - -;; (makunbound 'ac-source-jedi-direct) -(ac-define-source jedi-direct - '((candidates . jedi:ac-direct-matches) - (prefix . jedi:ac-direct-prefix) - (init . jedi:complete-request) - (requires . -1))) - -;;;###autoload -(defun jedi:ac-setup () - "Add Jedi AC sources to `ac-sources'. - -If auto-completion is all you need, you can call this function instead -of `jedi:setup', like this:: - - (add-hook 'python-mode-hook 'jedi:ac-setup) - -Note that this function calls `auto-complete-mode' if it is not -already enabled, for people who don't call `global-auto-complete-mode' -in their Emacs configuration." - (interactive) - (add-to-list 'ac-sources 'ac-source-jedi-direct) - (unless auto-complete-mode - (auto-complete-mode))) - - -;;; Call signature (get_in_function_call) - -(defface jedi:highlight-function-argument - '((t (:inherit bold))) - "Face used for the argument at point in a function's argument list" - :group 'jedi) - -(defun* jedi:get-in-function-call--construct-call-signature - (&key params index call_name) - (let ((current-arg (nth index params))) - (when (and current-arg (null jedi:tooltip-method)) - (setf (nth index params) - (propertize current-arg 'face 'jedi:highlight-function-argument))) - (concat call_name "(" (mapconcat #'identity params ", ") ")"))) - -(defun jedi:get-in-function-call--tooltip-show (args) - (when (and args (not ac-completing)) - (jedi:tooltip-show - (apply #'jedi:get-in-function-call--construct-call-signature args)))) - -(defun jedi:get-in-function-call () - "Manually show call signature tooltip." - (interactive) - (deferred:nextc - (jedi:call-deferred 'get_in_function_call) - #'jedi:get-in-function-call--tooltip-show)) - -(defun jedi:get-in-function-call-when-idle () - "Show tooltip when Emacs is ilde." - (unless jedi:get-in-function-call--d - (setq jedi:get-in-function-call--d - (deferred:try - (deferred:$ - (deferred:wait-idle jedi:get-in-function-call-delay) - (deferred:nextc it - (lambda () - (when jedi-mode ; cursor may be moved - (deferred:timeout - jedi:get-in-function-call-timeout - nil - (jedi:call-deferred 'get_in_function_call))))) - (deferred:nextc it #'jedi:get-in-function-call--tooltip-show)) - :finally - (lambda () - (setq jedi:get-in-function-call--d nil)))))) - -(defun jedi:tooltip-show (string) - (cond - ((and (memq 'pos-tip jedi:tooltip-method) window-system - (featurep 'pos-tip)) - (pos-tip-show (jedi:string-fill-paragraph string) - 'popup-tip-face nil nil 0)) - ((and (memq 'popup jedi:tooltip-method) - (featurep 'popup)) - (popup-tip string)) - (t (when (stringp string) - (let ((message-log-max nil)) - (message string)))))) - -(defun jedi:string-fill-paragraph (string &optional justify) - (with-temp-buffer - (erase-buffer) - (insert string) - (goto-char (point-min)) - (fill-paragraph justify) - (buffer-string))) - - -;;; Goto - -(defvar jedi:goto-definition--index nil) -(defvar jedi:goto-definition--cache nil) -(defvar jedi:goto-definition--marker-ring - (make-ring jedi:goto-definition-marker-ring-length) - "Marker ring that stores `jedi:goto-definition' call positions") - -(defun jedi:goto-definition (&optional other-window deftype use-cache index) - "Goto the definition of the object at point. - -See `jedi:goto-definition-config' for how this function works -when universal prefix arguments \(``C-u``) are given. If -*numeric* prefix argument(s) \(e.g., ``M-0``) are given, goto -point of the INDEX-th result. Note that you cannot mix universal -and numeric prefixes. It is Emacs's limitation. If you mix both -kinds of prefix, you get numeric prefix. - -When used as a lisp function, popup a buffer when OTHER-WINDOW is -non-nil. DEFTYPE must be either `assignment' (default) or -`definition'. When USE-CACHE is non-nil, use the locations of -the last invocation of this command. If INDEX is specified, goto -INDEX-th result." - (interactive - (if (integerp current-prefix-arg) - (list nil nil nil current-prefix-arg) - (nth (let ((i (car current-prefix-arg))) - (if i (floor (log i 4)) 0)) - jedi:goto-definition-config))) - (cond - ((and (or use-cache index) - jedi:goto-definition--cache) - (setq jedi:goto-definition--index (or index 0)) - (jedi:goto-definition--nth other-window)) - ((and (eq last-command 'jedi:goto-definition) - (> (length jedi:goto-definition--cache) 1)) - (jedi:goto-definition-next other-window)) - (t - (setq jedi:goto-definition--index (or index 0)) - (lexical-let ((other-window other-window)) - (deferred:nextc (jedi:call-deferred - (case deftype - ((assignment nil) 'goto) - (definition 'get_definition) - (t (error "Unsupported deftype: %s" deftype)))) - (lambda (reply) - (jedi:goto-definition--callback reply other-window))))))) - -(defun jedi:goto-definition-push-marker () - "Push point onto goto-definition marker ring." - (ring-insert jedi:goto-definition--marker-ring (point-marker))) - -(defun jedi:goto-definition-pop-marker () - "Goto the last point where `jedi:goto-definition' was called." - (interactive) - (if (ring-empty-p jedi:goto-definition--marker-ring) - (error "Jedi marker ring is empty, can't pop") - (let ((marker (ring-remove jedi:goto-definition--marker-ring 0))) - (switch-to-buffer (or (marker-buffer marker) - (error "Buffer has been deleted"))) - (goto-char (marker-position marker)) - ;; Cleanup the marker so as to avoid them piling up. - (set-marker marker nil nil)))) - -(defun jedi:goto-definition-next (&optional other-window) - "Goto the next cached definition. See: `jedi:goto-definition'." - (interactive "P") - (let ((len (length jedi:goto-definition--cache)) - (n (1+ jedi:goto-definition--index))) - (setq jedi:goto-definition--index (if (>= n len) 0 n)) - (jedi:goto-definition--nth other-window))) - -(defun jedi:goto-definition--callback (reply other-window) - (if (not reply) - (message "Definition not found.") - (setq jedi:goto-definition--cache reply) - (jedi:goto-definition--nth other-window t))) - -(defun jedi:goto--line-column (line column) - "Like `goto-char' but specify the position by LINE and COLUMN." - (goto-char (point-min)) - (forward-line (1- line)) - (forward-char column)) - -(defun jedi:goto-definition--nth (other-window &optional try-next) - (let* ((len (length jedi:goto-definition--cache)) - (n jedi:goto-definition--index) - (next (lambda () - (when (< n (1- len)) - (incf jedi:goto-definition--index) - (jedi:goto-definition--nth other-window) - t)))) - (destructuring-bind (&key line_nr column module_path module_name - &allow-other-keys) - (nth n jedi:goto-definition--cache) - (cond - ((equal module_name "__builtin__") - (unless (and try-next (funcall next)) - (message "Cannot see the definition of __builtin__."))) - ((not (and module_path (file-exists-p module_path))) - (unless (and try-next (funcall next)) - (message "File '%s' does not exist." module_path))) - (t - (jedi:goto-definition-push-marker) - (funcall (if other-window #'find-file-other-window #'find-file) - module_path) - (jedi:goto--line-column line_nr column) - (jedi:goto-definition--notify-alternatives len n)))))) - -(defun jedi:goto-definition--notify-alternatives (len n) - (unless (= len 1) - (message - "%d-th point in %d candidates.%s" - (1+ n) - len - ;; Note: It must be `last-command', not `last-command' because - ;; this function is called in deferred at the first time. - (if (eq last-command 'jedi:goto-definition) - (format " Type %s to go to the next point." - (key-description - (car (where-is-internal 'jedi:goto-definition)))) - "")))) - - -;;; Full name - -(defun jedi:get-full-name-deferred () - (deferred:$ - (jedi:call-deferred 'get_definition) - (deferred:nextc it - (lambda (reply) - (loop for def in reply - do (destructuring-bind (&key full_name &allow-other-keys) - def - (when full_name - (return full_name)))))))) - -(defun* jedi:get-full-name-sync (&key (timeout 500)) - (epc:sync - (jedi:get-epc) - (deferred:timeout timeout nil (jedi:get-full-name-deferred)))) - - -;;; Related names - -(defun jedi:related-names--source (name candidates) - `((name . ,name) - (candidates . ,candidates) - (recenter) - (type . file-line))) - -(defun jedi:related-names--to-file-line (reply) - (mapcar - (lambda (x) - (destructuring-bind - (&key line_nr column module_name module_path description) - x - (format "%s:%s: %s - %s" module_path line_nr - module_name description))) - reply)) - -(defun jedi:related-names--helm (helm) - (lexical-let ((helm helm)) - (deferred:nextc - (let ((to-file-line #'jedi:related-names--to-file-line)) - (deferred:parallel - (deferred:nextc (jedi:call-deferred 'related_names) to-file-line) - (deferred:nextc (jedi:call-deferred 'goto) to-file-line))) - (lambda (candidates-list) - (funcall - helm - :sources (list (jedi:related-names--source "Jedi Related Names" - (car candidates-list)) - (jedi:related-names--source "Jedi Goto" - (cadr candidates-list))) - :buffer (format "*%s jedi:related-names*" helm)))))) - -;;;###autoload -(defun helm-jedi-related-names () - "Find related names of the object at point using `helm' interface." - (interactive) - (jedi:related-names--helm 'helm)) - -;;;###autoload -(defun anything-jedi-related-names () - "Find related names of the object at point using `anything' interface." - (interactive) - (jedi:related-names--helm 'anything)) - - -;;; Show document (get-definition) - -(defvar jedi:doc-buffer-name "*jedi:doc*") - -(defun jedi:show-doc () - "Show the documentation of the object at point." - (interactive) - (deferred:nextc (jedi:call-deferred 'get_definition) - (lambda (reply) - (with-current-buffer (get-buffer-create jedi:doc-buffer-name) - (loop with has-doc = nil - with first = t - with inhibit-read-only = t - initially (erase-buffer) - for def in reply - do (destructuring-bind - (&key doc desc_with_module line_nr module_path - &allow-other-keys) - def - (unless (or (null doc) (equal doc "")) - (if first - (setq first nil) - (insert "\n\n---\n\n")) - (insert "Docstring for " desc_with_module "\n\n" doc) - (setq has-doc t))) - finally do - (if (not has-doc) - (message "Document not found.") - (progn - (goto-char (point-min)) - (when (fboundp jedi:doc-mode) - (funcall jedi:doc-mode)) - (run-hooks 'jedi:doc-hook) - (funcall jedi:doc-display-buffer (current-buffer))))))))) - - -;;; Defined names (imenu) - -(defvar jedi:defined-names--cache nil) -(make-variable-buffer-local 'jedi:defined-names--cache) - -(defun jedi:defined-names-deferred () - (deferred:nextc - (epc:call-deferred - (jedi:get-epc) - 'defined_names - (list (buffer-substring-no-properties (point-min) (point-max)) - (jedi:-buffer-file-name))) - (lambda (reply) - (setq jedi:defined-names--cache reply)))) - -(defun jedi:defined-names--singleton-deferred () - "Like `jedi:defined-names-deferred', but make sure that only -one request at the time is emitted." - (unless jedi:defined-names--singleton-d - (setq jedi:defined-names--singleton-d - (deferred:watch (jedi:defined-names-deferred) - (lambda (_) (setq jedi:defined-names--singleton-d nil)))))) - -(defun jedi:defined-names--sync () - (unless jedi:defined-names--cache - (epc:sync (jedi:get-epc) (jedi:defined-names--singleton-deferred))) - jedi:defined-names--cache) - -(defun jedi:after-change-handler (&rest _) - (unless (or (ac-menu-live-p) (ac-inline-live-p)) - (jedi:defined-names--singleton-deferred))) - -(defun jedi:imenu-make-marker (def) - (destructuring-bind (&key line_nr column &allow-other-keys) def - (save-excursion (jedi:goto--line-column line_nr column) - (point-marker)))) - -(defun jedi:create-nested-imenu-index--item (def) - (cons (plist-get def :name) (jedi:imenu-make-marker def))) - -(defun jedi:create-nested-imenu-index () - "`imenu-create-index-function' for Jedi.el. -See also `jedi:imenu-create-index-function'." - (when (called-interactively-p 'interactive) (jedi:defined-names--sync)) - (jedi:create-nested-imenu-index-1)) - -(defun jedi:create-nested-imenu-index-1 (&optional items) - (loop for (def . subdefs) in (or items jedi:defined-names--cache) - if subdefs - collect (append - (list (plist-get def :local_name) - (jedi:create-nested-imenu-index--item def)) - (jedi:create-nested-imenu-index-1 subdefs)) - else - collect (jedi:create-nested-imenu-index--item def))) - -(defun jedi:create-flat-imenu-index () - "`imenu-create-index-function' for Jedi.el to create flatten index. -See also `jedi:imenu-create-index-function'." - (when (called-interactively-p 'interactive) (jedi:defined-names--sync)) - (jedi:create-flat-imenu-index-1)) - -(defun jedi:create-flat-imenu-index-1 (&optional items) - (loop for (def . subdefs) in (or items jedi:defined-names--cache) - collect (cons (plist-get def :local_name) (jedi:imenu-make-marker def)) - when subdefs - append (jedi:create-flat-imenu-index-1 subdefs))) - - -;;; Meta info - -(defun jedi:show-setup-info () - "Show installation and configuration info in a buffer. -Paste the result of this function when asking question or -reporting bug. This command also tries to detect errors when -communicating with Jedi EPC server. If you have some problem you -may find some information about communication error." - (interactive) - (let (epc get-epc-error version-reply) - (condition-case err - (setq epc (jedi:get-epc)) - (error (setq get-epc-error err))) - (when epc - (setq version-reply - (condition-case err - (epc:sync - epc - (deferred:$ - (deferred:timeout 500 - '(:timeout nil) - (epc:call-deferred epc 'get_jedi_version nil)) - (deferred:error it - (lambda (err) `(:error ,err))))) - (error `(:sync-error ,err))))) - (let ((standard-output (get-buffer-create "*jedi:show-setup-info*"))) - (with-current-buffer standard-output - (emacs-lisp-mode) - (erase-buffer) - (insert ";; Emacs Lisp version:\n") - (pp `(:emacs-version ,emacs-version - :jedi-version ,jedi:version - :python-environment-version ,python-environment-version)) - (insert ";; Python version:\n") - (pp version-reply) - (when get-epc-error - (insert "\n;; EPC error:\n") - (pp `(:get-epc-error ,get-epc-error))) - (insert ";; Command line:\n") - (pp `(:virtualenv - ,(executable-find (car python-environment-virtualenv)) - :virtualenv-version - ,(ignore-errors (jedi:-virtualenv-version)))) - (insert ";; Customization:\n") - (pp (jedi:-list-customization)) - (display-buffer standard-output))))) - -(defun jedi:-list-defcustoms () - (loop for sym being the symbols - for name = (symbol-name sym) - when (and (or (string-prefix-p "jedi:" name) - (string-prefix-p "python-environment-" name)) - (custom-variable-p sym)) - collect sym)) - -(defun jedi:-list-customization () - (loop for sym in (sort (jedi:-list-defcustoms) - (lambda (x y) - (string< (symbol-name x) - (symbol-name y)))) - collect (cons sym (symbol-value sym)))) - -(defun jedi:-virtualenv-version () - "Return output of virtualenv --version" - (with-temp-buffer - (erase-buffer) - (call-process (executable-find (car python-environment-virtualenv)) - nil t nil - "--version") - (buffer-string))) - -(defun jedi:get-jedi-version-request () - "Request version of Python modules and return a deferred object." - (epc:call-deferred (jedi:get-epc) 'get_jedi_version nil)) - -(defun jedi:show-version-info () - "Show version info of Python modules used by the server. -Paste the result of this function in bug report." - (interactive) - (deferred:nextc (jedi:get-jedi-version-request) - (lambda (reply) - (let ((standard-output (get-buffer-create "*jedi:version*"))) - (with-current-buffer standard-output - (emacs-lisp-mode) - (erase-buffer) - (pp `(:emacs-version ,emacs-version :jedi-version ,jedi:version)) - (pp reply) - (display-buffer standard-output)))))) - -(define-obsolete-function-alias - 'jedi:show-jedi-version 'jedi:show-version-info "0.1.3") - -(defun jedi:print-jedi-version () - (pp (epc:sync (jedi:get-epc) (jedi:get-jedi-version-request)))) - - -;;; Setup - -(defun jedi:import-python-el-settings-setup () - "Make jedi aware of python.el virtualenv and path settings. -This is automatically added to the `jedi-mode-hook' when -`jedi:import-python-el-settings' is non-nil." - (let ((args)) - (when (bound-and-true-p python-shell-extra-pythonpaths) - (mapc - (lambda (path) - (setq args (append (list "--sys-path" path) args))) - python-shell-extra-pythonpaths)) - (when (bound-and-true-p python-shell-virtualenv-path) - (setq args - (append - (list "--virtual-env" python-shell-virtualenv-path) - args))) - (when args - (set (make-local-variable 'jedi:server-args) - (append args jedi:server-args))))) - -;;;###autoload -(defun jedi:setup () - "Fully setup jedi.el for current buffer. -It setups `ac-sources' (calls `jedi:ac-setup') and turns -`jedi-mode' on. - -This function is intended to be called from `python-mode-hook', -like this:: - - (add-hook 'python-mode-hook 'jedi:setup) - -You can also call this function as a command, to quickly test -what jedi can do." - (interactive) - (jedi:ac-setup) - (when jedi:import-python-el-settings - ;; Hack to access buffer/dir-local vars: http://bit.ly/Y5IfMV. - ;; Given that `jedi:setup' is added to the `python-mode-hook' - ;; this will modify `hack-local-variables-hook' on python - ;; buffers only and will allow us to access buffer/directory - ;; local variables in `jedi:import-python-el-settings-setup'. - (add-hook 'hack-local-variables-hook - #'jedi:import-python-el-settings-setup nil t)) - (jedi-mode 1)) - - -;;; Virtualenv setup -(defvar jedi:install-server--command - `("pip" "install" "--upgrade" ,(convert-standard-filename jedi:source-dir))) - -;;;###autoload -(defun jedi:install-server () - "This command installs Jedi server script jediepcserver.py in a -Python environment dedicated to Emacs. By default, the -environment is at ``~/.emacs.d/.python-environments/default/``. -This environment is automatically created by ``virtualenv`` if it -does not exist. - -Run this command (i.e., type ``M-x jedi:install-server RET``) -whenever Jedi.el shows a message to do so. It is a good idea to -run this every time after you update Jedi.el to sync version of -Python modules used by Jedi.el and Jedi.el itself. - -You can modify the location of the environment by changing -`jedi:environment-root' and/or `python-environment-directory'. More -specifically, Jedi.el will install Python modules under the directory -``PYTHON-ENVIRONMENT-DIRECTORY/JEDI:ENVIRONMENT-ROOT``. Note that you -need command line program ``virtualenv``. If you have the command in -an unusual location, use `python-environment-virtualenv' to specify the -location. - -.. NOTE:: jediepcserver.py is installed in a virtual environment but it - does not mean Jedi.el cannot recognize the modules in virtual - environment you are using for your Python development. Jedi - EPC server recognize the virtualenv it is in (i.e., the - environment variable ``VIRTUAL_ENV`` in your Emacs) and then - add modules in that environment to its ``sys.path``. You can - also add ``--virtual-env PATH/TO/ENV`` to `jedi:server-args' - to include modules of virtual environment even you launch - Emacs outside of the virtual environment. - -.. NOTE:: It is highly recommended to use this command to install - Python modules for Jedi.el. You still can install Python - modules used by Jedi.el manually. However, you are then - responsible for keeping Jedi.el and Python modules compatible. - -See also: - -- https://github.com/tkf/emacs-jedi/pull/72 -- https://github.com/tkf/emacs-jedi/issues/140#issuecomment-37358527" - (interactive) - (deferred:$ - (python-environment-run jedi:install-server--command - jedi:environment-root - jedi:environment-virtualenv) - (deferred:watch it - (lambda (_) - (setq-default jedi:server-command (jedi:-env-server-command)))))) - -;;;###autoload -(defun jedi:install-server-block () - "Blocking version `jedi:install-server'." - (prog1 - (python-environment-run-block jedi:install-server--command - jedi:environment-root - jedi:environment-virtualenv) - (setq-default jedi:server-command (jedi:-env-server-command)))) - -(defcustom jedi:install-python-jedi-dev-command - '("pip" "install" "--upgrade" - "git+https://github.com/davidhalter/jedi.git@dev#egg=jedi") - "Pip command to be used for `jedi:install-python-jedi-dev'." - :group 'jedi) - -(defun jedi:install-python-jedi-dev () - "Install developmental version of Python-Jedi from GitHub." - (interactive) - (deferred:$ - (python-environment-run jedi:install-python-jedi-dev-command - jedi:environment-root - jedi:environment-virtualenv) - (deferred:watch it - (lambda (_) - (message "\ -Now restart EPC servers. Then you are ready to go with Jedi-dev!"))))) - - -;;; Debugging - -(defun jedi:pop-to-epc-buffer () - "Open the buffer associated with EPC server process. -Use this command to see the output (e.g., traceback) of the server process." - (interactive) - (pop-to-buffer (process-buffer (epc:manager-server-process jedi:epc)))) - -(defun jedi:toggle-log-traceback () - "Toggle on/off traceback logging for EPC server for the current buffer. -When there is an error during traceback logging is enabled, traceback -is printed in the EPC buffer. You can use `jedi:pop-to-epc-buffer' to -open that buffer. - -You can also pass ``--log-traceback`` option to jediepcserver.py -to start server with traceback logging turned on. This is useful when -there is a problem in communication (thus this command does not work). -You can use `jedi:start-dedicated-server' to restart EPC server for the -current buffer with specific arguments." - (interactive) - (deferred:$ - (epc:call-deferred (jedi:get-epc) 'toggle_log_traceback nil) - (deferred:nextc it - (lambda (flag) - (message "Traceback logging is %s" (if flag "enabled" "disabled")))))) - -(defvar jedi:server-command--backup nil) -(defvar jedi:server-args--backup nil) - -(defun jedi:toggle-debug-server () - "Setup `jedi:server-command' and `jedi:server-args' to debug -server using pdb or ipdb. - -When this command is called, it essentially execute the following -code:: - - (jedi:stop-server) - (setq jedi:server-command (list \"cat\" \"jedi-port.log\" ) - jedi:server-args nil) - -It means to pass the port number recorded in the file -jedi-port.log to EPC client. - -To start Jedi server in terminal and record port to the file, -use the following command:: - - python jediepcserver.py --port-file jedi-port.log --pdb - -This command will be copied in the kill-ring (clipboard) when -this command is called. You can use `--ipdb` instead of `--pdb` -to use ipdb instead of pdb. - -Calling this command again restores the original setting of -`jedi:server-command' and `jedi:server-args' then stops the -running server." - (interactive) - (if jedi:server-command--backup - (progn - (setq jedi:server-command jedi:server-command--backup - jedi:server-command--backup nil - jedi:server-args jedi:server-args--backup) - (jedi:stop-server) - (message "Quit debugging. Original setting restored.")) - (setq jedi:server-command--backup jedi:server-command - jedi:server-args--backup jedi:server-args - jedi:server-command (list "cat" (expand-file-name - "jedi-port.log" jedi:source-dir)) - jedi:server-args nil) - (jedi:stop-server) - (kill-new "python jediepcserver.py --port-file jedi-port.log --ipdb") - (message "Now, start server with: --port-file jedi-port.log --ipdb.\ - (command is copied in the kill-ring)"))) - - -(provide 'jedi) - -;; Local Variables: -;; coding: utf-8 -;; indent-tabs-mode: nil -;; End: - -;;; jedi.el ends here diff --git a/emacs.d/elpa/jedi-20140321.1323/jediepcserver.py b/emacs.d/elpa/jedi-20140321.1323/jediepcserver.py deleted file mode 100755 index 69af58f..0000000 --- a/emacs.d/elpa/jedi-20140321.1323/jediepcserver.py +++ /dev/null @@ -1,314 +0,0 @@ -#!/usr/bin/env python - -""" -Jedi EPC server. - -Copyright (C) 2012 Takafumi Arakaki - -Author: Takafumi Arakaki - -This file is NOT part of GNU Emacs. - -Jedi EPC server 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. - -Jedi EPC server 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 Jedi EPC server. -If not, see . - -""" - -import os -import sys -import re -import itertools -import logging -import site - -jedi = None # I will load it later - - -PY3 = (sys.version_info[0] >= 3) -NEED_ENCODE = not PY3 - - -def jedi_script(source, line, column, source_path): - if NEED_ENCODE: - source = source.encode('utf-8') - source_path = source_path and source_path.encode('utf-8') - return jedi.Script(source, line, column, source_path or '') - - -def candidate_symbol(comp): - """ - Return a character representing completion type. - - :type comp: jedi.api.Completion - :arg comp: A completion object returned by `jedi.Script.complete`. - - """ - try: - return comp.type[0].lower() - except (AttributeError, TypeError): - return '?' - - -def candidates_description(comp): - """ - Return `comp.description` in an appropriate format. - - * Avoid return a string 'None'. - * Strip off all newlines. This is required for using - `comp.description` as candidate summary. - - """ - desc = comp.description - return _WHITESPACES_RE.sub(' ', desc) if desc and desc != 'None' else '' -_WHITESPACES_RE = re.compile(r'\s+') - - -def complete(*args): - reply = [] - for comp in jedi_script(*args).complete(): - reply.append(dict( - word=comp.word, - doc=comp.doc, - description=candidates_description(comp), - symbol=candidate_symbol(comp), - )) - return reply - - -def get_in_function_call(*args): - call_def = jedi_script(*args).get_in_function_call() - if call_def: - return dict( - # p.get_code(False) should do the job. But jedi-vim use replace. - # So follow what jedi-vim does... - params=[p.get_code().replace('\n', '') for p in call_def.params], - index=call_def.index, - call_name=call_def.call_name, - ) - else: - return [] # nil - - -def _goto(method, *args): - """ - Helper function for `goto` and `related_names`. - - :arg method: `jedi.Script.goto` or `jedi.Script.related_names` - :arg args: Arguments to `jedi_script` - - """ - # `definitions` is a list. Each element is an instances of - # `jedi.api_classes.BaseOutput` subclass, i.e., - # `jedi.api_classes.RelatedName` or `jedi.api_classes.Definition`. - definitions = method(jedi_script(*args)) - return [dict( - column=d.column, - line_nr=d.line_nr, - module_path=d.module_path if d.module_path != '__builtin__' else [], - module_name=d.module_name, - description=d.description, - ) for d in definitions] - - -def goto(*args): - return _goto(jedi.Script.goto, *args) - - -def related_names(*args): - return _goto(jedi.Script.related_names, *args) - - -def definition_to_dict(d): - return dict( - doc=d.doc, - description=d.description, - desc_with_module=d.desc_with_module, - line_nr=d.line_nr, - column=d.column, - module_path=d.module_path, - name=getattr(d, 'name', []), - full_name=getattr(d, 'full_name', []), - type=getattr(d, 'type', []), - ) - - -def get_definition(*args): - definitions = jedi_script(*args).get_definition() - return list(map(definition_to_dict, definitions)) - - -def get_names_recursively(definition, parent=None): - """ - Fetch interesting defined names in sub-scopes under `definition`. - - :type names: jedi.api_classes.Definition - - """ - d = definition_to_dict(definition) - try: - d['local_name'] = parent['local_name'] + '.' + d['name'] - except (AttributeError, TypeError): - d['local_name'] = d['name'] - if definition.type == 'class': - ds = definition.defined_names() - return [d] + [get_names_recursively(c, d) for c in ds] - else: - return [d] - - -def defined_names(*args): - return list(map(get_names_recursively, jedi.api.defined_names(*args))) - - -def get_module_version(module): - try: - from pkg_resources import get_distribution, DistributionNotFound - try: - return get_distribution(module.__name__).version - except DistributionNotFound: - pass - except ImportError: - pass - - notfound = object() - for key in ['__version__', 'version']: - version = getattr(module, key, notfound) - if version is not notfound: - return version - - -def get_jedi_version(): - import epc - import sexpdata - return [dict( - name=module.__name__, - file=getattr(module, '__file__', []), - version=get_module_version(module) or [], - ) for module in [sys, jedi, epc, sexpdata]] - - -def jedi_epc_server(address='localhost', port=0, port_file=sys.stdout, - sys_path=[], virtual_env=[], - debugger=None, log=None, log_level=None, - log_traceback=None): - add_virtualenv_path() - for p in virtual_env: - add_virtualenv_path(p) - sys_path = map(os.path.expandvars, map(os.path.expanduser, sys_path)) - sys.path = [''] + list(filter(None, itertools.chain(sys_path, sys.path))) - # Workaround Jedi's module cache. Use this workaround until Jedi - # got an API to set module paths. - # See also: https://github.com/davidhalter/jedi/issues/36 - import_jedi() - import epc.server - server = epc.server.EPCServer((address, port)) - server.register_function(complete) - server.register_function(get_in_function_call) - server.register_function(goto) - server.register_function(related_names) - server.register_function(get_definition) - server.register_function(defined_names) - server.register_function(get_jedi_version) - - @server.register_function - def toggle_log_traceback(): - server.log_traceback = not server.log_traceback - return server.log_traceback - - port_file.write(str(server.server_address[1])) # needed for Emacs client - port_file.write("\n") - port_file.flush() - if port_file is not sys.stdout: - port_file.close() - - # This is not supported Python-EPC API, but I am using this for - # backward compatibility for Python-EPC < 0.0.4. In the future, - # it should be passed to the constructor. - server.log_traceback = bool(log_traceback) - - if log: - handler = logging.FileHandler(filename=log, mode='w') - if log_level: - log_level = getattr(logging, log_level.upper()) - handler.setLevel(log_level) - server.logger.setLevel(log_level) - server.logger.addHandler(handler) - if debugger: - server.set_debugger(debugger) - handler = logging.StreamHandler() - handler.setLevel(logging.DEBUG) - server.logger.addHandler(handler) - server.logger.setLevel(logging.DEBUG) - - server.serve_forever() - server.logger.info('exit') - return server - - -def import_jedi(): - global jedi - import jedi - import jedi.api - - -def add_virtualenv_path(venv=os.getenv('VIRTUAL_ENV')): - """Add virtualenv's site-packages to `sys.path`.""" - if not venv: - return - venv = os.path.abspath(venv) - path = os.path.join( - venv, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages') - sys.path.insert(0, path) - site.addsitedir(path) - - -def main(args=None): - import argparse - parser = argparse.ArgumentParser( - formatter_class=argparse.RawTextHelpFormatter, - description=__doc__) - parser.add_argument( - '--address', default='localhost') - parser.add_argument( - '--port', default=0, type=int) - parser.add_argument( - '--port-file', '-f', default='-', type=argparse.FileType('wt'), - help='file to write port on. default is stdout.') - parser.add_argument( - '--sys-path', '-p', default=[], action='append', - help='paths to be inserted at the top of `sys.path`.') - parser.add_argument( - '--virtual-env', '-v', default=[], action='append', - help='paths to be used as if VIRTUAL_ENV is set to it.') - parser.add_argument( - '--log', help='save server log to this file.') - parser.add_argument( - '--log-level', - choices=['CRITICAL', 'ERROR', 'WARN', 'INFO', 'DEBUG'], - help='logging level for log file.') - parser.add_argument( - '--log-traceback', action='store_true', default=False, - help='Include traceback in logging output.') - parser.add_argument( - '--pdb', dest='debugger', const='pdb', action='store_const', - help='start pdb when error occurs.') - parser.add_argument( - '--ipdb', dest='debugger', const='ipdb', action='store_const', - help='start ipdb when error occurs.') - ns = parser.parse_args(args) - jedi_epc_server(**vars(ns)) - - -if __name__ == '__main__': - main() diff --git a/emacs.d/elpa/jedi-20140321.1323/setup.py b/emacs.d/elpa/jedi-20140321.1323/setup.py deleted file mode 100644 index b450558..0000000 --- a/emacs.d/elpa/jedi-20140321.1323/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -try: - from setuptools import setup - args = {} -except ImportError: - from distutils.core import setup - args = dict(scripts=['jediepcserver.py']) - print("""\ -*** WARNING: setuptools is not found. Using distutils... -It is highly recommended to install Jedi.el via M-x jedi:install-server. -Note: If you are using Windows, then Jedi.el will not work with distutils. -""") - -setup( - name='jediepcserver', - py_modules=['jediepcserver'], - install_requires=[ - "jedi>=0.7.0", - "epc>=0.0.4", - "argparse", - ], - entry_points={ - 'console_scripts': ['jediepcserver = jediepcserver:main'], - }, - **args -) diff --git a/emacs.d/elpa/jedi-20150413.2208/jedi-autoloads.el b/emacs.d/elpa/jedi-20150413.2208/jedi-autoloads.el new file mode 100644 index 0000000..c8cbf0e --- /dev/null +++ b/emacs.d/elpa/jedi-20150413.2208/jedi-autoloads.el @@ -0,0 +1,42 @@ +;;; jedi-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "jedi" "jedi.el" (21837 24206 0 0)) +;;; Generated autoloads from jedi.el + +(autoload 'jedi:ac-setup "jedi" "\ +Add Jedi AC sources to `ac-sources'. + +If auto-completion is all you need, you can call this function instead +of `jedi:setup', like this:: + + (add-hook 'python-mode-hook 'jedi:ac-setup) + +Note that this function calls `auto-complete-mode' if it is not +already enabled, for people who don't call `global-auto-complete-mode' +in their Emacs configuration. + +\(fn)" t nil) + +(autoload 'jedi:complete "jedi" "\ +Complete code at point. + +\(fn &key (expand ac-expand-on-auto-complete))" t nil) + +(autoload 'jedi:auto-complete-mode "jedi" "\ + + +\(fn)" nil nil) + +(setq jedi:setup-function #'jedi:ac-setup jedi:mode-function #'jedi:auto-complete-mode) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; jedi-autoloads.el ends here diff --git a/emacs.d/elpa/jedi-20150413.2208/jedi-pkg.el b/emacs.d/elpa/jedi-20150413.2208/jedi-pkg.el new file mode 100644 index 0000000..aaec797 --- /dev/null +++ b/emacs.d/elpa/jedi-20150413.2208/jedi-pkg.el @@ -0,0 +1 @@ +(define-package "jedi" "20150413.2208" "a Python auto-completion for Emacs" '((emacs "24") (jedi-core "0.2.2") (auto-complete "1.4"))) diff --git a/emacs.d/elpa/jedi-20150413.2208/jedi.el b/emacs.d/elpa/jedi-20150413.2208/jedi.el new file mode 100644 index 0000000..0c2a608 --- /dev/null +++ b/emacs.d/elpa/jedi-20150413.2208/jedi.el @@ -0,0 +1,112 @@ +;;; jedi.el --- a Python auto-completion for Emacs -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 Takafumi Arakaki + +;; Author: Takafumi Arakaki +;; Package-Requires: ((emacs "24") (jedi-core "0.2.2") (auto-complete "1.4")) +;; Version: 0.2.3 +;; Package-Version: 20150413.2208 + +;; 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: + +;;; Code: + +(require 'cl-lib) +(require 'auto-complete) +(require 'jedi-core) + +;;; AC source +(defun jedi:ac-direct-matches () + (mapcar + (lambda (x) + (destructuring-bind (&key word doc description symbol) + x + (popup-make-item word + :symbol symbol + :document (unless (equal doc "") doc) + :summary description))) + jedi:complete-reply)) + +;;;###autoload +(defun jedi:ac-setup () + "Add Jedi AC sources to `ac-sources'. + +If auto-completion is all you need, you can call this function instead +of `jedi:setup', like this:: + + (add-hook 'python-mode-hook 'jedi:ac-setup) + +Note that this function calls `auto-complete-mode' if it is not +already enabled, for people who don't call `global-auto-complete-mode' +in their Emacs configuration." + (interactive) + (add-to-list 'ac-sources 'ac-source-jedi-direct) + (unless auto-complete-mode + (auto-complete-mode))) + +(defun jedi:ac-direct-prefix () + (or (ac-prefix-default) + (when (= jedi:complete-request-point (point)) + jedi:complete-request-point))) + +(defun jedi:after-change-handler (&rest _) + (unless (or (ac-menu-live-p) (ac-inline-live-p)) + (jedi:defined-names--singleton-deferred))) + +;; (makunbound 'ac-source-jedi-direct) +(ac-define-source jedi-direct + '((candidates . jedi:ac-direct-matches) + (prefix . jedi:ac-direct-prefix) + (init . jedi:complete-request) + (requires . -1))) + +;;;###autoload +(cl-defun jedi:complete (&key (expand ac-expand-on-auto-complete)) + "Complete code at point." + (interactive) + (deferred:nextc (jedi:complete-request) + (lambda () + (let ((ac-expand-on-auto-complete expand)) + (ac-start :triggered 'command))))) +;; Calling `auto-complete' or `ac-update-greedy' instead of `ac-start' +;; here did not work. + +(defun jedi:dot-complete (nchars) + "Insert dot and complete code at point." + (interactive "p") + (self-insert-command nchars) + (unless (or (/= nchars 1) ;; don't complete if inserted 2+ dots + (ac-cursor-on-diable-face-p) + ;; don't complete if the dot is immediately after int literal + (looking-back "\\(\\`\\|[^._[:alnum:]]\\)[0-9]+\\.")) + (jedi:complete :expand nil))) + +;;;###autoload +(defun jedi:auto-complete-mode () + (let ((map jedi-mode-map)) + (if jedi:complete-on-dot + (define-key map "." 'jedi:dot-complete) + (define-key map "." nil))) + (if jedi-mode + (add-hook 'after-change-functions 'jedi:after-change-handler nil t) + (remove-hook 'after-change-functions 'jedi:after-change-handler t))) + +;;;###autoload +(setq jedi:setup-function #'jedi:ac-setup + jedi:mode-function #'jedi:auto-complete-mode) + +(provide 'jedi) +;;; jedi.el ends here diff --git a/emacs.d/elpa/jedi-core-20150507.438/Makefile b/emacs.d/elpa/jedi-core-20150507.438/Makefile new file mode 100644 index 0000000..2c44031 --- /dev/null +++ b/emacs.d/elpa/jedi-core-20150507.438/Makefile @@ -0,0 +1,201 @@ +ENV = env + +VIRTUALENV_SYSTEM_SITE_PACKAGES ?= true +VIRTUALENV = \ + VIRTUALENV_SYSTEM_SITE_PACKAGES=$(VIRTUALENV_SYSTEM_SITE_PACKAGES) \ + virtualenv --python=$(PYTHON) +PIP_INSTALL = $(ENV)/$(BINDIR)/pip install +JEDI_DEV_URL = https://github.com/davidhalter/jedi/archive/dev.zip + +PYTHON ?= python +CASK ?= cask +export EMACS ?= emacs + +BINDIR ?= bin + +ELPA_DIR = \ + .cask/$(shell ${EMACS} -Q --batch --eval '(princ emacs-version)')/elpa +# See: cask-elpa-dir + +VIRTUAL_EMACS = ${CASK} exec ${EMACS} -Q \ +--eval "(setq python-environment--verbose t)" \ +--eval "(setq jedi:environment-root \"$(PWD)/$(ENV)\")" + +.PHONY : test test-1 tryout clean-elpa requirements env clean-env clean \ + print-deps travis-ci doc + +TEST_DEPS = elpa env +test: ${TEST_DEPS} + ${MAKE} test-1 + +test-1: + ${VIRTUAL_EMACS} -batch \ + -L . -l test-jedi.el -f ert-run-tests-batch-and-exit + tox + +compile: elpa clean-elc + ${VIRTUAL_EMACS} -batch \ + -L . -f batch-byte-compile *.el + +clean-elc: + rm -rf *.elc + +tryout: compile env + ${VIRTUAL_EMACS} -L . -l tryout-jedi.el + +doc: elpa + make -C doc html + +ensure-git: + test -d .git # Running task that can be run only in git repository + +elpa: ${ELPA_DIR} +${ELPA_DIR}: Cask + ${CASK} install + test -d $@ + touch $@ + + +clean-elpa: + rm -rf ${ELPA_DIR} + +requirements: + @echo "**************************************************************" + @echo " ERROR: \"make requirements\" is obsolete!" + @echo " Please run \"M-x jedi:install-server\" inside of your Emacs." + @echo " * If you are using el-get, please update it first." + @echo " See also: https://github.com/dimitri/el-get/pull/1603" + @echo "**************************************************************" + @exit 1 + +install-jedi-dev: + ${PIP_INSTALL} --upgrade ${JEDI_DEV_URL} + +env: $(ENV)/$(BINDIR)/jediepcserver +$(ENV)/$(BINDIR)/jediepcserver: ${ELPA_DIR} jediepcserver.py setup.py + ${VIRTUAL_EMACS} -batch -L . -l jedi.el -f "jedi:install-server-block" + test -f $@ + +clean-env: + rm -rf $(ENV) + +clean-el: clean-elpa clean-elc +clean: clean-env clean-el + rm -rf .cask + +print-deps: elpa env + @echo "----------------------- Dependencies -----------------------" + $(EMACS) --version + ${VIRTUAL_EMACS} -batch -L . -l jedi.el -f jedi:print-jedi-version + ls -d $(ENV)/*/python*/site-packages/*egg-info + @echo "------------------------------------------------------------" + +before-test: ${TEST_DEPS} + tox --notest + +travis-ci: print-deps test + test ! -d ~/.emacs.d/.python-environments + + + +# Run test against Emacs listed in ${EMACS_LIST}. +# This is for running tests for multiple Emacs versions. +# This is not used in Travis CI. Usage:: +# +# make EMACS_LIST="emacs emacs-snapshot emacs23" test-all +# +# See: http://stackoverflow.com/a/12110773/727827 +# +# Use ${MET_MAKEFLAGS} to do the tests in parallel. +# +# MET_MAKEFLAGS=-j4 + +JOBS := $(addprefix job-,${EMACS_LIST}) +.PHONY: ${JOBS} + +${JOBS}: job-%: + ${MAKE} EMACS=$* clean-elc elpa + ${MAKE} EMACS=$* ${MET_MAKEFLAGS} test-1 + +test-all: env ${JOBS} + + + +### Packaging +# +# Create dist/${PACKAGE}-${VERSION}.tar.gz ready for distribution. +# +# See: (info "(elisp) Multi-file Packages") +PACKAGE = jedi +VERSION = $(shell grep ';; Version:' jedi.el | sed 's/^.* \([0-9].*\)$$/\1/') +DIST_FILES = jedi-pkg.el jedi.el jediepcserver.py \ + Makefile tryout-jedi.el + +.PHONY: dist ${PACKAGE}-${VERSION}.tar.gz ${PACKAGE}-${VERSION} \ + clean-dist clean-dist-all + +dist: clean-dist + ${MAKE} dist-1 + +dist-1: dist/${PACKAGE}-${VERSION}.tar dist/${PACKAGE}-${VERSION}.tar.gz + +dist/${PACKAGE}-${VERSION}.tar: ${PACKAGE}-${VERSION}.tar +${PACKAGE}-${VERSION}.tar: ${PACKAGE}-${VERSION} + tar --directory dist -cvf dist/$@ $< + +dist/${PACKAGE}-${VERSION}.tar.gz: ${PACKAGE}-${VERSION}.tar.gz +${PACKAGE}-${VERSION}.tar.gz: ${PACKAGE}-${VERSION} + tar --directory dist -cvzf dist/$@ $< + +${PACKAGE}-${VERSION}: dist/${PACKAGE}-${VERSION} +dist/${PACKAGE}-${VERSION}: + mkdir -p $@ + cp -v ${DIST_FILES} $@ + +clean-dist: + rm -rf dist/${PACKAGE}-${VERSION}* + +clean-dist-all: + rm -rf dist + + + +### Package installation +PACKAGE_USER_DIR = +TEST_PACKAGE_DIR = dist/test + +install-dist: + test -d '${PACKAGE_USER_DIR}' + ${EMACS} --batch -Q \ + -l package \ + --eval " \ + (add-to-list 'package-archives \ + '(\"marmalade\" . \"http://marmalade-repo.org/packages/\") t)" \ + --eval '(setq package-user-dir "${PWD}/${PACKAGE_USER_DIR}")' \ + --eval '(package-list-packages)' \ + --eval '(package-install-file "${PWD}/dist/${PACKAGE}-${VERSION}.tar")' + +test-install: dist/${PACKAGE}-${VERSION}.tar + rm -rf ${TEST_PACKAGE_DIR} + mkdir -p ${TEST_PACKAGE_DIR} + ${MAKE} install-dist PACKAGE_USER_DIR=${TEST_PACKAGE_DIR} + +test-install-requirement: test-install + ${MAKE} --directory ${TEST_PACKAGE_DIR}/${PACKAGE}-${VERSION} \ + requirements + + + +### GH pages +MAKE_GH_PAGES = $(MAKE) --directory doc --file gh-pages.mk + +gh-pages-latest: + $(MAKE_GH_PAGES) + +# Publish released documentation. This task can be run only when the +# current revision has tag (i.e., released). +gh-pages-released: + # Make sure it's on tag + git describe --tags --dirty | grep -v - + # Run doc/gh-pages.mk + $(MAKE_GH_PAGES) DOC_VER=released diff --git a/emacs.d/elpa/jedi-core-20150507.438/jedi-core-autoloads.el b/emacs.d/elpa/jedi-core-20150507.438/jedi-core-autoloads.el new file mode 100644 index 0000000..5f59746 --- /dev/null +++ b/emacs.d/elpa/jedi-core-20150507.438/jedi-core-autoloads.el @@ -0,0 +1,107 @@ +;;; jedi-core-autoloads.el --- automatically extracted autoloads +;; +;;; Code: +(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +;;;### (autoloads nil "jedi-core" "jedi-core.el" (21837 24206 0 0)) +;;; Generated autoloads from jedi-core.el + +(autoload 'jedi:start-dedicated-server "jedi-core" "\ +Start Jedi server dedicated to this buffer. +This is useful, for example, when you want to use different +`sys.path' for some buffer. When invoked as an interactive +command, it asks you how to start the Jedi server. You can edit +the command in minibuffer to specify the way Jedi server run. + +If you want to setup how Jedi server is started programmatically +per-buffer/per-project basis, make `jedi:server-command' and +`jedi:server-args' buffer local and set it in `python-mode-hook'. +See also: `jedi:server-args'. + +\(fn COMMAND)" t nil) + +(autoload 'helm-jedi-related-names "jedi-core" "\ +Find related names of the object at point using `helm' interface. + +\(fn)" t nil) + +(autoload 'anything-jedi-related-names "jedi-core" "\ +Find related names of the object at point using `anything' interface. + +\(fn)" t nil) + +(autoload 'jedi:setup "jedi-core" "\ +Fully setup jedi.el for current buffer. +It setups `ac-sources' or `company-backends' and turns +`jedi-mode' on. + +This function is intended to be called from `python-mode-hook', +like this:: + + (add-hook 'python-mode-hook 'jedi:setup) + +You can also call this function as a command, to quickly test +what jedi can do. + +\(fn)" t nil) + +(autoload 'jedi:install-server "jedi-core" "\ +This command installs Jedi server script jediepcserver.py in a +Python environment dedicated to Emacs. By default, the +environment is at ``~/.emacs.d/.python-environments/default/``. +This environment is automatically created by ``virtualenv`` if it +does not exist. + +Run this command (i.e., type ``M-x jedi:install-server RET``) +whenever Jedi.el shows a message to do so. It is a good idea to +run this every time after you update Jedi.el to sync version of +Python modules used by Jedi.el and Jedi.el itself. + +You can modify the location of the environment by changing +`jedi:environment-root' and/or `python-environment-directory'. More +specifically, Jedi.el will install Python modules under the directory +``PYTHON-ENVIRONMENT-DIRECTORY/JEDI:ENVIRONMENT-ROOT``. Note that you +need command line program ``virtualenv``. If you have the command in +an unusual location, use `python-environment-virtualenv' to specify the +location. + +.. NOTE:: jediepcserver.py is installed in a virtual environment but it + does not mean Jedi.el cannot recognize the modules in virtual + environment you are using for your Python development. Jedi + EPC server recognize the virtualenv it is in (i.e., the + environment variable ``VIRTUAL_ENV`` in your Emacs) and then + add modules in that environment to its ``sys.path``. You can + also add ``--virtual-env PATH/TO/ENV`` to `jedi:server-args' + to include modules of virtual environment even you launch + Emacs outside of the virtual environment. + +.. NOTE:: It is highly recommended to use this command to install + Python modules for Jedi.el. You still can install Python + modules used by Jedi.el manually. However, you are then + responsible for keeping Jedi.el and Python modules compatible. + +See also: + +- https://github.com/tkf/emacs-jedi/pull/72 +- https://github.com/tkf/emacs-jedi/issues/140#issuecomment-37358527 + +\(fn)" t nil) + +(autoload 'jedi:install-server-block "jedi-core" "\ +Blocking version `jedi:install-server'. + +\(fn)" nil nil) + +;;;*** + +;;;### (autoloads nil nil ("jedi-core-pkg.el") (21837 24206 483113 +;;;;;; 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; End: +;;; jedi-core-autoloads.el ends here diff --git a/emacs.d/elpa/jedi-core-20150507.438/jedi-core-pkg.el b/emacs.d/elpa/jedi-core-20150507.438/jedi-core-pkg.el new file mode 100644 index 0000000..ac93454 --- /dev/null +++ b/emacs.d/elpa/jedi-core-20150507.438/jedi-core-pkg.el @@ -0,0 +1,8 @@ +(define-package "jedi-core" "20150507.438" "Common code of jedi.el and company-jedi.el" + '((emacs "24") + (epc "0.1.0") + (python-environment "0.0.2") + (cl-lib "0.5"))) +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/emacs.d/elpa/jedi-core-20150507.438/jedi-core.el b/emacs.d/elpa/jedi-core-20150507.438/jedi-core.el new file mode 100644 index 0000000..56e6fc5 --- /dev/null +++ b/emacs.d/elpa/jedi-core-20150507.438/jedi-core.el @@ -0,0 +1,1282 @@ +;;; jedi-core.el --- Common code of jedi.el and company-jedi.el -*- lexical-binding: t; -*- + +;; Author: Takafumi Arakaki +;; Package-Requires: ((emacs "24") (epc "0.1.0") (python-environment "0.0.2") (cl-lib "0.5")) +;; Version: 0.2.3 + +;; This file is NOT part of GNU Emacs. + +;; jedi.el is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; jedi.el is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with jedi.el. +;; If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'cl-lib) +(require 'ring) + +(require 'epc) +(require 'python-environment) + +(declare-function popup-tip "popup") +(declare-function pos-tip-show "pos-tip") + + +(defgroup jedi nil + "Auto-completion for Python." + :group 'completion + :prefix "jedi:") + +(defconst jedi:version "0.2.1") + +(defvar jedi:source-dir (if load-file-name + (file-name-directory load-file-name) + default-directory)) + +(defvar jedi:epc nil) +(make-variable-buffer-local 'jedi:epc) + +(defvar jedi:server-script + (convert-standard-filename + (expand-file-name "jediepcserver.py" jedi:source-dir)) + "Full path to Jedi server script file ``jediepcserver.py``.") + +(defvar jedi:setup-function nil) +(defvar jedi:mode-function nil) + + +;;; Configuration variables + +(defcustom jedi:environment-root nil + "Name of Python environment to use. +If it is nil, `python-environment-default-root-name' is used. + +You can specify a full path instead of a name (relative path). +In that case, `python-environment-directory' is ignored and +Python virtual environment is created at the specified path." + :group 'jedi) + +(defcustom jedi:environment-virtualenv nil + "``virtualenv`` command to use. A list of string. +If it is nil, `python-environment-virtualenv' is used instead. + +You must set non-`nil' value to `jedi:environment-root' in order +to make this setting work." + :group 'jedi) + +(defun jedi:-env-server-command () + (let* ((getbin (lambda (x) (python-environment-bin x jedi:environment-root))) + (script (or (funcall getbin "jediepcserver") + (funcall getbin "jediepcserver.py")))) + (when script + (list script)))) + +(defcustom jedi:server-command + (or (jedi:-env-server-command) + (list "python" jedi:server-script)) + "Command used to run Jedi server. + +.. NOTE:: + + If you used `jedi:install-server' (recommended) to install + Python server jediepcserver.py, you don't need to mess around + with jediepcserver.py. Jedi.el handles everything + automatically. + +If you install Python server jediepcserver.py using +`jedi:install-server' command, `jedi:server-command' should be +automatically set to:: + + '(\"~/.emacs.d/.python-environments/default/bin/jediepcserver.py\") + +Otherwise, it is set to:: + + '(\"python\" \"JEDI:SOURCE-DIR/jediepcserver.py\") + +.. NOTE:: If you installed jediepcserver.py manually, then you + have to set `jedi:server-command' appropriately. + + If you can run ``jediepcserver.py --help`` in your shell, then + you can simply set:: + + (setq jedi:server-command '(\"jediepcserver.py\")) + + Otherwise, you need to find where you installed + jediepcserver.py then set the path directly:: + + (setq jedi:server-command '(\"PATH/TO/jediepcserver.py\")) + +If you want to use a specific version of Python, setup +`jedi:environment-virtualenv' variable appropriately and +reinstall jediepcserver.py. + +If you want to pass some arguments to the Jedi server command, +use `jedi:server-args' instead of appending them +`jedi:server-command'." + :group 'jedi) + +(defcustom jedi:server-args nil + "Command line arguments to be appended to `jedi:server-command'. + +If you want to add some special `sys.path' when starting Jedi +server, do something like this:: + + (setq jedi:server-args + '(\"--sys-path\" \"MY/SPECIAL/PATH\" + \"--sys-path\" \"MY/OTHER/SPECIAL/PATH\")) + +If you want to include some virtualenv, do something like the +following. Note that actual environment variable ``VIRTUAL_ENV`` +is treated automatically so you don't need to pass it. Also, +you need to start Jedi EPC server with the same python version +that you use for the virtualenv.:: + + (setq jedi:server-args + '(\"--virtual-env\" \"SOME/VIRTUAL_ENV_1\" + \"--virtual-env\" \"SOME/VIRTUAL_ENV_2\")) + +To see what other arguments Jedi server can take, execute the +following command:: + + python jediepcserver.py --help + + +**Advanced usage** + +Sometimes you want to configure how Jedi server is started per +buffer. To do that, you should make this variable buffer local +in `python-mode-hook' and set it to some buffer specific variable, +like this:: + + (defun my-jedi-server-setup () + (let ((cmds (GET-SOME-PROJECT-SPECIFIC-COMMAND)) + (args (GET-SOME-PROJECT-SPECIFIC-ARGS))) + (when cmds (set (make-local-variable 'jedi:server-command) cmds)) + (when args (set (make-local-variable 'jedi:server-args) args)))) + + (add-hook 'python-mode-hook 'my-jedi-server-setup) + +Note that Jedi server run by the same command is pooled. So, +there is only one Jedi server for the same set of command. If +you want to check how many EPC servers are running, use the EPC +GUI: M-x `epc:controller'. You will see a table of EPC connections +for Jedi.el and other EPC applications. + +If you want to start a new ad-hoc server for the current buffer, +use the command `jedi:start-dedicated-server'." + :group 'jedi) + +(defcustom jedi:complete-on-dot nil + "Non-`nil' means automatically start completion after inserting a dot. +To make this option work, you need to use `jedi:setup' instead of +`jedi:ac-setup' to start Jedi." + :group 'jedi) + +(defcustom jedi:tooltip-method '(pos-tip popup) + "Configuration for `jedi:tooltip-show'. +This is a list which may contain symbol(s) `pos-tip' and/or +`popup'. It determines tooltip method to use. Setting this +value to nil means to use minibuffer instead of tooltip." + :group 'jedi) + +(defcustom jedi:get-in-function-call-timeout 3000 + "Cancel request to server for call signature after this period +specified in in millisecond." + :group 'jedi) + +(defcustom jedi:get-in-function-call-delay 1000 + "How long Jedi should wait before showing call signature +tooltip in millisecond." + :group 'jedi) + +(defcustom jedi:goto-definition-config + '((nil nil nil) + (t nil nil) + (nil definition nil) + (t definition nil) + (nil nil t ) + (t nil t ) + (nil definition t ) + (t definition t )) + "Configure how prefix argument modifies `jedi:goto-definition' behavior. + +Each element of the list is arguments (list) passed to +`jedi:goto-definition'. Note that this variable has no effect on +`jedi:goto-definition' when it is used as a lisp function + +The following setting is default (last parts are omitted). +Nth element is used as the argument when N universal prefix +arguments (``C-u``) are given.:: + + (setq jedi:goto-definition-config + '((nil nil nil) ; C-. + (t nil nil) ; C-u C-. + (nil definition nil) ; C-u C-u C-. + (t definition nil) ; C-u C-u C-u C-. + ...)) + +For example, if you want to follow \"substitution path\" by default, +use the setting like this:: + + (setq jedi:goto-definition-config + '((nil definition nil) + (t definition nil) + (nil nil nil) + (t nil nil) + (nil definition t ) + (t definition t ) + (nil nil t ) + (t nil t ))) + +You can rearrange the order to have most useful sets of arguments +at the top." + :group 'jedi) + +(defcustom jedi:doc-mode 'rst-mode + "Major mode to use when showing document." + :group 'jedi) + +(defcustom jedi:doc-hook '(view-mode) + "The hook that's run after showing a document." + :type 'hook + :group 'jedi) + +(defcustom jedi:doc-display-buffer 'display-buffer + "A function to be called with a buffer to show document." + :group 'jedi) + +(defcustom jedi:install-imenu nil + "[EXPERIMENTAL] If `t', use Jedi to create `imenu' index. +To use this feature, you need to install the developmental +version (\"dev\" branch) of Jedi." + :group 'jedi) + +(defcustom jedi:imenu-create-index-function 'jedi:create-nested-imenu-index + "`imenu-create-index-function' for Jedi.el. +It must be a function that takes no argument and return an object +described in `imenu--index-alist'. +This can be set to `jedi:create-flat-imenu-index'. +Default is `jedi:create-nested-imenu-index'." + :group 'jedi) + +(make-obsolete-variable 'jedi:setup-keys nil "0.1.3") +(defcustom jedi:setup-keys nil + "Setup recommended keybinds. + +.. warning:: Use of this value is obsolete now. As of 0.1.3, + jedi.el has default keybinds, which are different than these. See also + `jedi-mode'. + +.. admonition:: Default keybinds + + ```` : = `jedi:key-complete' + Complete code at point. (`jedi:complete') + + ``C-.`` : = `jedi:key-goto-definition' + Goto the definition of the object at point. (`jedi:goto-definition') + + ``C-c d`` : = `jedi:key-show-doc' + Show the documentation of the object at point. (`jedi:show-doc') + + ``C-c r`` : = `jedi:key-related-names' + Find related names of the object at point. + (`helm-jedi-related-names' / `anything-jedi-related-names') + +When `jedi:setup-keys' is non-`nil', recommended keybinds are set +in `jedi-mode-map' when **loading** jedi.el. Therefore, you must +set this value before jedi.el is loaded. As recommended usage of +jedi.el is to call `jedi:setup' via `python-mode-hook' where +`jedi:setup' is autloaded, setting `jedi:setup-keys' to `t' in +you emacs setup (e.g., ``.emacs.d/init.el``) works fine.:: + + (setq jedi:setup-keys t) + (add-hook 'python-mode-hook 'jedi:setup) + +If you want to require jedi.el explicitly when loading Emacs, +make sure to set `jedi:setup-keys' before loading jedi.el:: + + (setq jedi:setup-keys t) + (require 'jedi) + +Byte compiler warns about unbound variable if you set +`jedi:setup-keys' before loading jedi.el. The proper way to +suppress this warning is the following:: + + (eval-when-compile (require 'jedi nil t)) + (setq jedi:setup-keys t) + +You can change these keybinds by changing `jedi:key-complete', +`jedi:key-goto-definition', `jedi:key-show-doc', and +`jedi:key-related-names'. For example, default keybind for +ropemacs's `rope-show-doc' is same as `jedi:show-doc'. You can +avoid collision by something like this:: + + (setq jedi:key-show-doc (kbd \"C-c D\"))" + :group 'jedi) + +(defcustom jedi:key-complete (kbd "") + "Keybind for command `jedi:complete'." + :group 'jedi) + +(defcustom jedi:key-goto-definition (kbd "C-.") + "Keybind for command `jedi:goto-definition'." + :group 'jedi) + +(defcustom jedi:key-show-doc (kbd "C-c d") + "Keybind for command `jedi:show-doc'." + :group 'jedi) + +(defcustom jedi:key-related-names (kbd "C-c r") + "Keybind for command `helm-jedi-related-names' or +`anything-jedi-related-names'." + :group 'jedi) + +(defcustom jedi:key-goto-definition-pop-marker (kbd "C-,") + "Keybind for command `jedi:goto-definition-pop-marker'." + :group 'jedi) + +(defcustom jedi:use-shortcuts nil + "If non-`nil', enable the following shortcuts: + +| ``M-.`` `jedi:goto-definition' +| ``M-,`` `jedi:goto-definition-pop-marker' +" + :group 'jedi) + +(defcustom jedi:import-python-el-settings t + "Automatically import setting from python.el variables." + :group 'jedi) + +(defcustom jedi:goto-definition-marker-ring-length 16 + "Length of marker ring to store `jedi:goto-definition' call positions" + :group 'jedi) + + +;;; Internal variables + +(defvar jedi:get-in-function-call--d nil + "Bounded to deferred object while requesting get-in-function-call.") + +(defvar jedi:defined-names--singleton-d nil + "Bounded to deferred object while requesting defined_names.") + + +;;; Jedi mode + +(defvar jedi-mode-map (make-sparse-keymap)) + +(defun jedi:handle-post-command () + (jedi:get-in-function-call-when-idle)) + +(define-minor-mode jedi-mode + "Jedi mode. +When `jedi-mode' is on, call signature is automatically shown as +toolitp when inside of function call. + +\\{jedi-mode-map}" + :keymap jedi-mode-map + :group 'jedi + (let ((map jedi-mode-map)) + (when jedi:use-shortcuts + (define-key map (kbd "M-.") 'jedi:goto-definition) + (define-key map (kbd "M-,") 'jedi:goto-definition-pop-marker))) + (if jedi-mode + (progn + (when jedi:install-imenu + (jedi:defined-names-deferred) + (setq imenu-create-index-function jedi:imenu-create-index-function)) + (add-hook 'post-command-hook 'jedi:handle-post-command nil t) + (add-hook 'kill-buffer-hook 'jedi:server-pool--gc-when-idle nil t)) + (remove-hook 'post-command-hook 'jedi:handle-post-command t) + (remove-hook 'kill-buffer-hook 'jedi:server-pool--gc-when-idle t) + (jedi:server-pool--gc-when-idle)) + (when jedi:mode-function + (funcall jedi:mode-function))) + +;; Define keybinds. +;; See: https://github.com/tkf/emacs-jedi/issues/47 +(let ((map jedi-mode-map)) + (when (and (boundp 'auto-complete-mode) auto-complete-mode) + (define-key map (kbd "") 'jedi:complete)) + (define-key map (kbd "C-c ?") 'jedi:show-doc) + (define-key map (kbd "C-c .") 'jedi:goto-definition) + (define-key map (kbd "C-c ,") 'jedi:goto-definition-pop-marker) + (let ((command (cond + ((featurep 'helm) 'helm-jedi-related-names) + ((featurep 'anything) 'anything-jedi-related-names) + ((locate-library "helm") 'helm-jedi-related-names) + ((locate-library "anything") 'anything-jedi-related-names)))) + (when command + (define-key map (kbd "C-c /") command)))) + +(when jedi:setup-keys + (let ((map jedi-mode-map)) + (define-key map jedi:key-complete 'jedi:complete) + (define-key map jedi:key-goto-definition 'jedi:goto-definition) + (define-key map jedi:key-show-doc 'jedi:show-doc) + (define-key map jedi:key-goto-definition-pop-marker + 'jedi:goto-definition-pop-marker) + (let ((command (cond + ((featurep 'helm) 'helm-jedi-related-names) + ((featurep 'anything) 'anything-jedi-related-names)))) + (when command + (define-key map jedi:key-related-names command))))) + + +;;; EPC utils + +(defun jedi:epc--live-p (mngr) + "Return non-nil when MNGR is an EPC manager object with a live +connection." + (let ((proc (ignore-errors + (epc:connection-process (epc:manager-connection mngr))))) + (and (processp proc) + ;; Same as `process-live-p' in Emacs >= 24: + (memq (process-status proc) '(run open listen connect stop))))) + +(defmacro jedi:-with-run-on-error (body &rest run-on-error) + (declare (indent 1)) + `(let ((something-happened t)) + (unwind-protect + (prog1 ,body + (setq something-happened nil)) + (when something-happened + ,@run-on-error)))) + +(defun jedi:epc--start-epc (server-prog server-args) + "Same as `epc:start-epc', but set query-on-exit flag for +associated processes to nil." + (let ((mngr (jedi:-with-run-on-error + (epc:start-epc server-prog server-args) + (display-warning 'jedi "\ +Failed to start Jedi EPC server. +*** You may need to run \"M-x jedi:install-server\". *** +This could solve the problem especially if you haven't run the command yet +since Jedi.el installation or update and if the server complains about +Python module imports." :error)))) + (set-process-query-on-exit-flag (epc:connection-process + (epc:manager-connection mngr)) + nil) + (set-process-query-on-exit-flag (epc:manager-server-process mngr) nil) + mngr)) + + +;;; Server pool + +(defvar jedi:server-pool--table (make-hash-table :test 'equal) + "A hash table that holds a pool of EPC server instances.") + +(defun jedi:server-pool--start (command) + "Get an EPC server instance from server pool by COMMAND as a +key, or start new one if there is none." + (let ((cached (gethash command jedi:server-pool--table))) + (if (and cached (jedi:epc--live-p cached)) + cached + (let* ((default-directory "/") + (mngr (jedi:epc--start-epc (car command) (cdr command)))) + (puthash command mngr jedi:server-pool--table) + (jedi:server-pool--gc-when-idle) + mngr)))) + +(defun jedi:-get-servers-in-use () + "Return a list of non-nil `jedi:epc' in all buffers." + (cl-loop with mngr-list + for buffer in (buffer-list) + for mngr = (with-current-buffer buffer jedi:epc) + when (and mngr (not (memq mngr mngr-list))) + collect mngr into mngr-list + finally return mngr-list)) + +(defvar jedi:server-pool--gc-timer nil) + +(defun jedi:server-pool--gc () + "Stop unused servers." + (let ((servers-in-use (jedi:-get-servers-in-use))) + (maphash + (lambda (key mngr) + (unless (memq mngr servers-in-use) + (remhash key jedi:server-pool--table) + (epc:stop-epc mngr))) + jedi:server-pool--table)) + ;; Clear timer so that GC is started next time + ;; `jedi:server-pool--gc-when-idle' is called. + (setq jedi:server-pool--gc-timer nil)) + +(defun jedi:server-pool--gc-when-idle () + "Run `jedi:server-pool--gc' when idle." + (unless jedi:server-pool--gc-timer + (setq jedi:server-pool--gc-timer + (run-with-idle-timer 10 nil 'jedi:server-pool--gc)))) + + +;;; Server management + +(defun jedi:start-server () + (if (jedi:epc--live-p jedi:epc) + (message "Jedi server is already started!") + (setq jedi:epc (jedi:server-pool--start + (append jedi:server-command jedi:server-args)))) + jedi:epc) + +(defun jedi:stop-server () + "Stop Jedi server. Use this command when you want to restart +Jedi server (e.g., when you changed `jedi:server-command' or +`jedi:server-args'). Jedi srever will be restarted automatically +later when it is needed." + (interactive) + (if jedi:epc + (epc:stop-epc jedi:epc) + (message "Jedi server is already killed.")) + (setq jedi:epc nil) + ;; It could be non-nil due to some error. Rescue it in that case. + (setq jedi:get-in-function-call--d nil) + (setq jedi:defined-names--singleton-d nil)) + +(defun jedi:get-epc () + (if (jedi:epc--live-p jedi:epc) + jedi:epc + (jedi:start-server))) + +;;;###autoload +(defun jedi:start-dedicated-server (command) + "Start Jedi server dedicated to this buffer. +This is useful, for example, when you want to use different +`sys.path' for some buffer. When invoked as an interactive +command, it asks you how to start the Jedi server. You can edit +the command in minibuffer to specify the way Jedi server run. + +If you want to setup how Jedi server is started programmatically +per-buffer/per-project basis, make `jedi:server-command' and +`jedi:server-args' buffer local and set it in `python-mode-hook'. +See also: `jedi:server-args'." + (interactive + (list (split-string-and-unquote + (read-string "Run Jedi server: " + (mapconcat + #'identity + (append jedi:server-command + jedi:server-args) + " "))))) + ;; Reset `jedi:epc' so that a new server is created when COMMAND is + ;; new. If it is already in the server pool, the server instance + ;; already in the pool is picked up by `jedi:start-server'. + (setq jedi:epc nil) + ;; Set `jedi:server-command', so that this command is used + ;; when restarting EPC server of this buffer. + (set (make-local-variable 'jedi:server-command) command) + (set (make-local-variable 'jedi:server-args) nil) + (jedi:start-server)) + +(defun jedi:-buffer-file-name () + "Return `buffer-file-name' without text properties. +See: https://github.com/tkf/emacs-jedi/issues/54" + (substring-no-properties (or (buffer-file-name) ""))) + +(defun jedi:call-deferred (method-name) + "Call ``Script(...).METHOD-NAME`` and return a deferred object." + (let ((source (buffer-substring-no-properties (point-min) (point-max))) + (line (count-lines (point-min) (min (1+ (point)) (point-max)))) + (column (- (point) (line-beginning-position))) + (source-path (jedi:-buffer-file-name))) + (epc:call-deferred (jedi:get-epc) + method-name + (list source line column source-path)))) + + +;;; Completion + +(defvar jedi:complete-reply nil + "Last reply to `jedi:complete-request'.") + +(defvar jedi:complete-request-point 0 + ;; It is passed to `=', so do not initialize this value by `nil'. + "The point where `jedi:complete-request' is called.") + +(defun jedi:complete-request () + "Request ``Script(...).complete`` and return a deferred object. +`jedi:complete-reply' is set to the reply sent from the server." + (setq jedi:complete-request-point (point)) + (deferred:nextc (jedi:call-deferred 'complete) + (lambda (reply) + (setq jedi:complete-reply reply)))) + + +;;; Call signature (get_in_function_call) + +(defface jedi:highlight-function-argument + '((t (:inherit bold))) + "Face used for the argument at point in a function's argument list" + :group 'jedi) + +(cl-defun jedi:get-in-function-call--construct-call-signature + (&key params index call_name) + (if (not index) + (concat call_name "()") + (let ((current-arg (nth index params))) + (when (and current-arg (null jedi:tooltip-method)) + (setf (nth index params) + (propertize current-arg 'face 'jedi:highlight-function-argument))) + (concat call_name "(" (mapconcat #'identity params ", ") ")")))) + +(defun jedi:get-in-function-call--tooltip-show (args) + (when (and args (and (boundp 'ac-completing) (not ac-completing))) + (jedi:tooltip-show + (apply #'jedi:get-in-function-call--construct-call-signature args)))) + +(defun jedi:get-in-function-call () + "Manually show call signature tooltip." + (interactive) + (deferred:nextc + (jedi:call-deferred 'get_in_function_call) + #'jedi:get-in-function-call--tooltip-show)) + +(defun jedi:get-in-function-call-when-idle () + "Show tooltip when Emacs is ilde." + (unless jedi:get-in-function-call--d + (setq jedi:get-in-function-call--d + (deferred:try + (deferred:$ + (deferred:wait-idle jedi:get-in-function-call-delay) + (deferred:nextc it + (lambda () + (when jedi-mode ; cursor may be moved + (deferred:timeout + jedi:get-in-function-call-timeout + nil + (jedi:call-deferred 'get_in_function_call))))) + (deferred:nextc it #'jedi:get-in-function-call--tooltip-show)) + :finally + (lambda () + (setq jedi:get-in-function-call--d nil)))))) + +(defun jedi:tooltip-show (string) + (cond + ((and (memq 'pos-tip jedi:tooltip-method) window-system + (featurep 'pos-tip)) + (pos-tip-show (jedi:string-fill-paragraph string) + 'popup-tip-face nil nil 0)) + ((and (memq 'popup jedi:tooltip-method) + (featurep 'popup)) + (popup-tip string)) + (t (when (stringp string) + (let ((message-log-max nil)) + (message string)))))) + +(defun jedi:string-fill-paragraph (string &optional justify) + (with-temp-buffer + (erase-buffer) + (insert string) + (goto-char (point-min)) + (fill-paragraph justify) + (buffer-string))) + + +;;; Goto + +(defvar jedi:goto-definition--index nil) +(defvar jedi:goto-definition--cache nil) +(defvar jedi:goto-definition--marker-ring + (make-ring jedi:goto-definition-marker-ring-length) + "Marker ring that stores `jedi:goto-definition' call positions") + +(defun jedi:goto-definition (&optional other-window deftype use-cache index) + "Goto the definition of the object at point. + +See `jedi:goto-definition-config' for how this function works +when universal prefix arguments \(``C-u``) are given. If +*numeric* prefix argument(s) \(e.g., ``M-0``) are given, goto +point of the INDEX-th result. Note that you cannot mix universal +and numeric prefixes. It is Emacs's limitation. If you mix both +kinds of prefix, you get numeric prefix. + +When used as a lisp function, popup a buffer when OTHER-WINDOW is +non-nil. DEFTYPE must be either `assignment' (default) or +`definition'. When USE-CACHE is non-nil, use the locations of +the last invocation of this command. If INDEX is specified, goto +INDEX-th result." + (interactive + (if (integerp current-prefix-arg) + (list nil nil nil current-prefix-arg) + (nth (let ((i (car current-prefix-arg))) + (if i (floor (log i 4)) 0)) + jedi:goto-definition-config))) + (cond + ((and (or use-cache index) + jedi:goto-definition--cache) + (setq jedi:goto-definition--index (or index 0)) + (jedi:goto-definition--nth other-window)) + ((and (eq last-command 'jedi:goto-definition) + (> (length jedi:goto-definition--cache) 1)) + (jedi:goto-definition-next other-window)) + (t + (setq jedi:goto-definition--index (or index 0)) + (deferred:nextc (jedi:call-deferred + (cl-case deftype + ((assignment nil) 'goto) + (definition 'get_definition) + (t (error "Unsupported deftype: %s" deftype)))) + (lambda (reply) + (jedi:goto-definition--callback reply other-window)))))) + +(defun jedi:goto-definition-push-marker () + "Push point onto goto-definition marker ring." + (ring-insert jedi:goto-definition--marker-ring (point-marker))) + +(defun jedi:goto-definition-pop-marker () + "Goto the last point where `jedi:goto-definition' was called." + (interactive) + (if (ring-empty-p jedi:goto-definition--marker-ring) + (error "Jedi marker ring is empty, can't pop") + (let ((marker (ring-remove jedi:goto-definition--marker-ring 0))) + (switch-to-buffer (or (marker-buffer marker) + (error "Buffer has been deleted"))) + (goto-char (marker-position marker)) + ;; Cleanup the marker so as to avoid them piling up. + (set-marker marker nil nil)))) + +(defun jedi:goto-definition-next (&optional other-window) + "Goto the next cached definition. See: `jedi:goto-definition'." + (interactive "P") + (let ((len (length jedi:goto-definition--cache)) + (n (1+ jedi:goto-definition--index))) + (setq jedi:goto-definition--index (if (>= n len) 0 n)) + (jedi:goto-definition--nth other-window))) + +(defun jedi:goto-definition--callback (reply other-window) + (if (not reply) + (message "Definition not found.") + (setq jedi:goto-definition--cache reply) + (jedi:goto-definition--nth other-window t))) + +(defun jedi:goto--line-column (line column) + "Like `goto-char' but specify the position by LINE and COLUMN." + (goto-char (point-min)) + (forward-line (1- line)) + (forward-char column)) + +(defun jedi:goto-definition--nth (other-window &optional try-next) + (let* ((len (length jedi:goto-definition--cache)) + (n jedi:goto-definition--index) + (next (lambda () + (when (< n (1- len)) + (cl-incf jedi:goto-definition--index) + (jedi:goto-definition--nth other-window) + t)))) + (cl-destructuring-bind (&key line_nr column module_path module_name + &allow-other-keys) + (nth n jedi:goto-definition--cache) + (cond + ((equal module_name "__builtin__") + (unless (and try-next (funcall next)) + (message "Cannot see the definition of __builtin__."))) + ((not (and module_path (file-exists-p module_path))) + (unless (and try-next (funcall next)) + (message "File '%s' does not exist." module_path))) + (t + (jedi:goto-definition-push-marker) + (funcall (if other-window #'find-file-other-window #'find-file) + module_path) + (jedi:goto--line-column line_nr column) + (jedi:goto-definition--notify-alternatives len n)))))) + +(defun jedi:goto-definition--notify-alternatives (len n) + (unless (= len 1) + (message + "%d-th point in %d candidates.%s" + (1+ n) + len + ;; Note: It must be `last-command', not `last-command' because + ;; this function is called in deferred at the first time. + (if (eq last-command 'jedi:goto-definition) + (format " Type %s to go to the next point." + (key-description + (car (where-is-internal 'jedi:goto-definition)))) + "")))) + + +;;; Full name + +(defun jedi:get-full-name-deferred () + (deferred:$ + (jedi:call-deferred 'get_definition) + (deferred:nextc it + (lambda (reply) + (cl-loop for def in reply + do (cl-destructuring-bind (&key full_name &allow-other-keys) + def + (when full_name + (return full_name)))))))) + +(cl-defun jedi:get-full-name-sync (&key (timeout 500)) + (epc:sync + (jedi:get-epc) + (deferred:timeout timeout nil (jedi:get-full-name-deferred)))) + + +;;; Related names + +(defun jedi:related-names--source (name candidates) + `((name . ,name) + (candidates . ,candidates) + (recenter) + (type . file-line))) + +(defun jedi:related-names--to-file-line (reply) + (mapcar + (lambda (x) + (cl-destructuring-bind + (&key line_nr module_name module_path description &allow-other-keys) + x + (format "%s:%s: %s - %s" module_path line_nr + module_name description))) + reply)) + +(defun jedi:related-names--helm (helm) + (deferred:nextc + (let ((to-file-line #'jedi:related-names--to-file-line)) + (deferred:parallel + (deferred:nextc (jedi:call-deferred 'related_names) to-file-line) + (deferred:nextc (jedi:call-deferred 'goto) to-file-line))) + (lambda (candidates-list) + (funcall + helm + :sources (list (jedi:related-names--source "Jedi Related Names" + (car candidates-list)) + (jedi:related-names--source "Jedi Goto" + (cadr candidates-list))) + :buffer (format "*%s jedi:related-names*" helm))))) + +;;;###autoload +(defun helm-jedi-related-names () + "Find related names of the object at point using `helm' interface." + (interactive) + (jedi:related-names--helm 'helm)) + +;;;###autoload +(defun anything-jedi-related-names () + "Find related names of the object at point using `anything' interface." + (interactive) + (jedi:related-names--helm 'anything)) + + +;;; Show document (get-definition) + +(defvar jedi:doc-buffer-name "*jedi:doc*") + +(defun jedi:show-doc () + "Show the documentation of the object at point." + (interactive) + (deferred:nextc (jedi:call-deferred 'get_definition) + (lambda (reply) + (with-current-buffer (get-buffer-create jedi:doc-buffer-name) + (cl-loop with has-doc = nil + with first = t + with inhibit-read-only = t + initially (erase-buffer) + for def in reply + do (cl-destructuring-bind + (&key doc desc_with_module &allow-other-keys) + def + (unless (or (null doc) (equal doc "")) + (if first + (setq first nil) + (insert "\n\n---\n\n")) + (insert "Docstring for " desc_with_module "\n\n" doc) + (setq has-doc t))) + finally do + (if (not has-doc) + (message "Document not found.") + (progn + (goto-char (point-min)) + (when (fboundp jedi:doc-mode) + (funcall jedi:doc-mode)) + (run-hooks 'jedi:doc-hook) + (funcall jedi:doc-display-buffer (current-buffer))))))))) + + +;;; Defined names (imenu) + +(defvar jedi:defined-names--cache nil) +(make-variable-buffer-local 'jedi:defined-names--cache) + +(defun jedi:defined-names-deferred () + (deferred:nextc + (epc:call-deferred + (jedi:get-epc) + 'defined_names + (list (buffer-substring-no-properties (point-min) (point-max)) + (jedi:-buffer-file-name))) + (lambda (reply) + (setq jedi:defined-names--cache reply)))) + +(defun jedi:defined-names--singleton-deferred () + "Like `jedi:defined-names-deferred', but make sure that only +one request at the time is emitted." + (unless jedi:defined-names--singleton-d + (setq jedi:defined-names--singleton-d + (deferred:watch (jedi:defined-names-deferred) + (lambda (_) (setq jedi:defined-names--singleton-d nil)))))) + +(defun jedi:defined-names--sync () + (unless jedi:defined-names--cache + (epc:sync (jedi:get-epc) (jedi:defined-names--singleton-deferred))) + jedi:defined-names--cache) + +(defun jedi:imenu-make-marker (def) + (cl-destructuring-bind (&key line_nr column &allow-other-keys) def + (save-excursion (jedi:goto--line-column line_nr column) + (point-marker)))) + +(defun jedi:create-nested-imenu-index--item (def) + (cons (plist-get def :name) (jedi:imenu-make-marker def))) + +(defun jedi:create-nested-imenu-index () + "`imenu-create-index-function' for Jedi.el. +See also `jedi:imenu-create-index-function'." + (when (called-interactively-p 'interactive) (jedi:defined-names--sync)) + (jedi:create-nested-imenu-index-1)) + +(defun jedi:create-nested-imenu-index-1 (&optional items) + (cl-loop for (def . subdefs) in (or items jedi:defined-names--cache) + if subdefs + collect (append + (list (plist-get def :local_name) + (jedi:create-nested-imenu-index--item def)) + (jedi:create-nested-imenu-index-1 subdefs)) + else + collect (jedi:create-nested-imenu-index--item def))) + +(defun jedi:create-flat-imenu-index () + "`imenu-create-index-function' for Jedi.el to create flatten index. +See also `jedi:imenu-create-index-function'." + (when (called-interactively-p 'interactive) (jedi:defined-names--sync)) + (jedi:create-flat-imenu-index-1)) + +(defun jedi:create-flat-imenu-index-1 (&optional items) + (cl-loop for (def . subdefs) in (or items jedi:defined-names--cache) + collect (cons (plist-get def :local_name) (jedi:imenu-make-marker def)) + when subdefs + append (jedi:create-flat-imenu-index-1 subdefs))) + + +;;; Meta info + +(defun jedi:show-setup-info () + "Show installation and configuration info in a buffer. +Paste the result of this function when asking question or +reporting bug. This command also tries to detect errors when +communicating with Jedi EPC server. If you have some problem you +may find some information about communication error." + (interactive) + (let (epc get-epc-error version-reply) + (condition-case err + (setq epc (jedi:get-epc)) + (error (setq get-epc-error err))) + (when epc + (setq version-reply + (condition-case err + (epc:sync + epc + (deferred:$ + (deferred:timeout 500 + '(:timeout nil) + (epc:call-deferred epc 'get_jedi_version nil)) + (deferred:error it + (lambda (err) `(:error ,err))))) + (error `(:sync-error ,err))))) + (let ((standard-output (get-buffer-create "*jedi:show-setup-info*"))) + (with-current-buffer standard-output + (emacs-lisp-mode) + (erase-buffer) + (insert ";; Emacs Lisp version:\n") + (pp `(:emacs-version ,emacs-version + :jedi-version ,jedi:version + :python-environment-version ,python-environment-version)) + (insert ";; Python version:\n") + (pp version-reply) + (when get-epc-error + (insert "\n;; EPC error:\n") + (pp `(:get-epc-error ,get-epc-error))) + (insert ";; Command line:\n") + (pp `(:virtualenv + ,(executable-find (car python-environment-virtualenv)) + :virtualenv-version + ,(ignore-errors (jedi:-virtualenv-version)))) + (insert ";; Customization:\n") + (pp (jedi:-list-customization)) + (display-buffer standard-output))))) + +(defun jedi:-list-defcustoms () + (cl-loop for sym being the symbols + for name = (symbol-name sym) + when (and (or (string-prefix-p "jedi:" name) + (string-prefix-p "python-environment-" name)) + (custom-variable-p sym)) + collect sym)) + +(defun jedi:-list-customization () + (cl-loop for sym in (sort (jedi:-list-defcustoms) + (lambda (x y) + (string< (symbol-name x) + (symbol-name y)))) + collect (cons sym (symbol-value sym)))) + +(defun jedi:-virtualenv-version () + "Return output of virtualenv --version" + (with-temp-buffer + (erase-buffer) + (call-process (executable-find (car python-environment-virtualenv)) + nil t nil + "--version") + (buffer-string))) + +(defun jedi:get-jedi-version-request () + "Request version of Python modules and return a deferred object." + (epc:call-deferred (jedi:get-epc) 'get_jedi_version nil)) + +(defun jedi:show-version-info () + "Show version info of Python modules used by the server. +Paste the result of this function in bug report." + (interactive) + (deferred:nextc (jedi:get-jedi-version-request) + (lambda (reply) + (let ((standard-output (get-buffer-create "*jedi:version*"))) + (with-current-buffer standard-output + (emacs-lisp-mode) + (erase-buffer) + (pp `(:emacs-version ,emacs-version :jedi-version ,jedi:version)) + (pp reply) + (display-buffer standard-output)))))) + +(define-obsolete-function-alias + 'jedi:show-jedi-version 'jedi:show-version-info "0.1.3") + +(defun jedi:print-jedi-version () + (pp (epc:sync (jedi:get-epc) (jedi:get-jedi-version-request)))) + + +;;; Setup + +(defun jedi:import-python-el-settings-setup () + "Make jedi aware of python.el virtualenv and path settings. +This is automatically added to the `jedi-mode-hook' when +`jedi:import-python-el-settings' is non-nil." + (let ((args)) + (when (bound-and-true-p python-shell-extra-pythonpaths) + (mapc + (lambda (path) + (setq args (append (list "--sys-path" path) args))) + python-shell-extra-pythonpaths)) + (when (bound-and-true-p python-shell-virtualenv-path) + (setq args + (append + (list "--virtual-env" python-shell-virtualenv-path) + args))) + (when args + (set (make-local-variable 'jedi:server-args) + (append args jedi:server-args))))) + +;;;###autoload +(defun jedi:setup () + "Fully setup jedi.el for current buffer. +It setups `ac-sources' or `company-backends' and turns +`jedi-mode' on. + +This function is intended to be called from `python-mode-hook', +like this:: + + (add-hook 'python-mode-hook 'jedi:setup) + +You can also call this function as a command, to quickly test +what jedi can do." + (interactive) + (when jedi:setup-function + (funcall jedi:setup-function)) + (when jedi:import-python-el-settings + ;; Hack to access buffer/dir-local vars: http://bit.ly/Y5IfMV. + ;; Given that `jedi:setup' is added to the `python-mode-hook' + ;; this will modify `hack-local-variables-hook' on python + ;; buffers only and will allow us to access buffer/directory + ;; local variables in `jedi:import-python-el-settings-setup'. + (add-hook 'hack-local-variables-hook + #'jedi:import-python-el-settings-setup nil t)) + (jedi-mode 1)) + + +;;; Virtualenv setup +(defvar jedi:install-server--command + `("pip" "install" "--upgrade" ,(convert-standard-filename jedi:source-dir))) + +;;;###autoload +(defun jedi:install-server () + "This command installs Jedi server script jediepcserver.py in a +Python environment dedicated to Emacs. By default, the +environment is at ``~/.emacs.d/.python-environments/default/``. +This environment is automatically created by ``virtualenv`` if it +does not exist. + +Run this command (i.e., type ``M-x jedi:install-server RET``) +whenever Jedi.el shows a message to do so. It is a good idea to +run this every time after you update Jedi.el to sync version of +Python modules used by Jedi.el and Jedi.el itself. + +You can modify the location of the environment by changing +`jedi:environment-root' and/or `python-environment-directory'. More +specifically, Jedi.el will install Python modules under the directory +``PYTHON-ENVIRONMENT-DIRECTORY/JEDI:ENVIRONMENT-ROOT``. Note that you +need command line program ``virtualenv``. If you have the command in +an unusual location, use `python-environment-virtualenv' to specify the +location. + +.. NOTE:: jediepcserver.py is installed in a virtual environment but it + does not mean Jedi.el cannot recognize the modules in virtual + environment you are using for your Python development. Jedi + EPC server recognize the virtualenv it is in (i.e., the + environment variable ``VIRTUAL_ENV`` in your Emacs) and then + add modules in that environment to its ``sys.path``. You can + also add ``--virtual-env PATH/TO/ENV`` to `jedi:server-args' + to include modules of virtual environment even you launch + Emacs outside of the virtual environment. + +.. NOTE:: It is highly recommended to use this command to install + Python modules for Jedi.el. You still can install Python + modules used by Jedi.el manually. However, you are then + responsible for keeping Jedi.el and Python modules compatible. + +See also: + +- https://github.com/tkf/emacs-jedi/pull/72 +- https://github.com/tkf/emacs-jedi/issues/140#issuecomment-37358527" + (interactive) + (deferred:$ + (python-environment-run jedi:install-server--command + jedi:environment-root + jedi:environment-virtualenv) + (deferred:watch it + (lambda (_) + (setq-default jedi:server-command (jedi:-env-server-command)))))) + +;;;###autoload +(defun jedi:install-server-block () + "Blocking version `jedi:install-server'." + (prog1 + (python-environment-run-block jedi:install-server--command + jedi:environment-root + jedi:environment-virtualenv) + (setq-default jedi:server-command (jedi:-env-server-command)))) + +(defcustom jedi:install-python-jedi-dev-command + '("pip" "install" "--upgrade" + "git+https://github.com/davidhalter/jedi.git@dev#egg=jedi") + "Pip command to be used for `jedi:install-python-jedi-dev'." + :group 'jedi) + +(defun jedi:install-python-jedi-dev () + "Install developmental version of Python-Jedi from GitHub." + (interactive) + (deferred:$ + (python-environment-run jedi:install-python-jedi-dev-command + jedi:environment-root + jedi:environment-virtualenv) + (deferred:watch it + (lambda (_) + (message "\ +Now restart EPC servers. Then you are ready to go with Jedi-dev!"))))) + + +;;; Debugging + +(defun jedi:pop-to-epc-buffer () + "Open the buffer associated with EPC server process. +Use this command to see the output (e.g., traceback) of the server process." + (interactive) + (pop-to-buffer (process-buffer (epc:manager-server-process jedi:epc)))) + +(defun jedi:toggle-log-traceback () + "Toggle on/off traceback logging for EPC server for the current buffer. +When there is an error during traceback logging is enabled, traceback +is printed in the EPC buffer. You can use `jedi:pop-to-epc-buffer' to +open that buffer. + +You can also pass ``--log-traceback`` option to jediepcserver.py +to start server with traceback logging turned on. This is useful when +there is a problem in communication (thus this command does not work). +You can use `jedi:start-dedicated-server' to restart EPC server for the +current buffer with specific arguments." + (interactive) + (deferred:$ + (epc:call-deferred (jedi:get-epc) 'toggle_log_traceback nil) + (deferred:nextc it + (lambda (flag) + (message "Traceback logging is %s" (if flag "enabled" "disabled")))))) + +(defvar jedi:server-command--backup nil) +(defvar jedi:server-args--backup nil) + +(defun jedi:toggle-debug-server () + "Setup `jedi:server-command' and `jedi:server-args' to debug +server using pdb or ipdb. + +When this command is called, it essentially execute the following +code:: + + (jedi:stop-server) + (setq jedi:server-command (list \"cat\" \"jedi-port.log\" ) + jedi:server-args nil) + +It means to pass the port number recorded in the file +jedi-port.log to EPC client. + +To start Jedi server in terminal and record port to the file, +use the following command:: + + python jediepcserver.py --port-file jedi-port.log --pdb + +This command will be copied in the kill-ring (clipboard) when +this command is called. You can use `--ipdb` instead of `--pdb` +to use ipdb instead of pdb. + +Calling this command again restores the original setting of +`jedi:server-command' and `jedi:server-args' then stops the +running server." + (interactive) + (if jedi:server-command--backup + (progn + (setq jedi:server-command jedi:server-command--backup + jedi:server-command--backup nil + jedi:server-args jedi:server-args--backup) + (jedi:stop-server) + (message "Quit debugging. Original setting restored.")) + (setq jedi:server-command--backup jedi:server-command + jedi:server-args--backup jedi:server-args + jedi:server-command (list "cat" (expand-file-name + "jedi-port.log" jedi:source-dir)) + jedi:server-args nil) + (jedi:stop-server) + (kill-new "python jediepcserver.py --port-file jedi-port.log --ipdb") + (message "Now, start server with: --port-file jedi-port.log --ipdb.\ + (command is copied in the kill-ring)"))) + + +(provide 'jedi-core) + +;; Local Variables: +;; coding: utf-8 +;; indent-tabs-mode: nil +;; End: + +;;; jedi-core.el ends here diff --git a/emacs.d/elpa/jedi-core-20150507.438/jediepcserver.py b/emacs.d/elpa/jedi-core-20150507.438/jediepcserver.py new file mode 100755 index 0000000..e940b5c --- /dev/null +++ b/emacs.d/elpa/jedi-core-20150507.438/jediepcserver.py @@ -0,0 +1,321 @@ +#!/usr/bin/env python + +""" +Jedi EPC server. + +Copyright (C) 2012 Takafumi Arakaki + +Author: Takafumi Arakaki + +This file is NOT part of GNU Emacs. + +Jedi EPC server 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. + +Jedi EPC server 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 Jedi EPC server. +If not, see . + +""" + +import os +import sys +import re +import itertools +import logging +import site + +jedi = None # I will load it later + + +PY3 = (sys.version_info[0] >= 3) +NEED_ENCODE = not PY3 + + +def jedi_script(source, line, column, source_path): + if NEED_ENCODE: + source = source.encode('utf-8') + source_path = source_path and source_path.encode('utf-8') + return jedi.Script(source, line, column, source_path or '') + + +def candidate_symbol(comp): + """ + Return a character representing completion type. + + :type comp: jedi.api.Completion + :arg comp: A completion object returned by `jedi.Script.completions`. + + """ + try: + return comp.type[0].lower() + except (AttributeError, TypeError): + return '?' + + +def candidates_description(comp): + """ + Return `comp.description` in an appropriate format. + + * Avoid return a string 'None'. + * Strip off all newlines. This is required for using + `comp.description` as candidate summary. + + """ + desc = comp.description + return _WHITESPACES_RE.sub(' ', desc) if desc and desc != 'None' else '' +_WHITESPACES_RE = re.compile(r'\s+') + + +def complete(*args): + reply = [] + for comp in jedi_script(*args).completions(): + reply.append(dict( + word=comp.name, + doc=comp.doc, + description=candidates_description(comp), + symbol=candidate_symbol(comp), + )) + return reply + + +def get_in_function_call(*args): + sig = jedi_script(*args).call_signatures() + call_def = sig[0] if sig else None + + if call_def: + return dict( + # p.get_code(False) should do the job. But jedi-vim use replace. + # So follow what jedi-vim does... + params=[p.get_code().replace('\n', '') for p in call_def.params], + index=call_def.index, + call_name=call_def.call_name, + ) + else: + return [] # nil + + +def _goto(method, *args): + """ + Helper function for `goto_assignments` and `usages`. + + :arg method: `jedi.Script.goto_assignments` or `jedi.Script.usages` + :arg args: Arguments to `jedi_script` + + """ + # `definitions` is a list. Each element is an instances of + # `jedi.api_classes.BaseOutput` subclass, i.e., + # `jedi.api_classes.RelatedName` or `jedi.api_classes.Definition`. + definitions = method(jedi_script(*args)) + return [dict( + column=d.column, + line_nr=d.line, + module_path=d.module_path if d.module_path != '__builtin__' else [], + module_name=d.module_name, + description=d.description, + ) for d in definitions] + + +def goto(*args): + return _goto(jedi.Script.goto_assignments, *args) + + +def related_names(*args): + return _goto(jedi.Script.usages, *args) + + +def definition_to_dict(d): + return dict( + doc=d.doc, + description=d.description, + desc_with_module=d.desc_with_module, + line_nr=d.line, + column=d.column, + module_path=d.module_path, + name=getattr(d, 'name', []), + full_name=getattr(d, 'full_name', []), + type=getattr(d, 'type', []), + ) + + +def get_definition(*args): + definitions = jedi_script(*args).goto_definitions() + return list(map(definition_to_dict, definitions)) + + +def get_names_recursively(definition, parent=None): + """ + Fetch interesting defined names in sub-scopes under `definition`. + + :type names: jedi.api_classes.Definition + + """ + d = definition_to_dict(definition) + try: + d['local_name'] = parent['local_name'] + '.' + d['name'] + except (AttributeError, TypeError): + d['local_name'] = d['name'] + if definition.type == 'class': + ds = definition.defined_names() + return [d] + [get_names_recursively(c, d) for c in ds] + else: + return [d] + + +def defined_names(*args): + return list(map(get_names_recursively, jedi.api.defined_names(*args))) + + +def get_module_version(module): + try: + from pkg_resources import get_distribution, DistributionNotFound + try: + return get_distribution(module.__name__).version + except DistributionNotFound: + pass + except ImportError: + pass + + notfound = object() + for key in ['__version__', 'version']: + version = getattr(module, key, notfound) + if version is not notfound: + return version + + +def get_jedi_version(): + import epc + import sexpdata + return [dict( + name=module.__name__, + file=getattr(module, '__file__', []), + version=get_module_version(module) or [], + ) for module in [sys, jedi, epc, sexpdata]] + + +def path_expand_vars_and_user(p): + return os.path.expandvars(os.path.expanduser(p)) + + +def jedi_epc_server(address='localhost', port=0, port_file=sys.stdout, + sys_path=[], virtual_env=[], + debugger=None, log=None, log_level=None, + log_traceback=None): + default_venv = os.getenv('VIRTUAL_ENV') + if default_venv: + add_virtualenv_path(default_venv) + + for p in virtual_env: + add_virtualenv_path(path_expand_vars_and_user(p)) + sys_path = map(path_expand_vars_and_user, sys_path) + sys.path = [''] + list(filter(None, itertools.chain(sys_path, sys.path))) + # Workaround Jedi's module cache. Use this workaround until Jedi + # got an API to set module paths. + # See also: https://github.com/davidhalter/jedi/issues/36 + import_jedi() + import epc.server + server = epc.server.EPCServer((address, port)) + server.register_function(complete) + server.register_function(get_in_function_call) + server.register_function(goto) + server.register_function(related_names) + server.register_function(get_definition) + server.register_function(defined_names) + server.register_function(get_jedi_version) + + @server.register_function + def toggle_log_traceback(): + server.log_traceback = not server.log_traceback + return server.log_traceback + + port_file.write(str(server.server_address[1])) # needed for Emacs client + port_file.write("\n") + port_file.flush() + if port_file is not sys.stdout: + port_file.close() + + # This is not supported Python-EPC API, but I am using this for + # backward compatibility for Python-EPC < 0.0.4. In the future, + # it should be passed to the constructor. + server.log_traceback = bool(log_traceback) + + if log: + handler = logging.FileHandler(filename=log, mode='w') + if log_level: + log_level = getattr(logging, log_level.upper()) + handler.setLevel(log_level) + server.logger.setLevel(log_level) + server.logger.addHandler(handler) + if debugger: + server.set_debugger(debugger) + handler = logging.StreamHandler() + handler.setLevel(logging.DEBUG) + server.logger.addHandler(handler) + server.logger.setLevel(logging.DEBUG) + + return server + + +def import_jedi(): + global jedi + import jedi + import jedi.api + + +def add_virtualenv_path(venv): + """Add virtualenv's site-packages to `sys.path`.""" + venv = os.path.abspath(venv) + path = os.path.join( + venv, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages') + sys.path.insert(0, path) + site.addsitedir(path) + + +def main(args=None): + import argparse + parser = argparse.ArgumentParser( + formatter_class=argparse.RawTextHelpFormatter, + description=__doc__) + parser.add_argument( + '--address', default='localhost') + parser.add_argument( + '--port', default=0, type=int) + parser.add_argument( + '--port-file', '-f', default='-', type=argparse.FileType('wt'), + help='file to write port on. default is stdout.') + parser.add_argument( + '--sys-path', '-p', default=[], action='append', + help='paths to be inserted at the top of `sys.path`.') + parser.add_argument( + '--virtual-env', '-v', default=[], action='append', + help='paths to be used as if VIRTUAL_ENV is set to it.') + parser.add_argument( + '--log', help='save server log to this file.') + parser.add_argument( + '--log-level', + choices=['CRITICAL', 'ERROR', 'WARN', 'INFO', 'DEBUG'], + help='logging level for log file.') + parser.add_argument( + '--log-traceback', action='store_true', default=False, + help='Include traceback in logging output.') + parser.add_argument( + '--pdb', dest='debugger', const='pdb', action='store_const', + help='start pdb when error occurs.') + parser.add_argument( + '--ipdb', dest='debugger', const='ipdb', action='store_const', + help='start ipdb when error occurs.') + ns = parser.parse_args(args) + server = jedi_epc_server(**vars(ns)) + server.serve_forever() + server.logger.info('exit') + + +if __name__ == '__main__': + main() diff --git a/emacs.d/elpa/jedi-core-20150507.438/setup.py b/emacs.d/elpa/jedi-core-20150507.438/setup.py new file mode 100644 index 0000000..54b815b --- /dev/null +++ b/emacs.d/elpa/jedi-core-20150507.438/setup.py @@ -0,0 +1,25 @@ +try: + from setuptools import setup + args = {} +except ImportError: + from distutils.core import setup + args = dict(scripts=['jediepcserver.py']) + print("""\ +*** WARNING: setuptools is not found. Using distutils... +It is highly recommended to install Jedi.el via M-x jedi:install-server. +Note: If you are using Windows, then Jedi.el will not work with distutils. +""") + +setup( + name='jediepcserver', + py_modules=['jediepcserver'], + install_requires=[ + "jedi>=0.8.1", + "epc>=0.0.4", + "argparse", + ], + entry_points={ + 'console_scripts': ['jediepcserver = jediepcserver:main'], + }, + **args +) diff --git a/emacs.d/elpa/js2-mode-20150423.1929/js2-mode-autoloads.el b/emacs.d/elpa/js2-mode-20150423.1929/js2-mode-autoloads.el deleted file mode 100644 index d6feb57..0000000 --- a/emacs.d/elpa/js2-mode-20150423.1929/js2-mode-autoloads.el +++ /dev/null @@ -1,50 +0,0 @@ -;;; js2-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "js2-imenu-extras" "js2-imenu-extras.el" (21824 -;;;;;; 55276 0 0)) -;;; Generated autoloads from js2-imenu-extras.el - -(autoload 'js2-imenu-extras-setup "js2-imenu-extras" "\ - - -\(fn)" nil nil) - -(autoload 'js2-imenu-extras-mode "js2-imenu-extras" "\ -Toggle Imenu support for frameworks and structural patterns. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "js2-mode" "js2-mode.el" (21824 55276 0 0)) -;;; Generated autoloads from js2-mode.el - -(autoload 'js2-minor-mode "js2-mode" "\ -Minor mode for running js2 as a background linter. -This allows you to use a different major mode for JavaScript editing, -such as `js-mode', while retaining the asynchronous error/warning -highlighting features of `js2-mode'. - -\(fn &optional ARG)" t nil) - -(autoload 'js2-mode "js2-mode" "\ -Major mode for editing JavaScript code. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("js2-mode-pkg.el") (21824 55276 756778 -;;;;;; 0)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; js2-mode-autoloads.el ends here diff --git a/emacs.d/elpa/js2-mode-20150423.1929/js2-mode-pkg.el b/emacs.d/elpa/js2-mode-20150423.1929/js2-mode-pkg.el deleted file mode 100644 index 0932919..0000000 --- a/emacs.d/elpa/js2-mode-20150423.1929/js2-mode-pkg.el +++ /dev/null @@ -1,8 +0,0 @@ -(define-package "js2-mode" "20150423.1929" "Improved JavaScript editing mode" - '((emacs "24.1") - (cl-lib "0.5")) - :url "https://github.com/mooz/js2-mode/" :keywords - '("languages" "javascript")) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/emacs.d/elpa/js2-mode-20150423.1929/js2-mode.el b/emacs.d/elpa/js2-mode-20150423.1929/js2-mode.el deleted file mode 100644 index 3d71d2e..0000000 --- a/emacs.d/elpa/js2-mode-20150423.1929/js2-mode.el +++ /dev/null @@ -1,12427 +0,0 @@ -;;; js2-mode.el --- Improved JavaScript editing mode - -;; Copyright (C) 2009, 2011-2015 Free Software Foundation, Inc. - -;; Author: Steve Yegge -;; mooz -;; Dmitry Gutov -;; URL: https://github.com/mooz/js2-mode/ -;; http://code.google.com/p/js2-mode/ -;; Version: 20150202 -;; Keywords: languages, javascript -;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) - -;; 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 JavaScript editing mode supports: - -;; - strict recognition of the Ecma-262 language standard -;; - support for most Rhino and SpiderMonkey extensions from 1.5 and up -;; - parsing support for ECMAScript for XML (E4X, ECMA-357) -;; - accurate syntax highlighting using a recursive-descent parser -;; - on-the-fly reporting of syntax errors and strict-mode warnings -;; - undeclared-variable warnings using a configurable externs framework -;; - "bouncing" line indentation to choose among alternate indentation points -;; - smart line-wrapping within comments and strings -;; - code folding: -;; - show some or all function bodies as {...} -;; - show some or all block comments as /*...*/ -;; - context-sensitive menu bar and popup menus -;; - code browsing using the `imenu' package -;; - many customization options - -;; Installation: -;; -;; To install it as your major mode for JavaScript editing: - -;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) - -;; Alternatively, to install it as a minor mode just for JavaScript linting, -;; you must add it to the appropriate major-mode hook. Normally this would be: - -;; (add-hook 'js-mode-hook 'js2-minor-mode) - -;; You may also want to hook it in for shell scripts running via node.js: - -;; (add-to-list 'interpreter-mode-alist '("node" . js2-mode)) - -;; To customize how it works: -;; M-x customize-group RET js2-mode RET - -;; Notes: - -;; This mode includes a port of Mozilla Rhino's scanner, parser and -;; symbol table. Ideally it should stay in sync with Rhino, keeping -;; `js2-mode' current as the EcmaScript language standard evolves. - -;; Unlike cc-engine based language modes, js2-mode's line-indentation is not -;; customizable. It is a surprising amount of work to support customizable -;; indentation. The current compromise is that the tab key lets you cycle among -;; various likely indentation points, similar to the behavior of python-mode. - -;; This mode does not yet work with "multi-mode" modes such as `mmm-mode' -;; and `mumamo', although it could be made to do so with some effort. -;; This means that `js2-mode' is currently only useful for editing JavaScript -;; files, and not for editing JavaScript within