2011-09-07 11 views
7

.emacs dosyasındaki içerik.php modu ayarlarını .emacs'den .dir-locals.el'ye nasıl taşıyabilirim?

(add-hook 'php-mode-hook 
     (lambda() 
     (c-set-style "bsd") 
     (setq indent-tabs-mode t) 
     (setq c-basic-offset 4) 
     (setq tab-width 4) 
     (c-set-offset 'arglist-close 'c-lineup-arglist-operators) 
     (c-set-offset 'arglist-intro '+) 
     (c-set-offset 'arglist-cont-nonempty 'c-lineup-math) 
     (c-set-offset 'case-label '+)  
     )) 

Bu biçimlendirme ayarlarını projeye özel dizine taşımak istiyorum. (c-set-offset 'arglist-intro '+): Ben setq ifadeleri (örn (setq indent-tabs-mode t)) için kolayca yapabilirsiniz rağmen fonksiyon gibi çağrıları için, bunu yapmak mümkün değilim.

;;; Directory Local Variables 
;;; See Info node `(emacs) Directory Variables' for more information. 

    ((php-mode 
     (c-set-style "bsd") 
     (indent-tabs-mode . t) 
     (c-basic-offset . 4) 
     (tab-width . 4) 
     (c-set-offset 'arglist-close 'c-lineup-arglist-operators) 
     (c-set-offset 'arglist-intro 'c-basic-offset) 
     (c-set-offset 'arglist-cont-nonempty 'c-lineup-math) 
     (c-set-offset 'case-label '+)  
    )) 

burada yanlış nedir: İşte

benim .dir-locals.el yazdıklarıyla koyduk edilir? ; Değişkenler -

cevap

10

Dizin yerel değişkenler adından anlaşılacağı gibi sadece değerlendirilecek elisp formları değil. Neyse ki, bu eval sözde değişkeni üzerinden sağlanır:

((php-mode 
    (indent-tabs-mode . t) 
    (c-basic-offset . 4) 
    (tab-width . 4) 
    (eval . (progn 
      (c-set-style "bsd") 
      (c-set-offset 'arglist-close 'c-lineup-arglist-operators) 
      (c-set-offset 'arglist-intro 'c-basic-offset) 
      (c-set-offset 'arglist-cont-nonempty 'c-lineup-math) 
      (c-set-offset 'case-label '+))))) 

Emacs onu karşılaştığında kod güvenli olduğunu teyit isteyecektir, ve custom-set-variables bölümlerde safe-local-variable-values listeye kaydeder senin isterseniz init dosyası.

İlgili konular