From: Robin Neatherway <robin.neatherway@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Prompt for files with given extensions
Date: Mon, 16 Feb 2015 10:47:08 +0000 [thread overview]
Message-ID: <CALhoy21Ga6=raWt9ME5_X8-g0-zL2RawCa00HGscUXV+1BTT5A@mail.gmail.com> (raw)
In-Reply-To: <878ug4mpeu.fsf@web.de>
Great, thanks a lot! I missed that option in the documentation.
On Wed, Feb 11, 2015 at 3:35 PM, Michael Heerdegen
<michael_heerdegen@web.de> wrote:
> Robin Neatherway <robin.neatherway@gmail.com> writes:
>
>> At the moment I use `read-file-name` with `foo.results` as a default,
>> but I would like to filter the possible completions by file extension.
>> Is this possible?
>
> You can just use the PREDICATE arg of `read-file-name' for that:
>
> --8<---------------cut here---------------start------------->8---
> ;; -*- lexical-binding: t -*-
>
> (defun my-filter-file-by-extension (extension)
> (lambda (file) (let ((file-extension (file-name-extension file)))
> (and (stringp file-extension)
> (string= file-extension extension)))))
>
> ;; Use like this:
> (read-file-name
> "File: " "~/" nil t nil
> (my-filter-file-by-extension "txt"))
>
> --8<---------------cut here---------------end--------------->8---
>
>
> Michael.
>
>
next prev parent reply other threads:[~2015-02-16 10:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-11 10:17 Prompt for files with given extensions Robin Neatherway
2015-02-11 15:00 ` Drew Adams
2015-02-11 15:35 ` Michael Heerdegen
2015-02-16 10:47 ` Robin Neatherway [this message]
2015-02-12 2:41 ` Robert Thorpe
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALhoy21Ga6=raWt9ME5_X8-g0-zL2RawCa00HGscUXV+1BTT5A@mail.gmail.com' \
--to=robin.neatherway@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=michael_heerdegen@web.de \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.