emacs-diffs
[Top][All Lists]
Advanced

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

master 7c034f65fdc: Take better care when setting margins in erc-stamp


From: F. Jason Park
Subject: master 7c034f65fdc: Take better care when setting margins in erc-stamp
Date: Mon, 10 Apr 2023 16:44:33 -0400 (EDT)

branch: master
commit 7c034f65fdca0293ba6c54f2574f12372a256183
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>

    Take better care when setting margins in erc-stamp
    
    * lisp/erc/erc-stamp.el (erc-stamp--adjust-right-margin,
    erc-stamp--display-margin-mode): Prefer setting
    `fringes-outside-margins' to hiding right margin, and check whether
    current buffer is showing before adjusting anything.  (Bug#60936.)
---
 lisp/erc/erc-stamp.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index 8bca9bdb56b..61f289a8753 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -302,10 +302,9 @@ or one col more than the `string-width' of
                                         (current-time)
                                         erc-timestamp-format)))))
            (+ right-margin-width cols))))
-    (setq right-margin-width width
-          right-fringe-width 0)
-    (set-window-margins nil left-margin-width width)
-    (set-window-fringes nil left-fringe-width 0)))
+    (setq right-margin-width width)
+    (when (eq (current-buffer) (window-buffer))
+      (set-window-margins nil left-margin-width width))))
 
 ;;;###autoload
 (defun erc-stamp-prefix-log-filter (text)
@@ -344,6 +343,9 @@ message text so that stamps will be visible when yanked."
   :interactive nil
   (if erc-stamp--display-margin-mode
       (progn
+        (setq fringes-outside-margins t)
+        (when (eq (current-buffer) (window-buffer))
+          (set-window-buffer (selected-window) (current-buffer)))
         (erc-stamp--adjust-right-margin 0)
         (add-function :filter-return (local 'filter-buffer-substring-function)
                       #'erc--remove-text-properties)
@@ -354,9 +356,10 @@ message text so that stamps will be visible when yanked."
     (remove-function (local 'erc-insert-timestamp-function)
                      #'erc-stamp--display-margin-force)
     (kill-local-variable 'right-margin-width)
-    (kill-local-variable 'right-fringe-width)
-    (set-window-margins nil left-margin-width nil)
-    (set-window-fringes nil left-fringe-width nil)))
+    (kill-local-variable 'fringes-outside-margins)
+    (when (eq (current-buffer) (window-buffer))
+      (set-window-margins nil left-margin-width nil)
+      (set-window-buffer (selected-window) (current-buffer)))))
 
 (defun erc-insert-timestamp-left (string)
   "Insert timestamps at the beginning of the line."



reply via email to

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