phillord / lentic

Create views of the same content in two Emacs buffers
183 stars 12 forks source link

Crash on standard shortcuts #52

Closed kevinboulain closed 5 years ago

kevinboulain commented 5 years ago

Hi there,

I tried this mode and it seems really nice but I encountered some errors that make it painful to use as they sometimes crash Emacs on standard shortcuts. There isn't much activity on this repository so I hope it's still maintained and that it only means it's stable :)

Follows how to reproduce an issue with a completely new Emacs configuration.

I'll use straight.el and use-package to install lentic, feel free to copy/paste the following steps as they shouldn't modify your environment and setup everything in /tmp/trash:

mkdir /tmp/trash

cat > /tmp/trash/config.el << EOF
(setq user-emacs-directory "/tmp/trash")

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)

(use-package lentic
  :straight (:host github :repo "phillord/lentic"))
(global-lentic-mode 1)
EOF

cat > /tmp/trash/.dir-locals.el << EOF
((org-mode (lentic-init . lentic-org-el-init)))
EOF

cat > /tmp/trash/crash.org << EOF
hello world
EOF

Once the above is done, everything is in place to:

So let's proceed:

emacs -Q -l /tmp/trash/config.el /tmp/trash/crash.org

Once the initial setup is done, I validate the loading of .dir-locals.el with !. Then, in the crash.org buffer that is now open I C-c , c (which creates the lentic buffer) and I open the lentic buffer with C-c , t which correctly displays crash.el (with ;; hello world).

Finally I simply M-c to uppercase the h of hello world (since I didn't even move the point it should be on the first line).

I'll get the following error:

There has been an error in lentic-mode.
The following is debugging information

Hook: after change
Symbol’s value as variable is void: end

My Emacs version (both on Linux and macOS):

emacs --version
GNU Emacs 26.1
...

I didn't investigate much yet since this is only one side of the problem: with my complete Emacs configuration it makes Emacs go into an infinite loop (funnily emitting an infinite stream of bells :)) and I have to SIGTERM it (sometimes even SIGKILL) :( However it seems related to global-hl-line-mode (the M-c command make it crash inside this one it seems) but I couldn't reproduce it for now.

Any idea before I fully investigate?

Thanks for the package!

Regards.

phillord commented 5 years ago

Yep, that's strange. Clearly it's a bug since "value-as-variable" can only come from broken code. A quick search for "end" suggests that's it's lentic-update-contents' where theendshould bestop`.

That code only gets called rarely and is there to cope with when Emacs says it is going to do one thing and actually does another. At some point in my life I will fix Emacs.

I'll try testing tonight and see if I can get this working. Thanks for the report and the very clean reproduction.

kevinboulain commented 5 years ago

Wow, I wasn't expecting this simple fix to resolve the issue I had with my complete configuration (the infinite stream of bells with Error in post-command-hook (global-hl-line-highlight): (args-out-of-range 5051) and the need to kill the unresponsive Emacs).

Thanks!

phillord commented 5 years ago

Yeah, messing around with the post-command and after-change hooks in such a major way as lentic is pretty hairy. Amazed I managed to miss that bug for so long.