`vip` select wrong region in org-mode
pysnow530 opened this issue · comments
Issue type
- Bug report
Environment
Emacs version: GNU Emacs 28.2 (build 1, x86_64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6) of 2022-09-15
Operating System: macOS Sonoma 14.2.1
Evil version: Evil version 1.15.0
Evil installation type: MELPA
Graphical/Terminal: Graphical
Tested in a make emacs
session (see CONTRIBUTING.md): Yes
Reproduction steps
- Start Emacs
:e /tmp/a.org
- insert the code follow
- move cursor to
a
in table, pressvip
* example
| a | b |
| c | d |
#+begin_src emacs-lisp
(+ 2 3)
#+end_src
Expected behavior
select the table
Actual behavior
table was selected, with org header, and begin_src header
Further notes
- In vim, it just select the table.
- In fundamental-mode, the behavior is expected.
I found the cause of this issue.
Evil's vip
depends on forward-paragraph
, this function use paragraph-start
and paragraph-seperate
. When entering org-mode, org.el
will change these two variable to new variable that about org element.
workaround in doomemacs:
(after! org
(defadvice! recover-paragraph-seperate ()
"Recover org paragraph mark position."
:after 'org-setup-filling
(setq-local paragraph-start "[\f\\|[ \t]*$]")
(setq-local paragraph-separate "[ \t\f]*$")))
If Org mode redefines paragraphs there is little that can be done without introducing other surprises, I am afraid. FWIW, I use the following advice so that Evil paragraph motions and text objects always act consistently:
;; Always use blank lines as paragraph delimiters in motions/text objects
(define-advice forward-evil-paragraph (:around (orig-fun &rest args))
(let ((paragraph-start (default-value 'paragraph-start))
(paragraph-separate (default-value 'paragraph-separate))
(paragraph-ignore-fill-prefix t))
(apply orig-fun args)))