help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dired: "!" How to see not just result, but !-cmd too?


From: Kevin Rodgers
Subject: Re: dired: "!" How to see not just result, but !-cmd too?
Date: Fri, 21 Jan 2005 10:38:34 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Matthias wrote:
> Here is a modified `shell-command': it shows the command in the header
> line of the output buffer.

Ah, now I see what you've done.  Using header-line-format format is much
better than inserting a comment.  But using defadvice is much better
than redefining an 86-line function:

(defadvice shell-command (after insert-command-comment activate)
  "Insert COMMAND as a comment at the top of the output buffer."
  ;; Alternatives to truncating multi-line commands:
  ;; 1. Replace each newline with a semicolon.
  ;; 2. Truncate, but append an ellipsis.
  (save-excursion
    ;; (ad-get-arg 0) == COMMAND
    ;; (ad-get-arg 1) == OUTPUT-BUFFER
    (set-buffer (or (ad-get-arg 1)
                    "*Shell Command Output*"))
    (setq header-line-format
          (replace-regexp-in-string "%" "%%"
                                    (substring (ad-get-arg 0)
                                               0
                                               (string-match "\n"

(ad-get-arg 0)))
                                    nil t))))

--
Kevin Rodgers

reply via email to

[Prev in Thread] Current Thread [Next in Thread]