Subject: bug#9820: 24.0.90; Behaviour of add-file-local-variable

From: Juri Linkov <[email-masked]>
Date: Fri, 21 Oct 2011 17:06:10 +0300

> Transcripts of exchanges on emacs-devel.
> http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00850.html
> http://lists.gnu.org/archive/html/emacs-devel/2011-10/msg00867.html

Thanks for filing the bug report based on that discussion.
As suggested, the following patch implements displaying a message.

> Additional note: All other file-local related commands may have to be
> audited for the requested behaviour.

It displays a message only in `add-file-local-variable' and
`add-file-local-variable-prop-line'.  I have no opinion
what other commands might do.

=== modified file 'lisp/files-x.el'
--- lisp/files-x.el	2011-04-19 13:44:55 +0000
+++ lisp/files-x.el	2011-10-21 14:04:22 +0000
@@ -214,7 +214,11 @@ (defun add-file-local-variable (variable
   (interactive
    (let ((variable (read-file-local-variable "Add file-local variable")))
      (list variable (read-file-local-variable-value variable))))
-  (modify-file-local-variable variable value 'add-or-replace))
+  (modify-file-local-variable variable value 'add-or-replace)
+  (when (and (called-interactively-p 'interactive)
+	     (symbolp variable) (boundp variable)
+	     (not (equal (symbol-value variable) value)))
+    (message "Revisit file to make this change take effect")))
 
 ;;;###autoload
 (defun delete-file-local-variable (variable)
@@ -335,7 +339,11 @@ (defun add-file-local-variable-prop-line
   (interactive
    (let ((variable (read-file-local-variable "Add -*- file-local variable")))
      (list variable (read-file-local-variable-value variable))))
-  (modify-file-local-variable-prop-line variable value 'add-or-replace))
+  (modify-file-local-variable-prop-line variable value 'add-or-replace)
+  (when (and (called-interactively-p 'interactive)
+	     (symbolp variable) (boundp variable)
+	     (not (equal (symbol-value variable) value)))
+    (message "Revisit file to make this change take effect")))
 
 ;;;###autoload
 (defun delete-file-local-variable-prop-line (variable)