unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Subject: files.el
Date: Fri, 13 May 2005 21:07:58 -0500 (CDT)	[thread overview]
Message-ID: <200505140207.j4E27wZ04939@raven.dms.auburn.edu> (raw)

Rev 1.765 of files.el introduced the new function
`hack-local-variables-confirm', but this was not mentioned in the ChangeLog:

    * files.el (read-directory-name): Fix previous change.

Either the omission from the ChangeLog or the change itself must have
been inadvertent.  I presume the former.

The change has two problems.  If `enable-local-variables' is 'ask, it
_always_ asks the user about the -*- line, even when it actually is
going to process a local variables list or an eval or hook local
variable.  Also, after the change, the former support for non-file
visiting buffers no longer works.

Put:

-*- mode: text; aa: 89; -*-
ahaha
Local Variables:
eval: (setq ww 345)
bb: 99
End:

in a file, and then visit that file in Emacs with
`enable-local-variables' set to 'ask.  You get asked three times an
identical question.

Copy the same text in a non file visiting buffer and do, still with
enable-local-variables set to 'ask:

M-: (hack-local-variables)

An error results.

The patch below corrects all above problems.  I can install if desired.

===File ~/files-diff========================================
*** files.el	13 May 2005 19:25:16 -0500	1.769
--- files.el	13 May 2005 20:05:31 -0500	
***************
*** 2152,2158 ****
         (goto-char beg)
         end))))
  
! (defun hack-local-variables-confirm ()
    (or (eq enable-local-variables t)
        (and enable-local-variables
  	   (save-window-excursion
--- 2152,2158 ----
         (goto-char beg)
         end))))
  
! (defun hack-local-variables-confirm (string)
    (or (eq enable-local-variables t)
        (and enable-local-variables
  	   (save-window-excursion
***************
*** 2169,2176 ****
  	     (save-excursion
  	       (beginning-of-line)
  	       (set-window-start (selected-window) (point)))
! 	     (y-or-n-p (format "Set local variables as specified in -*- line of %s? "
! 			       (file-name-nondirectory buffer-file-name)))))))
  
  (defun hack-local-variables-prop-line (&optional mode-only)
    "Set local variables specified in the -*- line.
--- 2169,2178 ----
  	     (save-excursion
  	       (beginning-of-line)
  	       (set-window-start (selected-window) (point)))
! 	     (y-or-n-p (format string
! 			       (if buffer-file-name
! 				   (file-name-nondirectory buffer-file-name)
! 				 (concat "buffer " (buffer-name)))))))))
  
  (defun hack-local-variables-prop-line (&optional mode-only)
    "Set local variables specified in the -*- line.
***************
*** 2226,2232 ****
        (if mode-only mode-specified
  	(if (and result
  		 (or mode-only
! 		     (hack-local-variables-confirm)))
  	    (let ((enable-local-eval enable-local-eval))
  	      (while result
  		(hack-one-local-variable (car (car result)) (cdr (car result)))
--- 2228,2235 ----
        (if mode-only mode-specified
  	(if (and result
  		 (or mode-only
! 		     (hack-local-variables-confirm
! 		      "Set local variables as specified in -*- line of %s? ")))
  	    (let ((enable-local-eval enable-local-eval))
  	      (while result
  		(hack-one-local-variable (car (car result)) (cdr (car result)))
***************
*** 2256,2262 ****
        (when (let ((case-fold-search t))
  	      (and (search-forward "Local Variables:" nil t)
  		   (or mode-only
! 		       (hack-local-variables-confirm))))
  	(skip-chars-forward " \t")
  	(let ((enable-local-eval enable-local-eval)
  	      ;; suffix is what comes after "local variables:" in its line.
--- 2259,2266 ----
        (when (let ((case-fold-search t))
  	      (and (search-forward "Local Variables:" nil t)
  		   (or mode-only
! 		       (hack-local-variables-confirm
! 			"Set local variables as specified at end of %s? "))))
  	(skip-chars-forward " \t")
  	(let ((enable-local-eval enable-local-eval)
  	      ;; suffix is what comes after "local variables:" in its line.
***************
*** 2477,2483 ****
  		      (hack-one-local-variable-eval-safep val))
  		 ;; Permit eval if not root and user says ok.
  		 (and (not (zerop (user-uid)))
! 		      (hack-local-variables-confirm)))
  	     (if (eq var 'eval)
  		 (save-excursion (eval val))
  	       (make-local-variable var)
--- 2481,2488 ----
  		      (hack-one-local-variable-eval-safep val))
  		 ;; Permit eval if not root and user says ok.
  		 (and (not (zerop (user-uid)))
! 		      (hack-local-variables-confirm
! 		       "Process `eval' or hook local variables in %s? ")))
  	     (if (eq var 'eval)
  		 (save-excursion (eval val))
  	       (make-local-variable var)
============================================================

             reply	other threads:[~2005-05-14  2:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-14  2:07 Luc Teirlinck [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-03-18  4:32 files.el Luc Teirlinck
2004-03-18 13:30 ` files.el Luc Teirlinck

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=200505140207.j4E27wZ04939@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    /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).