From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Hong Xu Newsgroups: gmane.emacs.bugs Subject: bug#23436: [PATCH] Attemp to use the true name of a file to determine responsible vc if the genuine name does not work. Date: Sat, 29 Oct 2016 17:42:01 -0700 Message-ID: <87funefz1i.fsf@topbug.net> References: <1462311145-5959-1-git-send-email-hong@topbug.net> <85f11f8a-1799-befd-3e5b-f7d7a6eac660@topbug.net> <072a649f-d11a-7c82-b3ae-32d9a92c8f8b@topbug.net> <5d653522-49bd-8b48-e3d6-0c09d1c65fae@yandex.ru> <377f4ee1-54a9-b10c-dc18-3acea6492bec@yandex.ru> <1ad97145-d21e-5d64-8b6c-4b4b2bc2ab49@yandex.ru> <87zilss0z6.fsf@topbug.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1477788223 1082 195.159.176.226 (30 Oct 2016 00:43:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Oct 2016 00:43:43 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 25.1.50.8 Cc: 23436@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 30 02:43:38 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1c0eDO-0004mX-OU for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Oct 2016 02:43:11 +0200 Original-Received: from localhost ([::1]:56522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0eDR-0007dy-F5 for geb-bug-gnu-emacs@m.gmane.org; Sat, 29 Oct 2016 20:43:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0eDL-0007dt-1a for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 20:43:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0eDG-0008FX-3Y for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 20:43:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49727) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c0eDF-0008FT-W7 for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 20:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c0eDF-0000WL-Mq for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2016 20:43:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Hong Xu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Oct 2016 00:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23436 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 23436-submit@debbugs.gnu.org id=B23436.14777881381947 (code B ref 23436); Sun, 30 Oct 2016 00:43:01 +0000 Original-Received: (at 23436) by debbugs.gnu.org; 30 Oct 2016 00:42:18 +0000 Original-Received: from localhost ([127.0.0.1]:36892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0eCY-0000VL-DQ for submit@debbugs.gnu.org; Sat, 29 Oct 2016 20:42:18 -0400 Original-Received: from sender163-mail.zoho.com ([74.201.84.163]:21469) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c0eCW-0000VC-Jk for 23436@debbugs.gnu.org; Sat, 29 Oct 2016 20:42:17 -0400 Original-Received: from localhost (cpe-104-32-170-214.socal.res.rr.com [104.32.170.214]) by mx.zohomail.com with SMTPS id 1477788129215315.99542122911805; Sat, 29 Oct 2016 17:42:09 -0700 (PDT) In-reply-to: X-Zoho-Virus-Status: 1 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: 208.118.235.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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:125134 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2016-10-25 Tue 16:12 GMT-0700, Dmitry Gutov wrote: > On 25.10.2016 22:05, Hong Xu wrote: > >> I don't understand why find-alternate-file should be used. > > For no reason other than the resulting command could be useful in more=20 > situations than just this one. > >> The reason we >> used (vc-follow-link) is to pass the correct file path to >> vc-responsible-backend. I don't see how find-alternate-file can be used = here. > > It would open the file (or directory) than is the true name of the=20 > currently visited file (or directory), and kill the previous buffer. > > vc-responsible-backend would be called with the true name automatically.= =20 > This is close to what vc-follow-link does already. > > But if that's definitely not what you want, how about a command like this? > > (defun vc-refresh-as-link-target () > (interactive) > (let ((buffer-file-name (file-truename buffer-file-name))) > (vc-refresh-state))) > > By the way, please remind us why vc-follow-symlinks (the variable) with=20 > the default value `ask' is not sufficient for you? OK, I think I have screwed it up. vc-responsible-backend looks like a funct= ion mainly provided for elisp programming purpose, which people can make use in their own customization. Thus, none of these functions should be used. Instead, file-truename or file-chase-links should be used. That is, (vc-responsible-backend (file-chase-links file)) > >>> OK, mention where? >> >> In the doc string. > > The docstring of what? Please be more precise, the less I have to think=20 > about or make choices regarding documentation, the happier I am. > >> Maybe we should also mention `vc-responsible-backend' >> in the info doc "Supported Version Control Systems" in general. > > Care to send the proposed addition in the form of a patch? The attachment is a draft of my proposed doc change. Feel free to adjust the contents and the language. Hong --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=vc-doc.patch Content-Transfer-Encoding: quoted-printable diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index aca29910b7d3..8f31fa168c23 100644 =2D-- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -223,7 +223,7 @@ Version Control Systems @cindex SRC @cindex src @item =2DSRC (src) is RCS, reloaded - a specialized version-control system +SRC (src) is RCS, reloaded---a specialized version-control system designed for single-file projects worked on by only one person. It allows multiple files with independent version-control histories to exist in one directory, and is thus particularly well suited for @@ -233,6 +233,22 @@ Version Control Systems supports almost all SRC operations. @end itemize =20 +@defun vc-responsible-backend file +This function can be used to determine the responsible VC backend of +the given file path @var{file}. For example, if @code{emacs.c} is a +file tracked by git, @code{(vc-responsible-backend "emacs.c")} returns +@code{"Git"}. Note that if @var{file} is a symbolic link, +@code{vc-responsible-backend} will not resolve it---it always reports +the backend of the symbolic link file itself. Instead, to get the +backend VC of the file to which @var{file} refers, wrap @var{file} +with a symbolic link resolving function such as +@code{file-chase-links}: + +@smallexample +(vc-responsible-backend (file-chase-links "emacs.c")) +@end smallexample +@end defun + @node VCS Concepts @subsubsection Concepts of Version Control =20 diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index ac020d095397..a1e4388f6e5c 100644 =2D-- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -959,7 +959,11 @@ vc-responsible-backend If FILE is already registered, return the backend of FILE. If FILE is not registered, then the first backend in `vc-handled-backends' that declares itself =2Dresponsible for FILE is returned." +responsible for FILE is returned. + +Note that if FILE is a symbolic link, it will not be resolved -- +it will report the responsible backend system for the symbolic +link itself." (or (and (not (file-directory-p file)) (vc-backend file)) (catch 'found ;; First try: find a responsible backend. If this is for registration, --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJYFUHZAAoJECZsfTOCL4R4NVcP/jrU3hpEPXdsdhN8mZQklcqK Fc/7Dsn6sDxZkthYpUiRG/5vzvwQ2Fk+Mwg7NUdVAjaaCJ9B7R5Vq8xOiMPGTV7+ wkvrYFZ+sQSkCCBc99yPkGxfhgpUiQjswvaPRkm5WwwdbCKQCowcvCsZE/fQGFhR CS5/UboUzXiGBiCyRNjPVkvsYuoT+8NZcRbO8lbQoUQV8EQ9rjwYdEJ3mv+EMmOm VuqJNtvfKBLaqt931aUraerflXni+Qxx2ax02qzHgLGVEDy+ZGGZd9LZScuxsAq7 lxpume26fD7jLhyUoqa2grNDPj9LUQ4M4F+4YLTLfj+2pTM7Rk3LhZiQ9KlKkC+d RHbM1VrDS6HnH9yvHpjPr1UA5OYxORv4rLboxCzDwFsk4waqT1ELhgSXWcYPQqNc A7pCDZHvsxktg5baSfZ2QC0OTgzwN+VsDpz94zSpsqwGzHgsNeAlHruq4tZIar1b 6apcSZVSKnyGKA+IQrDYrndoJFgS/x7BEnqDo0IXf/PL01JSRUzwmYHd1at6MVkL hFMsOFM3RGd23kcJ3tfNia2SCMSp6k3PxORZho1rxMA8Dj9bXfEbvsuBd6qfLlnv LE2Q4a8kuH6vPiacBNQUhF55S8UhpCT1aOXBxedWcJq7hpaJisMuyRByF/QC1BJ5 X0ap9Xv/lRgN2R+/2tAY =QCzP -----END PGP SIGNATURE----- --==-=-=--