From 7e3a535fb8e85da585478aaaa2e0502c007c556f Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 12 Apr 2002 17:39:33 +0000 Subject: [PATCH] (hack-one-local-variable): Clear text props from string value. Recognize several additional patterns as risky. Mark many more variables as risky. (file-expand-wildcards): Use save-match-data. (format-alist): Mark as risky. --- lisp/ChangeLog | 8 ++++ lisp/files.el | 104 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 79 insertions(+), 33 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 86b64dbd356..415841d5856 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2002-04-12 Richard M. Stallman + + * files.el (hack-one-local-variable): Clear text props from string + value. Recognize several additional patterns as risky. Mark many + more variables as risky. + (file-expand-wildcards): Use save-match-data. + (format-alist): Mark as risky. + 2002-04-12 Tom Tromey * progmodes/tcl.el (tcl-do-fill-paragraph): Find and fill on more diff --git a/lisp/files.el b/lisp/files.el index e9ced2fc033..a42038b7fcc 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1862,11 +1862,18 @@ is specified, returning t if it is specified." (put 'ignored-local-variables 'risky-local-variable t) (put 'eval 'risky-local-variable t) (put 'file-name-handler-alist 'risky-local-variable t) +(put 'minor-mode-alist 'risky-local-variable t) (put 'minor-mode-map-alist 'risky-local-variable t) +(put 'minor-mode-overriding-map-alist 'risky-local-variable t) +(put 'overriding-local-map 'risky-local-variable t) +(put 'overriding-terminal-local-map 'risky-local-variable t) +(put 'auto-mode-alist 'risky-local-variable t) (put 'after-load-alist 'risky-local-variable t) (put 'buffer-file-name 'risky-local-variable t) +(put 'buffer-undo-list 'risky-local-variable t) (put 'buffer-auto-save-file-name 'risky-local-variable t) (put 'buffer-file-truename 'risky-local-variable t) +(put 'default-text-properties 'risky-local-variable t) (put 'exec-path 'risky-local-variable t) (put 'load-path 'risky-local-variable t) (put 'exec-directory 'risky-local-variable t) @@ -1876,6 +1883,27 @@ is specified, returning t if it is specified." ;; Don't wait for outline.el to be loaded, for the sake of outline-minor-mode. (put 'outline-level 'risky-local-variable t) (put 'rmail-output-file-alist 'risky-local-variable t) +(put 'special-display-buffer-names 'risky-local-variable t) +(put 'frame-title-format 'risky-local-variable t) +(put 'global-mode-string 'risky-local-variable t) +(put 'header-line-format 'risky-local-variable t) +(put 'icon-title-format 'risky-local-variable t) +(put 'input-method-alist 'risky-local-variable t) +(put 'format-alist 'risky-local-variable t) +(put 'vc-mode 'risky-local-variable t) +(put 'imenu-generic-expression 'risky-local-variable t) +(put 'imenu-index-alist 'risky-local-variable t) +(put 'standard-input 'risky-local-variable t) +(put 'standard-output 'risky-local-variable t) +(put 'unread-command-events 'risky-local-variable t) +(put 'max-lisp-eval-depth 'risky-local-variable t) +(put 'max-specpdl-size 'risky-local-variable t) +(put 'mode-line-format 'risky-local-variable t) +(put 'mode-line-modified 'risky-local-variable t) +(put 'mode-line-mule-info 'risky-local-variable t) +(put 'mode-line-buffer-identification 'risky-local-variable t) +(put 'mode-line-modes 'risky-local-variable t) +(put 'mode-line-position 'risky-local-variable t) ;; This one is safe because the user gets to check it before it is used. (put 'compile-command 'safe-local-variable t) @@ -1885,7 +1913,8 @@ is specified, returning t if it is specified." (defun hack-one-local-variable (var val) "\"Set\" one variable in a local variables spec. -A few variable names are treated specially." +A few patterns are specified so that any name which matches one +is considered risky." (cond ((eq var 'mode) (funcall (intern (concat (downcase (symbol-name val)) "-mode")))) @@ -1898,7 +1927,7 @@ A few variable names are treated specially." ;; Likewise for setting hook variables. ((or (get var 'risky-local-variable) (and - (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$" + (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$" (symbol-name var)) (not (get var 'safe-local-variable)))) ;; Permit evalling a put of a harmless property. @@ -1935,6 +1964,11 @@ A few variable names are treated specially." (message "Ignoring `eval:' in the local variables list"))) ;; Ordinary variable, really set it. (t (make-local-variable var) + ;; Make sure the string has no text properties. + ;; Some text properties can get evaluated in various ways, + ;; so it is risky to put them on with a local variable list. + (if (stringp val) + (set-text-properties 0 (length val) nil val)) (set var val)))) @@ -3416,37 +3450,41 @@ If PATTERN is written as a relative file name, it is interpreted relative to the current default directory, `default-directory'. The file names returned are normally also relative to the current default directory. However, if FULL is non-nil, they are absolute." - (let* ((nondir (file-name-nondirectory pattern)) - (dirpart (file-name-directory pattern)) - ;; A list of all dirs that DIRPART specifies. - ;; This can be more than one dir - ;; if DIRPART contains wildcards. - (dirs (if (and dirpart (string-match "[[*?]" dirpart)) - (mapcar 'file-name-as-directory - (file-expand-wildcards (directory-file-name dirpart))) - (list dirpart))) - contents) - (while dirs - (when (or (null (car dirs)) ; Possible if DIRPART is not wild. - (file-directory-p (directory-file-name (car dirs)))) - (let ((this-dir-contents - ;; Filter out "." and ".." - (delq nil - (mapcar #'(lambda (name) - (unless (string-match "\\`\\.\\.?\\'" - (file-name-nondirectory name)) - name)) - (directory-files (or (car dirs) ".") full - (wildcard-to-regexp nondir)))))) - (setq contents - (nconc - (if (and (car dirs) (not full)) - (mapcar (function (lambda (name) (concat (car dirs) name))) - this-dir-contents) - this-dir-contents) - contents)))) - (setq dirs (cdr dirs))) - contents)) + (save-match-data + (let* ((nondir (file-name-nondirectory pattern)) + (dirpart (file-name-directory pattern)) + ;; A list of all dirs that DIRPART specifies. + ;; This can be more than one dir + ;; if DIRPART contains wildcards. + (dirs (if (and dirpart (string-match "[[*?]" dirpart)) + (mapcar 'file-name-as-directory + (file-expand-wildcards + (directory-file-name dirpart))) + (list dirpart))) + contents) + (while dirs + (when (or (null (car dirs)) ; Possible if DIRPART is not wild. + (file-directory-p (directory-file-name (car dirs)))) + (let ((this-dir-contents + ;; Filter out "." and ".." + (delq nil + (mapcar #'(lambda (name) + (unless (string-match + "\\`\\.\\.?\\'" + (file-name-nondirectory name)) + name)) + (directory-files (or (car dirs) ".") full + (wildcard-to-regexp nondir)))))) + (setq contents + (nconc + (if (and (car dirs) (not full)) + (mapcar + (function (lambda (name) (concat (car dirs) name))) + this-dir-contents) + this-dir-contents) + contents)))) + (setq dirs (cdr dirs))) + contents))) (defun list-directory (dirname &optional verbose) "Display a list of files in or matching DIRNAME, a la `ls'. -- 2.39.2