[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 7ac8bcaacc1: Merge remote-tracking branch 'origin/master
From: |
Po Lu |
Subject: |
feature/android 7ac8bcaacc1: Merge remote-tracking branch 'origin/master' into feature/android |
Date: |
Thu, 11 May 2023 22:44:12 -0400 (EDT) |
branch: feature/android
commit 7ac8bcaacc1f3dbbda3febe09dde6d18a2d69729
Merge: 140c5bffc64 30501083f2f
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Merge remote-tracking branch 'origin/master' into feature/android
---
doc/emacs/custom.texi | 20 ++++++++++++++++++++
doc/lispref/variables.texi | 12 ++++++++++++
etc/NEWS | 4 ++++
lisp/dynamic-setting.el | 1 +
lisp/files.el | 37 ++++++++++++++++++++++++++++++++-----
lisp/net/soap-client.el | 13 ++++++++-----
lisp/progmodes/prog-mode.el | 1 +
lisp/term/haiku-win.el | 3 +++
lisp/x-dnd.el | 3 +++
src/lread.c | 14 ++++----------
test/lisp/files-tests.el | 21 +++++++++++++++++++++
11 files changed, 109 insertions(+), 20 deletions(-)
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 87290734cc9..d8abf81c75f 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1328,6 +1328,15 @@ pairs in the file, by typing @kbd{i} at the confirmation
prompt --
these pairs will thereafter be ignored in this file and in all other
files.
+ When Emacs asks for confirmation for setting directory-local
+variables (@pxref{Directory Variables}), typing @kbd{+} at the
+confirmation prompt will set all the variables, and also add the
+directory to the list in @code{safe-local-variable-directories}
+(described below), which will cause Emacs to consider this directory
+as safe for loading any directory-local variables in the future. The
+@kbd{+} response should only be used for directories whose contents
+you trust.
+
@vindex safe-local-variable-values
@vindex ignored-local-variable-values
@cindex risky variable
@@ -1344,6 +1353,17 @@ record safe values for risky variables, do it directly
by customizing
Similarly, if you want to record values of risky variables that should
be permanently ignored, customize @code{ignored-local-variable-values}.
+@vindex safe-local-variable-directories
+ Sometimes it is helpful to always trust directory-variables in
+certain directories, and skip the confirmation prompt when local
+variables are loaded from those directories, even if the variables are
+risky. The variable @code{safe-local-variable-directories} holds the
+list of such directories. The names of the directories in this list
+must be full absolute file names, and should end in a slash. If the
+variable @code{enable-remote-dir-locals} has a non-@code{nil} value,
+the list can include remote directories as well (@pxref{Remote
+Files}).
+
@vindex enable-local-variables
The variable @code{enable-local-variables} allows you to change the
way Emacs processes local variables. Its default value is @code{t},
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index eadb5c36de6..b3a8cd8110c 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1977,6 +1977,18 @@ this can be controlled by using this variable, which is
a list of
symbols.
@end defvar
+@defvar safe-local-variable-directories
+This is a list of directories where local variables are always
+enabled. Directory-local variables loaded from these directories,
+such as the variables in @file{.dir-locals.el}, will be enabled even
+if they are risky. The directories in this list must be
+fully-expanded absolute file names that end in a directory separator
+character. They may also be remote directories if the variable
+@code{enable-remote-dir-locals} is set non-@code{nil}. Directories in
+this list are matched case-sensitively, even if the filesystem is
+case-sensitive.
+@end defvar
+
@defun hack-local-variables &optional handle-mode
This function parses, and binds or evaluates as appropriate, any local
variables specified by the contents of the current buffer. The variable
diff --git a/etc/NEWS b/etc/NEWS
index 673db8c8f4f..1dc4f7898e7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -417,6 +417,10 @@ The new functions 'touch-screen-track-tap' and
'touch-screen-track-drag' handle tracking common touch screen gestures
from within a command.
+** New variable 'safe-local-variable-directories'.
+This variable names directories in which Emacs will treat all
+directory-local variables as safe.
+
** New variable 'inhibit-auto-fill' to temporarily prevent auto-fill.
** Functions and variables to transpose sexps
diff --git a/lisp/dynamic-setting.el b/lisp/dynamic-setting.el
index 9ce09657345..ebe25ab9c75 100644
--- a/lisp/dynamic-setting.el
+++ b/lisp/dynamic-setting.el
@@ -33,6 +33,7 @@
;;; Customizable variables
(declare-function font-get-system-font "xsettings.c" ())
+(declare-function reconsider-frame-font "frame.c" ())
(defvar font-use-system-font)
diff --git a/lisp/files.el b/lisp/files.el
index ada37d2e9e5..9fdae107068 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -681,7 +681,8 @@ The command \\[normal-mode], when used interactively,
always obeys file local variable specifications and the -*- line,
and ignores this variable.
-Also see the `permanently-enabled-local-variables' variable."
+Also see the `permanently-enabled-local-variables' and
+`safe-local-variable-directories' variables."
:risky t
:type '(choice (const :tag "Query Unsafe" t)
(const :tag "Safe Only" :safe)
@@ -3696,6 +3697,18 @@ variable to set.")
"A list of file-local variables that are always enabled.
This overrides any `enable-local-variables' setting.")
+(defcustom safe-local-variable-directories '()
+ "A list of directories where local variables are always enabled.
+Directory-local variables loaded from these directories, such as the
+variables in .dir-locals.el, will be enabled even if they are risky.
+The names of the directories in the list must be absolute, and must
+end in a slash. Remote directories can be included if the
+variable `enable-remote-dir-locals' is non-nil."
+ :version "30.1"
+ :type '(repeat string)
+ :risky t
+ :group 'find-file)
+
(defun hack-local-variables-confirm (all-vars unsafe-vars risky-vars dir-name)
"Get confirmation before setting up local variable values.
ALL-VARS is the list of all variables to be set up.
@@ -3734,7 +3747,11 @@ n -- to ignore the local variables list.")
! -- to apply the local variables list, and permanently mark these
values (*) as safe (in the future, they will be set automatically.)
i -- to ignore the local variables list, and permanently mark these
- values (*) as ignored\n\n")
+ values (*) as ignored"
+ (if dir-name "
++ -- to apply the local variables list, and trust all directory-local
+ variables in this directory\n\n"
+ "\n\n"))
(insert "\n\n"))
(dolist (elt all-vars)
(cond ((member elt unsafe-vars)
@@ -3758,7 +3775,11 @@ i -- to ignore the local variables list, and
permanently mark these
(pop-to-buffer buf '(display-buffer--maybe-at-bottom))
(let* ((exit-chars '(?y ?n ?\s))
(prompt (format "Please type %s%s: "
- (if offer-save "y, n, ! or i" "y or n")
+ (if offer-save
+ (if dir-name
+ "y, n, !, i, +"
+ "y, n, !, i")
+ "y or n")
(if (< (line-number-at-pos (point-max))
(window-body-height))
""
@@ -3766,8 +3787,13 @@ i -- to ignore the local variables list, and
permanently mark these
char)
(when offer-save
(push ?i exit-chars)
- (push ?! exit-chars))
+ (push ?! exit-chars)
+ (when dir-name
+ (push ?+ exit-chars)))
(setq char (read-char-choice prompt exit-chars))
+ (when (and offer-save dir-name (= char ?+))
+ (customize-push-and-save 'safe-local-variable-directories
+ (list dir-name)))
(when (and offer-save
(or (= char ?!) (= char ?i))
unsafe-vars)
@@ -3776,7 +3802,7 @@ i -- to ignore the local variables list, and permanently
mark these
'safe-local-variable-values
'ignored-local-variable-values)
unsafe-vars))
- (prog1 (memq char '(?! ?\s ?y))
+ (prog1 (memq char '(?! ?\s ?y ?+))
(quit-window t)))))))
(defconst hack-local-variable-regexp
@@ -3908,6 +3934,7 @@ DIR-NAME is the name of the associated directory.
Otherwise it is nil."
(null unsafe-vars)
(null risky-vars))
(memq enable-local-variables '(:all :safe))
+ (member dir-name safe-local-variable-directories)
(hack-local-variables-confirm all-vars unsafe-vars
risky-vars dir-name))
(dolist (elt all-vars)
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el
index e4b8bbd9cb5..866b33decc6 100644
--- a/lisp/net/soap-client.el
+++ b/lisp/net/soap-client.el
@@ -5,7 +5,7 @@
;; Author: Alexandru Harsanyi <AlexHarsanyi@gmail.com>
;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
;; Created: December, 2009
-;; Version: 3.2.1
+;; Version: 3.2.2
;; Keywords: soap, web-services, comm, hypermedia
;; Package: soap-client
;; URL: https://github.com/alex-hhh/emacs-soap-client
@@ -717,9 +717,12 @@ representing leap seconds."
second)
minute hour day month year second-fraction datatype time-zone)
(let ((time
- (encode-time (list
- (if new-decode-time new-decode-time-second second)
- minute hour day month year nil nil time-zone))))
+ ;; Continue calling encode-time the old way, for backward
+ ;; compatibility in GNU ELPA.
+ (apply
+ #'encode-time (list
+ (if new-decode-time new-decode-time-second second)
+ minute hour day month year nil nil time-zone))))
(if new-decode-time
(with-no-warnings (decode-time time nil t))
(decode-time time))))))
@@ -946,7 +949,7 @@ This is a specialization of `soap-encode-attributes' for
(t nil)))
(defun soap-type-is-array? (type)
- "Return t if TYPE defines an ARRAY."
+ "Return t if TYPE is an ARRAY."
(and (soap-xs-complex-type-p type)
(eq (soap-xs-complex-type-indicator type) 'array)))
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index 7a53399ad14..16497097061 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -36,6 +36,7 @@
(declare-function treesit-available-p "treesit.c")
(declare-function treesit-parser-list "treesit.c")
(declare-function treesit-node-type "treesit.c")
+(declare-function treesit-node-at "treesit.c")
(defgroup prog-mode nil
"Generic programming mode, from which others derive."
diff --git a/lisp/term/haiku-win.el b/lisp/term/haiku-win.el
index ae5a2f2fc6b..50c9cb5b9d4 100644
--- a/lisp/term/haiku-win.el
+++ b/lisp/term/haiku-win.el
@@ -36,6 +36,9 @@
(require 'menu-bar)
(require 'fontset)
(require 'dnd)
+;; For when building a --without-x configuration, where this is not
+;; preloaded.
+(eval-when-compile (require 'mwheel))
(add-to-list 'display-format-alist '(".*" . haiku))
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index acfbbed9677..b87fc97f8fd 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -31,6 +31,9 @@
;;; Code:
(require 'dnd)
+;; For when building a --without-x configuration, where this is not
+;; preloaded.
+(eval-when-compile (require 'mwheel))
;;; Customizable variables
(defcustom x-dnd-test-function #'x-dnd-default-test-function
diff --git a/src/lread.c b/src/lread.c
index fe48e614393..1d49e7ae6cd 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2883,12 +2883,6 @@ character_name_to_code (char const *name, ptrdiff_t
name_len,
Unicode 9.0.0 the maximum is 83, so this should be safe. */
enum { UNICODE_CHARACTER_NAME_LENGTH_BOUND = 200 };
-static AVOID
-invalid_escape_syntax_error (void)
-{
- error ("Invalid escape character syntax");
-}
-
/* Read a character escape sequence, assuming we just read a backslash
and one more character (next_char). */
static int
@@ -2920,7 +2914,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
case '\n':
/* ?\LF is an error; it's probably a user mistake. */
- error ("Invalid escape character syntax");
+ error ("Invalid escape char syntax: \\<newline>");
/* \M-x etc: set modifier bit and parse the char to which it applies,
allowing for chains such as \M-\S-\A-\H-\s-\C-q. */
@@ -2944,7 +2938,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
}
else
/* \M, \S, \H, \A not followed by a hyphen is an error. */
- invalid_escape_syntax_error ();
+ error ("Invalid escape char syntax: \\%c not followed by -", c);
}
modifiers |= mod;
c1 = READCHAR;
@@ -2964,7 +2958,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
{
int c1 = READCHAR;
if (c1 != '-')
- invalid_escape_syntax_error ();
+ error ("Invalid escape char syntax: \\%c not followed by -", c);
}
FALLTHROUGH;
/* The prefixes \C- and \^ are equivalent. */
@@ -3029,7 +3023,7 @@ read_char_escape (Lisp_Object readcharfun, int next_char)
}
if (count == 0)
- invalid_escape_syntax_error ();
+ error ("Invalid escape char syntax: \\x not followed by hex digit");
if (count < 3 && i >= 0x80)
i = BYTE8_TO_CHAR (i);
modifiers |= i & CHAR_MODIFIER_MASK;
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index aadb60e1de7..e87bb3cfa0a 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -166,6 +166,27 @@ form.")
(hack-local-variables)
(should (eq lexical-binding nil)))))
+(ert-deftest files-tests-safe-local-variable-directories ()
+ ;; safe-local-variable-directories should be risky,
+ ;; so use it as an arbitrary risky variable.
+ (let ((test-alist '((safe-local-variable-directories . "some_val")))
+ (fakedir "/test1/test2/")
+ (enable-local-eval t))
+ (with-temp-buffer
+ (setq safe-local-variable-directories (list fakedir))
+ (hack-local-variables-filter test-alist fakedir)
+ (should (equal file-local-variables-alist test-alist)))
+ (with-temp-buffer
+ (setq safe-local-variable-directories (list fakedir))
+ (setq noninteractive t)
+ (hack-local-variables-filter test-alist "wrong")
+ (should-not (equal file-local-variables-alist test-alist)))
+ (with-temp-buffer
+ (setq safe-local-variable-directories '())
+ (setq noninteractive t)
+ (hack-local-variables-filter test-alist fakedir)
+ (should-not (equal file-local-variables-alist test-alist)))))
+
(defvar files-test-bug-18141-file
(ert-resource-file "files-bug18141.el.gz")
"Test file for bug#18141.")