From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Add smerge-mode, conflicted-files support to vc-git. Date: Sat, 11 Jan 2014 21:52:23 -0500 Message-ID: References: <12408468.cjCttLLJHG@descartes> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1389495156 31732 80.91.229.3 (12 Jan 2014 02:52:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 12 Jan 2014 02:52:36 +0000 (UTC) Cc: emacs-devel@gnu.org To: =?windows-1252?Q?R=FCdiger?= Sonderfeld Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 12 03:52:42 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W2BAI-0000DR-4O for ged-emacs-devel@m.gmane.org; Sun, 12 Jan 2014 03:52:42 +0100 Original-Received: from localhost ([::1]:36202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2BAH-0007hW-PJ for ged-emacs-devel@m.gmane.org; Sat, 11 Jan 2014 21:52:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2BA8-0007gY-Og for emacs-devel@gnu.org; Sat, 11 Jan 2014 21:52:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2BA1-000754-8R for emacs-devel@gnu.org; Sat, 11 Jan 2014 21:52:32 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:41159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2BA1-00074L-4P for emacs-devel@gnu.org; Sat, 11 Jan 2014 21:52:25 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFxKG9/2dsb2JhbABEvw4Xc4IfAQVWIxALNBIUGA0kiCTBLZEKA4hhnBmBXoMV X-IPAS-Result: Av4EABK/CFFFxKG9/2dsb2JhbABEvw4Xc4IfAQVWIxALNBIUGA0kiCTBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="44749586" Original-Received: from 69-196-161-189.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.196.161.189]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 11 Jan 2014 21:52:23 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id CCD1BAE1FA; Sat, 11 Jan 2014 21:52:23 -0500 (EST) In-Reply-To: <12408468.cjCttLLJHG@descartes> (=?windows-1252?Q?=22R=FCdige?= =?windows-1252?Q?r?= Sonderfeld"'s message of "Sat, 11 Jan 2014 02:14:37 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:168144 Archived-At: > +(defun vc-git-find-file-hook () > + "Activate `smerge-mode' if there is a conflict." > + (when (and buffer-file-name > + (vc-git-conflicted-files buffer-file-name) > + (save-excursion > + (goto-char (point-min)) > + (re-search-forward "^<<<<<<< " nil 'noerror))) This is the main problem, of course. It means running git twice per file rather than once. We could probably improve this by only calling vc-git-conflicted-files if the file is under Git's control and only if it's locally modified. If you can think of some other check we could do to call the file even less frequently, that'd be even better. Also, I think the check shouldn't be in find-file-hook but in vc-git-state (so as to return `conflicted' state). I haven't looked in detail at the patch but did notice also that vc-git-conflicted-files is documented to take a `directory' as argument whereas here you call it with a file name. Stefan