Function: add-dir-local-variable

add-dir-local-variable is an autoloaded, interactive and byte-compiled function defined in files-x.el.gz.

Signature

(add-dir-local-variable MODE VARIABLE VALUE &optional FILE)

Documentation

Add directory-local VARIABLE with its VALUE and MODE to .dir-locals.el.

With a prefix argument, prompt for the file to modify.

When called from Lisp, FILE may be the expanded name of the dir-locals file where to add VARIABLE.

View in manual

Probably introduced at or before Emacs version 23.2.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/files-x.el.gz
;;;###autoload
(defun add-dir-local-variable (mode variable value &optional file)
  "Add directory-local VARIABLE with its VALUE and MODE to .dir-locals.el.

With a prefix argument, prompt for the file to modify.

When called from Lisp, FILE may be the expanded name of the dir-locals file
where to add VARIABLE."
  (interactive
   (let (variable)
     (list
      (read-file-local-variable-mode)
      (setq variable (read-file-local-variable "Add directory-local variable"))
      (read-file-local-variable-value variable)
      (when current-prefix-arg
        (read-dir-locals-file)))))
  (modify-dir-local-variable mode variable value 'add-or-replace file))