doomemacs / doomemacs/core

org-ctrl-c-star results in unexpected scrolling

Open
#5,273 1 comment 3 reactions 0 assignees View on GitHub
is:bug needs-triage
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?

When I move the cursor onto a plain list item in an org file and call the function org-ctrl-c-star, this should convert the plain list item to be converted to a heading.

### What actually happened?

This works, but an unexpected automatic scroll happens where that new heading jumps to the very top of the window.

### Describe your attempts to resolve the issue

I've narrowed down the code that's causing the trouble: in modules/lang/org/config.el, it's this advice which is added to toc-org:

```
(defadvice! +org-inhibit-scrolling-a (orig-fn &rest args)
"Prevent the jarring scrolling that occurs when the-ToC is regenerated."
:around #'toc-org-insert-toc
(let ((p (set-marker (make-marker) (point)))
(s (window-start)))
(prog1 (apply orig-fn args)
(goto-char p)
(set-window-start nil s t)
(set-marker p nil))))
```

Removing this advice fixes the bug. Of course, this advice was added for a reason, presumably to prevent some sort of ToC scrolling, but it causes undesirable behavior whenever org-ctrl-c-star is invoked.

### Steps to reproduce

1. Create an org file
2. Create three plain list items, like

```
- one
- two
- three
```
3. Put cursor on "three", and run function `org-ctrl-c-star`

### System Information

https://pastebin.com/MPnCxWVF

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.