Strange newline behaviour in Agda multiline comments
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
**What did you expect to happen?**
Take the following file, with normal state cursor represented by `█`.
```agda
{-
█
-}
```
Inserting a newline, via `o`, `O`, or `i`, works similarly to inserting a newline outside a comment block.
**What actually happened?**
- `o`: The file looks like the following.
```agda
{-
█
-}
```
Two lines have been added, and we are back in normal state. Error message: `Args out of range: "", 1, nil`.
- `O`: Similar result; same error message.
```agda
{-
█
-}
```
- `i`: Same error message, but we end in insert state. There's still an extra line.
```agda
{-
|
-}
```
**Additional details:**
- https://github.com/laMudri/doom.d
- `o` is `evil-open-below`. `O` is `evil-open-above`. `i` is `evil-insert`. `` is `newline-and-indent`.
- `Args out of range: "", 1, nil`
Just for `o`.
Debugger entered--Lisp error: (args-out-of-range "" 1 nil)
comment-normalize-vars()
comment-indent(nil)
comment-indent-new-line()
funcall(comment-indent-new-line)
(if comment-line-break-function (funcall comment-line-break-function) (comment-indent-new-line))
(cond ((sp-point-in-comment pos) (setq evil-auto-indent nil) (if comment-line-break-function (funcall comment-line-break-function) (comment-indent-new-line))) ((and (eq major-mode (quote haskell-mode)) (fboundp (quote haskell-indentation-newline-and-indent))) (setq evil-auto-indent nil) (haskell-indentation-newline-and-indent)) (t (insert (if use-hard-newlines hard-newline "\n")) (back-to-indentation)))
(if above (if (save-excursion (nth 4 (sp--syntax-ppss pos))) (let ((goal-column goal-column) (temporary-goal-column temporary-goal-column)) (setq evil-auto-indent nil) (goto-char pos) (let ((ws (abs (skip-chars-backward " \011")))) (save-excursion (if comment-line-break-function (funcall comment-line-break-function nil) (comment-indent-new-line)) (if (and (derived-mode-p ... ... ... ... ...) (eq ... 47)) (progn (insert "*"))) (insert (make-string (max 0 ...) 32))) (insert (make-string (max 1 ws) 32)))) (evil-move-beginning-of-line) (insert (if use-hard-newlines hard-newline "\n")) (forward-line -1) (back-to-indentation)) (evil-move-end-of-line) (cond ((sp-point-in-comment pos) (setq evil-auto-indent nil) (if comment-line-break-function (funcall comment-line-break-function) (comment-indent-new-line))) ((and (eq major-mode (quote haskell-mode)) (fboundp (quote haskell-indentation-newline-and-indent))) (setq evil-auto-indent nil) (haskell-indentation-newline-and-indent)) (t (insert (if use-hard-newlines hard-newline "\n")) (back-to-indentation))))
(let ((evil-restriction-stack (cons (cons (point-min) (point-max)) evil-restriction-stack))) (evil-narrow (field-beginning) (field-end)) (if above (if (save-excursion (nth 4 (sp--syntax-ppss pos))) (let ((goal-column goal-column) (temporary-goal-column temporary-goal-column)) (setq evil-auto-indent nil) (goto-char pos) (let ((ws (abs ...))) (save-excursion (if comment-line-break-function (funcall comment-line-break-function nil) (comment-indent-new-line)) (if (and ... ...) (progn ...)) (insert (make-string ... 32))) (insert (make-string (max 1 ws) 32)))) (evil-move-beginning-of-line) (insert (if use-hard-newlines hard-newline "\n")) (forward-line -1) (back-to-indentation)) (evil-move-end-of-line) (cond ((sp-point-in-comment pos) (setq evil-auto-indent nil) (if comment-line-break-function (funcall comment-line-break-function) (comment-indent-new-line))) ((and (eq major-mode (quote haskell-mode)) (fboundp (quote haskell-indentation-newline-and-indent))) (setq evil-auto-indent nil) (haskell-indentation-newline-and-indent)) (t (insert (if use-hard-newlines hard-newline "\n")) (back-to-indentation)))))
(save-restriction (let ((evil-restriction-stack (cons (cons (point-min) (point-max)) evil-restriction-stack))) (evil-narrow (field-beginning) (field-end)) (if above (if (save-excursion (nth 4 (sp--syntax-ppss pos))) (let ((goal-column goal-column) (temporary-goal-column temporary-goal-column)) (setq evil-auto-indent nil) (goto-char pos) (let ((ws ...)) (save-excursion (if comment-line-break-function ... ...) (if ... ...) (insert ...)) (insert (make-string ... 32)))) (evil-move-beginning-of-line) (insert (if use-hard-newlines hard-newline "\n")) (forward-line -1) (back-to-indentation)) (evil-move-end-of-line) (cond ((sp-point-in-comment pos) (setq evil-auto-indent nil) (if comment-line-break-function (funcall comment-line-break-function) (comment-indent-new-line))) ((and (eq major-mode (quote haskell-mode)) (fboundp (quote haskell-indentation-newline-and-indent))) (setq evil-auto-indent nil) (haskell-indentation-newline-and-indent)) (t (insert (if use-hard-newlines hard-newline "\n")) (back-to-indentation))))))
(let ((pos (save-excursion (beginning-of-line-text) (point))) comment-auto-fill-only-comments) (require (quote smartparens)) (save-restriction (let ((evil-restriction-stack (cons (cons (point-min) (point-max)) evil-restriction-stack))) (evil-narrow (field-beginning) (field-end)) (if above (if (save-excursion (nth 4 (sp--syntax-ppss pos))) (let ((goal-column goal-column) (temporary-goal-column temporary-goal-column)) (setq evil-auto-indent nil) (goto-char pos) (let (...) (save-excursion ... ... ...) (insert ...))) (evil-move-beginning-of-line) (insert (if use-hard-newlines hard-newline "\n")) (forward-line -1) (back-to-indentation)) (evil-move-end-of-line) (cond ((sp-point-in-comment pos) (setq evil-auto-indent nil) (if comment-line-break-function (funcall comment-line-break-function) (comment-indent-new-line))) ((and (eq major-mode ...) (fboundp ...)) (setq evil-auto-indent nil) (haskell-indentation-newline-and-indent)) (t (insert (if use-hard-newlines hard-newline "\n")) (back-to-indentation)))))))
+evil--insert-newline()
evil-insert-newline-below()
#f(compiled-function (count) (interactive "p") #)(1)
funcall(#f(compiled-function (count) (interactive "p") #) 1)
(let ((evil-auto-indent evil-auto-indent)) (funcall orig-fn count))
(progn (fset (quote evil-insert-newline-below) vnew) (let ((evil-auto-indent evil-auto-indent)) (funcall orig-fn count)))
(unwind-protect (progn (fset (quote evil-insert-newline-below) vnew) (let ((evil-auto-indent evil-auto-indent)) (funcall orig-fn count))) (fset (quote evil-insert-newline-below) old))
(let* ((vnew (function (lambda nil (+evil--insert-newline)))) (old (symbol-function (quote evil-insert-newline-below)))) (unwind-protect (progn (fset (quote evil-insert-newline-below) vnew) (let ((evil-auto-indent evil-auto-indent)) (funcall orig-fn count))) (fset (quote evil-insert-newline-below) old)))
(if (or (not +evil-want-o/O-to-continue-comments) (not (eq this-command (quote evil-open-below))) (evil-insert-state-p)) (funcall orig-fn count) (let* ((vnew (function (lambda nil (+evil--insert-newline)))) (old (symbol-function (quote evil-insert-newline-below)))) (unwind-protect (progn (fset (quote evil-insert-newline-below) vnew) (let ((evil-auto-indent evil-auto-indent)) (funcall orig-fn count))) (fset (quote evil-insert-newline-below) old))))
+evil--insert-newline-below-and-respect-comments-a(#f(compiled-function (count) (interactive "p") #) 1)
apply(+evil--insert-newline-below-and-respect-comments-a #f(compiled-function (count) (interactive "p") #) 1)
evil-open-below(1)
funcall-interactively(evil-open-below 1)
call-interactively(evil-open-below nil nil)
command-execute(evil-open-below)
**Steps to reproduce:**
1. Enable the `agda` module.
2. Create the above file, and call it `Foo.agda`.
3. Try the commands above.
**System information:**
emacs version 26.3
features XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
build May 06, 2020
buildopts (--prefix=/nix/store/1rx6bbd0fcw7h0shz1drrhza1flpvh0w-emacs-26.3 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200)
windowsys x
daemonp server-running
doom version 2.0.9
build HEAD -> develop, origin/develop, origin/HEAD 97a3950ec 2020-03-27 05:20:02 -0400
dir ~/.doom.d/
system type gnu/linux
config x86_64-pc-linux-gnu
shell /run/current-system/sw/bin/zsh
uname Linux 5.4.28 #1-NixOS SMP Wed Mar 25 07:26:00 UTC 2020 x86_64
path (~/.opam/system/bin ~/bin /run/wrappers/bin ~/.nix-profile/bin /etc/profiles/per-user/james/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin ~/.antigen/bundles/robbyrussell/oh-my-zsh/lib ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/cabal ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/catimg ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/colorize ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/common-aliases ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/copyfile ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/history-substring-search ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/sudo ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vi-mode ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/vundle ~/.antigen/bundles/hchbaw/auto-fu.zsh-pu ~/.antigen/bundles/olejorgenb/nix-zsh-completions-attribute-path-completion-2 ~/.antigen/bundles/zsh-users/zsh-syntax-highlighting ~/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/zsh_reload /nix/store/1rx6bbd0fcw7h0shz1drrhza1flpvh0w-emacs-26.3/libexec/emacs/26.3/x86_64-pc-linux-gnu/)
config envfile envvar-file
elc-files 0
modules (:input japanese :completion company ivy :ui doom doom-dashboard hl-todo modeline nav-flash ophints (popup +all +defaults) vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold multiple-cursors rotate-text snippets :emacs dired electric ibuffer vc :tools (eval +overlay) :checkers syntax :tools (lookup +docsets) magit :lang (agda +local) coq data emacs-lisp (haskell +dante) latex markdown nix (org +dragndrop +present) sh :config (default +bindings +smartparens))
packages ((solarized-theme) (evil-snipe :disable t))
unpin (n/a)
elpa (n/a)
Contributor guide
Assessment
This issue has not been assessed yet.