From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Adding an `or condition without changing code Date: Mon, 13 Jan 2020 09:37:51 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="161772"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 13 15:44:36 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ir0wG-000Rkv-1j for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 13 Jan 2020 15:43:32 +0100 Original-Received: from localhost ([::1]:51314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ir0wE-0005oy-NJ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 13 Jan 2020 09:43:30 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42551) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ir0vh-0005ol-F6 for help-gnu-emacs@gnu.org; Mon, 13 Jan 2020 09:42:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ir0vg-0004N2-Dl for help-gnu-emacs@gnu.org; Mon, 13 Jan 2020 09:42:57 -0500 Original-Received: from blaine.gmane.org ([195.159.176.226]:57722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ir0vg-0004LO-6Z for help-gnu-emacs@gnu.org; Mon, 13 Jan 2020 09:42:56 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1ir0u6-0000gu-As for help-gnu-emacs@gnu.org; Mon, 13 Jan 2020 15:41:18 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:hXvjRF4maTijzuM3VPxBQ6ZzWIc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:122216 Archived-At: > I'm implementing dired-single-buffer > > The function of the same name has the following `let initialization > > (let ((name (or default-dirname (dired-get-filename nil t)))) ;; > default-dirname is an optional argument to dired-single-buffer > > The two conditions to `or are not sufficient if I call dired-single-buffer > from an unvisited buffer. The result is that `name is nil and a string-p, > nil error is thrown. > > A simple hack is to add a third condition to `or > > (let ((name (or default-dirname (dired-get-filename nil t) "~/")))  ;; > fall-back to /home/user I guess using `default-directory` rather than "~" would be more generally useful. > But, it IS a hack and means I have altered some good citizen's code. Indeed. Luckily Emacs does make it possible to do that. > How can that be resolved? Might the solution be a customization of dired? I think it should be considered as a bug in `dired-single-buffer`. > From the documentation of dired-get-filename I don't grok a solution.... You can only meaningfully use `dired-get-filename` inside a dired buffer, so the problem is in that function. Stefan