[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
File local variable name containing ':'
From: |
Dan Davison |
Subject: |
File local variable name containing ':' |
Date: |
Thu, 02 Sep 2010 19:56:04 -0400 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) |
I think it isn't possible to use a Local Variables line to set the value
of a variable whose name contains a colon . E.g. something like
# Local Variables:
# var:name: value
# End:
doesn't work because of the colon in var:name.
Assuming I'm not overlooking an easy workaround, it seems that one
possible fix would be to recognise the separator character on-the-fly as
the character following the word "Variables". For what it's worth, I did
have a go at making that change (below). Could this behaviour be changed
or is this a limitation that's here to stay?
Dan
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/files.el b/lisp/files.el
index 3d9dd90..68ba1f0 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -3053,7 +3053,7 @@ If MODE-ONLY is non-nil, all we do is check whether the
major mode
is specified, returning t if it is specified."
(let ((enable-local-variables
(and local-enable-local-variables enable-local-variables))
- result)
+ result separator)
(unless mode-only
(setq file-local-variables-alist nil)
(report-errors "Directory-local variables error: %s"
@@ -3066,10 +3066,11 @@ is specified, returning t if it is specified."
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min))
'move)
(when (let ((case-fold-search t))
- (search-forward "Local Variables:" nil t))
+ (re-search-forward "Local Variables\\([^ \t\n]\\)" nil t))
+ (setq separator (match-string 1))
(skip-chars-forward " \t")
- ;; suffix is what comes after "local variables:" in its line.
- ;; prefix is what comes before "local variables:" in its line.
+ ;; suffix is what comes after "local variables<SEPARATOR>" in its
line.
+ ;; prefix is what comes before "local variables<SEPARATOR>" in its
line.
(let ((suffix
(concat
(regexp-quote (buffer-substring (point)
@@ -3088,7 +3089,7 @@ is specified, returning t if it is specified."
(save-excursion
(unless (let ((case-fold-search t))
(re-search-forward
- (concat prefix "[ \t]*End:[ \t]*" suffix)
+ (concat prefix "[ \t]*End" separator "[ \t]*" suffix)
nil t))
;; This used to be an error, but really all it means is
;; that this may simply not be a local-variables section,
@@ -3118,15 +3119,15 @@ is specified, returning t if it is specified."
;; Find the variable name; strip whitespace.
(skip-chars-forward " \t")
(setq beg (point))
- (skip-chars-forward "^:\n")
- (if (eolp) (error "Missing colon in local variables entry"))
+ (skip-chars-forward (concat "^\n" separator))
+ (if (eolp) (error "Missing separator character in local
variables entry"))
(skip-chars-backward " \t")
(let* ((str (buffer-substring beg (point)))
(var (let ((read-circle nil))
(read str)))
val)
;; Read the variable value.
- (skip-chars-forward "^:")
+ (skip-chars-forward (concat "^" separator))
(forward-char 1)
(let ((read-circle nil))
(setq val (read (current-buffer))))
--8<---------------cut here---------------end--------------->8---
- File local variable name containing ':',
Dan Davison <=