[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 05f8fe3ae30: Merge remote-tracking branch 'origin/master
From: |
Po Lu |
Subject: |
feature/android 05f8fe3ae30: Merge remote-tracking branch 'origin/master' into feature/android |
Date: |
Fri, 31 Mar 2023 20:57:59 -0400 (EDT) |
branch: feature/android
commit 05f8fe3ae30675d44121563edf9f368f9ace9d9d
Merge: ab3ef576b4c 6523359dfe2
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Merge remote-tracking branch 'origin/master' into feature/android
---
doc/lispref/parsing.texi | 47 ++++++++++++++++++++++++++++++++++++++++++++++
etc/NEWS | 8 ++++++++
lisp/net/tramp.el | 2 +-
lisp/shell.el | 40 +++++++++++++++++++++++++++++++++++++++
lisp/treesit.el | 44 +++++++++++++++++++++++++++++++++++++++++++
src/fns.c | 43 ++++++++++++++++++++++++------------------
src/lisp.h | 20 --------------------
test/infra/Dockerfile.emba | 9 ---------
8 files changed, 165 insertions(+), 48 deletions(-)
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 86a5d9f2e52..38c9ec8c2f0 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -849,6 +849,53 @@ Each node in the returned tree looks like
@heading More convenience functions
+@defun treesit-node-get node instructions
+This is a convenience function that chains together multiple node
+accessor functions together. For example, to get @var{node}'s
+parent's next sibling's second child's text:
+
+@example
+@group
+(treesit-node-get node
+ '((parent 1)
+ (sibling 1 nil)
+ (child 1 nil)
+ (text nil)))
+@end group
+@end example
+
+@var{instruction} is a list of INSTRUCTIONs of the form
+@w{@code{(@var{fn} @var{arg}...)}}. The following @var{fn}'s are
+supported:
+
+@table @code
+@item (child @var{idx} @var{named})
+Get the @var{idx}'th child.
+
+@item (parent @var{n})
+Go to parent @var{n} times.
+
+@item (field-name)
+Get the field name of the current node.
+
+@item (type)
+Get the type of the current node.
+
+@item (text @var{no-property})
+Get the text of the current node.
+
+@item (children @var{named})
+Get a list of children.
+
+@item (sibling @var{step} @var{named})
+Get the nth prev/next sibling, negative @var{step} means prev sibling,
+positive means next sibling.
+@end table
+
+Note that arguments like @var{named} and @var{no-property} can't be
+omitted, unlike in their original functions.
+@end defun
+
@defun treesit-filter-child node predicate &optional named
This function finds immediate children of @var{node} that satisfy
@var{predicate}.
diff --git a/etc/NEWS b/etc/NEWS
index 2e2812e3b93..a63a2f837f5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -192,6 +192,14 @@ correctly unloads Eshell and all of its modules.
After manually editing 'eshell-aliases-file', you can use this command
to load the edited aliases.
+** Shell Mode
+
++++
+*** New user option 'shell-get-old-input-include-continuation-lines'.
+When this user option is non-nil, 'shell-get-old-input' (C-RET)
+includes multiple shell "\" continuation lines from command output.
+Default is nil.
+
** Prog Mode
+++
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index defdb2bd546..b1bd93410bc 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -5815,7 +5815,7 @@ If the user quits via `C-g', it is propagated up to
`tramp-file-name-handler'."
(v (process-get proc 'tramp-vector)))
(dolist (p (delq proc (process-list)))
(when (tramp-file-name-equal-p v (process-get p 'tramp-vector))
- (accept-process-output p 0 nil t))))
+ (with-local-quit (accept-process-output p 0 nil t)))))
(with-current-buffer (process-buffer proc)
(let ((inhibit-read-only t)
diff --git a/lisp/shell.el b/lisp/shell.el
index 29f7d5c02d4..c7979e84ba0 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -366,6 +366,12 @@ Useful for shells like zsh that has this feature."
:group 'shell-directories
:version "28.1")
+(defcustom shell-get-old-input-include-continuation-lines nil
+ "Whether `shell-get-old-input' includes \"\\\" lines."
+ :type 'boolean
+ :group 'shell
+ :version "30.1")
+
(defcustom shell-kill-buffer-on-exit nil
"Kill a shell buffer after the shell process terminates."
:type 'boolean
@@ -506,6 +512,39 @@ Useful for shells like zsh that has this feature."
(push (mapconcat #'identity (nreverse arg) "") args)))
(cons (nreverse args) (nreverse begins)))))
+(defun shell-get-old-input ()
+ "Default for `comint-get-old-input' in `shell-mode'.
+If `comint-use-prompt-regexp' is nil, then either
+return the current input field (if point is on an input field), or the
+current line (if point is on an output field).
+If `comint-use-prompt-regexp' is non-nil, then return
+the current line, with any initial string matching the regexp
+`comint-prompt-regexp' removed.
+In either case, if `shell-get-old-input-include-continuation-lines'
+is non-nil and the current line ends with a backslash, the next
+line is also included and examined for a backslash, ending with a
+final line without a backslash."
+ (let (field-prop bof)
+ (if (and (not comint-use-prompt-regexp)
+ ;; Make sure we're in an input rather than output field.
+ (not (setq field-prop (get-char-property
+ (setq bof (field-beginning)) 'field))))
+ (field-string-no-properties bof)
+ (comint-bol)
+ (let ((start (point)))
+ (cond ((or comint-use-prompt-regexp
+ (eq field-prop 'output))
+ (goto-char (line-end-position))
+ (when shell-get-old-input-include-continuation-lines
+ ;; Include continuation lines as long as the current
+ ;; line ends with a backslash.
+ (while (and (not (eobp))
+ (= (char-before) ?\\))
+ (goto-char (line-end-position 2)))))
+ (t
+ (goto-char (field-end))))
+ (buffer-substring-no-properties start (point))))))
+
;;;###autoload
(defun split-string-shell-command (string)
"Split STRING (a shell command) into a list of strings.
@@ -642,6 +681,7 @@ command."
(setq-local font-lock-defaults '(shell-font-lock-keywords t))
(setq-local shell-dirstack nil)
(setq-local shell-last-dir nil)
+ (setq-local comint-get-old-input #'shell-get-old-input)
;; People expect Shell mode to keep the last line of output at
;; window bottom.
(setq-local scroll-conservatively 101)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index e3c7d569ea6..4c4ba4ad6ac 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -363,6 +363,50 @@ If NAMED is non-nil, count named child only."
(idx (treesit-node-index node)))
(treesit-node-field-name-for-child parent idx)))
+(defun treesit-node-get (node instructions)
+ "Get things from NODE by INSTRUCTIONS.
+
+This is a convenience function that chains together multiple node
+accessor functions together. For example, to get NODE's parent's
+next sibling's second child's text, call
+
+ (treesit-node-get node
+ \\='((parent 1)
+ (sibling 1 nil)
+ (child 1 nil)
+ (text nil)))
+
+INSTRUCTION is a list of INSTRUCTIONs of the form (FN ARG...).
+The following FN's are supported:
+
+\(child IDX NAMED) Get the IDX'th child
+\(parent N) Go to parent N times
+\(field-name) Get the field name of the current node
+\(type) Get the type of the current node
+\(text NO-PROPERTY) Get the text of the current node
+\(children NAMED) Get a list of children
+\(sibling STEP NAMED) Get the nth prev/next sibling, negative STEP
+ means prev sibling, positive means next
+
+Note that arguments like NAMED and NO-PROPERTY can't be omitted,
+unlike in their original functions."
+ (declare (indent 1))
+ (while (and node instructions)
+ (pcase (pop instructions)
+ ('(field-name) (setq node (treesit-node-field-name node)))
+ ('(type) (setq node (treesit-node-type node)))
+ (`(child ,idx ,named) (setq node (treesit-node-child node idx named)))
+ (`(parent ,n) (dotimes (_ n)
+ (setq node (treesit-node-parent node))))
+ (`(text ,no-property) (setq node (treesit-node-text node no-property)))
+ (`(children ,named) (setq node (treesit-node-children node named)))
+ (`(sibling ,step ,named)
+ (dotimes (_ (abs step))
+ (setq node (if (> step 0)
+ (treesit-node-next-sibling node named)
+ (treesit-node-prev-sibling node named)))))))
+ node)
+
;;; Query API supplement
(defun treesit-query-string (string query language)
diff --git a/src/fns.c b/src/fns.c
index bc4ec07421a..87e6748b19f 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -439,17 +439,29 @@ If string STR1 is greater, the value is a positive number
N;
}
/* Check whether the platform allows access to unaligned addresses for
- size_t integers without trapping or undue penalty (a few cycles is OK).
+ size_t integers without trapping or undue penalty (a few cycles is OK),
+ and that a word-sized memcpy can be used to generate such an access.
This whitelist is incomplete but since it is only used to improve
performance, omitting cases is safe. */
-#if defined __x86_64__|| defined __amd64__ \
- || defined __i386__ || defined __i386 \
- || defined __arm64__ || defined __aarch64__ \
- || defined __powerpc__ || defined __powerpc \
- || defined __ppc__ || defined __ppc \
- || defined __s390__ || defined __s390x__
+#if (defined __x86_64__|| defined __amd64__ \
+ || defined __i386__ || defined __i386 \
+ || defined __arm64__ || defined __aarch64__ \
+ || defined __powerpc__ || defined __powerpc \
+ || defined __ppc__ || defined __ppc \
+ || defined __s390__ || defined __s390x__) \
+ && defined __OPTIMIZE__
#define HAVE_FAST_UNALIGNED_ACCESS 1
+
+/* Load a word from a possibly unaligned address. */
+static inline size_t
+load_unaligned_size_t (const void *p)
+{
+ size_t x;
+ memcpy (&x, p, sizeof x);
+ return x;
+}
+
#else
#define HAVE_FAST_UNALIGNED_ACCESS 0
#endif
@@ -497,17 +509,12 @@ Symbols are also allowed; their print names are used
instead. */)
if (HAVE_FAST_UNALIGNED_ACCESS)
{
/* First compare entire machine words. */
- typedef size_t word_t;
- int ws = sizeof (word_t);
- const word_t *w1 = (const word_t *) SDATA (string1);
- const word_t *w2 = (const word_t *) SDATA (string2);
- while (b < nb - ws + 1)
- {
- if (UNALIGNED_LOAD_SIZE (w1, b / ws)
- != UNALIGNED_LOAD_SIZE (w2, b / ws))
- break;
- b += ws;
- }
+ int ws = sizeof (size_t);
+ const char *w1 = SSDATA (string1);
+ const char *w2 = SSDATA (string2);
+ while (b < nb - ws + 1 && load_unaligned_size_t (w1 + b)
+ == load_unaligned_size_t (w2 + b))
+ b += ws;
}
/* Scan forward to the differing byte. */
diff --git a/src/lisp.h b/src/lisp.h
index f7ba6775975..b7f76a366f3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -5327,26 +5327,6 @@ __lsan_ignore_object (void const *p)
}
#endif
-/* If built with USE_SANITIZER_UNALIGNED_LOAD defined, use compiler
- provided ASan functions to perform unaligned loads, allowing ASan
- to catch bugs which it might otherwise miss. */
-#if defined HAVE_SANITIZER_COMMON_INTERFACE_DEFS_H \
- && defined ADDRESS_SANITIZER \
- && defined USE_SANITIZER_UNALIGNED_LOAD
-# include <sanitizer/common_interface_defs.h>
-# if (SIZE_MAX == UINT64_MAX)
-# define UNALIGNED_LOAD_SIZE(a, i) \
- (size_t) __sanitizer_unaligned_load64 ((void *) ((a) + (i)))
-# elif (SIZE_MAX == UINT32_MAX)
-# define UNALIGNED_LOAD_SIZE(a, i) \
- (size_t) __sanitizer_unaligned_load32 ((void *) ((a) + (i)))
-# else
-# define UNALIGNED_LOAD_SIZE(a, i) *((a) + (i))
-# endif
-#else
-# define UNALIGNED_LOAD_SIZE(a, i) *((a) + (i))
-#endif
-
extern void xputenv (const char *);
extern char *egetenv_internal (const char *, ptrdiff_t);
diff --git a/test/infra/Dockerfile.emba b/test/infra/Dockerfile.emba
index f8a10f913ef..d7b0b0d3ded 100644
--- a/test/infra/Dockerfile.emba
+++ b/test/infra/Dockerfile.emba
@@ -72,15 +72,6 @@ RUN apt-get update && \
RUN bash -c "$(wget --no-check-certificate -O - https://apt.llvm.org/llvm.sh)"
RUN ln -s /usr/bin/clangd-15 /usr/bin/clangd
-# A recent pylsp. In Debian bookworm there is the package
-# python3-pylsp.
-RUN apt-get update && \
- apt-get install -y --no-install-recommends -o=Dpkg::Use-Pty=0 \
- python3-pyls \
- && rm -rf /var/lib/apt/lists/*
-# eglot.el knows pyls. However, eglot-tests.el checks only for pylsp.
-RUN ln -s /usr/bin/pyls /usr/bin/pylsp
-
COPY . /checkout
WORKDIR /checkout
RUN ./autogen.sh autoconf