* bug#14089: 24.3; file local variables can't have a colon in their name
@ 2013-03-29 19:01 schulte.eric
2013-04-03 12:14 ` Bastien
2013-04-14 1:01 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: schulte.eric @ 2013-03-29 19:01 UTC (permalink / raw)
To: 14089
[-- Attachment #1: Type: text/plain, Size: 205 bytes --]
To reproduce this bug, try to open a file like the attached Org-mode
file. The phrase "Malformed mode-line" will be echoed in the
mini-buffer even though this file uses legal file local variable syntax.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bug-example.org --]
[-- Type: text/x-org, Size: 430 bytes --]
# -*- org-babel-default-header-args:R ((session . "R")) -*-
#+Title: Example Demonstrating a File Local Variable Bug
#+Author: Eric Schulte
#+Date: <2013-03-29 Fri>
This `hack-local-variables-prop-line' function chokes on this variable
name. To my knowledge it is legal to have a ":" in a variable name,
and this practice is widely used in Org-mode, specifically in
variables which one would want to set in a file local manner.
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
This patch fixes this bug, I've signed the Emacs FSF copyright
assignment papers, but it is a tiny patch so it shouldn't matter.
Thanks!
[-- Attachment #4: temporary-file-variables-w-colons.txt --]
[-- Type: text/plain, Size: 2593 bytes --]
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: schulte.eric@gmail.com-20130328230926-46be4fl21w1g28wc
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
# testament_sha1: 969600ed8b879f2317f13e9f06968aafad4f786d
# timestamp: 2013-03-28 17:09:47 -0600
# base_revision_id: monnier@iro.umontreal.ca-20130328163306-\
# 419khox8aneaoaxv
#
# Begin patch
=== modified file 'lisp/files.el'
--- lisp/files.el 2013-03-24 06:42:25 +0000
+++ lisp/files.el 2013-03-28 23:09:26 +0000
@@ -3058,7 +3058,11 @@
(while (and (or (not mode-only)
(not result))
(< (point) end))
- (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
+ ;; The first of these next two regexs handles the
+ ;; case when a variable name includes a ":", such as
+ ;; the `org-babel-default-header-args:R' variable.
+ (unless (or (looking-at "[ \t]*\\([^ \t\n]?+\\)[ \t]*:[ \t]*")
+ (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*"))
(message "Malformed mode-line")
(throw 'malformed-line nil))
(goto-char (match-end 0))
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWUbmhKQAAan/gAAyACBQ////
0gAcD/////BQA80t1o3vPXpy93vdCSSJiMIGmJNhCT9FNMninqBiY0CDJEniaZNJ6T0oYR6gAAAA
AAyTEmSnhRmkDT1AAyDQB6hoADakmp5DRTam1DajamgA0PUAaAAAkkmkwmFPJijRkzRAAHqAGgAz
S1WEfhTwKtT3Lzh0ptUwFljq3RvPzgDg4+hi9JNFWatAiacBNp3IkDC56rp8faNALW4WJH9ce0I4
Z3GPJC6C2Mb/dxhkm8cOfdIQ66fN3VUdhn4rW+w5H6/o92st+ja2A7xflnsZ06UJhX+y7kGzooqq
7W3cVuusjwpFyfSvT2myqcZODnTyKrAEMOEEaFAZApCpsCwwBUubxmdbx0obNO9dlFeiheV1LyDX
grJNYIaa/OZTZslmmUv7NSjYTFSk0HuVurzo5oI0iIlY6e7GirGiM9qyooTyBr4gzgBdrWq+Udoe
0ELOU2gsNRtBGh50VBsck88MdLUo+pMxY1mqNkZFkcH8gVyOKsQDBAUtQV1RrZdWaaXBQEh+HE2Q
kWgqVFNjBZWqkg2pKMldeUECX3XNq1r2CtxigWqRU0OaIkCCVas9HdcHxV+nLC8RBtcVmSA7SxMZ
lwmjRRgRp2L4OsGG70jewey+edEe9QsThoPhM5SSi9uw8jxVmjPJsysa316MLrg4yithl8O1FIx2
kx7GAZzYWEYDCjyehjfA4NODyIKlnHwdst+b6fwry3abeeHKHYZrQ1gPqOmhUQTyKFRZZUcuSiqp
fIVPxXdinnCWLtFgZlnmXMvCh31Y6oR6F1mRwbL00PMnsNGv4VJfH63gBQrSAFt2TFK9pSLnQIUs
UEFLiW0xQw6o1drbk1zomZn0mlK6/l1Z1i/dpsovmyXGNUqwMRMb5wOO+4BiSsMIWzRm7CEds32t
xSnyoRc8RLKQ0YK1qmSsgqRtgjenIw0zyJ+3ZXoWrebSiyCwcsp67r24c2dGLM4pHGjGLGjH7AP9
/hT1q4JHj3qme3tF4qRBYqISdCql/Uzk+8rA3UoDaUwY2PDLU/IFNql4g1W3xQa7jkVwazlnC1Xg
bcAUimCaAIYmZiBzlVrw524UmJwhskwG4DTYolplKIXliWBxlgZsB4MzXkHiZKaaYz5CjEbRQJxB
wxlfWTlI6mdWCDgOSQMw0X7QHH/SKlmxuydL7cEQqDEdmqoZsyqoSoGVLDqORLbUOwFGCE7rGkzW
tXehClq6UIvm2YaBqeCIc0js7FE4NKr4IjM2IK2kU9OW5+kBzyGEE5o1MnSclPbVJUJUhMxGO6ak
Kb5XiWBuQ0UmBkKFYFeIWApYzQralEo0UqwMw60f/i7kinChII3NCUg=
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#14089: 24.3; file local variables can't have a colon in their name
2013-03-29 19:01 bug#14089: 24.3; file local variables can't have a colon in their name schulte.eric
@ 2013-04-03 12:14 ` Bastien
2013-04-03 14:31 ` Eric Schulte
2013-04-03 22:19 ` Stefan Monnier
2013-04-14 1:01 ` Stefan Monnier
1 sibling, 2 replies; 6+ messages in thread
From: Bastien @ 2013-04-03 12:14 UTC (permalink / raw)
To: schulte.eric; +Cc: 14089
[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]
Hi Eric,
here is an updated patch for handling this.
The idea is to allow ":" in mode's names and variables names.
No need to use two `looking-at' in this case I think.
I'll submit the patch to emacs-devel and apply it if it's good.
Thanks,
schulte.eric@gmail.com writes:
> === modified file 'lisp/files.el'
> --- lisp/files.el 2013-03-24 06:42:25 +0000
> +++ lisp/files.el 2013-03-28 23:09:26 +0000
> @@ -3058,7 +3058,11 @@
> (while (and (or (not mode-only)
> (not result))
> (< (point) end))
> - (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
> + ;; The first of these next two regexs handles the
> + ;; case when a variable name includes a ":", such as
> + ;; the `org-babel-default-header-args:R' variable.
> + (unless (or (looking-at "[ \t]*\\([^ \t\n]?+\\)[ \t]*:[ \t]*")
> + (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*"))
> (message "Malformed mode-line")
> (throw 'malformed-line nil))
> (goto-char (match-end 0))
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: files.el.patch --]
[-- Type: text/x-patch, Size: 784 bytes --]
=== modified file 'lisp/files.el'
--- lisp/files.el 2013-03-24 06:42:25 +0000
+++ lisp/files.el 2013-04-03 12:07:47 +0000
@@ -3046,7 +3046,7 @@
result)
(cond ((not end)
nil)
- ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)")
+ ((looking-at "[ \t]*\\([^ \t\n\r;]+\\)\\([ \t]*-\\*-\\)")
;; Simple form: "-*- MODENAME -*-".
(if mode-only
(intern (concat (match-string 1) "-mode"))))
@@ -3058,7 +3058,7 @@
(while (and (or (not mode-only)
(not result))
(< (point) end))
- (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
+ (unless (looking-at "[ \t]*\\([^ \t\n]+\\)[ \t]*:[ \t]*")
(message "Malformed mode-line")
(throw 'malformed-line nil))
(goto-char (match-end 0))
[-- Attachment #3: Type: text/plain, Size: 14 bytes --]
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#14089: 24.3; file local variables can't have a colon in their name
2013-04-03 12:14 ` Bastien
@ 2013-04-03 14:31 ` Eric Schulte
2013-04-03 22:19 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Eric Schulte @ 2013-04-03 14:31 UTC (permalink / raw)
To: Bastien; +Cc: 14089
Bastien <bzg@altern.org> writes:
> Hi Eric,
>
> here is an updated patch for handling this.
>
> The idea is to allow ":" in mode's names and variables names.
> No need to use two `looking-at' in this case I think.
>
> I'll submit the patch to emacs-devel and apply it if it's good.
>
Fantastic, Thanks.
>
> Thanks,
>
> schulte.eric@gmail.com writes:
>
>> === modified file 'lisp/files.el'
>> --- lisp/files.el 2013-03-24 06:42:25 +0000
>> +++ lisp/files.el 2013-03-28 23:09:26 +0000
>> @@ -3058,7 +3058,11 @@
>> (while (and (or (not mode-only)
>> (not result))
>> (< (point) end))
>> - (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
>> + ;; The first of these next two regexs handles the
>> + ;; case when a variable name includes a ":", such as
>> + ;; the `org-babel-default-header-args:R' variable.
>> + (unless (or (looking-at "[ \t]*\\([^ \t\n]?+\\)[ \t]*:[ \t]*")
>> + (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*"))
>> (message "Malformed mode-line")
>> (throw 'malformed-line nil))
>> (goto-char (match-end 0))
--
Eric Schulte
http://cs.unm.edu/~eschulte
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#14089: 24.3; file local variables can't have a colon in their name
2013-04-03 12:14 ` Bastien
2013-04-03 14:31 ` Eric Schulte
@ 2013-04-03 22:19 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2013-04-03 22:19 UTC (permalink / raw)
To: Bastien; +Cc: 14089, schulte.eric
> The idea is to allow ":" in mode's names and variables names.
> No need to use two `looking-at' in this case I think.
Agreed, except that other than SPC \t and \n e need to disallow ", (),
and ;. Also we read those names in hack-local-variables with things like
skip-chars-forward and that needs to be fixed there as well (probably
using looking-at). And we should share the regexp between the various
places where we match those names.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#14089: 24.3; file local variables can't have a colon in their name
2013-03-29 19:01 bug#14089: 24.3; file local variables can't have a colon in their name schulte.eric
2013-04-03 12:14 ` Bastien
@ 2013-04-14 1:01 ` Stefan Monnier
2013-04-14 6:57 ` Bastien
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-04-14 1:01 UTC (permalink / raw)
To: 14089-done
I installed the patch below which should make it possible to have colons
in local variables.
Stefan
=== modified file 'lisp/files.el'
--- lisp/files.el 2013-04-06 07:41:09 +0000
+++ lisp/files.el 2013-04-14 00:56:39 +0000
@@ -3029,6 +3029,9 @@
(prog1 (memq char '(?! ?\s ?y))
(quit-window t)))))))
+(defconst hack-local-variable-regexp
+ "[ \t]*\\([^][;\"'?()\\ \t\n]+\\)[ \t]*:[ \t]*")
+
(defun hack-local-variables-prop-line (&optional mode-only)
"Return local variables specified in the -*- line.
Returns an alist of elements (VAR . VAL), where VAR is a variable
@@ -3055,11 +3058,11 @@
;; (last ";" is optional).
;; If MODE-ONLY, just check for `mode'.
;; Otherwise, parse the -*- line into the RESULT alist.
- (while (and (or (not mode-only)
- (not result))
- (< (point) end))
- (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
- (message "Malformed mode-line")
+ (while (not (or (and mode-only result)
+ (>= (point) end)))
+ (unless (looking-at hack-local-variable-regexp)
+ (message "Malformed mode-line: %S"
+ (buffer-substring-no-properties (point) end))
(throw 'malformed-line nil))
(goto-char (match-end 0))
;; There used to be a downcase here,
@@ -3211,8 +3214,7 @@
(prefix
(concat "^" (regexp-quote
(buffer-substring (line-beginning-position)
- (match-beginning 0)))))
- beg)
+ (match-beginning 0))))))
(forward-line 1)
(let ((startpos (point))
@@ -3247,18 +3249,16 @@
(forward-line 1))
(goto-char (point-min))
- (while (and (not (eobp))
- (or (not mode-only)
- (not result)))
- ;; 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-backward " \t")
- (let* ((str (buffer-substring beg (point)))
- (var (let ((read-circle nil))
- (read str)))
+ (while (not (or (eobp)
+ (and mode-only result)))
+ ;; Find the variable name;
+ (unless (looking-at hack-local-variable-regexp)
+ (error "Malformed local variable line: %S"
+ (buffer-substring-no-properties
+ (point) (line-end-position))))
+ (goto-char (match-end 1))
+ (let* ((str (match-string 1))
+ (var (intern str))
val val2)
(and (equal (downcase (symbol-name var)) "mode")
(setq var 'mode))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#14089: 24.3; file local variables can't have a colon in their name
2013-04-14 1:01 ` Stefan Monnier
@ 2013-04-14 6:57 ` Bastien
0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2013-04-14 6:57 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 14089-done
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> I installed the patch below which should make it possible to have colons
> in local variables.
Thanks a lot!
--
Bastien
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-04-14 6:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29 19:01 bug#14089: 24.3; file local variables can't have a colon in their name schulte.eric
2013-04-03 12:14 ` Bastien
2013-04-03 14:31 ` Eric Schulte
2013-04-03 22:19 ` Stefan Monnier
2013-04-14 1:01 ` Stefan Monnier
2013-04-14 6:57 ` Bastien
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).