From 3487e6b38691e50587074a6c9aaf5648450fcdc0 Mon Sep 17 00:00:00 2001 From: Marcus Kammer <2262664-marcuskammer@users.noreply.gitlab.com> Date: Thu, 12 Dec 2019 21:36:58 +0100 Subject: [PATCH] Update packages --- bundle/custom.el | 2 +- bundle/newsfeeds.el | 1 + elpa/archives/gnu/archive-contents.signed | 2 +- elpa/elm-mode-20191125.1919/elm-font-lock.el | 209 +++ elpa/elm-mode-20191125.1919/elm-font-lock.elc | Bin 0 -> 6681 bytes elpa/elm-mode-20191125.1919/elm-format.el | 66 + elpa/elm-mode-20191125.1919/elm-format.elc | Bin 0 -> 4850 bytes elpa/elm-mode-20191125.1919/elm-imenu.el | 17 + elpa/elm-mode-20191125.1919/elm-imenu.elc | Bin 0 -> 748 bytes elpa/elm-mode-20191125.1919/elm-indent.el | 1267 +++++++++++++++++ elpa/elm-mode-20191125.1919/elm-indent.elc | Bin 0 -> 30534 bytes .../elm-mode-20191125.1919/elm-interactive.el | 1101 ++++++++++++++ .../elm-interactive.elc | Bin 0 -> 44665 bytes .../elm-mode-autoloads.el | 263 ++++ elpa/elm-mode-20191125.1919/elm-mode-pkg.el | 16 + elpa/elm-mode-20191125.1919/elm-mode.el | 181 +++ elpa/elm-mode-20191125.1919/elm-mode.elc | Bin 0 -> 6789 bytes elpa/elm-mode-20191125.1919/elm-tags.el | 71 + elpa/elm-mode-20191125.1919/elm-tags.elc | Bin 0 -> 1689 bytes elpa/elm-mode-20191125.1919/elm-util.el | 153 ++ elpa/elm-mode-20191125.1919/elm-util.elc | Bin 0 -> 4931 bytes elpa/elm-mode-20191125.1919/elm.tags | 4 + .../reformatter-autoloads.el | 74 + .../reformatter-pkg.el | 2 + elpa/reformatter-20191103.357/reformatter.el | 227 +++ elpa/reformatter-20191103.357/reformatter.elc | Bin 0 -> 5215 bytes 26 files changed, 3654 insertions(+), 2 deletions(-) create mode 100644 bundle/newsfeeds.el create mode 100644 elpa/elm-mode-20191125.1919/elm-font-lock.el create mode 100644 elpa/elm-mode-20191125.1919/elm-font-lock.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-format.el create mode 100644 elpa/elm-mode-20191125.1919/elm-format.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-imenu.el create mode 100644 elpa/elm-mode-20191125.1919/elm-imenu.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-indent.el create mode 100644 elpa/elm-mode-20191125.1919/elm-indent.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-interactive.el create mode 100644 elpa/elm-mode-20191125.1919/elm-interactive.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-mode-autoloads.el create mode 100644 elpa/elm-mode-20191125.1919/elm-mode-pkg.el create mode 100644 elpa/elm-mode-20191125.1919/elm-mode.el create mode 100644 elpa/elm-mode-20191125.1919/elm-mode.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-tags.el create mode 100644 elpa/elm-mode-20191125.1919/elm-tags.elc create mode 100644 elpa/elm-mode-20191125.1919/elm-util.el create mode 100644 elpa/elm-mode-20191125.1919/elm-util.elc create mode 100644 elpa/elm-mode-20191125.1919/elm.tags create mode 100644 elpa/reformatter-20191103.357/reformatter-autoloads.el create mode 100644 elpa/reformatter-20191103.357/reformatter-pkg.el create mode 100644 elpa/reformatter-20191103.357/reformatter.el create mode 100644 elpa/reformatter-20191103.357/reformatter.elc diff --git a/bundle/custom.el b/bundle/custom.el index 8912e4eb..65434723 100644 --- a/bundle/custom.el +++ b/bundle/custom.el @@ -83,7 +83,7 @@ '(package-enable-at-startup t) '(package-selected-packages (quote - (flymake-eslint json-mode elpy darkroom dockerfile-mode ein spacemacs-theme flucui-themes leuven-theme htmlize scss-mode berrys-theme web-mode python-docstring sphinx-doc sphinx-frontend sphinx-mode ox-nikola racket-mode slime gherkin-mode powershell typescript-mode ob-http ob-ipython ob-restclient nord-theme restclient request restclient-test yaml-mode magit))) + (elm-mode flymake-eslint json-mode elpy darkroom dockerfile-mode ein spacemacs-theme flucui-themes leuven-theme htmlize scss-mode berrys-theme web-mode python-docstring sphinx-doc sphinx-frontend sphinx-mode ox-nikola racket-mode slime gherkin-mode powershell typescript-mode ob-http ob-ipython ob-restclient nord-theme restclient request restclient-test yaml-mode magit))) '(python-shell-interpreter "python3") '(register-preview-delay 2) '(register-separator 43) diff --git a/bundle/newsfeeds.el b/bundle/newsfeeds.el new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/bundle/newsfeeds.el @@ -0,0 +1 @@ + diff --git a/elpa/archives/gnu/archive-contents.signed b/elpa/archives/gnu/archive-contents.signed index 654be911..5dd880fa 100644 --- a/elpa/archives/gnu/archive-contents.signed +++ b/elpa/archives/gnu/archive-contents.signed @@ -1 +1 @@ -Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) (trust undefined) created at 2019-11-30T23:50:03+0100 using RSA \ No newline at end of file +Good signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) (trust undefined) created at 2019-12-07T23:05:03+0100 using RSA \ No newline at end of file diff --git a/elpa/elm-mode-20191125.1919/elm-font-lock.el b/elpa/elm-mode-20191125.1919/elm-font-lock.el new file mode 100644 index 00000000..9662454b --- /dev/null +++ b/elpa/elm-mode-20191125.1919/elm-font-lock.el @@ -0,0 +1,209 @@ +;;; elm-font-lock.el --- Font locking module for Elm mode. + +;; Copyright (C) 2013, 2014 Joseph Collard +;; Copyright (C) 2015 Bogdan Popa + +;; Authors: Joseph Collard +;; URL: https://github.com/jcollard/elm-mode + +;; 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 program. If not, see . + +;;; Commentary: +;;; Code: +(require 'font-lock) +(require 'rx) + +(defgroup elm-font-lock nil + "Font locking for Elm code." + :group 'faces) + +(defface elm-font-lock-operators + '((t :inherit font-lock-builtin-face)) + "The default face used to highlight operators inside expressions." + :group 'elm-font-lock) + +(defcustom elm-font-lock-operators-face 'elm-font-lock-operators + "The face used to highlight operators inside expressions. +To disable this highlighting, set this to nil." + :type '(choice (const nil) + face) + :group 'elm-font-lock) + +(defface elm-font-lock-multiline-list-delimiters + '((t :inherit font-lock-keyword-face)) + "The default face used to highlight brackets and commas in multiline lists." + :group 'elm-font-lock) + +(defcustom elm-font-lock-multiline-list-delimiters-face 'elm-font-lock-multiline-list-delimiters + "The face used to highlight brackets and commas in multilist lists. +To disable this highlighting, set this to nil." + :type '(choice (const nil) + face) + :group 'elm-font-lock) + +(defconst elm--keywords + '("let" "case" "in" "if" "of" "then" "else" "effect" + "module" "import" "as" "exposing" "type" "where" + "alias" "port" "infix" "infixr" "infixl") + "Reserved keywords.") + +(defconst elm--regexp-keywords + (regexp-opt elm--keywords 'symbols) + "A regular expression representing the reserved keywords.") + +(defconst elm--font-lock-keywords + (cons elm--regexp-keywords font-lock-keyword-face) + "Highlighting for keywords.") + +(defun elm--syntax-stringify () + "Syntax propertize triple quoted strings." + (let* ((ppss (save-excursion + (backward-char 3) + (syntax-ppss))) + (string-started (and (not (nth 4 ppss)) (nth 8 ppss))) + (quote-starting-pos (- (point) 3)) + (quote-ending-pos (point))) + (if (not string-started) + (put-text-property quote-starting-pos (1+ quote-starting-pos) + 'syntax-table (string-to-syntax "|")) + (put-text-property (1- quote-ending-pos) quote-ending-pos + 'syntax-table (string-to-syntax "|"))))) + +(defconst elm--syntax-propertize + (syntax-propertize-rules + ;;; Syntax rule for char literals + ((rx (and (1+ " ") + (group "'") + (optional "\\") any + (group "'"))) + (1 "\"") + (2 "\"")) + + ((rx (and (or point + (not (any ?\\ ?\")) + (and (or (not (any ?\\)) point) ?\\ (* ?\\ ?\\) (any ?\"))) + (* ?\\ ?\\) + "\"\"\"")) + (0 (ignore (elm--syntax-stringify)))))) + +(defun elm--syntax-propertize-function (begin end) + "Mark special lexemes between BEGIN and END." + (funcall elm--syntax-propertize begin end) + (save-excursion + (goto-char begin) + (while (re-search-forward "\\\\[({]" end t) + (let ((open (match-beginning 0))) + (add-text-properties open (1+ open) '(syntax-table (1 . nil))))))) + +(defvar elm--syntax-table + (let ((st (make-syntax-table))) + ;;; Syntax entry for {- -} type comments. + (modify-syntax-entry ?\{ "(}1nb" st) + (modify-syntax-entry ?\} "){4nb" st) + (modify-syntax-entry ?- ". 123" st) + (modify-syntax-entry ?\n ">" st) + + (modify-syntax-entry ?\" "\"\"" st) + (modify-syntax-entry ?\\ "\\" st) + st)) + +;;; Name regexp is according to https://github.com/elm-lang/elm-compiler/blob/353930a474fee4d833f962100edde70417691bca/src/Parse/Helpers.hs#L65 +(defconst elm--regexp-function + "^\\([a-z_][0-9A-Za-z_']*\\|([^)]+)\\)" + "A regular expression representing function names.") + +(defconst elm--font-lock-functions + (cons elm--regexp-function font-lock-function-name-face) + "Highlighting for function names.") + +(defconst elm--regexp-type + "\\<[A-Z][0-9A-Za-z_']*" + "A regular expression representing modules and types.") + +(defconst elm--font-lock-types + (cons elm--regexp-type font-lock-type-face) + "Highlighting for module names and types.") + +(defconst elm--regexp-operators + (concat "\\(" "`[^`]+`" + "\\|" "\\B\\\\" + "\\|" "[-+*/\\\\|<>=:!@#$%^&,.]+" + "\\)") + "A regular expression representing operators inside expressions.") + +(defconst elm--font-lock-operators + (cons elm--regexp-operators '(1 elm-font-lock-operators-face)) + "Highlighting for operators inside expressions.") + +(defconst elm--regexp-multiline-list-comma-closing-brackets + (concat "^[[:space:]]*" (regexp-opt '("," "]" "}") t)) + "A regular expression representing commas and closing brackets in multiline lists and records.") + +(defconst elm--font-lock-multiline-list-comma-closing-brackets + (cons elm--regexp-multiline-list-comma-closing-brackets + '(1 elm-font-lock-multiline-list-delimiters-face)) + "Highlighting for commas and closing brackets in multiline lists and records.") + +(defun elm--match-multiline-list-opening-bracket (limit) + "Highlighting search function for opening brackets in multiline lists and records. +Also highlights opening brackets without a matching bracket." + (when (elm--search-forward-opening-bracket limit) + (let ((opening (point)) + (eol (line-end-position)) + (closing (elm--search-forward-closing-bracket))) + (if (or (= closing opening) (> closing eol)) + (progn + (set-match-data (match-data)) + (goto-char (+ 1 opening)) + t) + (elm--match-multiline-list-opening-bracket limit))))) + +(defun elm--search-forward-opening-bracket (limit) + "Go to the next opening bracket up to LIMIT." + (if (search-forward-regexp (regexp-opt '("[" "{")) limit t) + (progn + (backward-char) + t))) + +(defun elm--search-forward-closing-bracket () + "Go to the next matching bracket, assuming that the cursor is on an opening bracket." + (ignore-errors + (save-match-data + (forward-sexp))) + (point)) + +(defconst elm--font-lock-multiline-list-opening-brackets + '(elm--match-multiline-list-opening-bracket (0 elm-font-lock-multiline-list-delimiters-face)) + "Highlighting for opening brackets in multiline lists and records.") + +(defconst elm--font-lock-highlighting + (list (list elm--font-lock-keywords + elm--font-lock-functions + elm--font-lock-types + elm--font-lock-multiline-list-comma-closing-brackets + elm--font-lock-multiline-list-opening-brackets + elm--font-lock-operators) + nil nil)) + +(defun turn-on-elm-font-lock () + "Turn on Elm font lock." + (setq font-lock-multiline t) + (set-syntax-table elm--syntax-table) + (set (make-local-variable 'syntax-propertize-function) #'elm--syntax-propertize-function) + (set (make-local-variable 'font-lock-defaults) elm--font-lock-highlighting)) + +(provide 'elm-font-lock) +;;; elm-font-lock.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-font-lock.elc b/elpa/elm-mode-20191125.1919/elm-font-lock.elc new file mode 100644 index 0000000000000000000000000000000000000000..7f91d172610c586d0e65429ee5cd596fd5e09134 GIT binary patch literal 6681 zcmb_h`*YjI5!Os+T0N#SnM^uu>>sj*oCvT46)#ehoWyoqHT6uAA8MtY2}xHFcoZ=L z0R{kN$#MSoetU-p0g|@dR5nFmZ*On!yM5j2@#%NZ|GcrWvHke*V|t!UXJI5p@+FMv zbm|8gU5hjelbD?Dp({sThxvs3D57MRhtu$lpJO;X+?Io9lQ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txuBA;6~Nu2<=UnN z*Q)l=yW{)XK-u!044o9|EO#+>(ydlrYsHRrQL&?nhE_AD*0G9cY(tCv;!VVpox%8z z1E+KJdz=L>ptgNl9Ea4q7E(4eRC!m^%ZOXlef5AUfm%{pJ6e+w-#uvw;}$!{i|#GD z7`V8})aiJ1Hc#Ox_&Wvq!mOrj7B^ib2aAcn7O=!>CsjKHA^9UlX-mdjJaLP=?62F_ z#|6bxA(^rKq`t^TK*#0k{yI(;7 literal 0 HcmV?d00001 diff --git a/elpa/elm-mode-20191125.1919/elm-format.el b/elpa/elm-mode-20191125.1919/elm-format.el new file mode 100644 index 00000000..d0bafae2 --- /dev/null +++ b/elpa/elm-mode-20191125.1919/elm-format.el @@ -0,0 +1,66 @@ +;;; elm-format.el --- Automatically format an Elm buffer. + +;; Copyright (C) 2015 Bogdan Popa + +;; Author: Bogdan Popa +;; URL: https://github.com/jcollard/elm-mode + +;; 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 program. If not, see . + +;;; Commentary: +;;; Code: + +(require 'reformatter) + +(defcustom elm-format-on-save nil + "When non-nil, run `elm-format-buffer' on save. + +This variable is obsolete, and you should prefer to enable +`elm-format-on-save-mode' by adding it to your `elm-mode-hook', +or by placing a clause like the following in the .dir-locals.el +for your project: + + ((elm-mode (mode . elm-format-on-save)))" + :group 'elm-format + :type 'boolean) + +(defcustom elm-format-elm-version "0.19" + "The version of Elm against which code should be formatted." + :group 'elm-format + :type '(choice (const :tag "Default: 0.19" "0.19") + (const :tag "0.18" "0.18") + (const :tag "0.17" "0.17") + (const :tag "0.16" "0.16"))) + +(defcustom elm-format-command "elm-format" + "The name of the `elm-format' command." + :group 'elm-format + :type 'string) + +;;;###autoload (autoload 'elm-format-buffer "elm-format" nil t) +;;;###autoload (autoload 'elm-format-on-save-mode "elm-format" nil t) +(reformatter-define elm-format + :program elm-format-command + :args (list "--stdin" "--elm-version" elm-format-elm-version "--yes") + :group 'elm-format + :lighter " ElmFmt") + +;;;###autoload +(define-obsolete-function-alias 'elm-mode-format-buffer 'elm-format-buffer "20190113") + + +(provide 'elm-format) +;;; elm-format.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-format.elc b/elpa/elm-mode-20191125.1919/elm-format.elc new file mode 100644 index 0000000000000000000000000000000000000000..2238b6de7e6355f3476f5cceb54392724bf73195 GIT binary patch literal 4850 zcmd5=ZI9c=5x#FZtLS}bfi!)AGslZ9DL4vzk#sLc(4@X|Y9MtApVK$%08`{j+L+`j z+|^xFp#Qzk?2-~?TS0+*=>a+|cZajHv(G#;qbJwjJpIkV!9nNAlPC046-$|m%s$AH zu8SnqbSEk;RY}o!5Zje|X%>{^IjNvTH3>DmZCRhb}f z5(fc3;qfF2c@W_f<1@r(gwGhCvq{WrVfgr?tyBof5RxHFwxvcpQdkM`e#E+4Qjyga zoO$%R5JlKvuM8&Tq_im7=mnzGRI6MVaY}r{YqcW1P^&znB@E+> zR3u6^Vp6ts*Jk(yyxFDcno$Q3k~I7V)KtzCUiTMDz3rY(N>#DsGEY(#O$et1mMNES z1pp&xrt)0fTQ#Mf7-X{YbCo8!9*BHW!Usv3y-{4FteFcGrG=@U%@FH+uYK5zjN|sI2_Z<8o=7V zRf#!s+N@Fq{ptE^M#J@st3k&?6&DE>1UCWfAQyQj^7Sd4)O%iz>pCYrk2Gx)V-C$D=` zF$btKddxhl$|R>uYQS>si>gwU?puDaVSD^Z6Trv6MMwuAg7A00$0)>zgWS@=@gFb( zA%vq}9z8tz6ayRo53UZc+?aVF3Xcf?qi2r~A0Ahe*$<9XqWIwibQBE_ttj;K9+-$9 z)dC}tK>|G0$LyHw=;#>Zv+pK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NSyo7=aEB zfC6+(J3R89s`eGLBqMt7%W5`r0!cPdnWiM+lBy8*Ae$%-Ler`vth^hk5_lyTbi z1Q!&@4IZ}z$oGt0kY_3U)iOiHa!ccy`hk=o%K2QPPv{}a8dul8<-6%RclY~9t6cE@ z1YfzM!Kskk?SX9udjSj#Co{$tXAwKc*s3x5Za*9ZjK$H%3_w?`)`jX8_`J{{oMB)0 z%i*}0w5{=`w%c=~MbhrmK5*L&!T9(Q#I_9f2NPPZ40(U%>*kI)nQ>}DfdMok@4}hr z^X_=~W)GCQ=#*b5;8@}23Jn};bZD;MXypmQn14Z;s#Tfcl{XE-yOgZZ#={s!)0(ET z%rrV<@M+KX-+0kf2nwLU{@i1s*&Id>(514fLZV@|7}*Egee;`yY)xC*bhT-T_|O)3 mbr99rq~(ix#-_C9=K=DfAiM~|F!tCncM|D+`wD>D@B9}k6AN7c literal 0 HcmV?d00001 diff --git a/elpa/elm-mode-20191125.1919/elm-imenu.el b/elpa/elm-mode-20191125.1919/elm-imenu.el new file mode 100644 index 00000000..8a0d98ee --- /dev/null +++ b/elpa/elm-mode-20191125.1919/elm-imenu.el @@ -0,0 +1,17 @@ +;;; elm-imenu.el --- imenu support for elm +;;; Commentary: +;;; Code: +(require 'imenu) + +(defun elm-imenu-create-index () + "Create an imenu index for the current buffer." + (save-excursion + (imenu--generic-function + '(("Type" "^type \\([A-Z][^ \n]+\\)" 1) + ("Type Alias" "^type alias \\([A-Z][^ \n]+\\)" 1) + ("Port" "^port \\([^ ]+\\)" 1) + ("Function" "^\\([^ ]+\\) :" 1))))) + + +(provide 'elm-imenu) +;;; elm-imenu.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-imenu.elc b/elpa/elm-mode-20191125.1919/elm-imenu.elc new file mode 100644 index 0000000000000000000000000000000000000000..1533bacb52256d6ba3763ed741e02faf2b509fa2 GIT binary patch literal 748 zcmbtRO>5&Y6wFzFV2?ZNEYzm8Nt}Lco6ClfLZOF3d)hbwReEj&w&a!M?zX?avK>N~ zvZo4!kY?V@yr=oDWj2}XR{vpqx=rMs$d$g zYW2!}fL+FV@L{JM%AkVQk%N5EyjB9z2&x^%)nnh}Vns*Jiy%p*P1xkwlm#7+6?z{s-=m=D!tp#`=!igtOP(;=SPY mK0-(7H1;U2I>Tgx9P#)&GMwgT$tGcOW6iUYVTOn96ZQtlfZQMe literal 0 HcmV?d00001 diff --git a/elpa/elm-mode-20191125.1919/elm-indent.el b/elpa/elm-mode-20191125.1919/elm-indent.el new file mode 100644 index 00000000..07981fcd --- /dev/null +++ b/elpa/elm-mode-20191125.1919/elm-indent.el @@ -0,0 +1,1267 @@ +;;; elm-indent.el --- "semi-intelligent" indentation module for Elm Mode + +;; Copyright 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. +;; Copyright 1997-1998 Guy Lapalme +;; Copyright 2015 Bogdan Popa + +;; Author: 1997-1998 Guy Lapalme + +;; Keywords: indentation Elm layout-rule +;; Version: 1.2 +;; URL: http://www.iro.umontreal.ca/~lapalme/layout/index.html + +;; This file is not part of GNU Emacs. + +;; This file was adapted from `haskell-indent.el'. + +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 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 program. If not, see . + +;;; Commentary: +;;; Code: +(require 's) + +(with-no-warnings + (require 'cl)) + + +;;; Customizations +(defgroup elm-indent nil + "Elm indentation." + :group 'elm + :link '(custom-manual "(elm-mode)Indentation") + :prefix "elm-indent-") + +(defcustom elm-indent-offset 4 + "Indentation of Elm statements with respect to containing block." + :type 'integer + :group 'elm-indent) + +(defcustom elm-indent-rhs-align-column 0 + "Column on which to align right-hand sides (use 0 for ad-hoc alignment)." + :type 'integer + :group 'elm-indent) + +(defcustom elm-indent-look-past-empty-line t + "If nil, indentation engine will not look past an empty line for layout points." + :group 'elm-indent + :type 'boolean) + +(defcustom elm-indent-thenelse 0 + "If non-zero, \"then\" and \"else\" are indented by that amount." + :group 'elm-indent + :type 'integer) + +(defcustom elm-indent-after-keywords + `(("of" ,elm-indent-offset) + ("in" ,elm-indent-offset 0) + ("{" ,elm-indent-offset) + "if" + "then" + "else" + "let") + "Keywords after which indentation should be indented by some offset. +Each keyword info can have the following forms: + + KEYWORD | (KEYWORD OFFSET [OFFSET-HANGING]) + +If absent OFFSET-HANGING defaults to OFFSET. +If absent OFFSET defaults to `elm-indent-offset'. + +OFFSET-HANGING is the offset to use in the case where the keyword +is at the end of an otherwise-non-empty line." + :set-after '(elm-indent-offset) + :group 'elm-indent + :type '(repeat (choice string + (cons :tag "" (string :tag "keyword:") + (cons :tag "" (integer :tag "offset") + (choice (const nil) + (list :tag "" + (integer :tag "offset-pending")))))))) + +(defcustom elm-indent-dont-hang '("(") + "Lexemes that should never be considered as hanging." + :group 'elm-indent + :type '(repeat string)) + + +;;; Internals +(defconst elm-indent-start-keywords-re + (concat "\\<" + (regexp-opt '("module" "import" "type" "infix" "infixl" "infixr") t) + "\\>") + "Regexp for keywords to complete when standing at the first word of a line.") + +(defvar elm-indent-off-side-keywords-re + (concat "\\<" + (regexp-opt '("let")) + "\\>[ \t]*")) + +(defvar elm-indent-last-info nil) +(defvar elm-indent-info) + +(defvar elm-indent-current-line-first-ident "" + "Global variable that keeps track of the first ident of the line to indent.") + +(defvar elm-indent-inhibit-after-offset nil) + +(defun elm-indent-point-to-col (apoint) + "Return the column number of APOINT." + (save-excursion + (goto-char apoint) + (current-column))) + +(defun elm-indent-push-col (col &optional name) + "Push indentation information for the column COL. +The info is followed by NAME (if present). +Makes sure that the same indentation info is not pushed twice. +Uses free var `elm-indent-info'." + (let ((tmp (cons col name))) + (if (member tmp elm-indent-info) + elm-indent-info + (push tmp elm-indent-info)))) + +(defun elm-indent-push-pos (pos &optional name) + "Push indentation information for POS followed by NAME (if present)." + (elm-indent-push-col (elm-indent-point-to-col pos) name)) + +(defun elm-indent-column+offset (column offset) + (unless offset (setq offset elm-indent-offset)) + (setq column (+ column offset))) + +(defun elm-indent-push-pos-offset (pos &optional offset) + "Pushes indentation information for the column corresponding to POS +followed by an OFFSET (if present use its value otherwise use +`elm-indent-offset')." + (elm-indent-push-col (elm-indent-column+offset + (elm-indent-point-to-col pos) + offset))) + +(defun elm-indent-empty-line-p () + "Checks if the current line is empty; deals with Bird style scripts." + (save-excursion + (beginning-of-line) + (looking-at "[ \t]*$"))) + +(defun elm-indent-skip-blanks-and-newlines-forward (end) + "Skip forward blanks, tabs and newlines until END." + (skip-chars-forward " \t\n" end)) + +(defun elm-indent-skip-blanks-and-newlines-backward (start) + "Skip backward blanks, tabs and newlines up to START." + (skip-chars-backward " \t\n" start)) + +(defun elm-indent-start-of-def () + "Return the position of the start of a definition. +The start of a def is expected to be recognizable by starting in column 0, +unless `elm-indent-look-past-empty-line' is nil, in which case we +take a coarser approximation and stop at the first empty line." + (save-excursion + (let ((start-code nil) + (top-col 0) + (save-point (point))) + ;; determine the starting point of the current piece of code + (setq start-code (if start-code (1+ start-code) (point-min))) + ;; go backward until the first preceding empty line + (forward-line -1) + (while (and (if elm-indent-look-past-empty-line + (or (> (current-indentation) top-col) + (elm-indent-empty-line-p)) + (and (> (current-indentation) top-col) + (not (elm-indent-empty-line-p)))) + (> (point) start-code) + (= 0 (forward-line -1)))) + ;; go forward after the empty line + (if (elm-indent-empty-line-p) + (forward-line 1)) + (setq start-code (point)) + ;; find the first line of code which is not a comment + (forward-comment (point-max)) + (if (> (point) save-point) + start-code + (point))))) + +(defun elm-indent-open-structure (start end) + "If any structure (list or tuple) is not closed, between START and END, +returns the location of the opening symbol, nil otherwise." + (save-excursion + (nth 1 (parse-partial-sexp start end)))) + +(defun elm-indent-in-string (start end) + "If a string is not closed , between START and END, returns the +location of the opening symbol, nil otherwise." + (save-excursion + (let ((pps (parse-partial-sexp start end))) + (if (nth 3 pps) (nth 8 pps))))) + +(defun elm-indent-in-comment (start end) + "Check, starting from START, if END is at or within a comment. +Returns the location of the start of the comment, nil otherwise." + (when (<= start end) + (let (pps) + (cond ((= start end) nil) + ((nth 4 (save-excursion (setq pps (parse-partial-sexp start end)))) + (nth 8 pps)) + ;; We also want to say that we are *at* the beginning of a comment. + ((and (not (nth 8 pps)) + (>= (point-max) (+ end 2)) + (nth 4 (save-excursion + (setq pps (parse-partial-sexp end (+ end 2)))))) + (nth 8 pps)))))) + +(defun elm-indent-type-at-point () + "Return the type of the line (also puts information in `match-data')." + (cond + ((elm-indent-empty-line-p) 'empty) + ((elm-indent-in-comment (point-min) (point)) 'comment) + ((looking-at "\\(\\([[:alpha:]]\\(\\sw\\|'\\)*\\)\\|_\\)[ \t\n]*") 'ident) + ((looking-at "\\(|[^|]\\)[ \t\n]*") 'guard) + ((looking-at "\\(=[^>=]\\|:[^:]\\|->\\|<-\\)[ \t\n]*") 'rhs) + (t 'other))) + +(defun elm-indent-contour-line (start end) + "Generate contour information between START and END points." + (if (< start end) + (save-excursion + (goto-char end) + (elm-indent-skip-blanks-and-newlines-backward start) + (let ((cur-col (current-column)) ; maximum column number + (fl 0) ; number of lines that forward-line could not advance + contour) + (while (and (> cur-col 0) (= fl 0) (>= (point) start)) + (back-to-indentation) + (if (< (point) start) (goto-char start)) + (and (not (member (elm-indent-type-at-point) + '(empty comment))) ; skip empty and comment lines + (< (current-column) cur-col) ; less indented column found + (push (point) contour) ; new contour point found + (setq cur-col (current-column))) + (setq fl (forward-line -1))) + contour)))) + +(defun elm-indent-next-symbol (end) + "Move point to the next symbol." + (skip-syntax-forward ")" end) + (if (< (point) end) + (progn + (forward-sexp 1) + (elm-indent-skip-blanks-and-newlines-forward end)))) + +(defun elm-indent-next-symbol-safe (end) + "Puts point to the next following symbol, or to end if there are no more symbols in the sexp." + (condition-case errlist (elm-indent-next-symbol end) + (error (goto-char end)))) + +(defun elm-indent-separate-valdef (start end) + "Return a list of positions for important parts of a valdef." + (save-excursion + (let (valname valname-string aft-valname + guard aft-guard + rhs-sign aft-rhs-sign + type) + ;; "parse" a valdef separating important parts + (goto-char start) + (setq type (elm-indent-type-at-point)) + (if (or (memq type '(ident other))) ; possible start of a value def + (progn + (if (eq type 'ident) + (progn + (setq valname (match-beginning 0)) + (setq valname-string (match-string 0)) + (goto-char (match-end 0))) + (skip-chars-forward " \t" end) + (setq valname (point)) ; type = other + (elm-indent-next-symbol-safe end)) + (while (and (< (point) end) + (setq type (elm-indent-type-at-point)) + (or (memq type '(ident other)))) + (if (null aft-valname) + (setq aft-valname (point))) + (elm-indent-next-symbol-safe end)))) + (if (and (< (point) end) (eq type 'guard)) ; start of a guard + (progn + (setq guard (match-beginning 0)) + (goto-char (match-end 0)) + (while (and (< (point) end) + (setq type (elm-indent-type-at-point)) + (not (eq type 'rhs))) + (if (null aft-guard) + (setq aft-guard (point))) + (elm-indent-next-symbol-safe end)))) + (if (and (< (point) end) (eq type 'rhs)) ; start of a rhs + (progn + (setq rhs-sign (match-beginning 0)) + (goto-char (match-end 0)) + (if (< (point) end) + (setq aft-rhs-sign (point))))) + (list valname valname-string aft-valname + guard aft-guard rhs-sign aft-rhs-sign)))) + +(defsubst elm-indent-no-otherwise (guard) + "Check if there is no otherwise at GUARD." + (save-excursion + (goto-char guard) + (not (looking-at "|[ \t]*otherwise\\>")))) + +(defsubst elm-indent-union-operator-p (guard) + "Check if there is a union operator at GUARD." + (save-excursion + (goto-char guard) + (and (looking-at "|") + (not (looking-at "|>"))))) + + +(defun elm-indent-guard (start end end-visible indent-info) + "Find indentation information for a line starting with a guard." + (save-excursion + (let* ((elm-indent-info indent-info) + (sep (elm-indent-separate-valdef start end)) + (valname (nth 0 sep)) + (guard (nth 3 sep)) + (rhs-sign (nth 5 sep))) + ;; push information indentation for the visible part + (if (and guard (< guard end-visible) (elm-indent-no-otherwise guard)) + (elm-indent-push-pos guard) + (if rhs-sign + (elm-indent-push-pos rhs-sign) ; probably within a data definition... + (if valname + (elm-indent-push-pos-offset valname)))) + elm-indent-info))) + +(defun elm-indent-rhs (start end end-visible indent-info) + "Find indentation information for a line starting with a rhs." + (save-excursion + (let* ((elm-indent-info indent-info) + (sep (elm-indent-separate-valdef start end)) + (valname (nth 0 sep)) + (guard (nth 3 sep)) + (rhs-sign (nth 5 sep))) + ;; push information indentation for the visible part + (if (and rhs-sign (< rhs-sign end-visible)) + (elm-indent-push-pos rhs-sign) + (if (and guard (< guard end-visible)) + (elm-indent-push-pos-offset guard) + (if valname ; always visible !! + (elm-indent-push-pos-offset valname)))) + elm-indent-info))) + +(defconst elm-indent-decision-table + (let ((or "\\)\\|\\(")) + (concat "\\(" + "1.1.11" or ; 1= vn gd rh arh + "1.1.10" or ; 2= vn gd rh + "1.1100" or ; 3= vn gd agd + "1.1000" or ; 4= vn gd + "1.0011" or ; 5= vn rh arh + "1.0010" or ; 6= vn rh + "110000" or ; 7= vn avn + "100000" or ; 8= vn + "001.11" or ; 9= gd rh arh + "001.10" or ;10= gd rh + "001100" or ;11= gd agd + "001000" or ;12= gd + "000011" or ;13= rh arh + "000010" or ;14= rh + "000000" ;15= + "\\)"))) + +(defun elm-indent-find-case (test) + "Find the index that matches TEST in the decision table." + (if (string-match elm-indent-decision-table test) + ;; use the fact that the resulting match-data is a list of the form + ;; (0 6 [2*(n-1) nil] 0 6) where n is the number of the matching regexp + ;; so n= ((length match-data)/2)-1 + (- (/ (length (match-data 'integers)) 2) 1) + (error "elm-indent-find-case: impossible case: %s" test))) + +(defun elm-indent-after-list-item-p () + (with-no-warnings + ;; HACK: we depend on open being dynamically bound while handling + ;; indentation inside of a parenthesized expression. + (when open + (or (eq (char-after open) ?\() + (eq (char-after open) ?\[))))) + +(defun elm-indent-empty (start end end-visible indent-info) + "Find indentation points for an empty line." + (save-excursion + (let* ((elm-indent-info indent-info) + (sep (elm-indent-separate-valdef start end)) + (valname (pop sep)) + (valname-string (pop sep)) + (aft-valname (pop sep)) + (guard (pop sep)) + (aft-guard (pop sep)) + (rhs-sign (pop sep)) + (aft-rhs-sign (pop sep)) + (last-line (= end end-visible)) + (test (string + (if valname ?1 ?0) + (if (and aft-valname (< aft-valname end-visible)) ?1 ?0) + (if (and guard (< guard end-visible)) ?1 ?0) + (if (and aft-guard (< aft-guard end-visible)) ?1 ?0) + (if (and rhs-sign (< rhs-sign end-visible)) ?1 ?0) + (if (and aft-rhs-sign (< aft-rhs-sign end-visible)) ?1 ?0)))) + (if (and valname-string ; special case for start keywords + (string-match elm-indent-start-keywords-re valname-string)) + (progn + (elm-indent-push-pos valname) + ;; Special case for `type' declarations. + (if (string-match "\\" valname-string) + (elm-indent-push-pos-offset valname) + (elm-indent-push-pos-offset valname 0))) + (case ; general case + (elm-indent-find-case test) + ;; "1.1.11" 1= vn gd rh arh + (1 (elm-indent-push-pos valname) + (elm-indent-push-pos valname valname-string) + (if (elm-indent-no-otherwise guard) (elm-indent-push-pos guard "| ")) + (elm-indent-push-pos aft-rhs-sign)) + ;; "1.1.10" 2= vn gd rh + (2 (elm-indent-push-pos valname) + (elm-indent-push-pos valname valname-string) + (if last-line + (elm-indent-push-pos-offset guard) + (if (elm-indent-no-otherwise guard) (elm-indent-push-pos guard "| ")))) + ;; "1.1100" 3= vn gd agd + (3 (elm-indent-push-pos valname) + (elm-indent-push-pos aft-guard) + (if last-line (elm-indent-push-pos-offset valname))) + ;; "1.1000" 4= vn gd + (4 (elm-indent-push-pos valname) + (if last-line (elm-indent-push-pos-offset guard 2))) + ;; "1.0011" 5= vn rh arh + (5 (elm-indent-push-pos valname) + (if (or (and aft-valname (= (char-after rhs-sign) ?\=)) + (= (char-after rhs-sign) ?\:)) + (elm-indent-push-pos valname valname-string)) + (elm-indent-push-pos aft-rhs-sign)) + ;; "1.0010" 6= vn rh + (6 (elm-indent-push-pos valname) + (elm-indent-push-pos valname valname-string) + (if last-line (elm-indent-push-pos-offset valname))) + ;; "110000" 7= vn avn + (7 (elm-indent-push-pos valname) + (elm-indent-push-pos-offset valname)) + ;; "100000" 8= vn + (8 (if (elm-indent-after-list-item-p) + (progn + (elm-indent-push-pos valname) + (elm-indent-push-pos-offset valname)) + + (elm-indent-push-pos valname) + (elm-indent-push-pos-offset valname))) + ;; "001.11" 9= gd rh arh + (9 (if (elm-indent-no-otherwise guard) (elm-indent-push-pos guard "| ")) + (elm-indent-push-pos aft-rhs-sign)) + ;; "001.10" 10= gd rh + (10 (if (elm-indent-no-otherwise guard) (elm-indent-push-pos guard "| ")) + (if last-line (elm-indent-push-pos-offset guard))) + ;; "001100" 11= gd agd + (11 (if (elm-indent-no-otherwise guard) + (if (elm-indent-union-operator-p guard) + (elm-indent-push-pos guard "| ") + (elm-indent-push-pos guard "|> "))) + (elm-indent-push-pos aft-guard)) + ;; "001000" 12= gd + (12 (if (elm-indent-no-otherwise guard) (elm-indent-push-pos guard "|> ")) + (if last-line (elm-indent-push-pos-offset guard 2))) + ;; "000011" 13= rh arh + (13 (elm-indent-push-pos aft-rhs-sign)) + ;; "000010" 14= rh + (14 (if last-line (elm-indent-push-pos-offset rhs-sign 2 ))) + ;; "000000" 15= + (t (error "elm-indent-empty: %s impossible case" test )))) + elm-indent-info))) + +(defun elm-indent-ident (start end end-visible indent-info) + "Find indentation points for a line starting with an identifier." + (save-excursion + (let* + ((elm-indent-info indent-info) + (sep (elm-indent-separate-valdef start end)) + (valname (pop sep)) + (valname-string (pop sep)) + (aft-valname (pop sep)) + (guard (pop sep)) + (aft-guard (pop sep)) + (rhs-sign (pop sep)) + (aft-rhs-sign (pop sep)) + (last-line (= end end-visible)) + (is-where + (string-match "where[ \t]*" elm-indent-current-line-first-ident)) + (diff-first ; not a function def with the same name + (or (null valname-string) + (not (string= (s-trim valname-string) + (s-trim elm-indent-current-line-first-ident))))) + + ;; (is-type-def + ;; (and rhs-sign (eq (char-after rhs-sign) ?\:))) + (test (string + (if valname ?1 ?0) + (if (and aft-valname (< aft-valname end-visible)) ?1 ?0) + (if (and guard (< guard end-visible)) ?1 ?0) + (if (and aft-guard (< aft-guard end-visible)) ?1 ?0) + (if (and rhs-sign (< rhs-sign end-visible)) ?1 ?0) + (if (and aft-rhs-sign (< aft-rhs-sign end-visible)) ?1 ?0)))) + (if (and valname-string ; special case for start keywords + (string-match elm-indent-start-keywords-re valname-string)) + (progn + (elm-indent-push-pos valname) + (if (string-match "\\" valname-string) + ;; Special case for `type' declarations. + (elm-indent-push-pos-offset valname) + (if (not (string-match + elm-indent-start-keywords-re + elm-indent-current-line-first-ident)) + (elm-indent-push-pos-offset valname)))) + (if (string= elm-indent-current-line-first-ident ":") + (if valname (elm-indent-push-pos valname)) + (case ; general case + (elm-indent-find-case test) + ;; "1.1.11" 1= vn gd rh arh + (1 (if is-where + (elm-indent-push-pos guard) + (elm-indent-push-pos valname) + (if diff-first (elm-indent-push-pos aft-rhs-sign)))) + ;; "1.1.10" 2= vn gd rh + (2 (if is-where + (elm-indent-push-pos guard) + (elm-indent-push-pos valname) + (if last-line + (elm-indent-push-pos-offset guard)))) + ;; "1.1100" 3= vn gd agd + (3 (if is-where + (elm-indent-push-pos-offset guard) + (elm-indent-push-pos valname) + (if diff-first + (elm-indent-push-pos aft-guard)))) + ;; "1.1000" 4= vn gd + (4 (if is-where + (elm-indent-push-pos guard) + (elm-indent-push-pos valname) + (if last-line + (elm-indent-push-pos-offset guard 2)))) + ;; "1.0011" 5= vn rh arh + (5 (if is-where + (elm-indent-push-pos-offset valname) + (elm-indent-push-pos valname) + (if diff-first + (elm-indent-push-pos aft-rhs-sign)))) + ;; "1.0010" 6= vn rh + (6 (elm-indent-push-pos valname) + (elm-indent-push-pos valname valname-string) + (if last-line (elm-indent-push-pos-offset valname))) + ;; "110000" 7= vn avn + (7 (elm-indent-push-pos valname) + (elm-indent-push-pos-offset valname)) + ;; "100000" 8= vn + (8 (elm-indent-push-pos valname) + (elm-indent-push-pos-offset valname)) + ;; "001.11" 9= gd rh arh + (9 (if is-where + (elm-indent-push-pos guard) + (elm-indent-push-pos aft-rhs-sign))) + ;; "001.10" 10= gd rh + (10 (if is-where + (elm-indent-push-pos guard) + (if last-line + (elm-indent-push-pos-offset guard)))) + ;; "001100" 11= gd agd + (11 (if is-where + (elm-indent-push-pos guard) + (if (elm-indent-no-otherwise guard) + (elm-indent-push-pos aft-guard)))) + ;; "001000" 12= gd + (12 (if last-line (elm-indent-push-pos-offset guard 2))) + ;; "000011" 13= rh arh + (13 (elm-indent-push-pos aft-rhs-sign)) + ;; "000010" 14= rh + (14 (if last-line (elm-indent-push-pos-offset rhs-sign 2))) + ;; "000000" 15= + (t (error "elm-indent-ident: %s impossible case" test ))))) + elm-indent-info))) + +(defun elm-indent-other (start end end-visible indent-info) + "Find indentation points for a non-empty line starting with something other +than an identifier, a guard or rhs." + (save-excursion + (let* ((elm-indent-info indent-info) + (sep (elm-indent-separate-valdef start end)) + (valname (pop sep)) + (valname-string (pop sep)) + (aft-valname (pop sep)) + (guard (pop sep)) + (aft-guard (pop sep)) + (rhs-sign (pop sep)) + (aft-rhs-sign (pop sep)) + (last-line (= end end-visible)) + (test (string + (if valname ?1 ?0) + (if (and aft-valname (< aft-valname end-visible)) ?1 ?0) + (if (and guard (< guard end-visible)) ?1 ?0) + (if (and aft-guard (< aft-guard end-visible)) ?1 ?0) + (if (and rhs-sign (< rhs-sign end-visible)) ?1 ?0) + (if (and aft-rhs-sign (< aft-rhs-sign end-visible)) ?1 ?0)))) + (if (and valname-string ; special case for start keywords + (string-match elm-indent-start-keywords-re valname-string)) + (elm-indent-push-pos-offset valname) + (case ; general case + (elm-indent-find-case test) + ;; "1.1.11" 1= vn gd rh arh + (1 (elm-indent-push-pos aft-rhs-sign)) + ;; "1.1.10" 2= vn gd rh + (2 (if last-line + (elm-indent-push-pos-offset guard) + (elm-indent-push-pos-offset rhs-sign 2))) + ;; "1.1100" 3= vn gd agd + (3 (elm-indent-push-pos aft-guard)) + ;; "1.1000" 4= vn gd + (4 (elm-indent-push-pos-offset guard 2)) + ;; "1.0011" 5= vn rh arh + (5 (elm-indent-push-pos valname) + (elm-indent-push-pos aft-rhs-sign)) + ;; "1.0010" 6= vn rh + (6 (if last-line + (elm-indent-push-pos-offset valname) + (elm-indent-push-pos-offset rhs-sign 2))) + ;; "110000" 7= vn avn + (7 (elm-indent-push-pos valname) + (elm-indent-push-pos-offset valname)) + ;; "100000" 8= vn + (8 (elm-indent-push-pos valname)) + ;; "001.11" 9= gd rh arh + (9 (elm-indent-push-pos aft-rhs-sign)) + ;; "001.10" 10= gd rh + (10 (if last-line + (elm-indent-push-pos-offset guard) + (elm-indent-push-pos-offset rhs-sign 2))) + ;; "001100" 11= gd agd + (11 (if (elm-indent-no-otherwise guard) + (elm-indent-push-pos aft-guard))) + ;; "001000" 12= gd + (12 (if last-line (elm-indent-push-pos-offset guard 2))) + ;; "000011" 13= rh arh + (13 (elm-indent-push-pos aft-rhs-sign)) + ;; "000010" 14= rh + (14 (if last-line (elm-indent-push-pos-offset rhs-sign 2))) + ;; "000000" 15= + (t (error "elm-indent-other: %s impossible case" test )))) + elm-indent-info))) + +(defun elm-indent-valdef-indentation (start end end-visible curr-line-type + indent-info) + "Find indentation information for a value definition." + (let ((elm-indent-info indent-info)) + (if (< start end-visible) + (case curr-line-type + (empty (elm-indent-empty start end end-visible indent-info)) + (ident (elm-indent-ident start end end-visible indent-info)) + (guard (elm-indent-guard start end end-visible indent-info)) + (rhs (elm-indent-rhs start end end-visible indent-info)) + (comment (error "Comment indent should never happen")) + (other (elm-indent-other start end end-visible indent-info))) + elm-indent-info))) + +(defun elm-indent-line-indentation (line-start line-end end-visible + curr-line-type indent-info) + "Compute indentation info between LINE-START and END-VISIBLE. +Separate a line of program into valdefs between offside keywords +and find indentation info for each part." + (save-excursion + ;; point is (already) at line-start + (assert (eq (point) line-start)) + (let ((elm-indent-info indent-info) + (start (or (elm-indent-in-comment line-start line-end) + (elm-indent-in-string line-start line-end)))) + (if start ; if comment at the end + (setq line-end start)) ; end line before it + ;; loop on all parts separated by off-side-keywords + (while (and (re-search-forward elm-indent-off-side-keywords-re + line-end t) + (not (or (elm-indent-in-comment line-start (point)) + (elm-indent-in-string line-start (point))))) + (let ((beg-match (match-beginning 0)) ; save beginning of match + (end-match (match-end 0))) ; save end of match + ;; Do not try to find indentation points if off-side-keyword at + ;; the start... + (if (or (< line-start beg-match) + ;; Actually, if we're looking at a "let" inside a "do", we + ;; should add the corresponding indentation point. + (eq (char-after beg-match) ?l)) + (setq elm-indent-info + (elm-indent-valdef-indentation line-start beg-match + end-visible + curr-line-type + elm-indent-info))) + ;; ...but keep the start of the line if keyword alone on the line + (if (= line-end end-match) + (elm-indent-push-pos beg-match)) + (setq line-start end-match) + (goto-char line-start))) + (elm-indent-valdef-indentation line-start line-end end-visible + curr-line-type elm-indent-info)))) + + +(defun elm-indent-layout-indent-info (start contour-line) + (let ((elm-indent-info nil) + (curr-line-type (elm-indent-type-at-point)) + line-start line-end end-visible) + (save-excursion + (if (eq curr-line-type 'ident) + (let ; guess the type of line + ((sep + (elm-indent-separate-valdef + (point) (line-end-position)))) + ;; if the first ident is where or the start of a def + ;; keep it in a global variable + (setq elm-indent-current-line-first-ident + (if (string-match "where[ \t]*" (nth 1 sep)) + (nth 1 sep) + (if (nth 5 sep) ; is there a rhs-sign + (if (= (char-after (nth 5 sep)) ?\:) ;is it a typdef + ":" (nth 1 sep)) + ""))))) + (while contour-line ; explore the contour points + (setq line-start (pop contour-line)) + (goto-char line-start) + (setq line-end (line-end-position)) + (setq end-visible ; visible until the column of the + (if contour-line ; next contour point + (save-excursion + (move-to-column + (elm-indent-point-to-col (car contour-line))) + (point)) + line-end)) + (unless (or (elm-indent-open-structure start line-start) + (elm-indent-in-comment start line-start)) + (setq elm-indent-info + (elm-indent-line-indentation line-start line-end + end-visible curr-line-type + elm-indent-info))))) + elm-indent-info)) + +(defun elm-indent-find-matching-start (regexp limit &optional pred start) + (let ((open (elm-indent-open-structure limit (point)))) + (if open (setq limit (1+ open)))) + (unless start (setq start (point))) + (when (re-search-backward regexp limit t) + (let ((nestedcase (match-end 1)) + (outer (or (elm-indent-in-string limit (point)) + (elm-indent-in-comment limit (point)) + (elm-indent-open-structure limit (point)) + (if (and pred (funcall pred start)) (point))))) + (cond + (outer + (goto-char outer) + (elm-indent-find-matching-start regexp limit pred start)) + (nestedcase + ;; Nested case. + (and (elm-indent-find-matching-start regexp limit pred) + (elm-indent-find-matching-start regexp limit pred start))) + (t (point)))))) + + +(defun elm-indent-comment (open start) + "Compute indent info for comments and text inside comments. +OPEN is the start position of the comment in which point is." + ;; Ideally we'd want to guess whether it's commented out code or + ;; whether it's text. Instead, we'll assume it's text. + (save-excursion + (if (= open (point)) + ;; We're actually just in front of a comment: align with following + ;; code or with comment on previous line. + (let ((prev-line-info + (cond + ((eq (char-after) ?\{) nil) ;Align as if it were code. + ((and (forward-comment -1) + (> (line-beginning-position 3) open)) + ;; We're after another comment and there's no empty line + ;; between us. + (list (list (elm-indent-point-to-col (point))))) + (t nil)))) ;Else align as if it were code + ;; Align with following code. + (forward-comment (point-max)) + ;; There are several possible indentation points for this code-line, + ;; but the only valid indentation point for the comment is the one + ;; that the user will select for the code-line. Obviously we can't + ;; know that, so we just assume that the code-line is already at its + ;; proper place. + ;; Strictly speaking "assume it's at its proper place" would mean + ;; we'd just use (current-column), but since this is using info from + ;; lines further down and it's common to reindent line-by-line, + ;; we'll align not with the current indentation, but with the + ;; one that auto-indentation "will" select. + (append + prev-line-info + (let ((indent-info (save-excursion + (elm-indent-indentation-info start))) + (col (current-column))) + ;; Sort the indent-info so that the current indentation comes + ;; out first. + (setq indent-info + (sort indent-info + (lambda (x y) + (<= (abs (- col (car x))) (abs (- col (car y))))))) + indent-info))) + + ;; We really are inside a comment. + (if (looking-at "-}") + (progn + (forward-char 2) + (forward-comment -1) + (list (list (1+ (elm-indent-point-to-col (point)))))) + (let ((offset (if (looking-at "--?") + (- (match-beginning 0) (match-end 0))))) + (forward-line -1) ;Go to previous line. + (back-to-indentation) + (if (< (point) start) (goto-char start)) + + (list (list (if (and comment-start-skip (looking-at comment-start-skip)) + (if offset + (+ 2 offset (elm-indent-point-to-col (point))) + (elm-indent-point-to-col (match-end 0))) + (elm-indent-point-to-col (point)))))))))) + +(defun elm-indent-closing-keyword (start) + (let ((open (save-excursion + (elm-indent-find-matching-start + (case (char-after) + (?i "\\<\\(?:\\(in\\)\\|let\\)\\>") + (?o "\\<\\(?:\\(of\\)\\|case\\)\\>") + (?t "\\<\\(?:\\(then\\)\\|if\\)\\>") + (?e "\\<\\(?:\\(else\\)\\|if\\)\\>")) + start)))) + ;; For a "hanging let/case/if at EOL" we should use a different + ;; indentation scheme. + (save-excursion + (goto-char open) + (if (elm-indent-hanging-p) + (setq open (elm-indent-virtual-indentation start)))) + ;; FIXME: we should try and figure out if the `if' is in a `do' layout + ;; before using elm-indent-thenelse. + (list (list (+ (if (memq (char-after) '(?t ?e)) elm-indent-thenelse 0) + (elm-indent-point-to-col open)))))) + +(defun elm-indent-skip-lexeme-forward () + (and (zerop (skip-syntax-forward "w")) + (skip-syntax-forward "_") + (skip-syntax-forward "(") + (skip-syntax-forward ")"))) + +(defun elm-indent-offset-after-info () + "Return the info from `elm-indent-after-keywords' for keyword at point." + (let ((id (buffer-substring + (point) + (save-excursion + (elm-indent-skip-lexeme-forward) + (point))))) + (or (assoc id elm-indent-after-keywords) + (car (member id elm-indent-after-keywords))))) + +(defun elm-indent-hanging-p () + ;; A Hanging keyword is one that's at the end of a line except it's not at + ;; the beginning of a line. + (not (or (= (current-column) (current-indentation)) + (save-excursion + (let ((lexeme + (buffer-substring + (point) + (progn (elm-indent-skip-lexeme-forward) (point))))) + (or (member lexeme elm-indent-dont-hang) + (> (line-end-position) + (progn (forward-comment (point-max)) (point))))))))) + +(defun elm-indent-after-keyword-column (offset-info start &optional default) + (unless offset-info + (setq offset-info (elm-indent-offset-after-info))) + (unless default (setq default elm-indent-offset)) + (setq offset-info + (if elm-indent-inhibit-after-offset '(0) (cdr-safe offset-info))) + (if (not (elm-indent-hanging-p)) + (elm-indent-column+offset (current-column) + (or (car offset-info) default)) + ;; The keyword is hanging at the end of the line. + (elm-indent-column+offset + (elm-indent-virtual-indentation start) + (or (cadr offset-info) (car offset-info) default)))) + +(defun elm-indent-inside-paren-update-syntax-p (open) + (let ((end (point))) + (save-excursion + (goto-char open) + (and (not (looking-at ".*=")) + (progn + (forward-line) + (elm-indent-skip-blanks-and-newlines-forward end) + (eq (char-after) ?\|)))))) + +(defun elm-indent-inside-paren (open) + ;; there is an open structure to complete + (if (looking-at "\\s)\\|[|;,]") + ;; A close-paren or a , or ; can only correspond syntactically to + ;; the open-paren at `open'. So there is no ambiguity. + (let* ((is-close-brace (eq (char-after) ?\})) + (inside-update (elm-indent-inside-paren-update-syntax-p open))) + (if (and (eq (char-after) ?\;) (eq (char-after open) ?\()) + (message "Mismatched punctuation: `%c' in %c...%c" + (char-after) (char-after open) + (if (eq (char-after open) ?\() ?\) ?\}))) + (save-excursion + (goto-char open) + (list (list + (if (elm-indent-hanging-p) + (elm-indent-virtual-indentation nil) + (if (and inside-update + (not is-close-brace) + (eq (char-after open) ?\{)) + (elm-indent-point-to-col (+ elm-indent-offset open)) + (elm-indent-point-to-col open))))))) + ;; There might still be layout within the open structure. + (let* ((end (point)) + (basic-indent-info + ;; Anything else than a ) is subject to layout. + (if (looking-at "\\s.\\|\\$ ") + (elm-indent-point-to-col open) ; align a punct with ( + (let ((follow (save-excursion + (goto-char (1+ open)) + (elm-indent-skip-blanks-and-newlines-forward end) + (point)))) + (if (= follow end) + (save-excursion + (goto-char open) + (elm-indent-after-keyword-column nil nil 1)) + (elm-indent-point-to-col (+ elm-indent-offset follow)))))) + (open-column (elm-indent-point-to-col open)) + (contour-line (elm-indent-contour-line (1+ open) end))) + (if (null contour-line) + (list (list basic-indent-info)) + (let ((indent-info + (elm-indent-layout-indent-info + (1+ open) contour-line))) + ;; Fix up indent info. + (let ((base-elem (assoc open-column indent-info))) + (if base-elem + (progn (setcar base-elem basic-indent-info) + (setcdr base-elem nil)) + (if (not (eq basic-indent-info 0)) + (setq indent-info (append (list (list basic-indent-info)) indent-info)) + (setq indent-info (append indent-info (list (list basic-indent-info)))))) + indent-info)))))) + +(defun elm-indent-virtual-indentation (start) + "Compute the \"virtual indentation\" of text at point. +The \"virtual indentation\" is the indentation that text at point would have +had, if it had been placed on its own line." + (let ((col (current-column)) + (elm-indent-inhibit-after-offset (elm-indent-hanging-p))) + (if (save-excursion (skip-chars-backward " \t") (bolp)) + ;; If the text is indeed on its own line, than the virtual indent is + ;; the current indentation. + col + ;; Else, compute the indentation that it would have had. + (let ((info (elm-indent-indentation-info start)) + (max -1)) + ;; `info' is a list of possible indent points. Each indent point is + ;; assumed to correspond to a different parse. So we need to find + ;; the parse that corresponds to the case at hand (where there's no + ;; line break), which is assumed to always be the + ;; deepest indentation. + (dolist (x info) + (setq x (car x)) + ;; Sometimes `info' includes the current indentation (or yet + ;; deeper) by mistake, because elm-indent-indentation-info + ;; wasn't designed to be called on a piece of text that is not at + ;; BOL. So ignore points past `col'. + (if (and (> x max) (not (>= x col))) + (setq max x))) + ;; In case all the indent points are past `col', just use `col'. + (if (>= max 0) max col))))) + +(defun elm-indent-indentation-info (&optional start) + "Return a list of possible indentations for the current line. +These are then used by `elm-indent-cycle'. +START if non-nil is a presumed start pos of the current definition." + (unless start (setq start (elm-indent-start-of-def))) + (let (open contour-line) + (cond + ;; in string? + ((setq open (elm-indent-in-string start (point))) + (list (list (+ (elm-indent-point-to-col open) + (if (looking-at "\\\\") 0 1))))) + + ;; in comment ? + ((setq open (elm-indent-in-comment start (point))) + (elm-indent-comment open start)) + + ;; Closing the declaration part of a `let' or the test exp part of a case. + ((looking-at "\\(?:in\\|of\\|then\\|else\\)\\>") + (elm-indent-closing-keyword start)) + + ;; Right after a special keyword. + ((save-excursion + (forward-comment (- (point-max))) + (when (and (not (zerop (skip-syntax-backward "w"))) + (setq open (elm-indent-offset-after-info))) + (list (list (elm-indent-after-keyword-column open start)))))) + + ;; open structure? ie ( { [ + ((setq open (elm-indent-open-structure start (point))) + (elm-indent-inside-paren open)) + + ;; full indentation + ((setq contour-line (elm-indent-contour-line start (point))) + (elm-indent-layout-indent-info start contour-line)) + + (t + ;; simple contour just one indentation at start + (list (list (elm-indent-point-to-col start))))))) + +(defun elm-indent-cycle () + "Indentation cycle. + +We stay in the cycle as long as the TAB key is pressed." + (interactive "*") + (let ((marker (if (> (current-column) + (current-indentation)) + (point-marker))) + (bol (progn (beginning-of-line) (point)))) + (back-to-indentation) + (unless (and (eq last-command this-command) + (eq bol (car elm-indent-last-info))) + (save-excursion + (setq elm-indent-last-info + (list bol (elm-indent-indentation-info) 0 0)))) + + (let* ((il (nth 1 elm-indent-last-info)) + (index (nth 2 elm-indent-last-info)) + (last-insert-length (nth 3 elm-indent-last-info)) + (indent-info (nth index il))) + + (indent-line-to (car indent-info)) ; insert indentation + (delete-char last-insert-length) + (setq last-insert-length 0) + (let ((text (cdr indent-info))) + (if text + (progn + (insert text) + (setq last-insert-length (length text))))) + + (setq elm-indent-last-info + (list bol il (% (1+ index) (length il)) last-insert-length)) + + (if (= (length il) 1) + (message "Sole indentation") + (message "Indent cycle (%d)..." (length il))) + + (if marker + (goto-char (marker-position marker)))))) + +(defun elm-indent-region (start end) + "Apply `elm-indent-cycle' to every line between START and END." + (save-excursion + (goto-char start) + (while (< (point) end) + (elm-indent-cycle) + (forward-line)))) + +;;; Alignment functions +(defun elm-indent-shift-columns (dest-column region-stack) + "Shift columns in REGION-STACK to go to DEST-COLUMN. +Elements of the stack are pairs of points giving the start and end +of the regions to move." + (let (reg col diffcol reg-end) + (while (setq reg (pop region-stack)) + (setq reg-end (copy-marker (cdr reg))) + (goto-char (car reg)) + (setq col (current-column)) + (setq diffcol (- dest-column col)) + (if (not (zerop diffcol)) + (catch 'end-of-buffer + (while (<= (point) (marker-position reg-end)) + (if (< diffcol 0) + (backward-delete-char-untabify (- diffcol) nil) + (insert-char ?\ diffcol)) + (end-of-line 2) ; should be (forward-line 1) + (if (eobp) ; but it adds line at the end... + (throw 'end-of-buffer nil)) + (move-to-column col))))))) + +(defun elm-indent-align-def (p-arg type) + "Align guards or rhs within the current definition before point. +If P-ARG is t align all defs up to the mark. +TYPE is either 'guard or 'rhs." + (save-excursion + (let (start-block end-block + (maxcol (if (eq type 'rhs) elm-indent-rhs-align-column 0)) + contour sep defname defnamepos + defcol pos lastpos + regstack eqns-start start-found) + ;; find the starting and ending boundary points for alignment + (if p-arg + (if (mark) ; aligning everything in the region + (progn + (when (> (mark) (point)) (exchange-point-and-mark)) + (setq start-block + (save-excursion + (goto-char (mark)) + (line-beginning-position))) + (setq end-block + (progn (if (bolp) + (forward-line -1)) + (line-end-position)))) + (error "The mark is not set for aligning definitions")) + ;; aligning the current definition + (setq start-block (elm-indent-start-of-def)) + (setq end-block (line-end-position))) + ;; find the start of the current valdef using the contour line + ;; in reverse order because we need the nearest one from the end + (setq contour + (reverse (elm-indent-contour-line start-block end-block))) + (setq pos (car contour)) ; keep the start of the first contour + ;; find the nearest start of a definition + (while (and (not defname) contour) + (goto-char (pop contour)) + (if (elm-indent-open-structure start-block (point)) + nil + (setq sep (elm-indent-separate-valdef (point) end-block)) + (if (nth 5 sep) ; is there a rhs? + (progn (setq defnamepos (nth 0 sep)) + (setq defname (nth 1 sep)))))) + ;; start building the region stack + (if defnamepos + (progn ; there is a valdef + ;; find the start of each equation or guard + (if p-arg ; when indenting a region + ;; accept any start of id or pattern as def name + (setq defname "\\<\\|(")) + (setq defcol (elm-indent-point-to-col defnamepos)) + (goto-char pos) + (setq end-block (line-end-position)) + (catch 'top-of-buffer + (while (and (not start-found) + (>= (point) start-block)) + (if (<= (current-indentation) defcol) + (progn + (move-to-column defcol) + (if (and (looking-at defname) ; start of equation + (not (elm-indent-open-structure start-block (point)))) + (push (cons (point) 'eqn) eqns-start) + ;; found a less indented point not starting an equation + (setq start-found t))) + ;; more indented line + (back-to-indentation) + (if (and (eq (elm-indent-type-at-point) 'guard) ; start of a guard + (not (elm-indent-open-structure start-block (point)))) + (push (cons (point) 'gd) eqns-start))) + (if (bobp) + (throw 'top-of-buffer nil) + (backward-to-indentation 1)))) + ;; remove the spurious guards before the first equation + (while (and eqns-start (eq (cdar eqns-start) 'gd)) + (pop eqns-start)) + ;; go through each equation to find the region to indent + (while eqns-start + (let ((eqn (caar eqns-start))) + (setq lastpos (if (cdr eqns-start) + (save-excursion + (goto-char (caadr eqns-start)) + (forward-line -1) + (line-end-position)) + end-block)) + (setq sep (elm-indent-separate-valdef eqn lastpos))) + (if (eq type 'guard) + (setq pos (nth 3 sep)) + ;; check if what follows a rhs sign is more indented or not + (let ((rhs (nth 5 sep)) + (aft-rhs (nth 6 sep))) + (if (and rhs aft-rhs + (> (elm-indent-point-to-col rhs) + (elm-indent-point-to-col aft-rhs))) + (setq pos aft-rhs) + (setq pos rhs)))) + (if pos + (progn ; update region stack + (push (cons pos (or lastpos pos)) regstack) + (setq maxcol ; find the highest column number + (max maxcol + (progn ;find the previous non-empty column + (goto-char pos) + (skip-chars-backward + " \t" + (line-beginning-position)) + (if (bolp) + ;;if on an empty prefix + (elm-indent-point-to-col pos) ;keep original indent + (1+ (elm-indent-point-to-col (point))))))))) + (pop eqns-start)) + ;; now shift according to the region stack + (if regstack + (elm-indent-shift-columns maxcol regstack))))))) + + +;;; Insertion functions +(defun elm-indent-insert-equal () + "Insert an = sign and align the previous rhs of the current function." + (interactive "*") + (if (or (bolp) + (/= (preceding-char) ?\ )) + (insert ?\ )) + (insert "= ") + (elm-indent-align-def mark-active 'rhs)) + + +(defvar elm-indent-mode-map + (let ((map (make-sparse-keymap))) + (define-key map [?\C-c ?\C-=] 'elm-indent-insert-equal) + map)) + +(define-obsolete-variable-alias 'elm-indent-map 'elm-indent-mode-map) + +;;;###autoload +(define-minor-mode elm-indent-mode + "``Intelligent'' Elm indentation mode. + +This deals with the layout rules of Elm. + +\\[elm-indent-cycle] starts the cycle which proposes new +possibilities as long as the TAB key is pressed. Any other key +or mouse click terminates the cycle and is interpreted except for +RET which merely exits the cycle. + +Other special keys are: + + \\[elm-indent-insert-equal] + inserts an = + +Invokes `elm-indent-hook' if not nil." + :global nil + :lighter " EIndent" + :map 'elm-indent-mode-map + (if elm-indent-mode + (progn + (set (make-local-variable 'indent-line-function) 'elm-indent-cycle) + (set (make-local-variable 'indent-region-function) 'elm-indent-region)) + (kill-local-variable 'indent-line-function) + (kill-local-variable 'indent-region-function))) + +;;;###autoload +(define-obsolete-function-alias 'turn-on-elm-indent 'elm-indent-mode) + +(defun turn-off-elm-indent () + "Turn off ``intelligent'' Elm indentation mode." + (elm-indent-mode nil)) + + +(provide 'elm-indent) +;;; elm-indent.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-indent.elc b/elpa/elm-mode-20191125.1919/elm-indent.elc new file mode 100644 index 0000000000000000000000000000000000000000..df23d7954d9b8ff72336df33fa5a3f86c7417898 GIT binary patch literal 30534 zcmchA3wv9|)vnU#JFPE|_m>bb(1O`k2)2^Q*;mOn4a9_y<|!l`5=u*yRqM4Z zNzSEB&-v@;eb<`VnyrgNOZx?E@5|h0UEZ~3&FoL_etqZNQmM4`>8GFiclsx%oo;p@ zH=Uk;_oUSx`p>h$u+#7PQEe-hH!nJ)W53ny`u)>U=cMzu)(EeMTTAlt@o{J9AEFfh zY?uxGgIB%QNvG`}^xMPHpwl}V-oV?zaOAfR4zdG3uO-~sigu>TIOwB{UVr4b`@K;M ziO)ud)oncKRremtO$8y zHc86R)N$yR6{7~06|=2QswgU?VhYq2qs$nol8G{t(CtNnG82@SuKc9sUBqQZflTLj|Tm-Q$OpTR6D(ctT*y|ovvTL+dTm-@?NNU ztL*RQ3H{w}r}xa?GzFcsdS@+U*<=|fn5N48amI4R-#r~S6c zoo49JC_4g`J9P|>ht*cMbJPQYb|MvlY&0PI^m?zc4|n^i%rPCeaz|5^34H5^s5lhe_wDn>B#N9frh$NPpm)_&GI z;@cM;h!pZV^ZLx|gE=L;FWFgbxAm%jHu6vV=-Uug?)UrMjLGu(td5SeUe-lJr7}p0 zzh#5|4Zl(5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~yyI`B-JQ0366$Kwxwk5)5t-0FW>Q`Y>KlS!fo124GOId>JYDgbR1_1P6@* zOWb6BUo`~ukx{AO+PbHZj3QVfaKw*eog%bR9Ew!d6gE|F ziq#O-)nTmV{IRl+)y=llQUB-&z7`M>z9?12myWUlmV#8C5a&SfN=7`I{=lE|fYT_g z(|?99-%Vy4ob~X5y*|Ed;-qIM!4fiG*bcuz;$n?khy`@H+)K zxf|cFFp5*{UwDe_O5j~Ak+|aR>QH1Gjy%KhXg&No=-?9Is|{_%_6eTT#Y@NJ-LBy{ zcJm>GO-5Imuv;^doUIKV+=>k(n<4zPFOcL@%83qxh&l)UN6?C>5P3#wwaSX5ONB)M zO+6#4-RUYxQB70q$Q0TKBQRQ=iNnz3hG(<*PzY~wc4lcGnE*==Sp8{(Y|MuyMcI^p z$Em}N`{J2~`oJU+#bTVgSxa0+&54TmHM|Enwtmoura1uy%7zF%(GzGLJz@d!KG8a| zH1XM08N?00b%xJkLfDfsUiteF{*aKPE#Kc1p^rk~0q2(i39Gw)p%cR`9GT6cAZz;r znfFQ316kcwy5UzEQM-nhLusqV=I0)&Alq@jib~h$TAZ%)nBNzJLmxVezlW9J~~37VEs9T@QE+=1hK$E>pS{{bqa*69EM literal 0 HcmV?d00001 diff --git a/elpa/elm-mode-20191125.1919/elm-interactive.el b/elpa/elm-mode-20191125.1919/elm-interactive.el new file mode 100644 index 00000000..f89a8de6 --- /dev/null +++ b/elpa/elm-mode-20191125.1919/elm-interactive.el @@ -0,0 +1,1101 @@ +;;; elm-interactive.el --- Run an interactive Elm session. -*- lexical-binding: t -*- + +;; Copyright (C) 2015, 2016 Bogdan Popa + +;; Author: Bogdan Popa +;; URL: https://github.com/jcollard/elm-mode + +;; 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 program. If not, see . + +;;; Commentary: +;;; Code: +(require 'ansi-color) +(require 'comint) +(require 'compile) +(require 'cl-lib) +(require 'dash) +(require 'elm-font-lock) +(require 'elm-util) +(require 'f) +(require 'json) +(require 'let-alist) +(require 'rx) +(require 's) +(require 'seq) +(require 'subr-x) +(require 'tabulated-list) +(require 'url) + +(defvar elm-interactive--seen-prompt nil + "Non-nil represents the fact that a prompt has been spotted.") +(make-variable-buffer-local 'elm-interactive--seen-prompt) + +(defvar elm-interactive--current-project nil) +(defvar elm-interactive--process-name "elm") +(defvar elm-interactive--buffer-name "*elm*") +(defvar elm-reactor--process-name "elm-reactor") +(defvar elm-reactor--buffer-name "*elm-reactor*") + +(defcustom elm-interactive-command '("elm" "repl") + "The Elm REPL command. +For Elm 0.18 and earlier, set this to '(\"elm-repl\")." + :type '(repeat string) + :group 'elm) + +(defcustom elm-interactive-arguments '() + "Command line arguments to pass to the Elm REPL command." + :type '(repeat string) + :group 'elm) + +(defvar elm-interactive-prompt-regexp "^[>|] " + "Prompt for `run-elm-interactive'.") + +(defcustom elm-reactor-command '("elm" "reactor") + "The Elm Reactor command. +For Elm 0.18 and earlier, set this to '(\"elm-reactor\")." + :type '(repeat string) + :group 'elm) + +(defcustom elm-reactor-port "8000" + "The Elm Reactor port." + :type '(string) + :group 'elm) + +(defcustom elm-reactor-address "127.0.0.1" + "The Elm Reactor address." + :type '(string) + :group 'elm) + +(defcustom elm-reactor-arguments `("-p" ,elm-reactor-port "-a" ,elm-reactor-address) + "Command line arguments to pass to the Elm Reactor command." + :type '(repeat string) + :group 'elm) + +(defvar elm-compile--buffer-name "*elm-make*") + +(defcustom elm-compile-command '("elm" "make") + "The Elm compilation command." + :type '(repeat string) + :group 'elm) + +(defcustom elm-compile-arguments '("--output=elm.js") + "Command line arguments to pass to the Elm compilation command. +For Elm 0.18 and earlier, set this to '(\"--yes\" \"--warn\" \"--output=elm.js\")." + :type '(repeat string) + :group 'elm) + +(defvar elm-compile-error-regexp-alist-alist + '((elm-file "-- [^-]+ -+ \\(.+\\)$" 1 nil) + (elm-line "^\\([0-9]+\\)|" nil 1)) + "Regexps to match Elm compiler errors in compilation buffer.") + +(defvar elm-compile-error-regexp-alist '(elm-line elm-file)) + +(dolist (alist elm-compile-error-regexp-alist-alist) + (add-to-list 'compilation-error-regexp-alist-alist alist)) + +(dolist (symbol elm-compile-error-regexp-alist) + (add-to-list 'compilation-error-regexp-alist symbol)) + +(defcustom elm-create-package-command "elm make --yes" + "The command that is used to initialize a new package definition." + :type '(string) + :group 'elm) + +(defvar elm-package--contents nil + "The contents of the Elm package catalog.") + +(defvar elm-package--dependencies nil + "The package dependencies for the current Elm package.") + +(defvar elm-package--cache nil + "A cache for extended package information.") + +(defvar elm-package--marked-contents nil) + +(defvar elm-package--working-dir nil) + +(defvar elm-package-compile-buffer-name "*elm-package-compile*") + +(defvar elm-package-buffer-name "*elm-package*") + +(defcustom elm-package-command '("elm-package") + "The Elm package command. +For Elm 0.19 and greater, set this to '(\"elm\" \"package\")." + :type '(repeat string) + :group 'elm) + +(defcustom elm-package-arguments '("install" "--yes") + "Command line arguments to pass to the Elm package command." + :type '(repeat string) + :group 'elm) + +(defcustom elm-package-catalog-root + "http://package.elm-lang.org/" + "The root URI for the Elm package catalog." + :type '(string) + :group 'elm) + +(defvar elm-package-catalog-format + [(" " 1 nil) + ("Name" 30 t) + ("Version" 7 nil) + ("Status" 10 t) + ("Summary" 80 nil)] + "The format of the package list header.") + +(defvar elm-interactive-mode-map + (let ((map (make-keymap))) + (define-key map "\t" #'completion-at-point) + (define-key map (kbd "C-a") #'elm-interactive-mode-beginning) + (define-key map (kbd "C-c C-z") #'elm-repl-return-to-origin) + map) + "Keymap for Elm interactive mode.") + +(defcustom elm-oracle-command "elm-oracle" + "The Elm Oracle command." + :type '(string) + :group 'elm) + +(defconst elm-oracle--pattern + "\\(?:[^A-Za-z0-9_.']\\)\\(\\(?:[A-Za-z_][A-Za-z0-9_']*[.]\\)*[A-Za-z0-9_']*\\)" + "The prefix pattern used for completion.") + +(defvar elm-repl--origin nil + "Marker for buffer/position from which we jumped to this repl.") + +(defcustom elm-sort-imports-on-save nil + "Controls whether or not imports should be automaticaly reordered on save." + :type 'boolean + :group 'elm) + +(defvar elm-package-mode-map + (let ((map (make-keymap))) + (define-key map "g" #'elm-package-refresh) + (define-key map "n" #'elm-package-next) + (define-key map "p" #'elm-package-prev) + (define-key map "v" #'elm-package-view) + (define-key map "m" #'elm-package-mark) + (define-key map "i" #'elm-package-mark) + (define-key map "u" #'elm-package-unmark) + (define-key map "x" #'elm-package-install) + map) + "Keymap for Elm package mode.") + +(defun elm-interactive-mode-beginning () + "Go to the start of the line." + (interactive) + (beginning-of-line) + (goto-char (+ 2 (point)))) + +(defun elm-interactive--get-process-buffer () + "Get the REPL process buffer." + (get-buffer-process elm-interactive--buffer-name)) + +(defun elm-interactive--spot-prompt (_string) + "Spot the prompt, _STRING is ignored." + (let ((proc (elm-interactive--get-process-buffer))) + (when proc + (save-excursion + (goto-char (process-mark proc)) + (if (re-search-backward comint-prompt-regexp + (line-beginning-position) t) + (setq elm-interactive--seen-prompt t)))))) + +(defun elm-interactive--wait-for-prompt (proc &optional timeout) + "Wait until PROC sends us a prompt or TIMEOUT. +The process PROC should be associated to a comint buffer. + +Stolen from ‘haskell-mode’." + (with-current-buffer (process-buffer proc) + (while (progn + (goto-char comint-last-input-end) + (not (or elm-interactive--seen-prompt + (setq elm-interactive--seen-prompt + (re-search-forward comint-prompt-regexp nil t)) + (not (accept-process-output proc timeout)))))) + (unless elm-interactive--seen-prompt + (error "Can't find the prompt")))) + +(defun elm-interactive--send-command (command) + "Send a COMMAND to the REPL." + (let ((proc (elm-interactive--get-process-buffer))) + (with-current-buffer (process-buffer proc) + (elm-interactive--wait-for-prompt proc 10) + (goto-char (process-mark proc)) + (insert-before-markers command) + (move-marker comint-last-input-end (point)) + (setq elm-interactive--seen-prompt nil) + (comint-send-string proc command)))) + +(defun elm-interactive-kill-current-session () + "Stop the current REPL session and delete its buffer." + (interactive) + (when (and elm-interactive--current-project + (get-buffer-process elm-interactive--buffer-name) + (not (equal elm-interactive--current-project (elm--find-dependency-file-path))) + (y-or-n-p "This will kill your existing REPL session. Continue? ")) + (delete-process elm-interactive--buffer-name) + (kill-buffer elm-interactive--buffer-name))) + +;;;###autoload +(define-derived-mode elm-interactive-mode comint-mode "Elm Interactive" + "Major mode for `run-elm-interactive'. + +\\{elm-interactive-mode-map}" + + (setq-local comint-prompt-regexp elm-interactive-prompt-regexp) + (setq-local comint-prompt-read-only t) + (setq-local comint-use-prompt-regexp t) + + (add-hook 'comint-output-filter-functions #'elm-interactive--spot-prompt nil t) + + (turn-on-elm-font-lock)) + +;;;###autoload +(defun run-elm-interactive () + "Run an inferior instance of `elm-repl' inside Emacs." + (interactive) + (elm-interactive-kill-current-session) + (let* ((default-directory (elm--find-dependency-file-path)) + (origin (point-marker)) + (cmd (append (elm--ensure-list elm-interactive-command) elm-interactive-arguments))) + + (setq elm-interactive--current-project default-directory) + (let ((buffer (get-buffer-create elm-interactive--buffer-name))) + (apply #'make-comint-in-buffer elm-interactive--process-name buffer + (car cmd) nil (cdr cmd)) + (with-current-buffer buffer + (elm-interactive-mode) + (setq-local elm-repl--origin origin)) + (pop-to-buffer buffer)))) + +(defun elm-repl-return-to-origin () + "Jump back to the location from which we last jumped to the repl." + (interactive) + (let* ((pos elm-repl--origin) + (buffer (get-buffer (marker-buffer pos)))) + (when buffer + (pop-to-buffer buffer) + (goto-char pos)))) + +;;;###autoload +(defun elm-repl-load () + "Load an interactive REPL if there isn't already one running. +Changes the current root directory to be the directory with the closest +package json if one exists otherwise sets it to be the working directory +of the file specified." + (interactive) + (save-buffer) + (let ((import-statement (elm--build-import-statement))) + (run-elm-interactive) + (elm-interactive--send-command ":reset\n") + (elm-interactive--send-command import-statement))) + +;;;###autoload +(defun elm-repl-push (beg end) + "Push the region from BEG to END to an interactive REPL." + (interactive "r") + (let* ((to-push (buffer-substring-no-properties beg end)) + (lines (split-string (s-trim-right to-push) "\n"))) + (run-elm-interactive) + (dolist (line lines) + (elm-interactive--send-command (concat line " \\\n"))) + (elm-interactive--send-command "\n"))) + +;;;###autoload +(defun elm-repl-push-decl () + "Push the current top level declaration to the REPL." + (interactive) + (let ((lines (elm--get-decl))) + (run-elm-interactive) + (dolist (line lines) + (elm-interactive--send-command (concat line " \\\n"))) + (elm-interactive--send-command "\n"))) + +(defun elm--ensure-list (v) + "Return V if it is a list, otherwise a single-element list containing V." + (if (consp v) + v + (list v))) + +;;; Reactor: +;;;###autoload +(defun run-elm-reactor () + "Run the Elm reactor process." + (interactive) + (let ((default-directory (elm--find-dependency-file-path)) + (process (get-process elm-reactor--process-name))) + + (when process + (delete-process process)) + + (let ((cmd (append (elm--ensure-list elm-reactor-command) elm-reactor-arguments))) + (apply #'start-process elm-reactor--process-name elm-reactor--buffer-name + (car cmd) (cdr cmd))))) + +(defun elm-reactor--browse (path &optional debug) + "Open (reactor-relative) PATH in browser with optional DEBUG. + +Runs `elm-reactor' first." + (run-elm-reactor) + (browse-url (concat "http://" elm-reactor-address ":" elm-reactor-port "/" path (when debug "?debug")))) + +;;;###autoload +(defun elm-preview-buffer (debug) + "Preview the current buffer using Elm reactor (in debug mode if DEBUG is truthy)." + (interactive "P") + (let* ((fname (buffer-file-name)) + (deppath (elm--find-dependency-file-path)) + (path (f-relative fname deppath))) + (elm-reactor--browse path debug))) + +;;;###autoload +(defun elm-preview-main (debug) + "Preview the main elm file using Elm reactor (in debug mode if DEBUG is truthy)." + (interactive "P") + (elm-reactor--browse (elm--find-main-file) debug)) + + +;;; Make: +(defun elm-compile--command (file &optional output json) + "Generate a command that will compile FILE into OUTPUT, with or without JSON reporting." + (let ((elm-compile-arguments + (if output + (append (cl-remove-if (apply-partially #'string-prefix-p "--output=") elm-compile-arguments) + (list (concat "--output=" (expand-file-name output)))) + elm-compile-arguments))) + (s-join " " + (append (elm--ensure-list elm-compile-command) + (mapcar 'shell-quote-argument + (append (list file) + elm-compile-arguments + (when json + (list "--report=json")))))))) + +(defun elm-compile--filter () + "Filter function for compilation output." + (ansi-color-apply-on-region (point-min) (point-max))) + +(define-compilation-mode elm-compilation-mode "Elm-Compile" + "Elm compilation mode." + (progn + (add-hook 'compilation-filter-hook 'elm-compile--filter nil t))) + +(defun elm-compile--file (file &optional output) + "Compile FILE into OUTPUT." + (let ((default-directory (elm--find-dependency-file-path))) + (with-current-buffer + (compilation-start + (elm-compile--command file output) + 'elm-compilation-mode + (lambda (_) elm-compile--buffer-name))))) + +(defun elm-compile--file-json (file &optional output) + "Compile FILE into OUTPUT and return the JSON report. +The report is a list of elements sorted by their occurrence order +in the file." + (let* ((default-directory (elm--find-dependency-file-path)) + (report (shell-command-to-string + (elm-compile--command file output t)))) + (when (string-prefix-p "[" report) + (let ((json (json-read-from-string report))) + (cl-flet ((start-line (o) (let-alist o .region.start.line))) + (cl-sort (append json nil) (lambda (o1 o2) (< (start-line o1) (start-line o2))))))))) + +(defun elm-compile--temporary () + "Get a compilation report for the current buffer." + (let* ((input (make-temp-file "elm-comp-in-" nil ".elm")) + (output (make-temp-file "elm-comp-out-" nil ".js"))) + (unwind-protect + (progn + (write-region (point-min) (point-max) input) + (elm-compile--file-json input output)) + (delete-file output) + (delete-file input)))) + + +;;;###autoload +(defun elm-compile-buffer (&optional output) + "Compile the current buffer into OUTPUT." + (interactive + (when current-prefix-arg + (list (read-file-name "Output to: ")))) + (save-some-buffers) + (elm-compile--file (elm--buffer-local-file-name) output)) + +;;;###autoload +(defun elm-compile-main (&optional output) + "Compile the main elm file into OUTPUT." + (interactive + (when current-prefix-arg + (list (read-file-name "Output to: ")))) + (elm-compile--file (elm--find-main-file) output)) + +(defun elm-compile--ensure-saved () + "Ensure the current buffer has been saved." + (when (buffer-modified-p) + (if (y-or-n-p "Save current buffer? ") + (save-buffer) + (error "You must save your changes first")))) + +;;;###autoload +(defun elm-compile-clean-imports (&optional prompt) + "Remove unused imports from the current buffer, PROMPT optionally before deleting." + (interactive "P") + (let* ((report (elm-compile--temporary)) + (line-offset 0)) + (dolist (ob report) + (let-alist ob + (when (equal .tag "unused import") + (save-excursion + (goto-char 0) + (forward-line (- .region.start.line 1 line-offset)) + (when (or (not prompt) (y-or-n-p "Delete this import? ")) + (dotimes (_ (1+ (- .region.end.line + .region.start.line))) + (kill-whole-line) + (setq line-offset (1+ line-offset)))))))))) + +(defconst elm-import--pattern + (let* ((upper-word '(seq upper (0+ alnum))) + (lower-word '(seq lower (0+ alnum))) + (ws '(or space "\n")) + (exposing-item `(or ,lower-word + (seq ,upper-word + (opt (0+ ,ws) "(" (0+ ,ws) + (or ".." (seq ,upper-word (0+ (0+ ,ws) "," (0+ ,ws) ,upper-word))) + (0+ ,ws) ")")))) + (exposing-list `(seq ,exposing-item (0+ (0+ ,ws) "," (0+ ,ws) ,exposing-item)))) + ;; TODO: we don't yet allow for comments on lines within an import statement + (rx-to-string + `(seq line-start + "import" (1+ ,ws) (group ,upper-word (0+ "." ,upper-word)) + (opt (1+ ,ws) "as" (1+ ,ws) (group ,upper-word)) + (opt (1+ ,ws) "exposing" (1+ ,ws) "(" (0+ ,ws) (group (or ".." ,exposing-list)) (0+ ,ws) ")") + (0+ space) + line-end)) ) + "Regex to match elm import (including multiline). +Import consists of the word \"import\", real package name, and optional +\"as\" part, and \"exposing\" part, which must occur in that (standard) order. +Each is captured as a group.") + +;;;###autoload +(defun elm-sort-imports () + "Sort the import list in the current buffer." + (interactive) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward elm-import--pattern nil t) + ;; Sort block of contiguous imports, separated by empty lines + (let ((start (match-beginning 0))) + (forward-char 1) ;; Move past newline + (while (looking-at elm-import--pattern) + (goto-char (1+ (match-end 0)))) + (let ((end (point))) + (sort-regexp-fields nil elm-import--pattern "\\1" start end)))))) + + +;;;###autoload +(defun elm-compile-add-annotations (&optional prompt) + "Add missing type annotations to the current buffer, PROMPT optionally before inserting." + (interactive "P") + (let* ((report (elm-compile--temporary)) + (line-offset 0)) + (dolist (ob report) + (let-alist ob + (when (equal .tag "missing type annotation") + ;; Drop the first 2 lines from .details since they contain the warning itself. + (let ((annotation (s-join "\n" (cdr (cdr (s-split "\n" .details)))))) + (goto-char 0) + (forward-line (+ line-offset (1- .region.start.line))) + (setq line-offset (1+ line-offset)) + (when (or (not prompt) (y-or-n-p (format "Add annotation '%s'? " annotation))) + (princ (format "%s\n" annotation) (current-buffer))))))))) + +;;; Package: +;;;###autoload +(defun elm-create-package () + "Generate a new package definition in the current directory." + (interactive) + (when (elm--has-dependency-file) + (error "Elm-package.json already exists")) + (let* ((default-directory (elm--find-dependency-file-path))) + (message "Creating elm package definition. This might take a minute...") + (shell-command elm-create-package-command))) + +(defun elm-package--build-uri (&rest segments) + "Build a URI by combining the package catalog root and SEGMENTS." + (concat elm-package-catalog-root (s-join "/" segments))) + +(defun elm-package--format-entry (index entry) + "Format a package '(INDEX ENTRY) for display in the package listing." + (let-alist entry + (let ((mark (if (-contains? elm-package--marked-contents index) + "*" + "")) + (button (list .name . ())) + (status (if (-contains? elm-package--dependencies .name) + "dependency" + "available"))) + (list index (vector mark button (elt .versions 0) status .summary))))) + +(defun elm-package--entries () + "Return the formatted package list." + (-map-indexed #'elm-package--format-entry elm-package--contents)) + +(defun elm-package--get-marked-packages () + "Get packages that are marked for installation." + (-map (lambda (id) + (let-alist (nth id elm-package--contents) + (concat .name " " (elt .versions 0)))) + elm-package--marked-contents)) + +(defun elm-package--get-marked-install-commands () + "Get a list of the commands required to install the marked packages." + (-map (lambda (package) + (s-join " " (append (elm--ensure-list elm-package-command) elm-package-arguments (list package)))) + (elm-package--get-marked-packages))) + +(defun elm-package--read-dependencies () + "Read the current package's dependencies." + (setq elm-package--working-dir (elm--find-dependency-file-path)) + (let-alist (elm--read-dependency-file) + (setq elm-package--dependencies + (-map (lambda (dep) (symbol-name (car dep))) + (if (consp .dependencies.direct) + (append .dependencies.direct .dependencies.indirect) + .dependencies))))) + +(defun elm-package--read-json (uri) + "Read a JSON file from a URI." + (with-current-buffer (url-retrieve-synchronously uri) + (goto-char (point-min)) + (re-search-forward "^ *$") + (json-read))) + +(defun elm-package--read-package () + "Read a package from the minibuffer." + (completing-read "Package: " elm-package--dependencies nil t)) + +(defun elm-package--read-module (package) + "Read a module from PACKAGE from the minibuffer." + (completing-read "Module: " (elm-package-modules package) nil t)) + +(defun elm-package--read-module-definition (package module) + "Read a definition from PACKAGE and MODULE from the minibuffer." + (completing-read "Definition: " (elm-package-definitions package module) nil t)) + +(defun elm-package-refresh-package (package version) + "Refresh the cache for PACKAGE with VERSION." + (let ((documentation-uri + (elm-package--build-uri "packages" package version "docs.json"))) + (setq elm-package--cache + (cons `(,package . ,(elm-package--read-json documentation-uri)) + elm-package--cache)))) + +(defun elm-package-latest-version (package) + "Get the latest version of PACKAGE." + (let ((entry (assoc (intern-soft package) elm-package--contents))) + (if (not entry) + (error "Package not found") + (let ((versions (cdr entry))) + (elt versions 0))))) + +(defun elm-package--ensure-cached (package) + "Ensure that PACKAGE has been cached." + (unless (assoc package elm-package--cache) + (elm-package-refresh-package package (elm-package-latest-version package)))) + +(defun elm-package-modules (package) + "Get PACKAGE's module list." + (elm-package--ensure-cached package) + (sort + (mapcar (lambda (module) + (let-alist module .name)) + (cdr (assoc package elm-package--cache))) + #'string<)) + +(defun elm-package--select-module (package module-name) + "Select a PACKAGE's MODULE-NAME from the cache." + (elm-package--ensure-cached package) + (elt (cl-remove-if-not + (lambda (module) + (let-alist module (equal module-name .name))) + (cdr (assoc package elm-package--cache))) 0)) + +(defun elm-package-definitions (package module-name) + "Get all of PACKAGE's MODULE-NAME's definitions." + (let-alist (elm-package--select-module package module-name) + (let* ((extract (lambda (x) + (let ((name (cdr (assq 'name x)))) + (cons name nil)))) + (aliases (mapcar extract .aliases)) + (types (mapcar extract .types)) + (values (mapcar extract .values))) + (append aliases types values)))) + +(defun elm-package-definition (package module-name definition-name) + "Get documentation from PACKAGE's MODULE-NAME for DEFINITION-NAME." + (let-alist (elm-package--select-module package module-name) + (elt (cl-remove-if-not + (lambda (x) + (equal definition-name (cdr (assq 'name x)))) + (vconcat .aliases .types .values)) + 0))) + +(defun elm-package-refresh () + "Refresh the package catalog's contents." + (interactive) + (with-current-buffer elm-package-buffer-name + (elm-package--read-dependencies) + (tabulated-list-print :remember-pos))) + +(defun elm-package-prev (&optional n) + "Goto (Nth) previous package." + (interactive "p") + (elm-package-next (- n)) + (forward-line 0) + (forward-button 1)) + +(defun elm-package-next (&optional n) + "Goto (Nth) next package." + (interactive "p") + (dotimes (_ (abs n)) + (let ((d (cl-signum n))) + (forward-line (if (> n 0) 1 0)) + (when (eobp) + (forward-line -1)) + (forward-button d)))) + +(defun elm-package-mark () + "Mark the package at point." + (interactive) + (let ((id (tabulated-list-get-id))) + (when id + (setq elm-package--marked-contents (cons id elm-package--marked-contents)) + (elm-package-next 1) + (elm-package-refresh)))) + +(defun elm-package-unmark () + "Unmark the package at point." + (interactive) + (let ((id (tabulated-list-get-id))) + (when id + (setq elm-package--marked-contents + (-reject (lambda (x) (= id x)) + elm-package--marked-contents)) + (elm-package-next 1) + (elm-package-refresh)))) + +(defun elm-package-view () + "View the package at point in a browser." + (interactive) + (let ((id (tabulated-list-get-id))) + (when id + (let-alist (nth id elm-package--contents) + (browse-url (elm-package--build-uri "packages" .name (elt .versions 0))))))) + +(defun elm-package--install-sentinel (_proc _msg) + "Refreshes the package buffer on _PROC exit, ignoring _MSG." + (elm-package-refresh)) + +(defun elm-package-install () + "Install the marked packages." + (interactive) + (unless elm-package--marked-contents + (error "Nothing to install")) + (let* ((and (elm--shell-and-command)) + (command-to-run (s-join and (elm-package--get-marked-install-commands)))) + (when (yes-or-no-p (concat "Install " (s-join ", " (elm-package--get-marked-packages)) " ?")) + (let* ((default-directory elm-package--working-dir) + (compilation-buffer-name-function (lambda (_) elm-package-compile-buffer-name)) + (compilation-buffer (compile command-to-run))) + (setq elm-package--marked-contents nil) + (set-process-sentinel (get-buffer-process compilation-buffer) + #'elm-package--install-sentinel))))) + +;;;###autoload +(defun elm-package-catalog (refresh) + "Show the package catalog, refreshing the list if REFRESH is truthy." + (interactive "P") + (elm--assert-dependency-file) + (when (or refresh (not elm-package--contents)) + (elm-package-refresh-contents)) + (let ((buffer (get-buffer-create elm-package-buffer-name))) + (pop-to-buffer buffer) + (elm-package--read-dependencies) + (elm-package-mode))) + +;;;###autoload +(defun elm-package-refresh-contents () + "Refresh the package list." + (interactive) + (elm--assert-dependency-file) + (let* ((all-packages (elm-package--build-uri "all-packages"))) + (with-current-buffer (url-retrieve-synchronously all-packages) + (goto-char (point-min)) + (re-search-forward "^ *$") + (setq elm-package--marked-contents nil) + (setq elm-package--contents (append (json-read) nil))))) + +;;;###autoload +(defun elm-import (refresh) + "Import a module, refreshing if REFRESH is truthy." + (interactive "P") + (elm--assert-dependency-file) + (when (or refresh (not elm-package--contents)) + (elm-package-refresh-contents)) + (elm-package--read-dependencies) + (let* ((package (elm-package--read-package)) + (module (elm-package--read-module package)) + (statement (concat "import " module)) + (statement (read-string "Import statement: " statement))) + (save-excursion + (goto-char (point-min)) + (if (re-search-forward "^import " nil t) + (beginning-of-line) + (forward-line 1) + (insert "\n")) + (insert (concat statement "\n")))) + (elm-sort-imports)) + + +(defun elm-imports--list (buffer) + "Find all imports in the current BUFFER. +Return an alist of (FULL_NAME . ('as AS 'exposing EXPOSING), where +EXPOSING" + (with-current-buffer buffer + (save-excursion + (save-match-data + (let ((matches ())) + (goto-char (point-min)) + (while (re-search-forward elm-import--pattern nil t) + (let ((full (substring-no-properties (match-string 1))) + (as (match-string 2)) + (exposing (match-string 3))) + (push (list full + (cons 'as (if as (substring-no-properties as) full)) + (cons 'exposing exposing)) + matches))) + matches))))) + +(defun elm-imports--aliased (imports-list name full-name) + "Given IMPORTS-LIST, return the local name for function with NAME and FULL-NAME." + (let* ((suffix (concat "." name)) + (module-name (s-chop-suffix suffix full-name)) + (imports-entry (cl-assoc module-name imports-list :test 'string-equal))) + (let-alist imports-entry + (if (or (string-equal "Basics" module-name) + (when .exposing + (or (string-equal .exposing "..") + (cl-find name (s-split " *, *" .exposing) :test 'string-equal)))) + name + (concat (or .as module-name) suffix))))) + + +(defun elm-documentation--show (documentation) + "Show DOCUMENTATION in a help buffer." + (let-alist documentation + (help-setup-xref (list #'elm-documentation--show documentation) nil) + (save-excursion + (with-help-window (help-buffer) + (with-current-buffer (help-buffer) + (point-min) + (insert (propertize .name 'face 'font-lock-function-name-face)) + (when .args + (insert (concat " " (s-join " " .args)))) + (when .cases + (let ((first t)) + (mapc + (lambda (case) + (if first + (insert "\n = ") + (insert "\n | ")) + (insert (propertize (elt case 0) 'face 'font-lock-function-name-face)) + (insert (concat " " (s-join " " (elt case 1)))) + (setq first nil)) + .cases))) + (when .type + (insert " : ") + (insert (propertize .type 'face 'font-lock-type-face))) + (insert (concat "\n\n" (s-trim-left .comment))))))) ) + +;;;###autoload +(defun elm-documentation-lookup (refresh) + "Lookup the documentation for a function, refreshing if REFRESH is truthy." + (interactive "P") + (elm--assert-dependency-file) + (when (or refresh (not elm-package--contents)) + (elm-package-refresh-contents)) + (elm-package--read-dependencies) + (let* ((package (elm-package--read-package)) + (module (elm-package--read-module package)) + (definition (elm-package--read-module-definition package module)) + (documentation (elm-package-definition package module definition))) + (elm-documentation--show documentation))) + +;;;###autoload +(define-derived-mode elm-package-mode tabulated-list-mode "Elm Package" + "Special mode for elm-package. + +\\{elm-package-mode-map}" + + (buffer-disable-undo) + + (setq truncate-lines t + + tabulated-list-format elm-package-catalog-format + tabulated-list-entries #'elm-package--entries) + + (tabulated-list-init-header) + (tabulated-list-print)) + + +(autoload 'popup-make-item "popup") + +(defun elm-oracle--completion-prefix-at-point () + "Return the completions prefix found at point." + (save-excursion + (let* ((_ (re-search-backward elm-oracle--pattern nil t)) + (beg (1+ (match-beginning 0))) + (end (match-end 0))) + (s-trim (buffer-substring-no-properties beg end))))) + +(defun elm-oracle--get-completions (prefix &optional popup) + "Get elm-oracle completions for PREFIX with optional POPUP formatting." + (mapcar (if popup + (lambda (candidate) + (let-alist candidate + (popup-make-item .localName + :document (concat .signature "\n\n" .comment) + :summary .signature))) + (apply-partially 'alist-get 'localName)) + (elm-oracle--get-candidates prefix))) + +(defun elm-oracle--function-at-point () + "Get the name of the function at point." + (save-excursion + (skip-chars-forward "[A-Za-z0-9_.']") + (let* ((_ (re-search-backward elm-oracle--pattern nil t)) + (beg (1+ (match-beginning 0))) + (end (match-end 0)) + (item (s-trim (buffer-substring-no-properties beg end)))) + (if (string-empty-p item) + nil + item)))) + +(defun elm-oracle--item-at-point () + "Get the Oracle completion object at point." + (let ((prefix (elm-oracle--function-at-point))) + (when prefix + (cl-find-if + (lambda (candidate) + (let-alist candidate + (string= prefix .localName))) + (elm-oracle--get-catalogue))))) + +(defun elm-oracle--propertize-completion-type (completion) + "Propertize COMPLETION so that it can be displayed in the minibuffer." + (when completion + (let-alist completion + (concat (propertize .localName 'face 'font-lock-function-name-face) ": " .signature)))) + +(defun elm-oracle--type-at-point () + "Get the type of the function at point." + (elm-oracle--propertize-completion-type (elm-oracle--item-at-point))) + +;;;###autoload +(defun elm-oracle-type-at-point () + "Print the type of the function at point to the minibuffer." + (interactive) + (message (or (elm-oracle--type-at-point) "Unknown type"))) + +;;;###autoload +(defun elm-eldoc () + "Get the type of the function at point for eldoc." + (elm-oracle--type-at-point)) + +;;;###autoload +(defun elm-oracle-doc-at-point () + "Show the documentation of the value at point." + (interactive) + (let ((completion (elm-oracle--item-at-point))) + (if completion + (elm-documentation--show completion) + (message "Unknown symbol")))) + +;;;###autoload +(defun elm-oracle-completion-at-point-function () + "Completion at point function for elm-oracle." + (save-excursion + (let* ((_ (re-search-backward elm-oracle--pattern nil t)) + (beg (1+ (match-beginning 0))) + (end (match-end 0)) + (prefix (s-trim (buffer-substring-no-properties beg end))) + (completions (elm-oracle--get-completions prefix))) + (list beg end completions :exclusive 'no)))) + +;;;###autoload +(defun elm-oracle-setup-completion () + "Set up standard completion. +Add this function to your `elm-mode-hook' to enable an +elm-specific `completion-at-point' function." + (add-to-list (make-local-variable 'completion-at-point-functions) + #'elm-oracle-completion-at-point-function)) + +(defvar ac-sources) +(defvar ac-source-elm + `((candidates . (elm-oracle--get-completions ac-prefix t)) + (prefix . ,elm-oracle--pattern))) + +;;;###autoload +(defun elm-oracle-setup-ac () + "Set up auto-complete support. +Add this function to your `elm-mode-hook'." + (add-to-list 'ac-sources 'ac-source-elm)) + + +(declare-function company-begin-backend "company") +(declare-function company-doc-buffer "company") + +;;;###autoload +(defun company-elm (command &optional arg &rest ignored) + "Provide completion info according to COMMAND and ARG. IGNORED is not used." + (interactive (list 'interactive)) + (when (derived-mode-p 'elm-mode) + (cl-case command + (interactive (company-begin-backend 'company-elm)) + (sorted t) + (prefix (elm-oracle--completion-prefix-at-point)) + (doc-buffer (elm-company--docbuffer arg)) + (candidates (cons :async (apply-partially #'elm-company--candidates arg))) + (annotation (elm-company--signature arg)) + (meta (elm-company--meta arg))))) + +(defun elm-company--candidates (prefix &optional callback) + "Function providing candidates for company-mode for given PREFIX. +Passes completions to CALLBACK if present, otherwise returns them." + (funcall (if callback callback #'identity) + (mapcar #'elm-company--make-candidate (elm-oracle--get-candidates prefix)))) + +(defun elm-company--make-candidate (candidate) + "Create a ‘company-mode’ completion candidate from a CANDIDATE obtained via elm-oracle." + (let-alist candidate + (propertize .localName + 'signature .signature 'name .fullName 'comment .comment))) + +(defun elm-company--signature (candidate) + "Return company signature for CANDIDATE." + (format " %s" (get-text-property 0 'signature candidate))) + +(defun elm-company--meta (candidate) + "Return company meta for CANDIDATE." + (format "%s : %s" + (get-text-property 0 'name candidate) + (get-text-property 0 'signature candidate))) + +(defun elm-company--docbuffer (candidate) + "Return the documentation for CANDIDATE." + (company-doc-buffer + (format "%s : %s\n\n%s" + (get-text-property 0 'name candidate) + (get-text-property 0 'signature candidate) + (get-text-property 0 'comment candidate)))) + + +(defvar-local elm-oracle--cache nil + "This is a cons pair of (IMPORTS-LIST . CANDIDATES). +IMPORTS-LIST is the result of `elm-imports--list' at the time +`elm-oracle' was run, and CANDIDATES is the set of results.") + +(defun elm-oracle--get-candidates (prefix) + "Return elm-oracle completion candidates for given PREFIX." + (cl-sort + (cl-remove-if-not + (lambda (candidate) + (let-alist candidate + (or (string-prefix-p prefix .localName) + (string-prefix-p prefix .name)))) + (elm-oracle--get-catalogue)) + (lambda (c1 c2) + ;; Sort better matches first + (let ((n1 (alist-get 'localName c1)) + (n2 (alist-get 'localName c2))) + (> (s-index-of prefix n2) (s-index-of prefix n1)))))) + +(defun elm-oracle--get-catalogue () + "Return the full elm-oracle catalogue for the current file." + (let* + ((file (or (buffer-file-name) (elm--find-main-file))) + (imports-list (elm-imports--list (current-buffer)))) + (append + (elm-oracle--module-completions imports-list) + (if (and imports-list (equal imports-list (car elm-oracle--cache))) + (cdr elm-oracle--cache) + (setq elm-oracle--cache + (cons imports-list (elm-oracle--catalogue-with-local-names file imports-list))))))) + +;; These should arguably be in a separate completion backend, since +;; they could theoretically be used without elm-oracle +(defun elm-oracle--module-completions (imports-list) + "Return completions for modules in IMPORTS-LIST. +Completions are in the same format as those returned by + `elm-oracle--catalogue-with-local-names'." + (mapcar + (lambda (import) + (let ((full-name (car import))) + (list (cons 'localName (alist-get 'as (cdr import))) + (cons 'name "") + (cons 'fullName full-name) + (cons 'signature "")))) + imports-list)) + + +(defun elm-oracle--catalogue-with-local-names (file imports-list) + "Given FILE and IMPORTS-LIST, get an alias-adjusted catalogue of all symbols known to elm-oracle." + (mapcar + #'(lambda (candidate) + (let-alist candidate + (cons (cons 'localName + (concat (elm-imports--aliased imports-list .name .fullName))) + candidate))) + (elm-oracle--run "" file))) + +(defun elm-oracle--run (prefix &optional file) + "Get completions for PREFIX inside FILE." + (when (executable-find elm-oracle-command) + (let ((default-directory (elm--find-dependency-file-path)) + (command (s-join " " (list elm-oracle-command + (shell-quote-argument file) + (shell-quote-argument prefix)))) + (json-array-type 'list)) + (seq-uniq + (json-read-from-string (shell-command-to-string command)) + (lambda (i1 i2) + (string-equal (alist-get 'fullName i1) (alist-get 'fullName i2))))))) + +;;;###autoload +(defun elm-test-project () + "Run the elm-test command on the current project." + (interactive) + (let ((default-directory (elm--find-elm-test-root-directory)) + (compilation-buffer-name-function (lambda (_) "*elm-test*"))) + (compile "elm-test"))) + + +(provide 'elm-interactive) +;;; elm-interactive.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-interactive.elc b/elpa/elm-mode-20191125.1919/elm-interactive.elc new file mode 100644 index 0000000000000000000000000000000000000000..03e2c5648f396a0e7e2f14c6d617b724fb9bedbb GIT binary patch literal 44665 zcmeHw3wImWb*@B7G(|7Fc5|nBBu13nw4!W-Bq+iL z0U8g=u?Z^CP`}3{8xpe8$;%|QQ z8?)6vJ?nJaNAgRjXSPpUhePwcJs5WSJrg(95;^mtGdeM?ZrAkBMxE2nA6g@v9!#Q51)Fl; zE3HBM*c48hl_)SP-FEL8W>7e@y1HsU*>pD#M}to9SOf61o?y~k^fKk=H zes6fgyl4$EV_iRUjKjKkal(OjTbOOlEWf+DDyxLWp7P(~;^NA|%TYTx>>ssFZ9fS^ z{E3$KkgSKh)h8@hZi{-((VXxitnZs_-?Hrh+))1T2Jq?aQNI|!M_^tdl9(B6r z*nBetNp{<#pw;aRM`rN78Jc1HJ2M;~41({?sC6*rsvqG|I6WS8pPG1earx6mWbT6! zdw9s8eKu$h+r81yj859-7&M6=S|igkX9H~I$edtP58CaX8J_h=c-Y#n7gvtj$In}! zMGOpsZj+Kb&)Y#T#C3tak56A&e%Gv-X1#$uUpZ}k+YWGBr*+V62M6QhRJIo6c}jtEJnmt`Kz#U@BF`*82`!5%X|Kq_ zni>eJTU&itKZ=C);j3`vCt@^YUpTZ3ogQ=#$lXhASK z#4S6&Zl?#f%&y1#&sswn2ib$8Eli?T9>!C%P7X`zW>?vVV({z1xEGWLbz=q}fug{9 znDMjr_h+W|<&(evH>{%Nrl=9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yriXqlg){MD3~7o)dlzF^ PQRtwpcA*C}tS. + +;;; Commentary: + +;; Provides a major mode for editing Elm source code, and working with +;; common core and third-party Elm tools including the compiler, repl, +;; elm-format and more. + +;;; Code: +(require 'elm-tags) +(require 'elm-format) +(require 'elm-imenu) +(require 'elm-indent) +(require 'elm-interactive) +(require 'elm-font-lock) + +(defgroup elm nil + "Support for the elm programming language." + :link '(url-link :tag "Github" "https://github.com/jcollard/elm-mode") + :group 'languages) + +(defun elm-beginning-of-defun (&optional arg) + "Move backward to the beginning of an ELM \"defun\". +With ARG, do it that many times. Negative arg -N means move +forward to Nth following beginning of defun. Returns t unless +search stops due to beginning or end of buffer. + +Find the roots of this function in the c-awk-mode." + (interactive "p") + (or arg (setq arg 1)) + (save-match-data + (let ((found t) ; Has the most recent regexp search found b-of-defun? + (regexp "^[^- \t\n\r]")) + (if (>= arg 0) + ;; Go back one defun each time round the following loop. (For +ve arg) + (while (and found (< 0 arg) (not (eq (point) (point-min)))) + ;; Go back one "candidate" each time round the next loop until one + ;; is genuinely a beginning-of-defun. + + (setq found (search-backward-regexp + regexp (point-min) 'stop-at-limit)) + (when found + (while (and (forward-line -1) + (looking-at regexp) + (not (= (point-min) (point))))) + (forward-line)) + (setq arg (1- arg))) + ;; The same for a -ve arg. + (if (not (eq (point) (point-max))) (forward-char 1)) + (while (and found (< arg 0) (not (eq (point) (point-max)))) ; The same for -ve arg. + (setq found (search-forward-regexp + regexp (point-min) 'stop-at-limit)) + (setq arg (1+ arg)))) + (eq arg 0)))) + +(defun elm-end-of-defun (&optional arg) + "Move forward to the end of an ELM \"defun\". +With ARG, do it that many times. Negative arg -N means move +forward to Nth previous end of defun. Returns t unless +search stops due to beginning or end of buffer. + +Find the roots of this function in the c-awk-mode." + (interactive "p") + (or arg (setq arg 1)) + (save-match-data + (let ((found t) ; Has the most recent regexp search found b-of-defun? + (regexp "^\n\n")) + (if (>= arg 0) + ;; Go back one defun each time round the following loop. (For +ve arg) + (while (and found (< 0 arg) (not (eq (point) (point-max)))) + ;; Go back one "candidate" each time round the next loop until one + ;; is genuinely a beginning-of-defun. + (setq found (search-forward-regexp + regexp + (point-max) 'stop-at-limit)) + (setq arg (1- arg))) + ;; The same for a -ve arg. + (if (not (eq (point) (point-min))) (forward-char 1)) + (while (and found (< arg 0) (not (eq (point) (point-min)))) ; The same for -ve arg. + (setq found (search-backward-regexp + regexp (point-min) 'stop-at-limit)) + (setq arg (1+ arg))) + (if found (goto-char (match-beginning 0)))) + (eq arg 0)))) + + +(defun elm-mode-after-save-handler () + "Perform various operations upon saving a buffer." + (when elm-sort-imports-on-save + (elm-sort-imports)) + (when elm-tags-on-save + (elm-mode-generate-tags)) + (when (or elm-sort-imports-on-save + elm-tags-on-save) + (let ((before-save-hook '()) + (after-save-hook '())) + (basic-save-buffer)))) + +(defvar elm-mode-map + (let ((map (make-keymap))) + (define-key map (kbd "C-c C-f") 'elm-mode-format-buffer) + (define-key map (kbd "C-c M-t") 'elm-mode-generate-tags) + (define-key map (kbd "M-.") 'elm-mode-goto-tag-at-point) + (define-key map (kbd "M-,") 'pop-tag-mark) + (define-key map (kbd "C-c C-l") 'elm-repl-load) + (define-key map (kbd "C-c C-p") 'elm-repl-push) + (define-key map (kbd "C-c C-e") 'elm-repl-push-decl) + (define-key map (kbd "C-c C-z") 'run-elm-interactive) + (define-key map (kbd "C-c C-a") 'elm-compile-add-annotations) + (define-key map (kbd "C-c C-r") 'elm-compile-clean-imports) + (define-key map (kbd "C-c C-c") 'elm-compile-buffer) + (define-key map (kbd "C-c M-c") 'elm-compile-main) + (define-key map (kbd "C-c M-k") 'elm-package-catalog) + (define-key map (kbd "C-c C-n") 'elm-preview-buffer) + (define-key map (kbd "C-c C-m") 'elm-preview-main) + (define-key map (kbd "C-c C-d") 'elm-documentation-lookup) + (define-key map (kbd "C-c C-i") 'elm-import) + (define-key map (kbd "C-c C-s") 'elm-sort-imports) + (define-key map (kbd "C-c C-t") 'elm-oracle-type-at-point) + (define-key map (kbd "C-c M-d") 'elm-oracle-doc-at-point) + (define-key map (kbd "C-c C-v") 'elm-test-project) + map) + "Keymap for Elm major mode.") + +;;;###autoload +(define-derived-mode elm-mode prog-mode "Elm" + "Major mode for editing Elm source code." + (setq-local indent-tabs-mode nil) + + ;; Elm is not generally suitable for electric indentation, since + ;; there is no unambiguously correct indent level for any given + ;; line. + (when (boundp 'electric-indent-inhibit) + (setq-local electric-indent-inhibit t)) + + (setq-local comment-start "--") + (setq-local comment-end "") + (setq-local imenu-create-index-function #'elm-imenu-create-index) + (setq-local paragraph-separate "\\(\r\t\n\\|-}\\)$") + (setq-local beginning-of-defun-function #'elm-beginning-of-defun) + (setq-local end-of-defun-function #'elm-end-of-defun) + + (add-function :before-until (local 'eldoc-documentation-function) #'elm-eldoc) + + (when elm-format-on-save + (elm-format-on-save-mode)) + (add-hook 'after-save-hook #'elm-mode-after-save-handler nil t) + + (turn-on-elm-font-lock)) + +;; We enable intelligent indenting, but users can remove this from the +;; hook if they prefer. +(add-hook 'elm-mode-hook 'elm-indent-mode) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.elm\\'" . elm-mode)) + +(provide 'elm-mode) +;;; elm-mode.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-mode.elc b/elpa/elm-mode-20191125.1919/elm-mode.elc new file mode 100644 index 0000000000000000000000000000000000000000..14bd6f9d02b4798a72d3214e0143d978e84c6e69 GIT binary patch literal 6789 zcmd5>`)}OF5muo#QO>ZC#;uw<4KktJNLQHh@o{&G+yF@oH#M3Vft@-iOc~ze?cFir zt9-~&+x+kSW|q7oCHaRSEf51dk+Zws%<#0&g_J<9ryn4!`i@c0auChu{4ecRwcW$29O5$Z_zvcsx8lo-v-uM{fr1Xll{( zLjSXl3Qamr>`E~Rr2HZt-ZWbA%fm0fB5SS}b!r_AzGY+h?8z5*q2d%(tWgyu zD!m}shAxkY9_uA61h}eLlKq$xtV(u(Rd z)@3;;p~m5gaJV@vt=24XXJtVe)&QAj^EFD6xRk5hk@~E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7w&;i#{c+3pUz@0lP=;YCc$aEq6YH;*_1vN5YMbFV4REe4WQDOz9$bG4 ze*@PIg2wW?`g)C^r!;9&XaCr9hMXg#=)RPk$!+lQwa(g9(V&R;mDsS(%cQB<yGY844*%G1^z7L_CM_3R92NpVq?S_Z!Kh7g8ZYk(r4hR1Q DQ==GB literal 0 HcmV?d00001 diff --git a/elpa/elm-mode-20191125.1919/elm-tags.el b/elpa/elm-mode-20191125.1919/elm-tags.el new file mode 100644 index 00000000..053b0846 --- /dev/null +++ b/elpa/elm-mode-20191125.1919/elm-tags.el @@ -0,0 +1,71 @@ +;;; elm-tags.el --- etags support for Elm. + +;; Copyright (C) 2016 Bogdan Popa + +;; Author: Bogdan Popa +;; URL: https://github.com/jcollard/elm-mode + +;; 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 program. If not, see . + +;;; Commentary: +;;; Code: +(require 'elm-util) +(require 'f) + +(defcustom elm-tags-on-save nil + "Controls whether or not TAGS files should be generated on save." + :group 'elm-tags + :type 'boolean) + +(defcustom elm-tags-exclude-elm-stuff t + "Controls whether or not sources in the `elm-stuff' directory should be excluded from the TAGS file." + :group 'elm-tags + :type 'boolean) + +(defconst elm-tags-regexps + (f-join + (f-dirname load-file-name) + "elm.tags")) + +;;;###autoload +(defun elm-mode-goto-tag-at-point () + "Go to tag at point." + (interactive) + (let ((tag (find-tag-default))) + (unless tag + (user-error "No tag candidate found around point")) + (find-tag tag))) + +;;;###autoload +(defun elm-mode-generate-tags () + "Generate a TAGS file for the current project." + (interactive) + (when (elm--has-dependency-file) + (let* ((default-directory (elm--find-dependency-file-path)) + (find-command "find . -type f -name \"*.elm\" -print") + (exclude-command (if elm-tags-exclude-elm-stuff + (concat find-command " | egrep -v elm-stuff") + find-command)) + (etags-command (concat + exclude-command + " | etags --language=none --regex=@" + (shell-quote-argument elm-tags-regexps) + " -"))) + (call-process-shell-command (concat etags-command "&") nil 0)))) + + +(provide 'elm-tags) +;;; elm-tags.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-tags.elc b/elpa/elm-mode-20191125.1919/elm-tags.elc new file mode 100644 index 0000000000000000000000000000000000000000..3b0eef54704372fe60b9ef73be99c4e9a077bf1d GIT binary patch literal 1689 zcmbtU-*41L5WY9)Refs(RaJH3ppdJwmVaClLWBg0P=tgkRCwbeb>kiTjBKyjT_0S< zAJ4ZNpG%2&!n*Z&cV}n5neUrDfBy2~-fT9TpP!%8g>L)0VHGBIN6%YXSlY0$weBc8 ziSw}Yp>}JMO+&hObzA={9ky*e51Vh+wWShXXs~QaZ9Cc41u0!vXX>u9N7yyikyMHm zO;OUbI6J%LLuvTvw4*|IPQrL_rFevuPCR>k@!|y)YiVTR0P!e#bu^XvGw*@+84X_f}czKm5pclN^&J z#xceT#_1~eMrn$X9o!j@z$*0vmZ`VAWtE&p^w#kEp*Bq1v|?~|LnRf1b-ERbi$)q2 z8)<5J4PL#8la&=9!O9I&2lMCx1R32}`mkoVMrpMP#JzcT`8w#ql3nYeQJ$BIJ2ujR zf9T5lh$DJj89nrqcY5r$J=3+;4TGa8D1R)PL9y@))(vGz?%Tnw9!voRK{&uf|4fG- zl0vqH(`NextkJik(&#pvn9#@36+K$a4;7b?BIG*(GF;0}KwY&3a57Ie7(fMPn!lZDsGl}~DUN|&PmNYYed zxbh9j5S}sIAz7o}funDwJGuy3{36v8q?#Nb_$*K9K184Vy6Ui$|2+Evv-B0dvtRIy zg8YUBlmh)xf~j=*_wRTg|Ag1cE4. + +;;; Commentary: +;;; Code: +(require 'f) +(require 'json) +(require 'let-alist) +(require 's) + +(require 'haskell-decl-scan nil 'noerror) +(require 'inf-haskell nil 'noerror) + +(defcustom elm-main-file "Main.elm" + "Allows for a custom main file to be specified." + :type 'string + :group 'elm-util) + +(defcustom elm-flash-duration 0.40 + "Time in seconds for which declarations will be highlighted when applicable." + :type 'number + :group 'elm-util) + +(defcustom elm-package-json + "elm-package.json" + "The name of the package JSON configuration file. +Set to \"elm.json\" for use with Elm 0.19." + :type 'string + :group 'elm-util) + +(defun elm--get-module-name () + "Return the qualified name of the module in the current buffer." + (save-excursion + (goto-char (point-min)) + (unless (re-search-forward "module +\\([A-Z][A-Za-z0-9.]*\\)" nil t) + (error "Module declaration not found")) + (buffer-substring-no-properties (match-beginning 1) (match-end 1)))) + +(defun elm--get-decl () + "Return the current declaration. + +Relies on `haskell-mode' stuff." + (unless (fboundp #'haskell-ds-backward-decl) + (error "This functionality requires haskell-mode")) + + (save-excursion + (goto-char (1+ (point))) + (let* ((start (or (haskell-ds-backward-decl) (point-min))) + (end (or (haskell-ds-forward-decl) (point-max))) + (raw-decl (s-trim-right (buffer-substring start end))) + (lines (split-string raw-decl "\n")) + (first-line (car lines)) + ;; Shadow the defcustom pulse-delay variable. + (pulse-delay (/ elm-flash-duration 10.0))) + + (pulse-momentary-highlight-region start end) + (if (string-match-p "^[a-z].*:" first-line) + (cdr lines) + lines)))) + +(defun elm--build-import-statement () + "Generate a statement that will import the current module." + (concat "import " (elm--get-module-name) " exposing (..) \n")) + +(defun elm--get-buffer-dirname () + "Return the absolute dirname of the current buffer." + (file-name-as-directory default-directory)) + +(defun elm--buffer-local-file-name () + "Return the current file name relative to the dependency file." + (let ((dirname (buffer-file-name)) + (deppath (elm--find-dependency-file-path))) + (f-relative dirname deppath))) + +(defun elm--find-elm-test-root-directory () + "Find the directory from which to run \"elm-test\". +This is determined by looking for the closest parent directory +which is not called \"tests\" and which contains a file named as +per the `elm-package-json' variable." + (or (locate-dominating-file + default-directory + (lambda (dir) + (and (not (s-suffix-p "/tests/" dir)) + (file-exists-p (expand-file-name elm-package-json dir))))) + (error "No %s found in non-test parent directories" elm-package-json))) + +(defun elm--find-dependency-file-path () + "Recursively search for a directory containing a package JSON file." + (or (locate-dominating-file default-directory elm-package-json) + (file-name-as-directory (f-dirname (buffer-file-name))))) + +(defun elm--has-dependency-file () + "Check if a dependency file exists." + (f-exists? (f-join (elm--find-dependency-file-path) elm-package-json))) + +(declare-function elm-create-package "elm-interactive.el" nil) +(defun elm--assert-dependency-file () + "Report an error unless there is a package file." + (unless (elm--has-dependency-file) + (if (yes-or-no-p "Elm package file not found. Create a new package?") + (call-interactively #'elm-create-package) + (error "Elm package file not found")))) + +(defun elm--read-dependency-file () + "Find and read the JSON dependency file into an object." + (elm--assert-dependency-file) + (let ((dep-file (f-join (elm--find-dependency-file-path) elm-package-json))) + (json-read-file dep-file))) + +(defun elm--find-main-file () + "Find the main elm file." + (let-alist (elm--read-dependency-file) + (let ((source-dir (aref .source-directories 0))) + (if (equal "." source-dir) + elm-main-file + (f-join source-dir elm-main-file))))) + +(defun elm--shell-and-command () + "Determine the appropriate 'and' command for the current shell. + +Currently only special cases the Fish shell, returning '; and ' when +Fish is used as the default system shell. Returns ' && ' in all other +cases." + ;; TODO: Windows? + (let* ((shell (getenv "SHELL")) + (executable (car (reverse (s-split "/" shell))))) + (pcase executable + ("fish" "; and ") + (_ " && ")))) + + +(provide 'elm-util) +;;; elm-util.el ends here diff --git a/elpa/elm-mode-20191125.1919/elm-util.elc b/elpa/elm-mode-20191125.1919/elm-util.elc new file mode 100644 index 0000000000000000000000000000000000000000..11484916a3cd2891e292f32a41b4eabb144a5c6f GIT binary patch literal 4931 zcmbtYZExGw6*iC$b7XWFuyyUaqC2Ly*iJ*1A|*MBF(iiPuHDiOYw~HPhfw6D#e^bN zUeb=bKfmXkONz8D2L)ZEX#XkB{lJSS-^_#quT1>1+{3 znyyr-(;_Et;`s9BI<4juW*HUBDqW;Mg%w_FXCNx23KqjAIqk`jp|+@uqiV#06yJMMY7OS0NVHRboHIliWUeb^7hM6wSjjj4G)3 zM2-*hm~=r=nA1#AR)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&`dwfA&qp3HXjv5a8eN9`9r0j^QC8AiRSBjG?`#e@l zpj+jUIb@^LIZN7E5rvu5ubVj$zGjE}^eKqxjvj6Y*5kDu%Vmg^-P+oi&dL}Wl5CSS zXHv9km?LCg0(=^6yO?TMN{aEpiA;48wfS46%5-XG|sT1os42)dtm);M(CiYt_T3f^|o_XIig&K%o zJ3gjR50HID{u|b)Up)7zZ51{IKpfQCV3$SFM@EMqZ=1uw`Ocl}tV@w3z!u>I%8Mcl`% zzL6CuStpmA^=tfYy3 z@Ekh7Ef7~;0s!2T5W1elANfZnvZE;?D-{H7xv8pko++)FXlUob)h?FzgfY|_ZP5qJ zaY^9*TaKWZ#kRE|+ZD5VT@UBbX{k)z z%++}uOnft_pj1#UOEET|Z<6X!75utN+$J+s_)(Lm0Y~th_zC-iM zBZ2QRl77FngMZ#}$Fu(kqST(nxTq>4GrP(W6KBKys0vhBzw> +;; Keywords: convenience, tools +;; Homepage: https://github.com/purcell/reformatter.el +;; Package-Requires: ((emacs "24.3")) +;; Package-Version: 20191103.357 +;; Package-X-Original-Version: 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 library lets elisp authors easily define an idiomatic command +;; to reformat the current buffer using a command-line program, +;; together with an optional minor mode which can apply this command +;; automatically on save. + +;; In its initial release it supports only reformatters which read +;; from stdin and write to stdout, but a more versatile interface will +;; be provided as development continues. + +;; As an example, let's define a reformat command that applies the +;; "dhall format" command. We'll assume here that we've already defined a +;; variable `dhall-command' which holds the string name or path of the +;; dhall executable: + +;; (reformatter-define dhall-format +;; :program dhall-command +;; :args '("format")) + +;; The `reformatter-define' macro expands to code which generates +;; `dhall-format-buffer' and `dhall-format-region' interactive +;; commands, and a local minor mode called +;; `dhall-format-on-save-mode'. The :args" and :program expressions +;; will be evaluated at runtime, so they can refer to variables that +;; may (later) have a buffer-local value. A custom variable will be +;; generated for the mode lighter, with the supplied value becoming +;; the default. + +;; The generated minor mode allows idiomatic per-directory or per-file +;; customisation, via the "modes" support baked into Emacs' file-local +;; and directory-local variables mechanisms. For example, users of +;; the above example might add the following to a project-specific +;; .dir-locals.el file: + +;; ((dhall-mode +;; (mode . dhall-format-on-save))) + +;; See the documentation for `reformatter-define', which provides a +;; number of options for customising the generated code. + +;; Library authors might like to provide autoloads for the generated +;; code, e.g.: + +;; ;;;###autoload (autoload 'dhall-format-buffer "current-file" nil t) +;; ;;;###autoload (autoload 'dhall-format-region "current-file" nil t) +;; ;;;###autoload (autoload 'dhall-format-on-save-mode "current-file" nil t) + +;;; Code: +(eval-when-compile + (require 'cl-lib)) +(require 'ansi-color) + +;;;###autoload +(cl-defmacro reformatter-define (name &key program args (mode t) lighter keymap group) + "Define a reformatter command with NAME. + +When called, the reformatter will use PROGRAM and any ARGS to +reformat the current buffer. The contents of the buffer will be +passed as standard input to the reformatter, which should output +them to standard output. A nonzero exit code will be reported as +failure, and the output of the command to standard error will be +displayed to the user. + +The macro accepts the following keyword arguments: + +:program (required) + + Provides a form which should evaluate to a string at runtime, + e.g. a literal string, or the name of a variable which holds + the program path. + +:args + + If provided, this is a form which evaluates to a list of + strings at runtime. Default is the empty list. + +:mode + + Unless nil, also generate a minor mode that will call the + reformatter command from `before-save-hook' when enabled. + Default is t. + +:group + + If provided, this is the custom group used for any generated + modes or custom variables. Don't forget to declare this group + using a `defgroup' form. + +:lighter + + If provided, this is a mode lighter string which will be used + for the \"-on-save\" minor mode. It should have a leading + space. The supplied value will be used as the default for a + generated custom variable which specifies the mode lighter. + Default is nil, ie. no lighter. + +:keymap + + If provided, this is the symbol name of the \"-on-save\" mode's + keymap, which you must declare yourself. Default is no keymap. +" + (declare (indent defun)) + (cl-assert (symbolp name)) + (cl-assert program) + ;; Note: we skip using `gensym' here because the macro arguments are only + ;; referred to once below, but this may have to change later. + (let* ((buffer-fn-name (intern (format "%s-buffer" name))) + (region-fn-name (intern (format "%s-region" name))) + (minor-mode-form + (when mode + (let ((on-save-mode-name (intern (format "%s-on-save-mode" name))) + (lighter-name (intern (format "%s-on-save-mode-lighter" name)))) + `(progn + (defcustom ,lighter-name ,lighter + ,(format "Mode lighter for `%s'." on-save-mode-name) + :group ,group + :type 'string) + (define-minor-mode ,on-save-mode-name + ,(format "When enabled, call `%s' when this buffer is saved. + +To enable this unconditionally in a major mode, add this mode +to the major mode's hook. To enable it in specific files or directories, +use the local variables \"mode\" mechanism, e.g. in \".dir-locals.el\" you +might use: + + ((some-major-mode + (mode . %s-on-save))) + " buffer-fn-name name) nil + :global nil + :lighter ,lighter-name + :keymap ,keymap + :group ,group + (if ,on-save-mode-name + (add-hook 'before-save-hook ',buffer-fn-name nil t) + (remove-hook 'before-save-hook ',buffer-fn-name t)))))))) + `(progn + (defun ,region-fn-name (beg end &optional display-errors) + "Reformats the region from BEG to END. +When called interactively, or with prefix argument +DISPLAY-ERRORS, shows a buffer if the formatting fails." + (interactive "rp") + (let* ((err-file (make-temp-file ,(symbol-name name))) + (out-file (make-temp-file ,(symbol-name name))) + ;; Setting this coding system might not universally be + ;; the best default, but was apparently necessary for + ;; some hand-rolled reformatter functions that this + ;; library was written to replace. + (coding-system-for-read 'utf-8) + (coding-system-for-write 'utf-8)) + (unwind-protect + (let* ((error-buffer (get-buffer-create ,(format "*%s errors*" name))) + (retcode + (apply 'call-process-region beg end ,program + nil (list (list :file out-file) err-file) + nil + ,args))) + (with-current-buffer error-buffer + (let ((inhibit-read-only t)) + (insert-file-contents err-file nil nil nil t) + (ansi-color-apply-on-region (point-min) (point-max))) + (special-mode)) + (if (zerop retcode) + (save-restriction + ;; This replacement method minimises + ;; disruption to marker positions and the + ;; undo list + (narrow-to-region beg end) + (reformatter-replace-buffer-contents-from-file out-file) + ;; In future this might be made optional, or a user-provided + ;; ":after" form could be inserted for execution + (delete-trailing-whitespace)) + (if display-errors + (display-buffer error-buffer) + (message ,(concat (symbol-name name) " failed: see %s") (buffer-name error-buffer))))) + (delete-file err-file) + (delete-file out-file)))) + + (defun ,buffer-fn-name (&optional display-errors) + "Reformats the current buffer. +When called interactively, or with prefix argument +DISPLAY-ERRORS, shows a buffer if the formatting fails." + (interactive "p") + (message "Formatting buffer") + (,region-fn-name (point-min) (point-max) display-errors)) + + ;; This alias will be removed in a future version + (defalias ',name ',buffer-fn-name) + + ,minor-mode-form))) + +(defun reformatter-replace-buffer-contents-from-file (file) + "Replace the accessible portion of the current buffer with the contents of FILE." + ;; While the function `replace-buffer-contents' exists in recent + ;; Emacs versions, it exhibits pathologically slow behaviour in many + ;; cases, and the simple replacement approach we use instead is well + ;; proven and typically preserves point and markers to a reasonable + ;; degree. + (insert-file-contents file nil nil nil t)) + + +(provide 'reformatter) +;;; reformatter.el ends here diff --git a/elpa/reformatter-20191103.357/reformatter.elc b/elpa/reformatter-20191103.357/reformatter.elc new file mode 100644 index 0000000000000000000000000000000000000000..e6897c526174a01ef757adbe052becce025bd34b GIT binary patch literal 5215 zcmc&&`;Xhk5x%&I5~~RMK-v^2(2nUkqFhmsL_Kn6z_9F-uZQ^J!`W#OSO&ZzR}yQI z%W%m%D}Q~z*(G(-#qI<7p~9WSea!5<=UYCQJ$v%y!NEcE!Gj0%L?u}i%g_v>lxB$t zG+oMEM=GVkxa*shtEgC$h+|S&5hc-&qQJ85HqGM8b);ztE>vo%DcqzYi2@2$po=_8 zSGt4MTo)w5P=>TUrGMBR9R7qysK6st1qCWC1U8q&()$`SsW*M`By%d(*f{X*xiG=c`mg{$_tR`P-CX`qM!BSxNOj}| zDpq;BdG}F&G#JydTt=xRLAhM2JP`#{hjEgG6*rFgc6v60KL1$D6lRFw&JNU+djwYz zya)f#`Ni{-i|H9LwMaKKy*PP6g=*H^4P{W~xl9X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