Function: allout-adjust-file-variable
allout-adjust-file-variable is a byte-compiled function defined in
allout.el.gz.
Signature
(allout-adjust-file-variable VARNAME VALUE)
Documentation
Adjust the setting of an Emacs file variable named VARNAME to VALUE.
This activity is inhibited if either enable-local-variables or
allout-enable-file-variable-adjustment are nil.
When enabled, an entry for the variable is created if not already present, or changed if established with a different value. The section for the file variables, itself, is created if not already present. When created, the section lines (including the section line) exist as second-level topics in a top-level topic at the end of the file.
enable-local-variables must be true for any of this to happen.
Source Code
;; Defined in /usr/src/emacs/lisp/allout.el.gz
;;;_ > allout-adjust-file-variable (varname value)
(defun allout-adjust-file-variable (varname value)
"Adjust the setting of an Emacs file variable named VARNAME to VALUE.
This activity is inhibited if either `enable-local-variables' or
`allout-enable-file-variable-adjustment' are nil.
When enabled, an entry for the variable is created if not already present,
or changed if established with a different value. The section for the file
variables, itself, is created if not already present. When created, the
section lines (including the section line) exist as second-level topics in
a top-level topic at the end of the file.
`enable-local-variables' must be true for any of this to happen."
(if (not (and enable-local-variables
allout-enable-file-variable-adjustment))
nil
(save-excursion
(let ((inhibit-field-text-motion t)
(section-data (allout-file-vars-section-data))
beg prefix suffix)
(if section-data
(setq beg (car section-data)
prefix (cadr section-data)
suffix (car (cddr section-data)))
;; create the section
(goto-char (point-max))
(open-line 1)
(allout-open-topic 0)
(end-of-line)
(insert "Local emacs vars.\n")
(allout-open-topic 1)
(setq beg (point)
suffix ""
prefix (buffer-substring-no-properties (progn
(beginning-of-line)
(point))
beg))
(goto-char beg)
(insert "Local variables:\n")
(allout-open-topic 0)
(insert "End:\n")
)
;; look for existing entry or create one, leaving point for insertion
;; of new value:
(goto-char beg)
(allout-show-to-offshoot)
(if (search-forward (concat "\n" prefix varname ":") nil t)
(let* ((value-beg (point))
(line-end (progn (if (search-forward "\n" nil t)
(forward-char -1))
(point)))
(value-end (- line-end (length suffix))))
(if (> value-end value-beg)
(delete-region value-beg value-end)))
(end-of-line)
(open-line 1)
(forward-line 1)
(insert (concat prefix varname ":")))
(insert (format " %S%s" value suffix))
)
)
)
)