Configuring Emacs Per File

I have an Emacs Lisp file with custom macros. I want the font and padding to be different. The code looks like this:

(defmacro* when-let ((var value) &rest body)
  `(let ((,var ,value))
     (when ,var ,@body)))

(defun func ()
  (when-let (a 1)
    a))

I want to when-letsmooth as font-lock-keywordwell as indentation, as indicated above. I know I can do this in my .emacs file, but I would prefer to make it local or local. The problem is that the local settings of local and local files are apparently limited by setting variables. In my .emacs file, I have the following.

(add-hook 'emacs-lisp-mode-hook
   (lambda ()
             (put 'when-let 'lisp-indent-function 1)
             (font-lock-add-keywords nil
                                     '(("(\\(when-let\\)\\>" 1
                                        font-lock-keyword-face)))))

I want this in .dir-locals.elbecause it applies to only one file.

+5
source share
2 answers

elisp 1 eval: ( "Eval:", "eval:" ). :.

;;; Local Variables:
;;; mode: outline-minor
;;; eval: (hide-body)
;;; End:

Emacs , , . , , safe-local-variable-values (custom-set-variables) .

, ( mode ), , .

, eval, :

;;; Local Variables:
;;; eval: (outline-minor-mode 1)
;;; eval: (hide-body)
;;; End:

, , progn:

;;; Local Variables:
;;; eval: (progn (outline-minor-mode 1) (hide-body))
;;; End:

, safe-local-variable-values, eval .

1C-h i g (elisp) File Local Variables RET

+9

when-let :

(defmacro* when-let ((var value) &rest body)
  (declare (indent 1))
  `(let ((,var ,value))
     (when ,var ,@body)))

node (elisp)Indenting Macros . .

+3

All Articles