unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13685: a way to say that dir-locals should only apply to buffers with files
       [not found] <emtxpj7gzs.fsf@fencepost.gnu.org>
@ 2013-02-12  2:32 ` Glenn Morris
  2013-02-13  3:24   ` Josh
  0 siblings, 1 reply; 5+ messages in thread
From: Glenn Morris @ 2013-02-12  2:32 UTC (permalink / raw)
  To: 13685

Glenn Morris wrote:

> I think there should be some way in a dir-locals file to say
> "these settings should only be applied to buffers with files".
> Sometimes some options are not appropriate for file-less buffers.
> Ref bug#11127.

This seems easy to do, but I don't know what the best UI is.
An element in the dir-locals list:

  (fileonly . t)

or

  (apply-to . files)

The latter allows for

  (apply-to . nonfiles)

as well (though I can't think of a use for that).





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#13685: a way to say that dir-locals should only apply to buffers with files
  2013-02-12  2:32 ` bug#13685: a way to say that dir-locals should only apply to buffers with files Glenn Morris
@ 2013-02-13  3:24   ` Josh
  2013-02-13  8:36     ` Andreas Schwab
  2013-02-21 16:16     ` Ted Zlatanov
  0 siblings, 2 replies; 5+ messages in thread
From: Josh @ 2013-02-13  3:24 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 13685

On Mon, Feb 11, 2013 at 6:32 PM, Glenn Morris <rgm@gnu.org> wrote:
> Glenn Morris wrote:
>
>> I think there should be some way in a dir-locals file to say
>> "these settings should only be applied to buffers with files".
>> Sometimes some options are not appropriate for file-less buffers.
>> Ref bug#11127.
>
> This seems easy to do, but I don't know what the best UI is.
> An element in the dir-locals list:
>
>   (fileonly . t)
>
> or
>
>   (apply-to . files)

Or more generally, the cdr could specify a predicate taking a single
argument (the buffer), e.g.
(apply-if . buffer-file-name)

> The latter allows for
>
>   (apply-to . nonfiles)
>
> as well (though I can't think of a use for that).

Likewise, (apply-if . (lambda (buffer) (not (buffer-file-name buffer))))





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#13685: a way to say that dir-locals should only apply to buffers with files
  2013-02-13  3:24   ` Josh
@ 2013-02-13  8:36     ` Andreas Schwab
  2013-02-13 17:18       ` Josh
  2013-02-21 16:16     ` Ted Zlatanov
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2013-02-13  8:36 UTC (permalink / raw)
  To: Josh; +Cc: 13685

Josh <josh@foxtail.org> writes:

> Likewise, (apply-if . (lambda (buffer) (not (buffer-file-name buffer))))

Be careful about execution of arbitrary code.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#13685: a way to say that dir-locals should only apply to buffers with files
  2013-02-13  8:36     ` Andreas Schwab
@ 2013-02-13 17:18       ` Josh
  0 siblings, 0 replies; 5+ messages in thread
From: Josh @ 2013-02-13 17:18 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 13685

On Wed, Feb 13, 2013 at 12:36 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Josh <josh@foxtail.org> writes:
>
>> Likewise, (apply-if . (lambda (buffer) (not (buffer-file-name buffer))))
>
> Be careful about execution of arbitrary code.
>
> Andreas.

Indeed, such a feature should be governed by `enable-local-eval' and
`safe-local-eval-forms' or similar, with `buffer-file-name' being an
element of the latter by default.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#13685: a way to say that dir-locals should only apply to buffers with files
  2013-02-13  3:24   ` Josh
  2013-02-13  8:36     ` Andreas Schwab
@ 2013-02-21 16:16     ` Ted Zlatanov
  1 sibling, 0 replies; 5+ messages in thread
From: Ted Zlatanov @ 2013-02-21 16:16 UTC (permalink / raw)
  To: Josh; +Cc: 13685

On Tue, 12 Feb 2013 19:24:19 -0800 Josh <josh@foxtail.org> wrote: 

J> Or more generally, the cdr could specify a predicate taking a single
J> argument (the buffer), e.g.
J> (apply-if . buffer-file-name)
...

J> Likewise, (apply-if . (lambda (buffer) (not (buffer-file-name buffer))))

I like the idea, but why not structure it like a cond statement since
that's what you're doing anyway?

Ted





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-21 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <emtxpj7gzs.fsf@fencepost.gnu.org>
2013-02-12  2:32 ` bug#13685: a way to say that dir-locals should only apply to buffers with files Glenn Morris
2013-02-13  3:24   ` Josh
2013-02-13  8:36     ` Andreas Schwab
2013-02-13 17:18       ` Josh
2013-02-21 16:16     ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).