From: Sean Whitton Date: Sat, 12 Apr 2025 02:05:57 +0000 (+0800) Subject: vc-do-async-command: Ellipse later lines in multiline arguments X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=de53011093dc02bce2d0ee75713a0983c3bfa02a;p=emacs.git vc-do-async-command: Ellipse later lines in multiline arguments * lisp/emacs-lisp/cl-print.el (cl-print-expand-ellipsis): Bind inhibit-read-only to t. * lisp/vc/vc-dispatcher.el (require): Require cl-print at compile time. (vc-do-async-command): When printing command arguments that contain multiple lines, use cl-prin1 with cl-print-string-length bound in order to ellipse lines other than the first. Switch the outer quotation marks to single quotation marks. (cherry picked from commit 3b841700a8bef1d5b16542679458ddfb588ea777) --- diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el index 62cda07ac73..ba699f75b71 100644 --- a/lisp/emacs-lisp/cl-print.el +++ b/lisp/emacs-lisp/cl-print.el @@ -518,7 +518,9 @@ BUTTON can also be a buffer position or nil (to mean point)." (user-error "No ellipsis to expand here"))) (let* ((end (next-single-property-change (point) 'cl-print-ellipsis)) (begin (previous-single-property-change end 'cl-print-ellipsis)) - (value (get-text-property begin 'cl-print-ellipsis))) + (value (get-text-property begin 'cl-print-ellipsis)) + ;; Ensure clicking the button works even in read only buffers. + (inhibit-read-only t)) ;; FIXME: Rather than `t' (i.e. reuse the print-length/level unchanged), ;; I think it would make sense to increase the level by 1 and to ;; double the length at each expansion step. diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 1b4831d0bd6..b644a048630 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -109,7 +109,9 @@ ;; TODO: ;; - log buffers need font-locking. -(eval-when-compile (require 'cl-lib)) +(eval-when-compile + (require 'cl-lib) + (require 'cl-print)) ;; General customization @@ -473,10 +475,22 @@ Display the buffer in some window, but don't select it." (unless (eq (point) (point-min)) (insert " \n")) (setq new-window-start (point)) - (insert "Running \"" cmd) + (insert "Running '" cmd) (dolist (flag flags) - (insert " " flag)) - (insert "\"...\n") + (let ((lines (string-lines flag))) + (insert " ") + ;; If the argument has newlines in it (as a commit + ;; message commonly will) then ellipse it down so + ;; that the whole command is more readable. + (if (cdr lines) + (let ((flag (copy-sequence flag)) + (cl-print-string-length (length + (car lines)))) + (set-text-properties 0 (length flag) nil + flag) + (cl-prin1 flag buffer)) + (insert flag)))) + (insert "'...\n") args)))) (setq proc (apply #'vc-do-command t 'async command nil args)))) (unless vc--inhibit-async-window