[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24633: highlight-region func using (window-hscroll) in :align-to spe
From: |
npostavs |
Subject: |
bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop |
Date: |
Thu, 06 Oct 2016 21:01:32 -0400 |
Version: 25.1 24.5
This is sort of a continuation from Bug #21468 (see
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21468#46 and the
following). The overlay with newline approach did indeed turn up some
more problems, so we tried moving to the :overline :underline text
method for Emacs 25, but it turns out this causes Emacs to freeze in
certain circumstances (see
https://github.com/magit/magit/issues/2758#issuecomment-250838301).
There is some sentiment to abandon the horizontal bar effect and settle
for just applying a face, but I think this is a bug in Emacs that should
be fixed regardless. Or maybe it's just a case of "if it hurts, dont do
it"? (using (window-hscroll) in :align-to specs, that is)
-----------------------
With the code below as overlay-bars.el, run
emacs -Q overlay-bars.el -l overlay-bars.el
then move point to the end of the long line with all the semicolons, hit
C-SPC, and then C-n. Emacs gets stuck in an infinite loop that cannot
be interrupted by C-g.
(require 'cl-lib)
(defvar-local 21468-region-overlays nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
(defun 21468-update-hunk-region (start end window rol)
(mapc #'delete-overlay 21468-region-overlays)
(cl-flet ((ov (start end &rest args)
(let ((ov (make-overlay start end nil t)))
(while args (overlay-put ov (pop args) (pop args)))
(push ov 21468-region-overlays)
ov)))
(let* ((align (list 'space :align-to
`(+ ,(window-hscroll) (0 . right))))
(rend-line (save-excursion (goto-char end)
(cons (line-beginning-position)
(line-end-position))))
(face (list :underline (face-background 'highlight nil t))))
(message "align = %S" align)
(ov (car rend-line) (cdr rend-line) 'face face
'after-string (propertize "\s" 'face face 'display align 'cursor
t)))))
(setq-local redisplay-highlight-region-function '21468-update-hunk-region)
(setq-local redisplay-unhighlight-region-function
(lambda (rol) (mapc #'delete-overlay 21468-region-overlays)))
(setq-local truncate-lines t)
If the frame is split vertically with C-x 2 first, then Emacs doesn't
get stuck, but does the equivalent of (scroll-left 4) about once per
second; this can be interrupted by C-g.
Modifying the :align-to expression to `(+ ,(1- (window-hscroll)) (0
. right)) causes this assertion failure after some looping:
xdisp.c:19474: Emacs fatal error: assertion failed: row->pixel_width >= 0
Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=6,
backtrace_limit=2147483647)
at emacs.c:354
354 signal (sig, SIG_DFL);
(gdb) bt
#0 terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:354
#1 0x00000000005fb0aa in die (msg=0x6f64c2 "row->pixel_width >= 0",
file=0x6f3450 "xdisp.c",
line=19474) at alloc.c:7223
#2 0x0000000000479b64 in compute_line_metrics (it=0x7fffffff9110) at
xdisp.c:19474
#3 0x0000000000481e07 in display_line (it=0x7fffffff9110) at xdisp.c:21234
#4 0x0000000000471b56 in try_window (window=21548085, pos=..., flags=1) at
xdisp.c:17246
#5 0x000000000046e6ae in redisplay_window (window=21548085,
just_this_one_p=true) at xdisp.c:16695
#6 0x00000000004665a3 in redisplay_window_1 (window=21548085) at xdisp.c:14494
#7 0x000000000061b092 in internal_condition_case_1 (bfun=0x466561
<redisplay_window_1>,
arg=21548085, handlers=14582547, hfun=0x4664db <redisplay_window_error>) at
eval.c:1338
#8 0x00000000004657c2 in redisplay_internal () at xdisp.c:14119
#9 0x0000000000462ca2 in redisplay () at xdisp.c:13254
#10 0x00000000005768ea in read_char (commandflag=1, map=26212659, prev_event=0,
used_mouse_menu=0x7fffffffe36f, end_time=0x0) at keyboard.c:2477
#11 0x00000000005866f7 in read_key_sequence (keybuf=0x7fffffffe520, bufsize=30,
prompt=0,
dont_downcase_last=false, can_return_switch_frame=true,
fix_current_buffer=true,
prevent_redisplay=false) at keyboard.c:9063
#12 0x000000000057386d in command_loop_1 () at keyboard.c:1365
#13 0x000000000061aff8 in internal_condition_case (bfun=0x573431
<command_loop_1>, handlers=19056,
hfun=0x572ac3 <cmd_error>) at eval.c:1314
#14 0x0000000000573073 in command_loop_2 (ignore=0) at keyboard.c:1107
#15 0x000000000061a5c7 in internal_catch (tag=45888, func=0x57304a
<command_loop_2>, arg=0)
at eval.c:1079
#16 0x0000000000573015 in command_loop () at keyboard.c:1086
#17 0x00000000005725b3 in recursive_edit_1 () at keyboard.c:692
#18 0x00000000005727b3 in Frecursive_edit () at keyboard.c:763
#19 0x0000000000570560 in main (argc=5, argv=0x7fffffffe9b8) at emacs.c:1626
Lisp Backtrace:
"redisplay_internal (C function)" (0x0)
I see the same failure *without* modifying the :align-to expression on
Emacs 24.5.
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop,
npostavs <=
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, Eli Zaretskii, 2016/10/08
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, npostavs, 2016/10/08
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, Eli Zaretskii, 2016/10/08
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, npostavs, 2016/10/08
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, Eli Zaretskii, 2016/10/08
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, npostavs, 2016/10/09
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, Eli Zaretskii, 2016/10/09
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, npostavs, 2016/10/22
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, Eli Zaretskii, 2016/10/22
- bug#24633: highlight-region func using (window-hscroll) in :align-to spec can cause inf loop, npostavs, 2016/10/22