]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-do-async-command: Ellipse later lines in multiline arguments
authorSean Whitton <spwhitton@spwhitton.name>
Sat, 12 Apr 2025 02:05:57 +0000 (10:05 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sat, 12 Apr 2025 06:35:31 +0000 (08:35 +0200)
* 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)

lisp/emacs-lisp/cl-print.el
lisp/vc/vc-dispatcher.el

index 62cda07ac73ab82e05252e51367b9dccfb43af69..ba699f75b71254ba75eca670b0b741622c3a1f5e 100644 (file)
@@ -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.
index 1b4831d0bd6e245266a03a5b508d6dfebe341a1b..b644a048630ed41907693b2f5998bc420e39ebaf 100644 (file)
 ;; 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 "\f\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