Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs 24.3 previous-line on empty line moves pointer up two lines #31

Closed
imfranklin opened this issue Apr 18, 2013 · 5 comments
Closed

Comments

@imfranklin
Copy link

With version 1.84 in Emacs 24.3 on Mac OS X 10.8.3 previous-line (via or C-p) on an empty line moves the pointer up twice (to the previous, previous line).

@alpaker
Copy link
Owner

alpaker commented Apr 18, 2013

Thanks for the report. This is a known issue, caused by a bug that was introduced into Emacs's redisplay engine shortly before the release of 24.3. The bug has been fixed in Emacs trunk, so fci-mode will work correctly with head-of-line Emacs, as well as with 24.2 and earlier versions; it's only the current release that's affected. Unfortunately, since the bug is in C code, not Lisp, it isn't possible to monkey patch it: a fix requires that you rebuild Emacs itself.

I'll update the package header with a mention of this issue. But the only fix I can offer is to upgrade to Emacs rev. 112274 or later or to apply the below patch to 24.3 and rebuild. Sorry.

=== modified file 'src/indent.c'
--- src/indent.c    2013-04-02 01:54:56 +0000
+++ src/indent.c    2013-04-13 08:54:02 +0000
@@ -2006,11 +2006,15 @@
      const char *s = SSDATA (it.string);
      const char *e = s + SBYTES (it.string);

+     disp_string_at_start_p =
      /* If it.area is anything but TEXT_AREA, we need not bother
         about the display string, as it doesn't affect cursor
         positioning.  */
-     disp_string_at_start_p =
-       it.string_from_display_prop_p && it.area == TEXT_AREA;
+       it.area == TEXT_AREA
+       && it.string_from_display_prop_p
+       /* A display string on anything but buffer text (e.g., on
+          an overlay string) doesn't affect cursor positioning.  */
+       && (it.sp > 0 && it.stack[it.sp - 1].method == GET_FROM_BUFFER);
      while (s < e)
        {
          if (*s++ == '\n')

@alpaker alpaker closed this as completed Apr 18, 2013
alpaker pushed a commit that referenced this issue Aug 7, 2013
vincentbernat added a commit to vincentbernat/dot.emacs that referenced this issue Nov 6, 2013
The reason is that there is a bug in Emacs 24.3 that makes the cursor
jumps two lines instead of one and this is quite annoying. See:
 alpaker/fill-column-indicator#31
@remvee
Copy link

remvee commented Sep 24, 2014

Here's a workaround:

(defadvice previous-line (around avoid-jumpy-fci activate)
  (if (symbol-value 'fci-mode)
      (prog (fci-mode -1) ad-do-it (fci-mode 1))
    ad-do-it))

@joncol
Copy link

joncol commented Jan 3, 2015

Good stuff remvee. Only complaint is that your fix caused some problems when standing on line 1. Small modification:

(make-variable-buffer-local 'line-move-visual)
(defadvice previous-line (around avoid-jumpy-fci activate)
  (if (and (symbol-value 'fci-mode) (> (count-lines 1 (point)) 0))
      (progn (fci-mode -1) ad-do-it (fci-mode 1))
    ad-do-it))

@djs52
Copy link

djs52 commented Jan 13, 2016

For anyone who needs this fix still (e.g., if you are on Ubuntu 14.04), "prog" should be "progn", so:

(make-variable-buffer-local 'line-move-visual)
(defadvice previous-line (around avoid-jumpy-fci activate)
  (if (and (symbol-value 'fci-mode) (> (count-lines 1 (point)) 0))
      (progn (fci-mode -1) ad-do-it (fci-mode 1))
    ad-do-it))

@qrilka
Copy link

qrilka commented Oct 29, 2018

Shouldn't this issue be removed from the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants