evil icon indicating copy to clipboard operation
evil copied to clipboard

M-x moves the cursor position in visual mode

Open nettoyoussef opened this issue 5 years ago • 1 comments

Issue type

  • Bug report

Environment

Emacs version: 27.1 Operating System: Arch Linux linux 5.8.9.arch2-1 Evil version: 1.14.0 Evil installation type: MELPA Graphical/Terminal: X window Tested in a make emacs session: No

Reproduction steps

  • use the init file:
(require 'package)

(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (proto (if no-ssl "http" "https")))
  (when no-ssl (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
)
(package-initialize)

;; set file for custom variables
(setq custom-file (locate-user-emacs-file ".emacs-custom.el"))
(unless (file-exists-p custom-file)
  (write-region "" nil custom-file))
(load custom-file)
(org-babel-load-file (locate-user-emacs-file "minimal_config.org"))

  • use the config file minimal_config.org
* Use-package as package manager
#+BEGIN_SRC emacs-lisp
;; download use-package
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))
 #+END_SRC

* Use evil 

#+BEGIN_SRC emacs-lisp
(use-package evil
  :ensure t
  :config
  (evil-mode 1)
)
 #+END_SRC

* Helm

#+BEGIN_SRC emacs-lisp
;; Enable and install helm
(use-package helm
 :ensure t
 :bind
 (("M-x"      . helm-M-x))
 :config
 (helm-mode 1)
;; (setq helm-autoresize-mode t)
 (setq helm-buffer-max-length 40)
 (setq helm-buffers-fuzzy-matching t)
 (setq helm-recentf-fuzzy-match    t)
 (setq helm-apropos-fuzzy-match t)
)
#+END_SRC

* Colors - default config doesn't show highlight

#+BEGIN_SRC emacs-lisp
(use-package doom-themes 
  :ensure t
  :config
  (load-theme 'doom-gruvbox t)
  (setq doom-themes-enable-bold t)    ; if nil, bold is universally disabled
  (setq doom-themes-enable-italic t) ; if nil, italics is universally disabled
  (doom-themes-org-config)
)
#+END_SRC

  • Start Emacs
  • Select a line with S-vand press M-x

Expected behavior

The cursor position should be unaffected by the Helm M-x command when there is a selection in Visual Mode.

Actual behavior

The cursor position shifts to a new position after the M-x command when there is a selection in Visual Mode.

Further notes

I include two pictures highlighting what happens, to make it more clear. Particularly, this affects the use of evil-mc when trying to create a cursor for each line with vip + C-n as referred here.

evil_bug_1 evil_bug_2

nettoyoussef avatar Sep 28 '20 13:09 nettoyoussef

In fact, I just tested it without Helm, and the error still occurs with the default Emacs M-x, so the problem appears to be exclusively related to evil. Pictures from make Emacs using a github clone: image image

nettoyoussef avatar Sep 28 '20 14:09 nettoyoussef