summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-stamp.el
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2023-04-10 00:08:37 -0700
committerF. Jason Park <jp@neverwas.me>2023-04-10 13:42:29 -0700
commit7c034f65fdca0293ba6c54f2574f12372a256183 (patch)
tree3ccd482ffac63365f7c57117f8d674c0cede81aa /lisp/erc/erc-stamp.el
parentcb4f4dd89131e5a8956c788fee7ede65f13b2a69 (diff)
downloademacs-7c034f65fdca0293ba6c54f2574f12372a256183.tar.gz
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.)
Diffstat (limited to 'lisp/erc/erc-stamp.el')
-rw-r--r--lisp/erc/erc-stamp.el17
1 files 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."