From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#69606: [PATCH] Ensure default-directory exists when generating diff Date: Fri, 08 Mar 2024 07:47:29 +0000 Message-ID: <87sf115fn2.fsf@posteo.net> References: <87v85yo0h7.fsf@posteo.net> <87bk7q2vkx.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14399"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69606@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 08 08:49:21 2024 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 1riUym-0003TX-4R for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Mar 2024 08:49:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riUyB-0008SL-Vq; Fri, 08 Mar 2024 02:48:44 -0500 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 1riUxz-0008Ru-5s for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 02:48:34 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riUxy-0000wG-Cj for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 02:48:30 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1riUyU-0001Ex-7n for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 02:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Mar 2024 07:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69606 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69606-submit@debbugs.gnu.org id=B69606.17098840914510 (code B ref 69606); Fri, 08 Mar 2024 07:49:02 +0000 Original-Received: (at 69606) by debbugs.gnu.org; 8 Mar 2024 07:48:11 +0000 Original-Received: from localhost ([127.0.0.1]:56265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1riUxe-0001Ae-Vg for submit@debbugs.gnu.org; Fri, 08 Mar 2024 02:48:11 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]:59101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1riUxc-0001AP-4q for 69606@debbugs.gnu.org; Fri, 08 Mar 2024 02:48:09 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 173B0240103 for <69606@debbugs.gnu.org>; Fri, 8 Mar 2024 08:47:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1709884050; bh=oiiFDjLVHWIFLZt0dvWaFiNGbVDmRC8y8tFppLIieJQ=; h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version: Content-Type:From; b=B99oQYoHSFEqDROUH03H2liTLT51k/werBlcV2sQC/n0kXGIhP4O9G8Bmi/iXDQBR ymYxZo1nGIgd/l+Rba4dOGLY/t3TFUdiq70XYS7cfUt3OfUEmq3hTlJu1Va2IldGDG eTLuA7XU/w92Z6bOSrRAQpwDAVE6XhHsYzdWZf97sAX/vrI5J7iaic0P9LPe6XcdWB TNtfGBldU7WK5Sy/eUB4672wseZkvi6Cml60IPxar8p8ZkpjYFSiOrFffFK00VhfZk +lpDvar/QDvxdxKs23OiQc4smR8ldwlfiYo8Gr6jkKi7Q5VCEdp+XGsl1PMtuKVros UGuemxOYSlNFA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TrdYY3ltPz9rxF; Fri, 8 Mar 2024 08:47:29 +0100 (CET) In-Reply-To: <87bk7q2vkx.fsf@gmx.de> (Michael Albinus's message of "Thu, 07 Mar 2024 11:19:10 +0100") OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66; url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66"; preference=signencrypt 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:281211 Archived-At: Michael Albinus writes: > Philip Kaludercic writes: > > Hi Philip, > >> diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el >> index a64fbc47853..47566dbc40b 100644 >> --- a/lisp/vc/diff.el >> +++ b/lisp/vc/diff.el >> @@ -188,7 +188,9 @@ diff-no-select >> (list (or old-alt old) >> (or new-alt new))))) >> " ")) >> - (thisdir default-directory)) >> + (thisdir (if (file-exists-p default-directory) >> + default-directory >> + (expand-file-name "~")))) >> (with-current-buffer buf >> (setq buffer-read-only t) >> (buffer-disable-undo (current-buffer)) > > I would use temporary-file-directory (or even > small-temporary-file-directory). Spamming the home directory with > (temporary) diff files doesn't sound like a good idea. If I am not mistaken, the command does not create any files, the output of diff is written directly into the *diff* buffer. >> Any other ideas? Perhaps we should always set the default directory to >> that > > Perhaps, but I don't know whether there are undesired side effects, for > example when using relative file names. OTOH, if default-directory is > remote or unwritable, we might have problems anyway. I don't quite understand how, but it seems that some specific sequence of commands can start diff in a directory I just deleted, without this being necessary. The reason I was thinking about a more general solution, is that something like --8<---------------cut here---------------start------------->8--- (let ((default-directory "/this/does/not/exists")) (make-process :command '("true"))) --8<---------------cut here---------------end--------------->8--- will always fail, even though "true" doesn't use the current working directory. I think it would be useful to have some :fallback option for these situations, to ensure that if `default-directory' doesn't exist, any other directory should be used instead. > Best regards, Michael. -- Philip Kaludercic on peregrine