aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2013-06-16 01:44:38 +0300
committerJuri Linkov2013-06-16 01:44:38 +0300
commit31489a32f575cb5cfcd8748355f46ae2afcc4436 (patch)
treeaaeeaaaef9d43dcc3f89a8cbd81fb876a4554ef1
parent2809512e049af026719414c93998d3098a8735c5 (diff)
downloademacs-31489a32f575cb5cfcd8748355f46ae2afcc4436.tar.gz
emacs-31489a32f575cb5cfcd8748355f46ae2afcc4436.zip
* lisp/files-x.el (modify-file-local-variable-prop-line): Add local
variables to the end of the existing comment on the first line. Use `file-auto-mode-skip' to skip interpreter magic line, and also skip XML declaration.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/files-x.el41
2 files changed, 38 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 919772659ea..f7f42011575 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-06-15 Juri Linkov <juri@jurta.org>
2
3 * files-x.el (modify-file-local-variable-prop-line): Add local
4 variables to the end of the existing comment on the first line.
5 Use `file-auto-mode-skip' to skip interpreter magic line,
6 and also skip XML declaration.
7
12013-06-15 Stefan Monnier <monnier@iro.umontreal.ca> 82013-06-15 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * startup.el (package--builtin-versions): New var. 10 * startup.el (package--builtin-versions): New var.
diff --git a/lisp/files-x.el b/lisp/files-x.el
index 0ba245d423a..2ae1a0e4045 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -256,19 +256,40 @@ from the -*- line ignoring the input argument VALUE."
256 256
257 (goto-char (point-min)) 257 (goto-char (point-min))
258 258
259 ;; Skip interpreter magic line "#!" 259 ;; Skip interpreter magic line "#!" or XML declaration.
260 (when (looking-at "^\\(#!\\|'\\\\\"\\)") 260 (when (or (looking-at file-auto-mode-skip)
261 (looking-at "<\\?xml[^>\n]*>$"))
261 (forward-line 1)) 262 (forward-line 1))
262 263
264 (comment-normalize-vars)
263 (let ((comment-style 'plain) 265 (let ((comment-style 'plain)
264 (comment-start (or comment-start ";;; "))) 266 (comment-start (or comment-start ";;; "))
265 (comment-region 267 (line-beg (line-beginning-position))
266 (prog1 (point) 268 (ce nil))
267 (insert "-*-") 269 ;; If the first line contains a comment.
268 (setq beg (point-marker)) 270 (if (save-excursion
269 (setq end (point-marker)) 271 (and (looking-at comment-start-skip)
270 (insert "-*-\n")) 272 (goto-char (match-end 0))
271 (point)))) 273 (re-search-forward comment-end-skip)
274 (goto-char (match-beginning 0))
275 ;; Still on the same line?
276 (equal line-beg (line-beginning-position))
277 (setq ce (point))))
278 ;; Add local variables to the end of the existing comment.
279 (progn
280 (goto-char ce)
281 (insert " -*-")
282 (setq beg (point-marker))
283 (setq end (point-marker))
284 (insert "-*-"))
285 ;; Otherwise, add a new comment before the first line.
286 (comment-region
287 (prog1 (point)
288 (insert "-*-")
289 (setq beg (point-marker))
290 (setq end (point-marker))
291 (insert "-*-\n"))
292 (point)))))
272 293
273 (cond 294 (cond
274 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") 295 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)")