emacs-diffs
[Top][All Lists]
Advanced

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

feature/android 4fbaf6d9fe1: Merge remote-tracking branch 'origin/master


From: Po Lu
Subject: feature/android 4fbaf6d9fe1: Merge remote-tracking branch 'origin/master' into feature/android
Date: Tue, 9 May 2023 20:52:18 -0400 (EDT)

branch: feature/android
commit 4fbaf6d9fe1923d03c971a970ad4d2eef075aef3
Merge: 1230521f713 7791907c385
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Merge remote-tracking branch 'origin/master' into feature/android
---
 lisp/net/tramp-sh.el      | 38 ++++++++++++---------
 lisp/progmodes/eglot.el   | 35 ++++++++++---------
 lisp/treesit.el           |  3 +-
 src/regex-emacs.h         |  3 +-
 src/syntax.c              | 87 ++++++++++++++++++++---------------------------
 test/src/treesit-tests.el |  3 ++
 6 files changed, 81 insertions(+), 88 deletions(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index d020615af07..49e6d2d7aa9 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -4856,26 +4856,30 @@ Goes through the list `tramp-inline-compress-commands'."
          (stringp tramp-ssh-controlmaster-options))
     tramp-ssh-controlmaster-options)
 
+   ;; We can't auto-compute the options.
+   ((ignore-errors
+      (not (tramp-ssh-option-exists-p vec "ControlMaster=auto")))
+    "")
+
    ;; Determine the options.
    (t (ignore-errors
         ;; ControlMaster and ControlPath options are introduced in OpenSSH 3.9.
-       (when (tramp-ssh-option-exists-p vec "ControlMaster=auto")
-          (concat
-           "-o ControlMaster="
-           (if (eq tramp-use-connection-share 'suppress)
-               "no" "auto")
-
-           " -o ControlPath="
-           (if (eq tramp-use-connection-share 'suppress)
-               "none"
-             ;; Hashed tokens are introduced in OpenSSH 6.7.
-            (if (tramp-ssh-option-exists-p vec "ControlPath=tramp.%C")
-                "tramp.%%C" "tramp.%%r@%%h:%%p"))
-
-           ;; ControlPersist option is introduced in OpenSSH 5.6.
-          (when (and (not (eq tramp-use-connection-share 'suppress))
-                      (tramp-ssh-option-exists-p vec "ControlPersist=no"))
-            " -o ControlPersist=no")))))))
+        (concat
+         "-o ControlMaster="
+         (if (eq tramp-use-connection-share 'suppress)
+             "no" "auto")
+
+         " -o ControlPath="
+         (if (eq tramp-use-connection-share 'suppress)
+             "none"
+           ;; Hashed tokens are introduced in OpenSSH 6.7.
+          (if (tramp-ssh-option-exists-p vec "ControlPath=tramp.%C")
+              "tramp.%%C" "tramp.%%r@%%h:%%p"))
+
+         ;; ControlPersist option is introduced in OpenSSH 5.6.
+        (when (and (not (eq tramp-use-connection-share 'suppress))
+                    (tramp-ssh-option-exists-p vec "ControlPersist=no"))
+          " -o ControlPersist=no"))))))
 
 (defun tramp-scp-strict-file-name-checking (vec)
   "Return the strict file name checking argument of the local scp."
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index dc8d4674425..66d893a14b5 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -724,8 +724,23 @@ treated as in `eglot--dbind'."
 (cl-defgeneric eglot-handle-notification (server method &rest params)
   "Handle SERVER's METHOD notification with PARAMS.")
 
-(cl-defgeneric eglot-execute-command (server command arguments)
-  "Ask SERVER to execute COMMAND with ARGUMENTS.")
+(cl-defgeneric eglot-execute-command (_ _ _)
+  (declare (obsolete eglot-execute "30.1"))
+  (:method
+   (server command arguments)
+   (eglot--request server :workspace/executeCommand
+                   `(:command ,(format "%s" command) :arguments ,arguments))))
+
+(cl-defgeneric eglot-execute (server action)
+  "Ask SERVER to execute ACTION.
+ACTION is an LSP object of either `CodeAction' or `Command' type."
+  (:method
+   (server action) "Default implementation."
+   (eglot--dcase action
+     (((Command)) (eglot--request server :workspace/executeCommand action))
+     (((CodeAction) edit command)
+      (when edit (eglot--apply-workspace-edit edit))
+      (when command (eglot--request server :workspace/executeCommand 
action))))))
 
 (cl-defgeneric eglot-initialization-options (server)
   "JSON object to send under `initializationOptions'."
@@ -2181,13 +2196,6 @@ still unanswered LSP requests to the server\n")))
   (when (memq 'disallow-unknown-methods eglot-strict-mode)
     (jsonrpc-error "Unknown request method `%s'" method)))
 
-(cl-defmethod eglot-execute-command
-  (server command arguments)
-  "Execute COMMAND on SERVER with `:workspace/executeCommand'.
-COMMAND is a symbol naming the command."
-  (eglot--request server :workspace/executeCommand
-                  `(:command ,(format "%s" command) :arguments ,arguments)))
-
 (cl-defmethod eglot-handle-notification
   (_server (_method (eql window/showMessage)) &key type message)
   "Handle notification window/showMessage."
@@ -3465,14 +3473,7 @@ at point.  With prefix argument, prompt for ACTION-KIND."
                                           default-action)
                                   menu-items nil t nil nil default-action)
                                  menu-items))))))
-    (eglot--dcase chosen
-      (((Command) command arguments)
-       (eglot-execute-command server (intern command) arguments))
-      (((CodeAction) edit command)
-       (when edit (eglot--apply-workspace-edit edit))
-       (when command
-         (eglot--dbind ((Command) command arguments) command
-           (eglot-execute-command server (intern command) arguments)))))))
+    (eglot-execute server chosen)))
 
 (defmacro eglot--code-action (name kind)
   "Define NAME to execute KIND code action."
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 54f223dc40b..e9ca45c0d6c 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -251,8 +251,7 @@ than using NODE's type.  PRED can also be a predicate 
function,
 and more.  See `treesit-thing-settings' for details.
 
 If INCLUDE-NODE is non-nil, return NODE if it satisfies PRED."
-  (let ((pred (or pred (rx-to-string
-                        `(seq bos ,(treesit-node-type node) eos))))
+  (let ((pred (or pred (rx bos (literal (treesit-node-type node)) eos)))
         (result nil))
     (cl-loop for cursor = (if include-node node
                             (treesit-node-parent node))
diff --git a/src/regex-emacs.h b/src/regex-emacs.h
index 1bc973363e9..bc357633135 100644
--- a/src/regex-emacs.h
+++ b/src/regex-emacs.h
@@ -187,7 +187,8 @@ typedef enum { RECC_ERROR = 0,
               RECC_DIGIT, RECC_XDIGIT,
               RECC_BLANK, RECC_SPACE,
               RECC_MULTIBYTE, RECC_NONASCII,
-              RECC_ASCII, RECC_UNIBYTE
+              RECC_ASCII, RECC_UNIBYTE,
+              RECC_NUM_CLASSES = RECC_UNIBYTE
 } re_wctype_t;
 
 extern bool re_iswctype (int ch, re_wctype_t cc);
diff --git a/src/syntax.c b/src/syntax.c
index e9e04e2d638..839ab36bb2f 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -178,14 +178,14 @@ static ptrdiff_t find_start_begv;
 static modiff_count find_start_modiff;
 
 
-static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool);
+static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object);
 static Lisp_Object skip_syntaxes (bool, Lisp_Object, Lisp_Object);
 static Lisp_Object scan_lists (EMACS_INT, EMACS_INT, EMACS_INT, bool);
 static void scan_sexps_forward (struct lisp_parse_state *,
                                 ptrdiff_t, ptrdiff_t, ptrdiff_t, EMACS_INT,
                                 bool, int);
 static void internalize_parse_state (Lisp_Object, struct lisp_parse_state *);
-static bool in_classes (int, Lisp_Object);
+static bool in_classes (int c, int num_classes, const unsigned char *classes);
 static void parse_sexp_propertize (ptrdiff_t charpos);
 
 /* This setter is used only in this file, so it can be private.  */
@@ -1607,7 +1607,7 @@ Char classes, e.g. `[:alpha:]', are supported.
 Returns the distance traveled, either zero or positive.  */)
   (Lisp_Object string, Lisp_Object lim)
 {
-  return skip_chars (1, string, lim, 1);
+  return skip_chars (1, string, lim);
 }
 
 DEFUN ("skip-chars-backward", Fskip_chars_backward, Sskip_chars_backward, 1, 
2, 0,
@@ -1616,7 +1616,7 @@ See `skip-chars-forward' for details.
 Returns the distance traveled, either zero or negative.  */)
   (Lisp_Object string, Lisp_Object lim)
 {
-  return skip_chars (0, string, lim, 1);
+  return skip_chars (0, string, lim);
 }
 
 DEFUN ("skip-syntax-forward", Fskip_syntax_forward, Sskip_syntax_forward, 1, 
2, 0,
@@ -1643,8 +1643,7 @@ of this is the distance traveled.  */)
 }
 
 static Lisp_Object
-skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
-           bool handle_iso_classes)
+skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim)
 {
   int c;
   char fastmap[0400];
@@ -1661,11 +1660,9 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
   ptrdiff_t size_byte;
   const unsigned char *str;
   int len;
-  Lisp_Object iso_classes;
   USE_SAFE_ALLOCA;
 
   CHECK_STRING (string);
-  iso_classes = Qnil;
 
   if (NILP (lim))
     XSETINT (lim, forwardp ? ZV : BEGV);
@@ -1700,6 +1697,8 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
      If STRING contains non-ASCII characters, setup char_ranges for
      them and use fastmap only for their leading codes.  */
 
+  int nclasses = 0;
+  unsigned char classes[RECC_NUM_CLASSES];
   if (! string_multibyte)
     {
       bool string_has_eight_bit = 0;
@@ -1707,18 +1706,16 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
       /* At first setup fastmap.  */
       while (i_byte < size_byte)
        {
-         if (handle_iso_classes)
+         const unsigned char *ch = str + i_byte;
+         re_wctype_t cc = re_wctype_parse (&ch, size_byte - i_byte);
+         if (cc == 0)
+           error ("Invalid ISO C character class");
+         if (cc != -1)
            {
-             const unsigned char *ch = str + i_byte;
-             re_wctype_t cc = re_wctype_parse (&ch, size_byte - i_byte);
-             if (cc == 0)
-               error ("Invalid ISO C character class");
-             if (cc != -1)
-               {
-                 iso_classes = Fcons (make_fixnum (cc), iso_classes);
-                 i_byte = ch - str;
-                 continue;
-               }
+             if (!(nclasses && memchr (classes, cc, nclasses)))
+               classes[nclasses++] = cc;
+             i_byte = ch - str;
+             continue;
            }
 
          c = str[i_byte++];
@@ -1803,18 +1800,16 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
        {
          int leading_code = str[i_byte];
 
-         if (handle_iso_classes)
+         const unsigned char *ch = str + i_byte;
+         re_wctype_t cc = re_wctype_parse (&ch, size_byte - i_byte);
+         if (cc == 0)
+           error ("Invalid ISO C character class");
+         if (cc != -1)
            {
-             const unsigned char *ch = str + i_byte;
-             re_wctype_t cc = re_wctype_parse (&ch, size_byte - i_byte);
-             if (cc == 0)
-               error ("Invalid ISO C character class");
-             if (cc != -1)
-               {
-                 iso_classes = Fcons (make_fixnum (cc), iso_classes);
-                 i_byte = ch - str;
-                 continue;
-               }
+             if (!(nclasses && memchr (classes, cc, nclasses)))
+               classes[nclasses++] = cc;
+             i_byte = ch - str;
+             continue;
            }
 
          if (leading_code== '\\')
@@ -1960,7 +1955,7 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
                  stop = endp;
                }
              c = string_char_and_length (p, &nbytes);
-             if (! NILP (iso_classes) && in_classes (c, iso_classes))
+             if (nclasses && in_classes (c, nclasses, classes))
                {
                  if (negate)
                    break;
@@ -2001,7 +1996,7 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
                  stop = endp;
                }
 
-             if (!NILP (iso_classes) && in_classes (*p, iso_classes))
+             if (nclasses && in_classes (*p, nclasses, classes))
                {
                  if (negate)
                    break;
@@ -2035,7 +2030,7 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
 
              c = STRING_CHAR (p);
 
-             if (! NILP (iso_classes) && in_classes (c, iso_classes))
+             if (nclasses && in_classes (c, nclasses, classes))
                {
                  if (negate)
                    break;
@@ -2069,7 +2064,7 @@ skip_chars (bool forwardp, Lisp_Object string, 
Lisp_Object lim,
                  stop = endp;
                }
 
-             if (! NILP (iso_classes) && in_classes (p[-1], iso_classes))
+             if (nclasses && in_classes (p[-1], nclasses, classes))
                {
                  if (negate)
                    break;
@@ -2253,26 +2248,16 @@ skip_syntaxes (bool forwardp, Lisp_Object string, 
Lisp_Object lim)
   }
 }
 
-/* Return true if character C belongs to one of the ISO classes
-   in the list ISO_CLASSES.  Each class is represented by an
-   integer which is its type according to re_wctype.  */
+/* Return true if character C belongs to one of the ISO classes in the
+   array.  */
 
 static bool
-in_classes (int c, Lisp_Object iso_classes)
+in_classes (int c, int nclasses, const unsigned char *classes)
 {
-  bool fits_class = 0;
-
-  while (CONSP (iso_classes))
-    {
-      Lisp_Object elt;
-      elt = XCAR (iso_classes);
-      iso_classes = XCDR (iso_classes);
-
-      if (re_iswctype (c, XFIXNAT (elt)))
-       fits_class = 1;
-    }
-
-  return fits_class;
+  for (int i = 0; i < nclasses; i++)
+    if (re_iswctype (c, classes[i]))
+      return true;
+  return false;
 }
 
 /* Jump over a comment, assuming we are at the beginning of one.
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el
index 5b2955c34e3..4aa81a9ce0b 100644
--- a/test/src/treesit-tests.el
+++ b/test/src/treesit-tests.el
@@ -54,6 +54,9 @@
 (declare-function treesit-node-descendant-for-range "treesit.c")
 (declare-function treesit-node-eq "treesit.c")
 
+(declare-function treesit-search-forward "treesit.c")
+(declare-function treesit-search-subtree "treesit.c")
+
 ;;; Basic API
 
 (ert-deftest treesit-basic-parsing ()



reply via email to

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