From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: Prompt for files with given extensions
Date: Wed, 11 Feb 2015 16:35:53 +0100 [thread overview]
Message-ID: <878ug4mpeu.fsf@web.de> (raw)
In-Reply-To: CALhoy233rv6b4P+Cnzx2PZTyFuC-SEQdL5u2JTHjbcMq3695sA@mail.gmail.com
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-11 15:35 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 [this message]
2015-02-16 10:47 ` Robin Neatherway
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
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=878ug4mpeu.fsf@web.de \
--to=michael_heerdegen@web.de \
--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).