Received: (at 65511) by debbugs.gnu.org; 5 Sep 2023 11:15:35 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 05 07:15:35 2023 Received: from localhost ([127.0.0.1]:54436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qdU1v-0000Dy-9M for submit <at> debbugs.gnu.org; Tue, 05 Sep 2023 07:15:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qdU1t-0000Dk-A7 for 65511 <at> debbugs.gnu.org; Tue, 05 Sep 2023 07:15:33 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qdU1m-0003pj-77; Tue, 05 Sep 2023 07:15:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=H9ON7nVo5RkWIjsW9TyfbKzL8Tq1iUj1G+Juw2cuzmw=; b=i6bx8n1+XaHs rJsAy+wHlwF5NRTXJa8FDCZg4hviDx+w3H7RlNyyz6pIxW2WtSlsa7fuPbliLzXzcUxBkkoz2WONF GuT32dhZ8CtnBRDVcN2V2begQJb063xKs5kFIzVB6AhKyCRqWL0/qFkSnWsY7KF6k+oOf4D62UAP5 T6nqwfQ4BbbhbNxawXIS1Dfn03y82LDeaVScDRJkUEpdhm7KPDwOsFd1/4bCPrR3lT9EoTydTxxHB 0Y0QTyWcRufdIwz5yyt6JL1PkILpBRHK5l8aa+mOzOGQchbfFdQFM1gJSaThllEHAUY0SxL+QjNyT 3iEOzBpygA+i9o1s5W3axQ==; Date: Tue, 05 Sep 2023 14:14:48 +0300 Message-Id: <83jzt450t3.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Stefan Monnier <monnier@HIDDEN> In-Reply-To: <jwvjzt5mxg5.fsf-monnier+emacs@HIDDEN> (message from Stefan Monnier on Mon, 04 Sep 2023 18:17:44 -0400) Subject: Re: bug#65511: [PATCH] copy-next-command-output suggestion References: <87ttsoqfbn.fsf@HIDDEN> <83v8d3odvt.fsf@HIDDEN> <jwvjzt5mxg5.fsf-monnier+emacs@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65511 Cc: jb@HIDDEN, 65511 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Stefan Monnier <monnier@HIDDEN> > Cc: Jeremy Bryant <jb@HIDDEN>, 65511 <at> debbugs.gnu.org > Date: Mon, 04 Sep 2023 18:17:44 -0400 > > > I also wonder whether we should bind interprogram-cut-function to nil > > around the call to kill-new, since this stuff probably should be put > > in the clipboard, right? > > I don't understand: binding it to nil would *prevent* it from making it > to the clipboard, whereas I don't see why we shouldn't obey > `select-enable-clipboard` and `select-enable-primary` here. Sorry, I meant to say that this stuff should NOT be put into the clipboard. Which is why I suggested to bind interprogram-cut-function to nil. > > Also, what happens if some process-filter or process-sentinel or timer > > fire during the time these hooks are in effect: will the stuff added > > to the kill-ring include their output as well? > > Yes. > Not sure we should try to do something about it. Maybe just document it? > BTW, the reason why I haven't pushed to include it in Emacs is that I'm > not really satisfied with the UI: in most cases I don't know beforehand > that I want to capture a command's output, so a "postfix command" > (i.e. one we can run after the fact) would be much preferable. > > It might not be that hard to do: tho: just push markers in *Messages* at > the beginning/end of every command (unless there have been no messages > since the last push), make sure we throw away those markers that reach > `point-min`, and then add a `copy-last-command-output` command that uses > those markers to extract the last message using those markers. > The tricky part will be to find the right message when messages are > emitted (e.g. by the completion UI) while the user types > `M-x copy-last-command-output RET`. Maybe we should indeed try to come up with such an alternative implementation. > +@cindex{copy-next-command-output} > + You can also capture the messages of a command by running the > +command @code{copy-next-command-output} beforehand, which will put them > +in the kill ring. That "them" is ambiguous. Better say "those messages" or somesuch. > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -162,6 +162,8 @@ displayed on the mode line when 'appt-display-mode-line' is non-nil. > > * Editing Changes in Emacs 30.1 > > +** New command 'copy-next-command-output' to capture echo area messages ^ Period missing there. > + ;; - Within a minibuffer: commands run in the minibuffer should not affects ^^^^^^^ "affect"
bug-gnu-emacs@HIDDEN
:bug#65511
; Package emacs
.
Full text available.Received: (at 65511) by debbugs.gnu.org; 4 Sep 2023 22:18:01 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 04 18:18:01 2023 Received: from localhost ([127.0.0.1]:52878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qdHtQ-0004h8-I5 for submit <at> debbugs.gnu.org; Mon, 04 Sep 2023 18:18:01 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48919) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1qdHtN-0004gu-1E for 65511 <at> debbugs.gnu.org; Mon, 04 Sep 2023 18:17:58 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 888FF10006B; Mon, 4 Sep 2023 18:17:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1693865866; bh=+FQpQEkW7489HEz0sUINXaUgZfMxVICVbIc+AVQXHuk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=b6Uzn066CQuW03SEUK2Tpn2Gyl0rV0tH8TWziR/T4krat0pWD0l9oqPk/VH2fUE7s CC0UGRSSOTSDvbqJfScYVnQuU8VxAZUBr2Oyk+dfY+r0CH89TRpj88q40nnh4b7FJ5 FZqgRn1ZbxPiLdtcUD8nSReLMKsaHsr2gXau7n8rY4UJ0OlHpDTB7gOiaPTBz+/6aA xwMxklfbbUUCC0FmDRt/9J/6hrlaI+/jIROH/fSEmGdCc82vKraB0JlJVWlhjf6bwI iQyN9/SAcEdxSEUHgchWzuyv4Dymp/docdrGoDKGqpI+HOcq4t7z8JeWEKEKxI/UvL Mf/L0p5V/j65A== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id F32F4100046; Mon, 4 Sep 2023 18:17:45 -0400 (EDT) Received: from pastel (69-165-136-223.dsl.teksavvy.com [69.165.136.223]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B59231201E6; Mon, 4 Sep 2023 18:17:45 -0400 (EDT) From: Stefan Monnier <monnier@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#65511: [PATCH] copy-next-command-output suggestion In-Reply-To: <83v8d3odvt.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 25 Aug 2023 09:05:42 +0300") Message-ID: <jwvjzt5mxg5.fsf-monnier+emacs@HIDDEN> References: <87ttsoqfbn.fsf@HIDDEN> <83v8d3odvt.fsf@HIDDEN> Date: Mon, 04 Sep 2023 18:17:44 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.117 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65511 Cc: Jeremy Bryant <jb@HIDDEN>, 65511 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > Reading the code, I'm worried by adding/removing hooks without > suitable unwind-protect protection: what if some code signals an error > or the user hits C-g before this code runs to completion? We need to > make sure these hooks are cleaned up properly in those cases. This is a prefix command, like `C-u`, `C-x 8 u`, and a few more: it runs to completion before it does anything useful, since its mode of operation is to arrange for the next command to be run slightly differently. The way it tries to make sure to disable itself "soon" is to use `pre/post-command-hooks` in a way that should hopefully ensure it won't linger longer than desired. It's not as definite as I'd like either, but it's the best way I could come up with so far. I think that if we want to make it better, then we should seriously look at improving our command-loop to provide better built-in support for prefix commands. The patch below includes a longer comment explaining the various possible states,, which should hopefully help convince oneself that it should work acceptably. > I also wonder whether we should bind interprogram-cut-function to nil > around the call to kill-new, since this stuff probably should be put > in the clipboard, right? I don't understand: binding it to nil would *prevent* it from making it to the clipboard, whereas I don't see why we shouldn't obey `select-enable-clipboard` and `select-enable-primary` here. > Also, what happens if some process-filter or process-sentinel or timer > fire during the time these hooks are in effect: will the stuff added > to the kill-ring include their output as well? Yes. Not sure we should try to do something about it. > And finally, this feature only works with commands whose output goes > to *Messages*, right? Yup. > If so, there are commands which show messages in other ways, and at > the very least the doc string should mention that caveat. > Bonus points for adding ways of capturing those other kinds of output > as well. Agreed. BTW, the reason why I haven't pushed to include it in Emacs is that I'm not really satisfied with the UI: in most cases I don't know beforehand that I want to capture a command's output, so a "postfix command" (i.e. one we can run after the fact) would be much preferable. It might not be that hard to do: tho: just push markers in *Messages* at the beginning/end of every command (unless there have been no messages since the last push), make sure we throw away those markers that reach `point-min`, and then add a `copy-last-command-output` command that uses those markers to extract the last message using those markers. The tricky part will be to find the right message when messages are emitted (e.g. by the completion UI) while the user types `M-x copy-last-command-output RET`. Stefan diff --git a/doc/emacs/screen.texi b/doc/emacs/screen.texi index 5e9e89e6b11..4e65bc1105f 100644 --- a/doc/emacs/screen.texi +++ b/doc/emacs/screen.texi @@ -146,6 +146,11 @@ Echo Area this limit, one line is deleted from the beginning whenever a new message line is added at the end. +@cindex{copy-next-command-output} + You can also capture the messages of a command by running the +command @code{copy-next-command-output} beforehand, which will put them +in the kill ring. + @xref{Display Custom}, for options that control how Emacs uses the echo area. diff --git a/etc/NEWS b/etc/NEWS index fbb13254e64..d5bd372ecfb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -162,6 +162,8 @@ displayed on the mode line when 'appt-display-mode-line' is non-nil. * Editing Changes in Emacs 30.1 +** New command 'copy-next-command-output' to capture echo area messages + --- ** New global minor mode 'kill-ring-deindent-mode'. When enabled, text being saved to the kill ring will be de-indented by diff --git a/lisp/simple.el b/lisp/simple.el index 05a3c4b93d6..2fc1b2dad96 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5877,6 +5877,67 @@ copy-region-as-kill (setq deactivate-mark t) nil) +(defun copy-next-command-output () + "Prefix command to add the output of the next command to the `kill-ring`. +\"Output\" here refers to text emitted in the echo area, and currently this +is limited to those messages which also appear in the *Messages* buffer." + (interactive) + (let ((md (minibuffer-depth)) + (marker (with-current-buffer "*Messages*" + (point-max-marker)))) + ;; We consider the following states: + ;; - The command (and potentially a few other prefix commands) has just + ;; been run, `post-command-hook' is unaffected yet and `pre-command-hook' + ;; and `prefix-command-*' hooks are set. + ;; - The next command is about to be executed: we already run + ;; `pre-command-hook'. All the hooks are set. + ;; - We just finished running the next command: `post-command-hook' + ;; should then hopefully remove all the hooks. + ;; - Within a minibuffer: commands run in the minibuffer should not affects + ;; hooks since they are either "within" another prefix command + ;; (such as `C-x 8 u') or within the command we want to affect. + ;; We do (re)set the `marker', OTOH so as to try and skip the messages + ;; that occur while we're inside the minibuffer. + (cl-labels ((pre () + (unless (> (minibuffer-depth) md) + (add-hook 'post-command-hook #'post) + (prepare))) + (prepare () + (with-current-buffer "*Messages*" + (move-marker marker (point-max)))) + (preserve () + (unless (> (minibuffer-depth) md) + (remove-hook 'post-command-hook #'post) + (add-hook 'pre-command-hook #'pre))) + (echo () + (unless (> (minibuffer-depth) md) + "[copy-output]")) + (post () + (if (> (minibuffer-depth) md) + ;; Prepare, in case there's no pre-command-hook before + ;; the next post-command-hook. E.g. in the case of + ;; execute-extended-command. + (prepare) + (remove-hook 'pre-command-hook #'pre) + (remove-hook 'post-command-hook #'post) + (remove-hook 'prefix-command-preserve-state-hook + #'preserve) + (remove-hook 'prefix-command-echo-keystrokes-functions + #'echo) + (prefix-command-update) + (with-current-buffer (marker-buffer marker) + (when (< marker (point-max)) + (kill-new (buffer-substring marker (point-max))))) + (set-marker marker nil)))) + (add-hook 'prefix-command-preserve-state-hook #'preserve) + (add-hook 'prefix-command-echo-keystrokes-functions #'echo) + ;; (message "BEFORE: prefix-arg=%S current-prefix-arg=%S" + ;; prefix-arg current-prefix-arg) + (prefix-command-preserve-state) + ;; (message "AFTER: prefix-arg=%S current-prefix-arg=%S" + ;; prefix-arg current-prefix-arg) + ))) + (defun kill-ring-save (beg end &optional region) "Save the region as if killed, but don't kill it. In Transient Mark mode, deactivate the mark.
bug-gnu-emacs@HIDDEN
:bug#65511
; Package emacs
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 65511) by debbugs.gnu.org; 25 Aug 2023 06:05:55 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 25 02:05:55 2023 Received: from localhost ([127.0.0.1]:39001 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qZPxA-0002lp-BZ for submit <at> debbugs.gnu.org; Fri, 25 Aug 2023 02:05:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39346) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qZPx8-0002lY-Ec for 65511 <at> debbugs.gnu.org; Fri, 25 Aug 2023 02:05:51 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qZPww-0006Eg-2R; Fri, 25 Aug 2023 02:05:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=FZE3W+pLITNs4uBntoPJnR2jhbbxe57YV9bmJzrX38w=; b=fK8SGIU/GsYi MZQOV+CLRDtR2SLvTmZT7AYUP2i+3mFV+5WS4Edb/Klo9NVwRFJHNeoYYSQUQIxtSu4bDUHi34NhE DiKWJ039PEfJPRyw/4RjSVwhMDB7GN8POF//hXCoR3s5lxdfObHHZIux8nGmgGHnXHx7Pv+iTcaaY EgkwbDcsOgP/V9YkAajMYmIPr/7B3FN2yyNn3l/wzgndSci+B/NVgMg8lnUM/ulrPH1DD5SvTa0BF dofaqU96jJe7yYvs78Zml4wVT2gxmHSYQPscd4jtBAqABinJH0CrYWikJxfra53eVtki3NTpxOaVf BsP9c0zdpzb5NsLxd1TSYg==; Date: Fri, 25 Aug 2023 09:05:42 +0300 Message-Id: <83v8d3odvt.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Jeremy Bryant <jb@HIDDEN> In-Reply-To: <87ttsoqfbn.fsf@HIDDEN> (message from Jeremy Bryant on Thu, 24 Aug 2023 22:46:28 +0100) Subject: Re: bug#65511: [PATCH] copy-next-command-output suggestion References: <87ttsoqfbn.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65511 Cc: 65511 <at> debbugs.gnu.org, monnier@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Jeremy Bryant <jb@HIDDEN> > Date: Thu, 24 Aug 2023 22:46:28 +0100 > > The command copy-next-command-output copies the output of the next > command, and having used it for several months, I would like to suggest > this for Emacs core. It doesn't appear to be part of Emacs. I > typically bind this C-c u. > > This code was provided by Stefan on this list or emacs-devel, so the > author should be changed accordingly (I haven't modified Stefan's code, > just used it). > > Thoughts welcome as this is my first patch suggestion. It could also be > put in a package in ELPA. I have signed the paperwork. Thanks. On the formal level, this needs a NEWS entry and a suitable change for the user manual. Also, please always accompany changes by a commit log message formatted according to our conventions (see CONTRIBUTE and the examples shown by "git log"). Reading the code, I'm worried by adding/removing hooks without suitable unwind-protect protection: what if some code signals an error or the user hits C-g before this code runs to completion? We need to make sure these hooks are cleaned up properly in those cases. I also wonder whether we should bind interprogram-cut-function to nil around the call to kill-new, since this stuff probably should be put in the clipboard, right? Also, what happens if some process-filter or process-sentinel or timer fire during the time these hooks are in effect: will the stuff added to the kill-ring include their output as well? if not, how does this command prevent that? And finally, this feature only works with commands whose output goes to *Messages*, right? If so, there are commands which show messages in other ways, and at the very least the doc string should mention that caveat. Bonus points for adding ways of capturing those other kinds of output as well.
bug-gnu-emacs@HIDDEN
:bug#65511
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 24 Aug 2023 21:52:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 24 17:52:02 2023 Received: from localhost ([127.0.0.1]:38792 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qZIFG-0005vt-4I for submit <at> debbugs.gnu.org; Thu, 24 Aug 2023 17:52:02 -0400 Received: from lists.gnu.org ([2001:470:142::17]:49568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <jb@HIDDEN>) id 1qZIFE-0005vM-HB for submit <at> debbugs.gnu.org; Thu, 24 Aug 2023 17:52:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <jb@HIDDEN>) id 1qZIF5-0005AK-1F for bug-gnu-emacs@HIDDEN; Thu, 24 Aug 2023 17:51:51 -0400 Received: from p3plsmtp26-03-2.prod.phx3.secureserver.net ([216.69.139.28] helo=p3plwbeout26-03.prod.phx3.secureserver.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <jb@HIDDEN>) id 1qZIF2-0001r0-IK for bug-gnu-emacs@HIDDEN; Thu, 24 Aug 2023 17:51:50 -0400 Received: from mailex.mailcore.me ([94.136.40.142]) by :WBEOUT: with ESMTP id ZIEvqU55QxrDfZIEwqBRil; Thu, 24 Aug 2023 14:51:42 -0700 X-CMAE-Analysis: v=2.4 cv=Sawyytdu c=1 sm=1 tr=0 ts=64e7d0ee a=s1hRAmXuQnGNrIj+3lWWVA==:117 a=nzDM7VRi/FXkTBRroS9HBg==:17 a=yM0T0u6Ik-0A:10 a=UttIx32zK-AA:10 a=GDFeYmemqq2GeCUdHdoA:9 a=4ZrrpnpWAAAA:8 a=UMla8V_BtvULFz0MKFEA:9 a=1Cd5MWGGBJJ9eP861nmr:22 X-SECURESERVER-ACCT: jb@HIDDEN X-SID: ZIEvqU55QxrDf Received: from [152.37.91.204] (helo=hexa3.local.com) by smtp13.mailcore.me with esmtpa (Exim 4.94.2) (envelope-from <jb@HIDDEN>) id 1qZIEy-0002zi-GH; Thu, 24 Aug 2023 22:51:44 +0100 User-agent: mu4e 1.8.13; emacs 29.1 From: Jeremy Bryant <jb@HIDDEN> To: bug-gnu-emacs@HIDDEN, Stefan Monnier <monnier@HIDDEN> Subject: [PATCH] copy-next-command-output suggestion Date: Thu, 24 Aug 2023 22:46:28 +0100 Message-ID: <87ttsoqfbn.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Mailcore-Auth: 278589627 X-Mailcore-Domain: 1689493 X-123-reg-Authenticated: jb@HIDDEN X-Originating-IP: 152.37.91.204 X-CMAE-Envelope: MS4xfDLhtM6Ax++75Dh7xSNYGkDlVndqEyYk2cVQ0Md9iHy1nahYKCePuPQmpUkBV/5cQeCeeaDv9tpw0MXhvRvHWtvnzYd9fjcOk2WQXw0HTe5Xx8FQm2lu jdZwxddPjhpu8kVIveaPaEr1PNIE8Sl1lryLfu3TfLPcqo07nKvd4IofigAmjolcMnGO2HPr34dM6rpl1W0xwf1BtYPpsHKmmoc= Received-SPF: pass client-ip=216.69.139.28; envelope-from=jb@HIDDEN; helo=p3plwbeout26-03.prod.phx3.secureserver.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hello, Emacs maintainers. The command copy-next-command-output copies the output of the next command, and having used it for several months, I would like to suggest this for Emacs core. It doesn't appear to be part of Emacs. I typically bind this C-c u. This code was provided by Stefan on this list or emacs-devel, so the author should be changed accordingly (I haven't modified Stefan's code, just used it). Thoughts welcome as this is my first patch suggestion. It could also be put in a package in ELPA. I have signed the paperwork. Thanks in advance Jeremy --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-output-of-next-command-to-the-kill-ring.patch Content-Description: patch From 4b797454bbf09556bfb23cbd01cae3e424da29d7 Mon Sep 17 00:00:00 2001 From: Jeremy Bryant <jb@HIDDEN> Date: Thu, 24 Aug 2023 22:42:29 +0100 Subject: [PATCH] Add output of next command to the kill ring --- lisp/misc.el | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lisp/misc.el b/lisp/misc.el index e8b38fad42e..5bd3c720206 100644 --- a/lisp/misc.el +++ b/lisp/misc.el @@ -327,6 +327,53 @@ list-dynamic-libraries (display-buffer buffer) nil) +(defun copy-next-command-output () + "Prefix command to add the output of the next command to the `kill-ring`." + (interactive) + (let ((md (minibuffer-depth)) + (marker (with-current-buffer "*Messages*" + (point-max-marker)))) + (cl-labels ((pre () + (unless (> (minibuffer-depth) md) + (add-hook 'post-command-hook #'post) + (prepare))) + (prepare () + (with-current-buffer "*Messages*" + (move-marker marker (point-max)))) + (preserve () + (unless (> (minibuffer-depth) md) + (remove-hook 'post-command-hook #'post) + (add-hook 'pre-command-hook #'pre))) + (echo () + (unless (> (minibuffer-depth) md) + "[copy-output]")) + (post () + (if (> (minibuffer-depth) md) + ;; Prepare, in case there's no pre-command-hook before + ;; the next post-command-hook. E.g. in the case of + ;; execute-extended-command. + (prepare) + (remove-hook 'pre-command-hook #'pre) + (remove-hook 'post-command-hook #'post) + (remove-hook 'prefix-command-preserve-state-hook + #'preserve) + (remove-hook 'prefix-command-echo-keystrokes-functions + #'echo) + (prefix-command-update) + (with-current-buffer (marker-buffer marker) + (when (< marker (point-max)) + (kill-new (buffer-substring marker (point-max))))) + (set-marker marker nil)))) + (add-hook 'prefix-command-preserve-state-hook #'preserve) + (add-hook 'prefix-command-echo-keystrokes-functions #'echo) + ;; (message "BEFORE: prefix-arg=%S current-prefix-arg=%S" + ;; prefix-arg current-prefix-arg) + (prefix-command-preserve-state) + ;; (message "AFTER: prefix-arg=%S current-prefix-arg=%S" + ;; prefix-arg current-prefix-arg) + ))) + + (provide 'misc) ;;; misc.el ends here -- 2.40.1 --=-=-=--
Jeremy Bryant <jb@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#65511
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.