From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ivan Sokolov Newsgroups: gmane.emacs.bugs Subject: bug#64531: [PATCH] Add new command vc-dir-copy-filename-as-kill Date: Sat, 08 Jul 2023 10:51:53 +0300 Message-ID: <87bkgmq1ra.fsf@ya.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32451"; mail-complaints-to="usenet@ciao.gmane.io" To: 64531@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 08 09:53:26 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qI2ku-0008AU-8u for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Jul 2023 09:53:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qI2ka-0001mo-IQ; Sat, 08 Jul 2023 03:53:04 -0400 Original-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 ) id 1qI2kY-0001mQ-WC for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 03:53:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qI2kY-0003gM-Od for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 03:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qI2kY-0006jI-KU for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 03:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Sokolov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 Jul 2023 07:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64531 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168880275125828 (code B ref -1); Sat, 08 Jul 2023 07:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Jul 2023 07:52:31 +0000 Original-Received: from localhost ([127.0.0.1]:44239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qI2k3-0006iV-Ah for submit@debbugs.gnu.org; Sat, 08 Jul 2023 03:52:31 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42078) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qI2k0-0006iK-Sh for submit@debbugs.gnu.org; Sat, 08 Jul 2023 03:52:30 -0400 Original-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 ) id 1qI2k0-0001kq-M3 for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 03:52:28 -0400 Original-Received: from forward102b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:d102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qI2jw-0003Ze-U1 for bug-gnu-emacs@gnu.org; Sat, 08 Jul 2023 03:52:28 -0400 Original-Received: from mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:3faf:0:640:537b:0]) by forward102b.mail.yandex.net (Yandex) with ESMTP id 7038860043 for ; Sat, 8 Jul 2023 10:52:17 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 7qQkXH7DTiE0-V7tI57ST; Sat, 08 Jul 2023 10:52:15 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1688802736; bh=4q4vo5pWJjU5Cwng/SH7W0NYIfQ9UIxmL1HbxrTWvp4=; h=Message-ID:Date:Subject:To:From; b=neR9XJEcC8bBRvmtpqInQCKZ4mUMBJDGEAEtZN+H+1d8IrqMKqrM41rk1AeRcOjjb XfSEqyeFvubm9OKbhBvim09ISWKrsNoycqW5xcM4tWtoHzNPBG1T7zHumVILRIenSz P+ecVO0JF8ZZiLzwRRPaC5NDeG6OaB4IHCzNn16Y= Authentication-Results: mail-nwsmtp-smtp-production-main-29.myt.yp-c.yandex.net; dkim=pass header.i=@ya.ru Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:d102; envelope-from=ivan-p-sokolov@ya.ru; helo=forward102b.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264757 Archived-At: --=-=-= Content-Type: text/plain Hi! This new command is inspired by `dired-copy-filename-as-kill', but has a few differences, that can be easily reversed if there is such need. Changes: 1. even single filename is quoted; 2. filenames are relative by default, prefix makes them absolute; 3. value of prefix argument does not matter, in dired it has to be 0. I bound it to the `w' key because `w' is currently unbound in vc-dir-mode-map and it is what is used in dired. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-new-command-vc-dir-copy-filename-as-kill.patch Content-Description: [PATCH] Add new command vc-dir-copy-filename-as-kill >From d2edc8052d3f8a34b4f28f6721cb2b2ceca1d4a5 Mon Sep 17 00:00:00 2001 From: Ivan Sokolov Date: Sat, 8 Jul 2023 10:34:18 +0300 Subject: [PATCH] Add new command vc-dir-copy-filename-as-kill --- lisp/vc/vc-dir.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 53d58870b32..e348f1027ab 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -353,6 +353,7 @@ See `run-hooks'." (define-key map (kbd "M-s a C-s") #'vc-dir-isearch) (define-key map (kbd "M-s a M-C-s") #'vc-dir-isearch-regexp) (define-key map "G" #'vc-dir-ignore) + (define-key map "w" #'vc-dir-copy-filename-as-kill) (let ((branch-map (make-sparse-keymap))) (define-key map "b" branch-map) @@ -930,6 +931,24 @@ system." (interactive) (view-file (vc-dir-current-file))) +(defun vc-dir-copy-filename-as-kill (&optional absolutep) + "Copy names of marked files (or file under cursor) into the kill ring. +If there are severals names, they will be separated by a space. +Names are always quoted using `shell-quote-argument'. + +If ABSOLUTEP use the absolute names, otherwise names are relative +to the `default-directory'." + (interactive "P") + (let ((files (or (vc-dir-marked-files) + (list (vc-dir-current-file))))) + (unless absolutep + (setq files (mapcar #'file-relative-name files))) + (let ((string (mapconcat #'shell-quote-argument files " "))) + (if (eq last-command 'kill-region) + (kill-append string nil) + (kill-new string)) + (message "%s" string)))) + (defun vc-dir-isearch () "Search for a string through all marked buffers using Isearch." (interactive) -- 2.40.1 --=-=-=--