aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2019-09-03 17:33:26 +0000
committerAlan Mackenzie2019-09-03 17:33:26 +0000
commitc34dbd80e72204cd0ac65254ff3145dbd916f5c5 (patch)
treef2551c2035e865741f253c00aea26df52bb3187b
parentea5d591f29ba2e9e5d31da7ad450b958a4c9ca03 (diff)
downloademacs-c34dbd80e72204cd0ac65254ff3145dbd916f5c5.tar.gz
emacs-c34dbd80e72204cd0ac65254ff3145dbd916f5c5.zip
Use left margin to hold "=>" to indicate current error in fringeless windows
This applies to compilation-mode. It amends the fix for bug #36832. * lisp/progmodes/compile.el (compilation-arrow-overlay): renamed from overlay-arrow-overlay. (compilation-margin-string, compilation--dummy-string): New variables. (compilation-set-up-arrow-spec-in-margin) (compilation-tear-down-arrow-spec-in-margin): New functions. (compilation-set-overlay-arrow): Rewritten to use the new variables/functions.
-rw-r--r--lisp/progmodes/compile.el75
1 files changed, 49 insertions, 26 deletions
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 09188dc14bc..b7bd2243d90 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -2602,45 +2602,68 @@ column zero points to the current message."
2602 (point))) 2602 (point)))
2603 (set-window-point w mk)))) 2603 (set-window-point w mk))))
2604 2604
2605(defvar-local overlay-arrow-overlay nil 2605(defvar-local compilation-arrow-overlay nil
2606 "Overlay with the before-string property of `overlay-arrow-string'. 2606 "Overlay with the before-string property of `overlay-arrow-string'.
2607 2607
2608When non-nil, this overlay causes redisplay to display `overlay-arrow-string' 2608When non-nil, this overlay causes redisplay to display `overlay-arrow-string'
2609at the overlay's start position.") 2609at the overlay's start position.")
2610 2610
2611(defvar compilation-margin-string "=>"
2612 "The string which will appear in the margin in compilation mode.
2613This must be two characters long; there should be no need to
2614change the default.")
2615(put-text-property 0 2 'face 'default compilation-margin-string)
2616
2617(defconst compilation--dummy-string
2618 (propertize ">" 'display
2619 `((margin left-margin) ,compilation-margin-string))
2620 "A string which is only a placeholder for compilation-margin-string.
2621Actual value is never used, only the text property.")
2622
2623(defun compilation-set-up-arrow-spec-in-margin ()
2624 "Set up compilation-arrow-overlay to display as an arrow in a margin."
2625 (setq overlay-arrow-string "")
2626 (setq compilation-arrow-overlay
2627 (make-overlay overlay-arrow-position overlay-arrow-position))
2628 (overlay-put compilation-arrow-overlay
2629 'before-string compilation--dummy-string)
2630 (set-window-margins (selected-window) (+ (or (car (window-margins)) 0) 2)))
2631
2632(defun compilation-tear-down-arrow-spec-in-margin ()
2633 "Restore compilation-arrow-overlay to not using the margin, which is removed."
2634 (overlay-put compilation-arrow-overlay 'before-string nil)
2635 (delete-overlay compilation-arrow-overlay)
2636 (setq compilation-arrow-overlay nil)
2637 (set-window-margins (selected-window) (- (car (window-margins)) 2)))
2638
2611(defun compilation-set-overlay-arrow (w) 2639(defun compilation-set-overlay-arrow (w)
2612 "Set up, or switch off, the overlay-arrow for window W." 2640 "Set up, or switch off, the overlay-arrow for window W."
2613 (with-current-buffer (window-buffer w) 2641 (with-selected-window w ; So the later `goto-char' will work.
2614 (if (and (eq compilation-context-lines t) 2642 (if (and (eq compilation-context-lines t)
2615 (equal (car (window-fringes w)) 0)) ; No left fringe 2643 (equal (car (window-fringes w)) 0)) ; No left fringe
2616 ;; Insert a "=>" before-string overlay at the beginning of the 2644 ;; Insert a before-string overlay at the beginning of the line
2617 ;; line pointed to by `overlay-arrow-position'. 2645 ;; pointed to by `overlay-arrow-position', such that it will
2618 (cond 2646 ;; display in a 2-character margin.
2619 ((overlayp overlay-arrow-overlay) 2647 (progn
2620 (when (not (eq (overlay-start overlay-arrow-overlay) 2648 (cond
2621 overlay-arrow-position)) 2649 ((overlayp compilation-arrow-overlay)
2622 (if overlay-arrow-position 2650 (when (not (eq (overlay-start compilation-arrow-overlay)
2623 (progn 2651 overlay-arrow-position))
2624 (move-overlay overlay-arrow-overlay 2652 (if overlay-arrow-position
2653 (move-overlay compilation-arrow-overlay
2625 overlay-arrow-position overlay-arrow-position) 2654 overlay-arrow-position overlay-arrow-position)
2626 (setq overlay-arrow-string "=>") 2655 (compilation-tear-down-arrow-spec-in-margin))))
2627 (overlay-put overlay-arrow-overlay 2656
2628 'before-string overlay-arrow-string)) 2657 (overlay-arrow-position
2629 (delete-overlay overlay-arrow-overlay) 2658 (compilation-set-up-arrow-spec-in-margin)))
2630 (setq overlay-arrow-overlay nil)))) 2659 ;; Ensure that the "=>" remains in the window by causing
2631 2660 ;; the window to be scrolled, if needed.
2632 (overlay-arrow-position 2661 (goto-char (overlay-start compilation-arrow-overlay)))
2633 (setq overlay-arrow-overlay
2634 (make-overlay overlay-arrow-position overlay-arrow-position))
2635 (setq overlay-arrow-string "=>")
2636 (overlay-put overlay-arrow-overlay 'before-string overlay-arrow-string)))
2637 2662
2638 ;; `compilation-context-lines' isn't t, or we've got a left 2663 ;; `compilation-context-lines' isn't t, or we've got a left
2639 ;; fringe, so remove any overlay arrow. 2664 ;; fringe, so remove any overlay arrow.
2640 (when (overlayp overlay-arrow-overlay) 2665 (when (overlayp compilation-arrow-overlay)
2641 (setq overlay-arrow-string "") 2666 (compilation-tear-down-arrow-spec-in-margin)))))
2642 (delete-overlay overlay-arrow-overlay)
2643 (setq overlay-arrow-overlay nil)))))
2644 2667
2645(defvar next-error-highlight-timer) 2668(defvar next-error-highlight-timer)
2646 2669