branch: elpa/haskell-tng-mode commit fd06b8fbd5dc39e92d8f91a764bad291e39063b0 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
move haskell-tng-newline into the -extra package --- haskell-tng-extra.el | 34 ++++++++++++++++++++++++++++++++++ haskell-tng-smie.el | 33 --------------------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/haskell-tng-extra.el b/haskell-tng-extra.el index 7834dff..912bf69 100644 --- a/haskell-tng-extra.el +++ b/haskell-tng-extra.el @@ -19,6 +19,40 @@ (require 'subr-x) +;;###autoload +(defun haskell-tng-newline (&optional alt) + "A `newline-and-indent' with a better user experience for `haskell-tng-mode'. + +When in a comment and called with a prefix, the comment will be completed." + (interactive "P") + ;; TODO a dynamically bound variable might improve the quality of + ;; 'empty-line-token predictions. Parens are special-cased. + (when (<= (- (point-max) 1) (point)) + ;; WORKAROUND https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36432 + ;; TODO fix the bug properly in SMIE + (save-excursion (insert "\n\n"))) + (let ((rem (save-excursion + (skip-syntax-forward " ") + (unless (looking-at (rx (syntax close-parenthesis))) + (when (/= (point) (line-end-position)) + (buffer-substring-no-properties (point) (line-end-position))))))) + (when rem + (delete-region (point) (line-end-position))) + ;; TODO don't continue line comments if there is code before them + ;; + ;; TODO in-comment indent should observer but not repeat | haddock markers + (cond + (alt + (call-interactively #'newline-and-indent)) + ((looking-back (rx (>= 3 "-")) (line-beginning-position)) + ;; don't continue or indent visual line breaks + (call-interactively #'newline)) + (t + (call-interactively #'comment-indent-new-line))) + (when rem + (save-excursion + (insert rem))))) + ;;;###autoload (defun haskell-tng-stylish-haskell () "Apply `stylish-haskell' rules." diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index 2348d07..df2badb 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -31,39 +31,6 @@ (require 'haskell-tng-font-lock) (require 'haskell-tng-lexer) -(defun haskell-tng-newline (&optional alt) - "A `newline-and-indent' with a better user experience for `haskell-tng-mode'. - -When in a comment and called with a prefix, the comment will be completed." - (interactive "P") - ;; TODO a dynamically bound variable might improve the quality of - ;; 'empty-line-token predictions. Parens are special-cased. - (when (<= (- (point-max) 1) (point)) - ;; WORKAROUND https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36432 - ;; TODO fix the bug properly in SMIE - (save-excursion (insert "\n\n"))) - (let ((rem (save-excursion - (skip-syntax-forward " ") - (unless (looking-at (rx (syntax close-parenthesis))) - (when (/= (point) (line-end-position)) - (buffer-substring-no-properties (point) (line-end-position))))))) - (when rem - (delete-region (point) (line-end-position))) - ;; TODO don't continue line comments if there is code before them - ;; - ;; TODO in-comment indent should observer but not repeat | haddock markers - (cond - (alt - (call-interactively #'newline-and-indent)) - ((looking-back (rx (>= 3 "-")) (line-beginning-position)) - ;; don't continue or indent visual line breaks - (call-interactively #'newline)) - (t - (call-interactively #'comment-indent-new-line))) - (when rem - (save-excursion - (insert rem))))) - ;; TODO autodetection of indent options (defcustom haskell-tng-aligntypes nil