syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Ctrl + n stops showing cursor (when kept pressed) #5456

Closed jramapuram closed 7 years ago

jramapuram commented 8 years ago

Description

Ctrl + n stops scrolling abruptly until release when it warps to a new location. Issue does not happen with emacs native Issue does not happen with Ctrl + p Installed fresh spacemacs and see the issue.

Just in case fyi I installed emacs with brew using: brew install emacs --with-cocoa --with-gnutls --with-rsvg --with-imagemagick --srgb

Reproduction guide

Observed behaviour: See here: http://sendvid.com/zs96hs4j

Expected behaviour: Smooth scrolling & no warping.

System Info

(emacs-lisp)

Edit: add info about Ctrl+P

jramapuram commented 8 years ago

fyi this is not an issue with commit 0562f050b4b56470dc68744667794b20abe9570a

TheBB commented 8 years ago

Can you bisect?

jramapuram commented 8 years ago

There is quite a bit going on ... I tried to change swap out the themes el file as well as the python one (where I see the issue the most) and haven't found it yet. I will try to go rev by rev if I have some time. Surprised no one else is having this issue. It's pretty unbearable.

StreakyCobra commented 8 years ago

I will try to go rev by rev

Don't do this. Use git-bisect instead: http://www.metaltoad.com/blog/beginners-guide-git-bisect-process-elimination

Roughly:

  1. Start the bisect: git bisect start
  2. Find a non-working commit and annotate it: git bisect bad COMMIT_HASH
  3. Find a working commit and annotate it: git bisect good COMMIT_HASH
  4. Loop until git bisect has found the problematic commit:
    1. The bisect will checkout a new commit to try
    2. Try to reproduce your bug
    3. If the bug appears: git bisect bad, if it doesn't git bisect good
    4. Repeat

It will require you approximately 8 try (2^7 < 147 < 2^8).

jramapuram commented 8 years ago

Thank you, this is super useful in general. Will give it a shot and get back.

jramapuram commented 8 years ago

Here is the result:

(.venv)➜  .emacs.d git:(103bd2b) ✗ git bisect good
e33a39c7356119cc7201ab16cef7478fdc5b8afa is the first bad commit
commit e33a39c7356119cc7201ab16cef7478fdc5b8afa
Author: syl20bnr <sylvain.benner@gmail.com>
Date:   Wed Mar 2 09:13:09 2016 -0500

    Update, simplify and add smooth scrolling toggle on `SPC t v`

:040000 040000 c42dc16861f27dcf020015865a2438891619dd3e e022ecbce700fa0f3578e567b51a32cee74c88ba M  doc
:040000 040000 87c3425eff3f42acf7ce4f218221d8daf7d2ede4 3164366c9b70d25dbacb96bdb9caf95969283d86 M  layers
StreakyCobra commented 8 years ago

Link to the problematic commit: e33a39c7356119cc7201ab16cef7478fdc5b8afa

Seems to be related to smooth scrolling. Can you try to disable it it by adding it to the dotspacemacs-excluded-package list and see if you can still reproduce the bug?

d12frosted commented 8 years ago

Disabling smooth-scroll fixes bug :) But you don't have smooth-scroll anymore :)

StreakyCobra commented 8 years ago

@d12frosted Can you try reproducing this on stock emacs (without Spacemacs, SPC q D may help) so we see if this is a Spacemacs bug, an upstream bug, or a bug coming from packages combination.

d12frosted commented 8 years ago

Sure, I'll do it. But I think I'll do it only tomorrow :)

jramapuram commented 8 years ago

Hmm I disabled smooth-scroll but still seem to have the issue:

   dotspacemacs-excluded-packages
   '(
     smooth-scroll
     )

I also tried to disable smooth-scrolling-mode but still see the issue

StreakyCobra commented 8 years ago

smooth-scroll

smooth-scrolling :-)

jramapuram commented 8 years ago

Slight update: disabling smooth-scrolling on commit https://github.com/syl20bnr/spacemacs/commit/0562f050b4b56470dc68744667794b20abe9570a (ie the original working one) does not resolve the issue (the scrolling only remains linear with this package enabled). Tested this with a multi-page python file.

jramapuram commented 8 years ago

@d12frosted : Any update here?

jramapuram commented 8 years ago

@StreakyCobra : Just tried on base emacs install and it works perfectly.

