From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#34949: 27.0.50; Docstring of `vc-deduce-fileset' incomplete Date: Wed, 25 Mar 2020 00:16:52 +0200 Organization: LINKOV.NET Message-ID: <87369xs8zn.fsf@mail.linkov.net> References: <87sgizy16y.fsf@mail.linkov.net> <1f31a329-eaee-f704-9a58-1b048a6ee636@yandex.ru> <87fteyl64x.fsf@mail.linkov.net> <47fcc86a-a884-0658-d1cb-8666704924e8@yandex.ru> <87o8tkgbe2.fsf@mail.linkov.net> <8736avy640.fsf@mail.linkov.net> <76e52ade-bb44-427a-0910-3fe3cf65bf6d@yandex.ru> <87a751uonw.fsf@mail.linkov.net> <9bab3a53-ec31-3300-132f-dc1e17ee0c53@yandex.ru> <875zfd9lzm.fsf@mail.linkov.net> <87mu8mieve.fsf@mail.linkov.net> <87k13pkxdl.fsf@mail.linkov.net> <207d4e30-aa59-b8eb-c39a-0957757f39eb@yandex.ru> <875zf6cy3w.fsf@mail.linkov.net> <9c39f788-29f1-5a68-c8f3-a4b08ae9ea3b@yandex.ru> <87lfo1dvcf.fsf@mail.linkov.net> <44cda45a-db93-f2c1-626d-9ace68cd6fd1@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125016"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: Lars Ingebrigtsen , 34949@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 24 23:48:20 2020 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 1jGsLL-000WOi-Ip for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Mar 2020 23:48:19 +0100 Original-Received: from localhost ([::1]:56266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGsLK-00078H-8W for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Mar 2020 18:48:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46651) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGsL6-000785-G2 for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 18:48:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGsL4-0004ZF-Hz for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 18:48:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49752) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGsL4-0004Yw-1p for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 18:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jGsL3-00087i-VM for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 18:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Mar 2020 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34949 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 34949-submit@debbugs.gnu.org id=B34949.158509006131191 (code B ref 34949); Tue, 24 Mar 2020 22:48:01 +0000 Original-Received: (at 34949) by debbugs.gnu.org; 24 Mar 2020 22:47:41 +0000 Original-Received: from localhost ([127.0.0.1]:55723 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jGsKj-00086w-Dz for submit@debbugs.gnu.org; Tue, 24 Mar 2020 18:47:41 -0400 Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:51645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jGsKg-00086g-M3 for 34949@debbugs.gnu.org; Tue, 24 Mar 2020 18:47:39 -0400 Original-Received: from mail.gandi.net (m91-129-96-173.cust.tele2.ee [91.129.96.173]) (Authenticated sender: juri@linkov.net) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 07697200006; Tue, 24 Mar 2020 22:47:30 +0000 (UTC) In-Reply-To: <44cda45a-db93-f2c1-626d-9ace68cd6fd1@yandex.ru> (Dmitry Gutov's message of "Mon, 16 Mar 2020 22:17:38 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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" Xref: news.gmane.io gmane.emacs.bugs:177693 Archived-At: --=-=-= Content-Type: text/plain >> Maybe it's not working since vc-dir-refresh already doesn't use >> vc-run-delayed to run vc-dir-refresh-files and vc-dir-update. > > I don't know if that's the way to determine this. Doing both calls in the > callback is a good approach which is easy for vc-dir-refresh to > take. dired-vc-next-action couldn't do that, so vc-run-delayed could be > the next best option. Or not, of course. Actually, vc-run-delayed can't be used because it's fired when the first vc-process finishes, but vc-dir runs at least 4 processes in sequence. So the only available callback is in vc-dir-refresh, and only when `more-to-come' is nil. > Here's a slight modification: create both the hook and a function inside > the vc-dir package (let's call it vc-dir-mark-files) which will accept a > list of file names and mark them. dired-vc-next-action will then call it > from the hook. All this works fine with the patch below. The only part of the patch that I don't like is too much code in the first part of vc-dir-mark-files that just resolves discrepancy between Dired and VC-Dir: dired-get-marked-files returns directory names without the trailing slash, but vc-dir-fileinfo->name returns directories with the trailing slash. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-dir-mark-files.patch diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 6f50a3da6c..af4d29b556 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -3050,6 +3050,33 @@ dired-show-file-type (backward-delete-char 1)) (message "%s" (buffer-string))))) + +(declare-function vc-dir-mark-files "vc-dir") + +;;;###autoload +(defun dired-vc-next-action (verbose) + "Do the next version control operation on marked files/directories. +When only files are marked then call `vc-next-action' with the +same value of the VERBOSE argument. +When also directories are marked then call `vc-dir' and mark +the same files/directories in the VC-Dir buffer that were marked +in the Dired buffer." + (interactive "P") + (let ((mark-files + (let ((marked-files (dired-get-marked-files nil nil nil nil t))) + (when (cl-some #'file-directory-p marked-files) + marked-files)))) + (if mark-files + (let ((transient-hook (make-symbol "vc-dir-mark-files"))) + (fset transient-hook + (lambda () + (remove-hook 'vc-dir-refresh-hook transient-hook t) + (vc-dir-mark-files mark-files))) + (vc-dir-root) + (add-hook 'vc-dir-refresh-hook transient-hook nil t)) + (vc-next-action verbose)))) + + (provide 'dired-aux) ;; Local Variables: diff --git a/lisp/dired.el b/lisp/dired.el index 438f5e7d8b..51aaf6b01d 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1865,6 +1870,7 @@ dired-mode-map (define-key map "\177" 'dired-unmark-backward) (define-key map [remap undo] 'dired-undo) (define-key map [remap advertised-undo] 'dired-undo) + (define-key map [remap vc-next-action] 'dired-vc-next-action) ;; thumbnail manipulation (image-dired) (define-key map "\C-td" 'image-dired-display-thumbs) (define-key map "\C-tt" 'image-dired-tag-files) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 38b4937e85..43d4a7843c 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -771,6 +771,28 @@ vc-dir-toggle-mark (interactive "e") (vc-dir-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) +(defun vc-dir-mark-files (mark-files) + (let* ((backend (vc-responsible-backend default-directory)) + (rootdir (vc-call-backend backend 'root default-directory))) + (when (listp mark-files) + (setq mark-files (mapcar (lambda (file) + (file-relative-name + (if (file-directory-p file) + (file-name-as-directory file) + file) + rootdir)) + mark-files))) + (vc-dir-unmark-all-files t) + (ewoc-map + (lambda (filearg) + (when (cond ((consp mark-files) + (member (vc-dir-fileinfo->name filearg) mark-files)) + ((eq mark-files 'registered) + (memq (vc-dir-fileinfo->state filearg) '(edited added removed)))) + (setf (vc-dir-fileinfo->marked filearg) t) + t)) + vc-ewoc))) + (defun vc-dir-clean-files () "Delete the marked files, or the current file if no marks. The files will not be marked as deleted in the version control @@ -1193,7 +1215,8 @@ vc-dir-refresh (if remaining (vc-dir-refresh-files (mapcar 'vc-dir-fileinfo->name remaining)) - (setq mode-line-process nil)))))))))))) + (setq mode-line-process nil) + (run-hooks 'vc-dir-refresh-hook)))))))))))) (defun vc-dir-show-fileentry (file) "Insert an entry for a specific file into the current *VC-dir* listing. --=-=-=--