From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Use regexp with dir-locals-set-directory-class
Date: Wed, 20 Aug 2014 19:05:40 +0200 [thread overview]
Message-ID: <87k363m6qj.fsf@debian.uxu> (raw)
In-Reply-To: mailman.7268.1408525586.1147.help-gnu-emacs@gnu.org
Florian Lindner <mailinglists@xgm.de> writes:
> can I use a regular expression (or globbing pattern)
> as DIRECTORY argument to
> dir-locals-set-directory-class and set a class for
> all directories that match?
Interesting question! Seems short answer is no, if you
check out the help:
DIRECTORY is the name of a directory, a string.
But that of course doesn't mean you cannot have what
you want.
There should be many ways to do this. Perhaps even a
standard one?
The principle should be easy:
1. Apply the regexp on the set of possible directories,
to get a list of matches.
2. Feed those one-by-one to the function.
Now, step one is the tricky part. I would use the shell
and ls. Like this:
(let*((dirs-str (with-temp-buffer
(call-process-shell-command
"ls -d testdir/*/" ; shell regexp here
nil ; no INFILE
t) ; BUFFER (t -> current buffer = the temp one)
(buffer-substring (point-min) (point-max)) ))
(dirs (split-string dirs-str)) )
(dolist (dir dirs)
(dir-locals-set-directory-class dir 'class-one) ))
--
underground experts united
next parent reply other threads:[~2014-08-20 17:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.7268.1408525586.1147.help-gnu-emacs@gnu.org>
2014-08-20 17:05 ` Emanuel Berg [this message]
2014-08-20 9:05 Use regexp with dir-locals-set-directory-class Florian Lindner
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=87k363m6qj.fsf@debian.uxu \
--to=embe8573@student.uu.se \
--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.
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.