emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Risky local variable mechanism


From: Luc Teirlinck
Subject: Re: Risky local variable mechanism
Date: Fri, 10 Feb 2006 18:31:05 -0600 (CST)

Chong Yidong wrote:

   ! ;; Commonly-encountered local variables that are safe:
   ! (mapc (lambda (pair)
   !    (put (car pair) 'safe-local-variable (cdr pair)))
   !       '((compile-command  . stringp)
   !    (fill-column      . integerp)
   !    (fill-prefix      . t)
   !    (indent-tabs-mode . t)
   !    (page-delimiter   . t)
   !    (paragraph-separate . t)
   !    (sentence-end     . t)
   !    (sentence-end-double-space . t)
   !    (tab-width        . integerp)
   !    (version-control  . t)))

After some further thought, I would be very reluctant to use
(put 'myvar 'safe-local-variable t) for _any_ variable myvar.  There
is no reason to give an unscrupulous person any chance to try to play
games with perverse values.  So just always check that the value makes
sense.  This also automatically prevents problems if one later allows
dangerous values and forgets to update the 'safe-local-variables
property.  Why not something like:

   ! ;; Commonly-encountered local variables that are safe:
   ! (mapc (lambda (pair)
   !    (put (car pair) 'safe-local-variable (cdr pair)))
   !       '((compile-command  . stringp)
   !    (fill-column      . integerp)
   !    (fill-prefix      . (lambda (val) (or (not val) (stringp val))))
   !    ;; This is OK, because indent-tabs-mode is defined using
   !    ;; DEFVAR_BOOL and hence can only be set to t or nil. 
   !    (indent-tabs-mode . t)
   !    (page-delimiter   . stringp)
   !    (paragraph-separate . stringp)
   !    (sentence-end     . stringp)
   !    (sentence-end-double-space . (lambda (val) (memq val '(t nil))))
   !    (tab-width        . integerp)
   !    (version-control  . (lambda (val) (memq val '(t nil never))))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]