aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-12-28 13:00:51 +0000
committerSean Whitton2025-12-28 13:00:51 +0000
commitaefc4baca90d439d9a01664cdeb578d919604f35 (patch)
treebfc934d9ca77f0668781b8d212601c61afb46bc8
parent1b23b4a5ad31a13199b356ad2dd6465a462fbab8 (diff)
downloademacs-aefc4baca90d439d9a01664cdeb578d919604f35.tar.gz
emacs-aefc4baca90d439d9a01664cdeb578d919604f35.zip
Factor out vc--read-limit
* lisp/vc/vc.el (vc--read-limit): New function. (vc-print-root-log): Call it. (vc-print-log): Call it. Modernize style. Fix docs regarding LIMIT: it defaults to vc-log-show-limit only for interactive calls.
-rw-r--r--lisp/vc/vc.el40
1 files changed, 18 insertions, 22 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 71da7137166..1c7e66f6b5f 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -3932,13 +3932,20 @@ Each function runs in the log output buffer without args.")
3932 (lambda (_ignore-auto _noconfirm) 3932 (lambda (_ignore-auto _noconfirm)
3933 (vc-incoming-outgoing-internal backend upstream-location buffer-name type)))) 3933 (vc-incoming-outgoing-internal backend upstream-location buffer-name type))))
3934 3934
3935(defun vc--read-limit ()
3936 "Read a LIMIT argument for a VC log command."
3937 (string-to-number
3938 (read-from-minibuffer "Limit display (0 for unlimited): "
3939 (format "%s" vc-log-show-limit))))
3940
3935;;;###autoload 3941;;;###autoload
3936(defun vc-print-log (&optional working-revision limit) 3942(defun vc-print-log (&optional working-revision limit)
3937 "Show in another window the VC change history of the current fileset. 3943 "Show in another window the VC change history of the current fileset.
3938If WORKING-REVISION is non-nil, it should be a revision ID; position 3944If WORKING-REVISION is non-nil, it should be a revision ID; position
3939point in the change history buffer at that revision. 3945point in the change history buffer at that revision.
3940If LIMIT is non-nil, it should be a number specifying the maximum 3946If LIMIT is non-nil, it should be a number specifying the maximum
3941number of revisions to show; the default is `vc-log-show-limit'. 3947number of revisions to show; the default for interactive calls is
3948`vc-log-show-limit'.
3942 3949
3943When called interactively with a prefix argument, prompt for 3950When called interactively with a prefix argument, prompt for
3944WORKING-REVISION and LIMIT. 3951WORKING-REVISION and LIMIT.
@@ -3951,23 +3958,16 @@ shown log style is available via `vc-log-short-style'."
3951 (interactive 3958 (interactive
3952 (cond 3959 (cond
3953 (current-prefix-arg 3960 (current-prefix-arg
3954 (let ((rev (read-from-minibuffer "Leave point at revision (default: last revision): " nil 3961 (let ((rev (read-from-minibuffer (format-prompt "Leave point at revision"
3955 nil nil nil)) 3962 "last revision")))
3956 (lim (string-to-number 3963 (lim (vc--read-limit)))
3957 (read-from-minibuffer 3964 (list (and (not (string-empty-p rev)) rev) (and (plusp lim) lim))))
3958 "Limit display (unlimited: 0): "
3959 (format "%s" vc-log-show-limit)
3960 nil nil nil))))
3961 (when (string= rev "") (setq rev nil))
3962 (when (<= lim 0) (setq lim nil))
3963 (list rev lim)))
3964 (t 3965 (t
3965 (list nil (when (> vc-log-show-limit 0) vc-log-show-limit))))) 3966 (list nil (and (plusp vc-log-show-limit) vc-log-show-limit)))))
3966 (let* ((vc-fileset (vc-deduce-fileset t)) 3967 (let ((fileset (vc-deduce-fileset t))
3967 (backend (car vc-fileset)) 3968 (working-revision (or working-revision vc-buffer-revision)))
3968 (files (cadr vc-fileset)) 3969 (vc-print-log-internal (car fileset) (cadr fileset)
3969 (working-revision (or working-revision vc-buffer-revision))) 3970 working-revision nil limit)))
3970 (vc-print-log-internal backend files working-revision nil limit)))
3971 3971
3972;;;###autoload 3972;;;###autoload
3973(defun vc-print-root-log (&optional limit revision) 3973(defun vc-print-root-log (&optional limit revision)
@@ -3989,11 +3989,7 @@ with its diffs (if the underlying VCS backend supports that)."
3989 ((numberp current-prefix-arg) 3989 ((numberp current-prefix-arg)
3990 (list current-prefix-arg)) 3990 (list current-prefix-arg))
3991 (current-prefix-arg 3991 (current-prefix-arg
3992 (let ((lim (string-to-number 3992 (let ((lim (vc--read-limit)))
3993 (read-from-minibuffer
3994 "Limit display (unlimited: 0): "
3995 (format "%s" vc-log-show-limit)
3996 nil nil nil))))
3997 (list (and (plusp lim) lim)))) 3993 (list (and (plusp lim) lim))))
3998 (t 3994 (t
3999 (list (and (plusp vc-log-show-limit) vc-log-show-limit))))) 3995 (list (and (plusp vc-log-show-limit) vc-log-show-limit)))))