From: Dan Davison <davison@stats.ox.ac.uk>
To: emacs-devel@gnu.org
Subject: File local variable name containing ':'
Date: Thu, 02 Sep 2010 19:56:04 -0400 [thread overview]
Message-ID: <87r5hbzomj.fsf@stats.ox.ac.uk> (raw)
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---
next reply other threads:[~2010-09-02 23:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 23:56 Dan Davison [this message]
2010-09-03 7:57 ` File local variable name containing ':' Andreas Schwab
2010-09-03 10:53 ` Stefan Monnier
2010-09-03 14:35 ` Dan Davison
2010-09-03 21:27 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r5hbzomj.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).