emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

files.el


From: Luc Teirlinck
Subject: files.el
Date: Fri, 13 May 2005 21:07:58 -0500 (CDT)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]