Skip to main content
Rollback to Revision 5
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28

Yes, possible. You need to change the definition of hack-local-variables-confirm. Find the form (customize-push-and-save (if (= char ?!) ...)) and modify it.

I agree with you to some extent: these should be put into another file. But to be honest, I don’t recommend you change the function’s definition, because this is not elegant, so maybe we'll wait and see if there's any other way.


BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(setqlet custom((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
 "SOMEWHERE                                 (when (file-ELSE/customexists-p file-path)
                                    (with-temp-buffer
                                      (insert-file-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir-locals.el"
                                 "~/.emacs.d/.dir-locals-2.el"
                                 ;; Files that you trust ...
                                 ])))
    (loaddolist custom(mode-filevars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values
                                          safe-local-variable-values)))
(setq custom-file "SOMEWHERE-ELSE/custom-file.el")
(load custom-file)

Yes, possible. You need to change the definition of hack-local-variables-confirm. Find the form (customize-push-and-save (if (= char ?!) ...)) and modify it.

I agree with you to some extent: these should be put into another file. But to be honest, I don’t recommend you change the function’s definition, because this is not elegant, so maybe we'll wait and see if there's any other way.


BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(let ((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
                                  (when (file-exists-p file-path)
                                    (with-temp-buffer
                                      (insert-file-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir-locals.el"
                                 "~/.emacs.d/.dir-locals-2.el"
                                 ;; Files that you trust ...
                                 ])))
    (dolist (mode-vars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values
                                          safe-local-variable-values)))
deleted 1976 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28

Yes, possible. You need to change the definition of hack-local-variables-confirm. Find the form (customize-push-and-save (if (= char ?!) ...)) and modify it.

I agree with you to some extent: these should be put into another file. But to be honest, I don’t recommend you change the function’s definition, because this is not elegant, so maybe we'll wait and see if there's any other way.


BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(let ((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
                                  (when (file-exists-p file-path)
                                    (with-temp-buffer
                                     setq (insert-filecustom-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir"SOMEWHERE-locals.el"
                                 "~/.emacs.dELSE/.dir-localscustom-2file.el"
                                 ;; Files that you trust ...
                                 ])))
    (dolist (mode-vars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values
                                         load safe-local-variablecustom-values))file)

Yes, possible. You need to change the definition of hack-local-variables-confirm. Find the form (customize-push-and-save (if (= char ?!) ...)) and modify it.

I agree with you to some extent: these should be put into another file. But to be honest, I don’t recommend you change the function’s definition, because this is not elegant, so maybe we'll wait and see if there's any other way.


BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(let ((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
                                  (when (file-exists-p file-path)
                                    (with-temp-buffer
                                      (insert-file-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir-locals.el"
                                 "~/.emacs.d/.dir-locals-2.el"
                                 ;; Files that you trust ...
                                 ])))
    (dolist (mode-vars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values
                                          safe-local-variable-values)))
(setq custom-file "SOMEWHERE-ELSE/custom-file.el")
(load custom-file)
added 147 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28

BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(let ((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
                                  (when (file-exists-p file-path)
                                    (with-temp-buffer
                                      (insert-file-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir-locals.el"
                                 "~/.emacs.d/.dir-locals-2.el"
                                 ;; Files that you trust ...
                                 ])))
    (dolist (mode-vars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values
                                          safe-local-variable-values)))

BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question, but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(let ((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
                                  (when (file-exists-p file-path)
                                    (with-temp-buffer
                                      (insert-file-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir-locals.el"
                                 "~/.emacs.d/.dir-locals-2.el"
                                 ;; Files that you trust ...
                                 ])))
    (dolist (mode-vars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values safe-local-variable-values)))

BTW, you can take a look at my code. (Please ignore the coding style; I will refactor it someday but not now.) try the code shown below. It doesn't answer your question (or, you could say that it answers, because the files that you trust are where the safe variables are.), but does solve your problem: you just need to put the .dir-locals.el file’s path to your .emacs, then Emacs will never ask you to confirm, because these variables are stored in safe-local-variable-values and thus considered safe:

(let ((shynur/safe-local-variable-values (list)))
  (named-let get-vars ((dir-locals
                        (mapcan (lambda (file-path)
                                  (when (file-exists-p file-path)
                                    (with-temp-buffer
                                      (insert-file-contents file-path)
                                      (read (current-buffer)))))
                                ["~/.emacs.d/.dir-locals.el"
                                 "~/.emacs.d/.dir-locals-2.el"
                                 ;; Files that you trust ...
                                 ])))
    (dolist (mode-vars dir-locals)
      (let ((vars (cdr mode-vars)))
        (if (stringp (car mode-vars))
            (get-vars vars)
          (dolist (var-pair vars)
            (push var-pair shynur/safe-local-variable-values))))))
  (setq safe-local-variable-values (nconc shynur/safe-local-variable-values
                                          safe-local-variable-values)))
added 1085 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading
added 397 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading
Post Undeleted by shynur
added 260 characters in body
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading
Post Deleted by shynur
Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28
Loading