emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/git-commit 986515d93f 1/4: Deal with enabled long lines sh


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 986515d93f 1/4: Deal with enabled long lines shortcuts
Date: Thu, 7 Sep 2023 18:59:29 -0400 (EDT)

branch: elpa/git-commit
commit 986515d93f2214895e73e1066e9101b1d371fb62
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Deal with enabled long lines shortcuts
    
    Closes #4955.
---
 lisp/magit-section.el | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 03883475bb..df8df28a47 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -1607,12 +1607,15 @@ evaluated its BODY.  Admittedly that's a bit of a hack."
         (setq magit-section-unhighlight-sections
               magit-section-highlighted-sections)
         (setq magit-section-highlighted-sections nil)
-        (unless (eq section magit-root-section)
-          (run-hook-with-args-until-success
-           'magit-section-highlight-hook section selection))
-        (dolist (s magit-section-unhighlight-sections)
-          (run-hook-with-args-until-success
-           'magit-section-unhighlight-hook s selection))
+        (if (and (fboundp 'long-line-optimizations-p)
+                 (long-line-optimizations-p))
+            (magit-section--enable-long-lines-shortcuts)
+          (unless (eq section magit-root-section)
+            (run-hook-with-args-until-success
+             'magit-section-highlight-hook section selection))
+          (dolist (s magit-section-unhighlight-sections)
+            (run-hook-with-args-until-success
+             'magit-section-unhighlight-hook s selection)))
         (restore-buffer-modified-p nil)))
     (setq magit-section-highlight-force-update nil)
     (magit-section-maybe-paint-visibility-ellipses)))
@@ -1676,6 +1679,31 @@ invisible."
     (push ov magit-section-highlight-overlays)
     ov))
 
+(defvar magit-show-long-lines-warning t)
+
+(defun magit-section--enable-long-lines-shortcuts ()
+  (message "Enabling long lines shortcuts in %S" (current-buffer))
+  (setq-local redisplay-highlight-region-function
+              #'redisplay--highlight-overlay-function)
+  (setq-local redisplay-unhighlight-region-function
+              #'redisplay--unhighlight-overlay-function)
+  (when magit-show-long-lines-warning
+    (setq magit-show-long-lines-warning nil)
+    (display-warning 'magit "\
+Emacs has enabled redisplay shortcuts
+in this buffer because there are lines who's length go beyond
+`long-line-treshhold' \(%s characters).  As a result section
+highlighting and the special appearance of the region has been
+disabled.  Some existing highlighting might remain in effect.
+
+These shortcuts remain enables, even once there no longer are
+any long lines in this buffer.  To disable them again, kill
+and recreate the buffer.
+
+This message won't be shown for this session again.  To disable
+it for all future sessions, set `magit-show-long-lines-warning'
+to nil." :warning)))
+
 (cl-defgeneric magit-section-get-relative-position (section))
 
 (cl-defmethod magit-section-get-relative-position ((section magit-section))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]