Package: emacs;
Reported by: Konstantin Kharlamov <hi-angel <at> yandex.ru>
Date: Wed, 14 Jun 2023 11:18:01 UTC
Severity: normal
To reply to this bug, email your comments to 64063 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#64063
; Package emacs
.
(Wed, 14 Jun 2023 11:18:01 GMT) Full text and rfc822 format available.Konstantin Kharlamov <hi-angel <at> yandex.ru>
:bug-gnu-emacs <at> gnu.org
.
(Wed, 14 Jun 2023 11:18:01 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Konstantin Kharlamov <hi-angel <at> yandex.ru> To: bug-gnu-emacs <at> gnu.org Subject: smerge-mode highlight gets stuck if buffer autoreverted "delicately" Date: Wed, 14 Jun 2023 14:16:47 +0300
Basically, when autorevert is on and the file reverted contains a conflict, the conflict is highlighted. Then if you remove the conflict by external means, and Emacs autoreverts the buffer again, the conflict highlight usually gets removed. However, if autorevert is using `revert-buffer-insert-file-contents-delicately`, the highlight gets stuck. # Steps to reproduce 1. Create `/tmp/.emacs` with the following content: (require 'autorevert) ;; Do not break markers in a buffer upon reverting a buffer. Details: ;; https://github.com/magit/magit/issues/4442 (setq revert-buffer-insert-file-contents-function 'revert-buffer-insert- file-contents-delicately) (global-auto-revert-mode 1) 2. In a terminal, enter Emacs source-code repository, and create a conflict by executing: git checkout 5cace109d2 && git cherry-pick f24ea84f430 3. Open Emacs as `HOME=/tmp emacs etc/NEWS`. Note a conflict line that Emacs automatically jumped to. 4. In a terminal, execute `git cherry-pick --abort` and wait for Emacs to revert the buffer. Note that buffer no longer has conflict. ## Expected The reverted buffer does not have word "user option" highlighted ## Actual The reverted buffer has word "user option" highlighted in red. ------------------ In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-05-31 built on constantine-N61Ja Repository revision: 5cace109d2bce98a7d486e44378286031465f40f Repository branch: fix-smerge-highlight Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 System Description: Arch Linux Configured using: 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games --with-modules --without-libotf --without-m17n-flt --without-gconf --enable-link-time-optimization --with-native-compilation=yes --with-xinput2 --with-x-toolkit=gtk3 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm --without-compress-install '--program-transform-name=s/\([ec]tags\)/\1.emacs/' 'CFLAGS=-Wno-error -flto=2 -march=native -O3 -pipe -fno-stack-protector -fweb -fmerge-all-constants -fno-plt -fcommon' 'LDFLAGS=-flto=2 -O3 -march=native -fweb -fmerge-all-constants -floop-nest-optimize -Wl,--sort-common,-z,relro -fno-plt -fcommon'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LC_TIME: ru_RU.UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Shell-script Minor modes in effect: sh-electric-here-document-mode: t yas-global-mode: t yas-minor-mode: t company-box-mode: t global-git-commit-mode: t server-mode: t projectile-mode: t winum-mode: t global-color-identifiers-mode: t symbol-overlay-mode: t global-symbol-overlay-mode: t global-highlight-parentheses-mode: t highlight-parentheses-mode: t show-smartparens-global-mode: t show-smartparens-mode: t smartparens-global-mode: t smartparens-mode: t global-highlight-numbers-mode: t delete-selection-mode: t highlight-numbers-mode: t evil-goggles-mode: t global-evil-surround-mode: t evil-surround-mode: t shell-dirtrack-mode: t evil-mode: t evil-local-mode: t windmove-mode: t global-auto-revert-mode: t auto-revert-mode: t company-flx-mode: t global-company-mode: t company-mode: t override-global-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: ~/.emacs.d/lisp/popup hides /home/constantine/.emacs.d/elpa/popup- 20211231.1823/popup ~/.emacs.d/lisp/idomenu hides /home/constantine/.emacs.d/elpa/idomenu- 20141123.2120/idomenu /home/constantine/.emacs.d/elpa/cmake-mode-20220322.1258/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode /home/constantine/.emacs.d/elpa/ninja-mode-20181024.1439/ninja-mode hides /usr/share/emacs/site-lisp/ninja-mode /home/constantine/.emacs.d/elpa/transient-20220406.1156/transient hides /usr/share/emacs/30.0.50/lisp/transient /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package hides /usr/share/emacs/30.0.50/lisp/use-package/use-package /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-lint hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-lint /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-jump hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-jump /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-ensure hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-ensure /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-diminish hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-diminish /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-delight hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-delight /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-core hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-core /home/constantine/.emacs.d/elpa/use-package-20210207.1926/use-package-bind-key hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-bind-key /home/constantine/.emacs.d/elpa/bind-key-20210210.1609/bind-key hides /usr/share/emacs/30.0.50/lisp/use-package/bind-key /home/constantine/.emacs.d/elpa/let-alist-1.0.6/let-alist hides /usr/share/emacs/30.0.50/lisp/emacs-lisp/let-alist Features: (shadow sort mail-extr emacsbug shortdoc help-fns radix-tree emacs-news-mode woman man cua-base goto-chg dabbrev vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc bug-reference term/xterm xterm tabify flx quail misearch multi-isearch tramp-archive tramp-gvfs tramp-cache time-stamp zeroconf dbus xml tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat xdg parse-time iso8601 ls-lisp conf-mode yaml-mode dockerfile-mode smartparens-python python vimrc-mode sh-script treesit executable smartparens-markdown markdown-mode noutline outline yasnippet-snippets yasnippet vc-git vc-dispatcher face-remap meson-mode smie desktop frameset smex company-box company-box-doc frame-local company-box-icons evil-magit magit-submodule magit-obsolete magit-popup magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff git-commit log-edit message sendmail yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert magit-margin magit-transient magit-process with-editor server magit-mode transient magit-git magit-base magit-section format-spec crm compat projectile lisp-mnt grep compile text-property-search ibuf-ext ibuffer ibuffer-loaddefs smerge-mode diff-mode diff derived winum color-identifiers-mode symbol-overlay highlight-parentheses sp-sublimetext-like smartparens-config smartparens-text smartparens loadhist dash delsel highlight-numbers parent-mode ido emvil evil-goggles pulse color evil-surround evil evil-keybindings evil-integration evil-maps evil-commands reveal flyspell ispell evil-jumps evil-command-window evil-search evil-ex shell pcomplete comint ansi-osc ansi-color evil-types evil-macros evil-repeat evil-states evil-core comp comp-cstr warnings icons advice evil-common windmove calc calc-loaddefs calc-macs thingatpt rect evil-digraphs evil-vars use-package-ensure avy autorevert filenotify company-oddmuse company-keywords company-etags etags fileloop generator xref project ring company-gtags company-dabbrev-code company-dabbrev company-files company-clang company-capf company-cmake company-semantic company-template company-bbdb company-flx company cl-extra help-mode use-package-bind-key use-package-core edmacro kmacro bind-key easy-mmode cus-load string-inflection-autoloads php-mode-autoloads elixir-mode-autoloads yaml-mode-autoloads ninja-mode-autoloads lsp-mode-autoloads smartparens-autoloads company-flx-autoloads flx-autoloads treepy-autoloads bitbucket-autoloads request-autoloads vimrc-mode-autoloads posframe-autoloads company-box-autoloads frame-local-autoloads projectile-autoloads js2-mode-autoloads csv-mode-autoloads rx cc-styles cc-align cc-engine cc-vars cc-defs magit-autoloads pcase magit-section-autoloads compat-autoloads dash-autoloads company-autoloads info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 830707 760363) (symbols 48 33187 0) (strings 32 209268 43537) (string-bytes 1 6269384) (vectors 16 101229) (vector-slots 8 3036394 730693) (floats 8 456 39245) (intervals 56 35797 24006) (buffers 984 61))
bug-gnu-emacs <at> gnu.org
:bug#64063
; Package emacs
.
(Sat, 17 Jun 2023 00:17:02 GMT) Full text and rfc822 format available.Message #8 received at 64063 <at> debbugs.gnu.org (full text, mbox):
From: Konstantin Kharlamov <hi-angel <at> yandex.ru> To: 64063 <at> debbugs.gnu.org Cc: mardani29 <at> yahoo.es, emacs-devel <at> gnu.org Subject: smerge-mode highlight gets stuck if buffer autoreverted "delicately" Date: Sat, 17 Jun 2023 03:16:32 +0300
On Thu, 2023-06-01 at 13:35 +0200, Daniel Martín wrote: > > So, my question is, what "on change" hooks smerge-mode uses to detect that a > > change to the buffer has been made to check whether conflict markers are still > > in place? I tried searching for the word "hook" over the smerge-mode.el but > > didn't find anything relevant. > > If font-lock is enabled, smerge-mode uses it to fontify the conflicting > regions. See smerge-font-lock-keywords. So perhaps the regular > font-lock debugging techniques might help you investigate this issue in > more detail. So, I think the problem is that the highlight that gets stuck does not use font-lock, or at least not through means of `smerge-font-lock-keywords`. Whatever is defined in `smerge-font-lock-keywords` gets unhighlighted correctly. But the part that gets stuck instead is an overlay. So I presume besides font-lock-mode there's some other highlight management ongoing, the one that decides whether to put/remove overlays over some text.
bug-gnu-emacs <at> gnu.org
:bug#64063
; Package emacs
.
(Sat, 17 Jun 2023 00:40:02 GMT) Full text and rfc822 format available.Message #11 received at 64063 <at> debbugs.gnu.org (full text, mbox):
From: Konstantin Kharlamov <hi-angel <at> yandex.ru> To: 64063 <at> debbugs.gnu.org Cc: mardani29 <at> yahoo.es, emacs-devel <at> gnu.org Subject: Re: smerge-mode highlight gets stuck if buffer autoreverted "delicately" Date: Sat, 17 Jun 2023 03:39:20 +0300
On Sat, 2023-06-17 at 03:16 +0300, Konstantin Kharlamov wrote: > On Thu, 2023-06-01 at 13:35 +0200, Daniel Martín wrote: > > > So, my question is, what "on change" hooks smerge-mode uses to detect that > > > a > > > change to the buffer has been made to check whether conflict markers are > > > still > > > in place? I tried searching for the word "hook" over the smerge-mode.el > > > but > > > didn't find anything relevant. > > > > If font-lock is enabled, smerge-mode uses it to fontify the conflicting > > regions. See smerge-font-lock-keywords. So perhaps the regular > > font-lock debugging techniques might help you investigate this issue in > > more detail. > > So, I think the problem is that the highlight that gets stuck does not use > font-lock, > or at least not through means of `smerge-font-lock-keywords`. Whatever is > defined in > `smerge-font-lock-keywords` gets unhighlighted correctly. But the part that > gets > stuck instead is an overlay. > > So I presume besides font-lock-mode there's some other highlight management > ongoing, > the one that decides whether to put/remove overlays over some text. Okay, I think I figured it out. The hook upon which stuff gets highlighted is `find-file-hook`. It calls vc, vc calls smerge, which checks if there's any conflict markers; then finally `(smerge-refine)` gets called which adds the problematic overlay. I'm not quite sure though what is the correct fix in this case. The problem appears when autorevert-mode is enabled, so one way may be always adding a hook to `after-revert-hook` that clears up the overlays. But there *may* be some other way. I notice that if I remove a conflict marker manually, this makes the overlay disappear. I don't know what exactly causes that to happen, but the answer to this may hide another possibility to fix the bug. If anybody has the knowledge I will be glad to hear C:
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.