unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim Johnson <tim@akwebsoft.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Adding an `or condition without changing code
Date: Mon, 13 Jan 2020 09:55:17 -0900	[thread overview]
Message-ID: <78686b71-fbfc-a95c-2177-66f0c7fa98d4@akwebsoft.com> (raw)
In-Reply-To: <jwveew3zap6.fsf-monnier+emacs@gnu.org>

On 1/13/20 5:37 AM, Stefan Monnier wrote:
>> 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.

Thanks for those insights. I'm going with Drew Adams' dired+ instead.

dired+ easily takes care of multiple buffer issues.

cheers

-- 
Tim
tj49.com




      reply	other threads:[~2020-01-13 18:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-12 23:29 Adding an `or condition without changing code Tim Johnson
2020-01-13 14:37 ` Stefan Monnier
2020-01-13 18:55   ` Tim Johnson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=78686b71-fbfc-a95c-2177-66f0c7fa98d4@akwebsoft.com \
    --to=tim@akwebsoft.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).