From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tom Gillespie Newsgroups: gmane.emacs.bugs Subject: bug#43192: lisp/files.el; 6d10b607d0 introduced bug that breaks C-x C-c Date: Thu, 3 Sep 2020 19:49:33 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6146"; mail-complaints-to="usenet@ciao.gmane.io" To: 43192@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 04 04:50:13 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 1kE1no-0001Tq-UT for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Sep 2020 04:50:13 +0200 Original-Received: from localhost ([::1]:45948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kE1no-0000ob-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Sep 2020 22:50:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kE1nf-0000oE-39 for bug-gnu-emacs@gnu.org; Thu, 03 Sep 2020 22:50:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kE1ne-0002AV-Pn for bug-gnu-emacs@gnu.org; Thu, 03 Sep 2020 22:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kE1ne-0004fY-MT for bug-gnu-emacs@gnu.org; Thu, 03 Sep 2020 22:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tom Gillespie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Sep 2020 02:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43192 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bug Report Original-Received: via spool by submit@debbugs.gnu.org id=B.159918779117924 (code B ref -1); Fri, 04 Sep 2020 02:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Sep 2020 02:49:51 +0000 Original-Received: from localhost ([127.0.0.1]:36711 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kE1nT-0004f2-2e for submit@debbugs.gnu.org; Thu, 03 Sep 2020 22:49:51 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kE1nQ-0004eu-Qa for submit@debbugs.gnu.org; Thu, 03 Sep 2020 22:49:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kE1nQ-0000nm-IU for bug-gnu-emacs@gnu.org; Thu, 03 Sep 2020 22:49:48 -0400 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:56151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kE1nO-00025L-RB for bug-gnu-emacs@gnu.org; Thu, 03 Sep 2020 22:49:48 -0400 Original-Received: by mail-wm1-x32f.google.com with SMTP id a65so4662688wme.5 for ; Thu, 03 Sep 2020 19:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=O0H+gfw7K/RKKfZgkCe6xa1g7C366szCFBHQLnX4Lyg=; b=VFLNlaU5pw3F7ry9TQhmreuSEP7q8DqMdg17zTXcxt1IcgWdffgmGY8x9M5+UBPQsS 6pYuzCi9bnsZmc8Mbq58NOsuy4oTVfnViarFEGwbP3krJxn1/mwW8JNfgCsYKLQCvMSc MK3Mq7dzCAxuqI7iNTjWFNmrFW2SaKYIv2/KIXgGvehodyWCOQSMMPSBEL46VPUn6ifx jZaacLNZXqi2nEPnloqSPkXsriRzyk5TaVpGMUuhkAH+vdt4S/flepB9LuMjZdS6CGo3 Hx2o43QgLokCYF0MOgyZhp7oSiF6BnBCviO5Q6+nQUWiQjd3EheBtOQvPw6qe1oMUvcO M0kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=O0H+gfw7K/RKKfZgkCe6xa1g7C366szCFBHQLnX4Lyg=; b=aTqoOALtmRZkV/bwGI81I2zKsqLzkYIwezV8Olq7nGghB23LracUvPYxxiqYGQPJhY QIekOTwQd3h8vZC9BZr8s29VSBBhsF4pbxfnrFiShX/uzl40kxuTNXOlIo9VC5DJH2lw dZSs5dN+xomKeDhhFKOG8FGnv/037UPCf5jD1GJPQAjzj2P/lXI/PeuQ7lwgRQn//eEZ iVHbUjZ4bwQJdmDSuG+YNrdhAihjAuVN6CIbrR6t75em7+4BGF2DIXT4agLcc9AJddFr hWMO1Ufqw7IZQTgDcjmVMzLK7oFK7yU2l2f+p562vDpQHr9z5r5w17Mz3S38/VID5EXV ohTQ== X-Gm-Message-State: AOAM530OolniYCKuAiCUw2wCKFpctnWYUJpqa1oxH7EkSyOhAIJ1O6Mw cBWeT4SMBOuIX9ho4RIkrGK4sD+THkHeduySmgpeEvmEx30KAw== X-Google-Smtp-Source: ABdhPJzpGrBOZVWW3BKNL+Jo53rG5Cr5qcOnY25xgM0/VS2FSQFuX1Ur1+XGKi5ZLNIvni4siNReMw9wK3SgH8zaR/Y= X-Received: by 2002:a05:600c:24d3:: with SMTP id 19mr5093926wmu.98.1599187784616; Thu, 03 Sep 2020 19:49:44 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=tgbugs@gmail.com; helo=mail-wm1-x32f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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" Xref: news.gmane.io gmane.emacs.bugs:187063 Archived-At: Trying to run save-buffers-kill-terminal from a buffer that has no buffer-file-name fails with stringp, nil if there is more than one buffer with the same file name (which appends <> to the buffer name) and one of those buffers is unsaved. Here is the repro. #+begin_src bash emacs -Q --eval "\ (progn (setq auto-save-default nil) (ignore-errors (make-directory \"/tmp/a\")) (ignore-errors (make-directory \"/tmp/b\")) (with-current-buffer (find-file \"/tmp/a/file.ext\") (erase-buffer) (insert \"\n\") (save-buffer)) (with-current-buffer (find-file \"/tmp/b/file.ext\") (erase-buffer) (save-buffer) (insert \"some text\n\")) (switch-to-buffer \"*scratch*\") (with-current-buffer \"*scratch*\" (save-buffers-kill-terminal)))" #+end_src If you add a second (save-buffer) after (insert \"some text\n\") then emacs will exit as expected. The repro can also be run in batch mode and will exit with code 255 instead of 0, and could be added as a test to prevent this in the future. This happens because the *scratch* buffer does not have a buffer-file-name, and that branch of the or statement is reached because I have two files with the same name in different folders open and thus the buffer file name does not match the buffer name so it goes and looks at scratch which has no buffer file name at all, causing the stringp, nil error. The offending lines from 6d10b607d094bfd29b9ce0c4baf469e3683c3ac6 #+begin_src diff + (string-match + (concat "\\<" + (regexp-quote + (file-name-nondirectory + buffer-file-name)) + "<[0-9]+>\\'") + (buffer-name buffer))) #+end_src This is the second statement in a call to `or'. buffer-file-name is not guaranteed to be non-nil because buffers like *scratch* and *Messages* exist. In many workflows for emacsclient opening to scratch and closing again from scratch are common. I think that putting the string-match inside (if buffer-file-name ...) should be sufficient to fix the issue, but I don't know what the other branch should be, if anything. I worry that there may also be other issues with incorrect assumptions about the relationship between buffer-name and buffer-file-name when there is more than one file with the same name open, but I have not checked carefully.