Function: hack-one-local-variable

hack-one-local-variable is a byte-compiled function defined in files.el.gz.

Signature

(hack-one-local-variable VAR VAL)

Documentation

Set local variable VAR with value VAL.

If VAR is mode, call VAL-mode as a function unless it's already the major mode.

This function has :after advice: TeX--call-minor-mode.

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun hack-one-local-variable (var val)
  "Set local variable VAR with value VAL.
If VAR is `mode', call `VAL-mode' as a function unless it's
already the major mode."
  (pcase var
    ((and 'eval (guard (member val hack-local-variables--inhibit-eval))) nil)
    ('mode
     (let ((mode (intern (concat (downcase (symbol-name val))
                                 "-mode"))))
       (set-auto-mode-0 mode t)))
    ('eval
     (pcase val
       (`(add-hook ',hook . ,_) (hack-one-local-variable--obsolete hook)))
     (let ((hack-local-variables--inhibit-eval ;; FIXME: Should be buffer-local!
            (cons val hack-local-variables--inhibit-eval)))
       (save-excursion (eval val t))))
    (_
     (hack-one-local-variable--obsolete var)
     ;; Make sure the string has no text properties.
     ;; Some text properties can get evaluated in various ways,
     ;; so it is risky to put them on with a local variable list.
     (if (stringp val)
         (set-text-properties 0 (length val) nil val))
     (set (make-local-variable var) val))))