From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: A patch for `pwd' - copying the current directory to the kill ring Date: Thu, 25 Jan 2018 09:36:30 -0500 Message-ID: References: <871sieozdg.fsf@mbork.pl> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1516891201 20664 195.159.176.226 (25 Jan 2018 14:40:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 25 Jan 2018 14:40:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 25 15:39:57 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeigv-0004cZ-DA for ged-emacs-devel@m.gmane.org; Thu, 25 Jan 2018 15:39:49 +0100 Original-Received: from localhost ([::1]:44269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeiiu-0003ju-Ba for ged-emacs-devel@m.gmane.org; Thu, 25 Jan 2018 09:41:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eeieO-0000ut-TS for emacs-devel@gnu.org; Thu, 25 Jan 2018 09:37:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eeieK-0002mk-On for emacs-devel@gnu.org; Thu, 25 Jan 2018 09:37:12 -0500 Original-Received: from [195.159.176.226] (port=46447 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eeieK-0002jI-BS for emacs-devel@gnu.org; Thu, 25 Jan 2018 09:37:08 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eeic9-0004bE-3c for emacs-devel@gnu.org; Thu, 25 Jan 2018 15:34:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:RDMi2bBEUG80g2XyCi4leUOjWAU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:222231 Archived-At: > I wouldn't even mind copying the default-directory to kill ring by default. > Then you don't need C-u C-u. > - M-x pwd would show the pwd and *also copy it to kill-ring*. > - C-u M-x pwd will only insert the pwd at point (as before). I don't have an opinion on this change, but it gives me the impression that we'd be better served by a more general solution, something like (defvar copy-next-command-output--marker nil) (defun copy-next-command-output () "Add the output of the next command to the `kill-ring`." (interactive) (cl-labels ((pre () (remove-hook 'pre-command-hook #'pre) (add-hook 'post-command-hook #'post) (setq copy-next-command-output--marker (with-current-buffer "*Messages*" (point-max-marker)))) (post () (remove-hook 'post-command-hook #'post) (when copy-next-command-output--marker (with-current-buffer (marker-buffer copy-next-command-output--marker) (when (< copy-next-command-output--marker (point-max)) (kill-new (buffer-substring copy-next-command-output--marker (point-max))))) (setq copy-next-command-output--marker nil)))) (add-hook 'pre-command-hook #'pre))) Except making it work with M-x (the above will grab the "output" of the M-x itself (i.e. no output), rather than the output of the command Emacs runs after running the commands bound to M-x, p, w, d, and RET). Stefan