[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113002: * lisp/files-x.el (modify-file-local-variab
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] trunk r113002: * lisp/files-x.el (modify-file-local-variable-prop-line): Add local |
Date: |
Sat, 15 Jun 2013 22:44:43 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113002
revision-id: address@hidden
parent: address@hidden
committer: Juri Linkov <address@hidden>
branch nick: trunk
timestamp: Sun 2013-06-16 01:44:38 +0300
message:
* 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.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/files-x.el filesx.el-20091113204419-o5vbwnq5f7feedwu-10917
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-06-15 15:36:11 +0000
+++ b/lisp/ChangeLog 2013-06-15 22:44:38 +0000
@@ -1,3 +1,10 @@
+2013-06-15 Juri Linkov <address@hidden>
+
+ * 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.
+
2013-06-15 Stefan Monnier <address@hidden>
* startup.el (package--builtin-versions): New var.
=== modified file 'lisp/files-x.el'
--- a/lisp/files-x.el 2013-01-01 09:11:05 +0000
+++ b/lisp/files-x.el 2013-06-15 22:44:38 +0000
@@ -256,19 +256,40 @@
(goto-char (point-min))
- ;; Skip interpreter magic line "#!"
- (when (looking-at "^\\(#!\\|'\\\\\"\\)")
+ ;; Skip interpreter magic line "#!" or XML declaration.
+ (when (or (looking-at file-auto-mode-skip)
+ (looking-at "<\\?xml[^>\n]*>$"))
(forward-line 1))
+ (comment-normalize-vars)
(let ((comment-style 'plain)
- (comment-start (or comment-start ";;; ")))
- (comment-region
- (prog1 (point)
- (insert "-*-")
- (setq beg (point-marker))
- (setq end (point-marker))
- (insert "-*-\n"))
- (point))))
+ (comment-start (or comment-start ";;; "))
+ (line-beg (line-beginning-position))
+ (ce nil))
+ ;; If the first line contains a comment.
+ (if (save-excursion
+ (and (looking-at comment-start-skip)
+ (goto-char (match-end 0))
+ (re-search-forward comment-end-skip)
+ (goto-char (match-beginning 0))
+ ;; Still on the same line?
+ (equal line-beg (line-beginning-position))
+ (setq ce (point))))
+ ;; Add local variables to the end of the existing comment.
+ (progn
+ (goto-char ce)
+ (insert " -*-")
+ (setq beg (point-marker))
+ (setq end (point-marker))
+ (insert "-*-"))
+ ;; Otherwise, add a new comment before the first line.
+ (comment-region
+ (prog1 (point)
+ (insert "-*-")
+ (setq beg (point-marker))
+ (setq end (point-marker))
+ (insert "-*-\n"))
+ (point)))))
(cond
((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113002: * lisp/files-x.el (modify-file-local-variable-prop-line): Add local,
Juri Linkov <=