(require 'package)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "http://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.org/packages/")))
(package-initialize)

(defun ensure-package-installed (&rest packages)
  "Assure every package is installed, ask for installation if it’s not.
Return a list of installed packages or nil for every skipped package."
  (mapcar
   (lambda (package)
     ;; (package-installed-p 'evil)
     (if (package-installed-p package)
         nil
       (if (y-or-n-p (format "Package %s is missing. Install it? " package))
           (package-install package)
         package)))
   packages))

;; make sure to have downloaded archive description.
;; Or use package-archive-contents as suggested by Nicolas Dudebout
(or (file-exists-p package-user-dir)
    (package-refresh-contents))

(setq jr-packages  '(smooth-scrolling))

(dolist (pkg jr-packages)
  (ensure-package-installed pkg))

(package-initialize)
(require 'smooth-scrolling)
(smooth-scrolling-mode 1)
StreakyCobra commented 8 years ago

It's probably an interaction problem between several packages then. The goal is to find which ones :smiley:

jramapuram commented 8 years ago

Issue resolved by replacing this [in .emacs.d/layers/+distribution/spacemacs/packages.el]:

(defun spacemacs/init-smooth-scrolling ()
  (use-package smooth-scrolling
    :init
    (progn
      (setq smooth-scroll-margin 5)
      (spacemacs|add-toggle smooth-scrolling
        :status smooth-scrolling-mode
        :on (progn
              (smooth-scrolling-mode)
              (enable-smooth-scroll-for-function previous-line)
              (enable-smooth-scroll-for-function next-line)
              (enable-smooth-scroll-for-function isearch-repeat))
        :off (progn
               (smooth-scrolling-mode -1)
               (disable-smooth-scroll-for-function previous-line)
               (disable-smooth-scroll-for-function next-line)
               (disable-smooth-scroll-for-function isearch-repeat))
        :documentation "Smooth scrolling."
        :evil-leader "tv")
      (when dotspacemacs-smooth-scrolling
        (spacemacs/toggle-smooth-scrolling-on))
      ;; add hooks here only for emacs built-in packages that are not owned
      ;; by a layer.
      (defun spacemacs//unset-scroll-margin ()
        "Set scroll-margin to zero."
        (setq-local scroll-margin 0))
      (spacemacs/add-to-hooks 'spacemacs//unset-scroll-margin
                              '(messages-buffer-mode-hook)))))

with:

(defun spacemacs/init-smooth-scrolling ()
  (defun spacemacs//unset-scroll-margin ()
    "Set scroll-margin to zero."
    (setq-local scroll-margin 0))

  (use-package smooth-scrolling
    :if dotspacemacs-smooth-scrolling
    :init (setq smooth-scroll-margin 5
                scroll-conservatively 101
                scroll-preserve-screen-position t
                auto-window-vscroll nil)
    :config
    (progn
      (setq scroll-margin 5)
      ;; add hooks here only for emacs built-in packages
      (spacemacs/add-to-hooks 'spacemacs//unset-scroll-margin
                              '(messages-buffer-mode-hook
                                comint-mode-hook
                                term-mode-hook))))

  (unless dotspacemacs-smooth-scrolling
    ;; deactivate smooth-scrolling advices
    (ad-disable-advice 'previous-line 'after 'smooth-scroll-down)
    (ad-activate 'previous-line)
    (ad-disable-advice 'next-line 'after 'smooth-scroll-up)
    (ad-activate 'next-line)
    (ad-disable-advice 'isearch-repeat 'after 'isearch-smooth-scroll)
    (ad-activate 'isearch-repeat)))
StreakyCobra commented 8 years ago

@jramapuram If you think this may be useful for other users, you can do a PR to have it reviewed and eventually merged :smiley:

jramapuram commented 8 years ago

@StreakyCobra : Should be fine, however all I really did above is replace the new changes with the old ones. Not sure how this affects other packages which might require spacemacs|add-toggle smooth-scrolling as a dep.

nelson-liu commented 8 years ago

@jramapuram your solution works fantastically, thanks!

cydparser commented 8 years ago

Setting scroll-conservatively to something other than the default value of 0 fixes the issue for me. Try adding (setq scroll-conservatively 101) to dotspacemacs/user-config.

Edit: setting scroll-conservatively stopped working...

quicknir commented 8 years ago

This is still an issue. Any chance this can be merged? I'm not too eager to dig into the internals of the layers. I am trying to convince an emacs guy to try spacemacs, as it so happened he held down the down arrow key in emacs mode and hit on this issue in the first 30 seconds of using it, making it hard to convince him :-) (for me it's less of an issue because in evil, this interestingly only shows up in insert mode, not normal mode)

TheBB commented 8 years ago

We fixed a number of smooth-scrolling problems in develop. Can someone confirm if this is fixed?

jramapuram commented 8 years ago

@TheBB : Will give it a shot tomorrow! Thanks

jramapuram commented 7 years ago

Fixed in 0.200 running on emacs 25.1.1