From 8564fb295e9410b88df509af4b803ec0096ae96d Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Tue, 26 Aug 2025 08:51:16 +0200 Subject: Rename variables and a function that deal with the right margin We are going to (optionally) use the left margin too, so we can no longer talk about the right margin as if it was the only one. --- lisp/magit-log.el | 10 +++++----- lisp/magit-margin.el | 46 +++++++++++++++++++++++----------------------- lisp/magit-refs.el | 4 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lisp/magit-log.el b/lisp/magit-log.el index 20a162a..7250443 100644 --- a/lisp/magit-log.el +++ b/lisp/magit-log.el @@ -48,7 +48,7 @@ (defvar magit-refs-focus-column-width) (defvar magit-refs-margin) (defvar magit-refs-show-commit-count) -(defvar magit-buffer-margin) +(defvar magit--right-margin-config) (defvar magit-status-margin) (defvar magit-status-sections-hook) (defvar magit-status-use-buffer-arguments) @@ -1461,7 +1461,7 @@ Do not add this to a hook variable." (* (string-to-number (match-str 3 date)) 60)))) (magit-log-format-margin hash author date)) (when (and (eq style 'cherry) - (magit-buffer-margin-p)) + (magit--right-margin-active)) (apply #'magit-log-format-margin hash (split-string (magit-rev-format "%aN%x00%ct" hash) "\0"))) (when (and graph @@ -1620,15 +1620,15 @@ The shortstat style is experimental and rather slow." (magit-set-buffer-margin nil t)) (defun magit-log-format-margin (rev author date) - (when (magit-margin-option) + (when (magit--right-margin-option) (if magit-log-margin-show-shortstat (magit-log-format-shortstat-margin rev) (magit-log-format-author-margin author date)))) (defun magit-log-format-author-margin (author date) (pcase-let ((`(,_ ,style ,width ,details ,details-width) - (or magit-buffer-margin - (symbol-value (magit-margin-option)) + (or magit--right-margin-config + (symbol-value (magit--right-margin-option)) (error "No margin format specified for %s" major-mode)))) (magit-make-margin-overlay (concat (and details diff --git a/lisp/magit-margin.el b/lisp/magit-margin.el index 45cb58f..4b903e6 100644 --- a/lisp/magit-margin.el +++ b/lisp/magit-margin.el @@ -51,15 +51,15 @@ does not carry to other options." ;;; Settings -(defvar-local magit-set-buffer-margin-refresh nil) +(defvar-local magit--right-margin-delayed nil) -(defvar-local magit-buffer-margin nil) -(put 'magit-buffer-margin 'permanent-local t) +(defvar-local magit--right-margin-config nil) +(put 'magit--right-margin-config 'permanent-local t) -(defun magit-buffer-margin-p () - (car magit-buffer-margin)) +(defun magit--right-margin-active () + (car magit--right-margin-config)) -(defun magit-margin-option () +(defun magit--right-margin-option () (pcase major-mode ('magit-cherry-mode 'magit-cherry-margin) ('magit-log-mode 'magit-log-margin) @@ -88,9 +88,9 @@ does not carry to other options." :key "L" :transient t (interactive) - (unless (magit-margin-option) + (unless (magit--right-margin-option) (user-error "Magit margin isn't supported in this buffer")) - (setcar magit-buffer-margin (not (magit-buffer-margin-p))) + (setcar magit--right-margin-config (not (magit--right-margin-active))) (magit-set-buffer-margin)) (defvar magit-margin-default-time-format nil @@ -102,15 +102,15 @@ does not carry to other options." :key "l" :transient t (interactive) - (unless (magit-margin-option) + (unless (magit--right-margin-option) (user-error "Magit margin isn't supported in this buffer")) ;; This is only suitable for commit margins (there are not others). - (setf (cadr magit-buffer-margin) - (pcase (cadr magit-buffer-margin) + (setf (cadr magit--right-margin-config) + (pcase (cadr magit--right-margin-config) ('age 'age-abbreviated) ('age-abbreviated (let ((default (or magit-margin-default-time-format - (cadr (symbol-value (magit-margin-option)))))) + (cadr (symbol-value (magit--right-margin-option)))))) (if (stringp default) default "%Y-%m-%d %H:%M "))) (_ 'age))) (magit-set-buffer-margin nil t)) @@ -121,24 +121,24 @@ does not carry to other options." :key "d" :transient t (interactive) - (unless (magit-margin-option) + (unless (magit--right-margin-option) (user-error "Magit margin isn't supported in this buffer")) - (setf (nth 3 magit-buffer-margin) - (not (nth 3 magit-buffer-margin))) + (setf (nth 3 magit--right-margin-config) + (not (nth 3 magit--right-margin-config))) (magit-set-buffer-margin nil t)) ;;; Core (defun magit-set-buffer-margin (&optional reset refresh) - (when-let ((option (magit-margin-option))) + (when-let ((option (magit--right-margin-option))) (let* ((default (symbol-value option)) (default-width (nth 2 default))) - (when (or reset (not magit-buffer-margin)) - (setq magit-buffer-margin (copy-sequence default))) + (when (or reset (not magit--right-margin-config)) + (setq magit--right-margin-config (copy-sequence default))) (pcase-let ((`(,enable ,style ,_width ,details ,details-width) - magit-buffer-margin)) + magit--right-margin-config)) (when (functionp default-width) - (setf (nth 2 magit-buffer-margin) + (setf (nth 2 magit--right-margin-config) (funcall default-width style details details-width))) (dolist (window (get-buffer-window-list nil nil 0)) (with-selected-window window @@ -148,7 +148,7 @@ does not carry to other options." #'magit-set-window-margin nil t) (remove-hook 'window-configuration-change-hook #'magit-set-window-margin t)))) - (when (and enable (or refresh magit-set-buffer-margin-refresh)) + (when (and enable (or refresh magit--right-margin-delayed)) (magit-refresh-buffer)))))) (defun magit-set-window-margin (&optional window) @@ -156,8 +156,8 @@ does not carry to other options." (with-selected-window window (set-window-margins nil (car (window-margins)) - (and (magit-buffer-margin-p) - (nth 2 magit-buffer-margin)))))) + (and (magit--right-margin-active) + (nth 2 magit--right-margin-config)))))) (cl-defun magit-make-margin-overlay (&optional string (previous-line nil sline)) "Display STRING in the margin of the previous (or current) line. diff --git a/lisp/magit-refs.el b/lisp/magit-refs.el index 0a51284..bdb40ec 100644 --- a/lisp/magit-refs.el +++ b/lisp/magit-refs.el @@ -314,7 +314,7 @@ Type \\[magit-reset] to reset `HEAD' to the commit at point. (magit-buffer-arguments args))) (defun magit-refs-refresh-buffer () - (setq magit-set-buffer-margin-refresh (not (magit-buffer-margin-p))) + (setq magit--right-margin-delayed (not (magit--right-margin-active))) (unless (magit-rev-verify magit-buffer-upstream) (setq magit-refs-show-commit-count nil)) (magit-set-header-line-format @@ -797,7 +797,7 @@ line is inserted at all." (magit-make-margin-overlay))))) (defun magit-refs--maybe-format-margin (rev) - (when (magit-buffer-margin-p) + (when (magit--right-margin-active) (if-let ((line (magit-rev-format "%cN%x00%ct" rev))) (apply #'magit-log-format-margin rev (split-string line "\0")) (magit-make-margin-overlay)))) -- cgit v1.0