[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android 03c929e528 2/2: Merge remote-tracking branch 'origin/mas
From: |
Po Lu |
Subject: |
feature/android 03c929e528 2/2: Merge remote-tracking branch 'origin/master' into feature/android |
Date: |
Thu, 9 Feb 2023 09:59:15 -0500 (EST) |
branch: feature/android
commit 03c929e5282bc16fa487272d5d5280a1747fb5a8
Merge: 209ae003b7 1518fc5d7c
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Merge remote-tracking branch 'origin/master' into feature/android
---
lisp/iimage.el | 16 +++++++++++-----
lisp/progmodes/ruby-ts-mode.el | 9 ++++++++-
src/treesit.c | 8 ++++++--
test/lisp/progmodes/ruby-ts-mode-tests.el | 16 ++++++++++++++++
4 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/lisp/iimage.el b/lisp/iimage.el
index 96ab963bff..b4c175a7b6 100644
--- a/lisp/iimage.el
+++ b/lisp/iimage.el
@@ -64,9 +64,15 @@
`((,(concat "\\(`?file://\\|\\[\\[\\|<\\|`\\)?"
"\\(" iimage-mode-image-filename-regex "\\)"
"\\(\\]\\]\\|>\\|'\\)?") . 2))
- "Alist of filename REGEXP vs NUM.
-Each element looks like (REGEXP . NUM).
-NUM specifies which parenthesized expression in the regexp.
+ "Alist that specifies how to detect filenames of images to be displayed
inline.
+The value should be an alist whose elements have the form
+
+ (REGEXP . NUM)
+
+where REGEXP is a regular expression to search buffer text for what
+might be a specification of an inline image, and NUM is the number
+of a parenthesized sub-expression of REGEXP which gives the name of
+the image file to look up.
Examples of image filename patterns to match:
file://foo.png
@@ -93,7 +99,7 @@ Examples of image filename patterns to match:
(iimage-mode 0))
(defun iimage-modification-hook (beg end)
- "Remove display property if a display region is modified."
+ "Remove display property if a display region BEG..END is modified."
;;(debug-print "ii1 begin %d, end %d\n" beg end)
(let ((inhibit-modification-hooks t)
(beg (previous-single-property-change end 'display
@@ -112,8 +118,8 @@ Examples of image filename patterns to match:
file)
(with-silent-modifications
(save-excursion
- (goto-char (point-min))
(dolist (pair iimage-mode-image-regex-alist)
+ (goto-char (point-min))
(while (re-search-forward (car pair) nil t)
(when (and (setq file (match-string (cdr pair)))
(setq file (locate-file file image-path)))
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 7a130f42dc..f15387c91b 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -571,7 +571,7 @@ a statement container is a node that matches
;; Incomplete buffer state, better not reindent (bug#61017).
((and (parent-is "ERROR")
(or (node-is ,ruby-ts--class-or-module-regex)
- (node-is "\\`def\\'")))
+ (node-is "\\`\\(?:def\\|identifier\\)\\'")))
no-indent 0)
;; if then else elseif notes:
@@ -661,6 +661,13 @@ a statement container is a node that matches
((n-p-gp nil "body_statement" ,ruby-ts--method-regex) ;other
statements
(ruby-ts--align-keywords ruby-ts--grand-parent-node)
ruby-indent-level)
+ ;; Quirk of the ruby parser: these "alignable" nodes don't
+ ;; have the "container" child node when there are no
+ ;; statements inside. Thus we have to have a separate rule
+ ;; for the "empty if/unless/case/def" situation.
+ ((match "\\`\\'" "\\`\\(?:if\\|unless\\|case\\|method\\)\\'")
+ (ruby-ts--align-keywords ruby-ts--parent-node) ruby-indent-level)
+
;; Chained calls:
;; if `ruby-align-chained-calls' is true, the first query
;; matches and the node is aligned under the first dot (.);
diff --git a/src/treesit.c b/src/treesit.c
index b15d44fca0..cfa3721b5e 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -617,10 +617,14 @@ treesit_load_language (Lisp_Object language_symbol,
eassume (handle != NULL);
dynlib_error ();
TSLanguage *(*langfn) (void);
- char *c_name = xstrdup (SSDATA (base_name));
- treesit_symbol_to_c_name (c_name);
+ char *c_name;
if (found_override)
c_name = xstrdup (SSDATA (override_c_name));
+ else
+ {
+ c_name = xstrdup (SSDATA (base_name));
+ treesit_symbol_to_c_name (c_name);
+ }
langfn = dynlib_sym (handle, c_name);
xfree (c_name);
error = dynlib_error ();
diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el
b/test/lisp/progmodes/ruby-ts-mode-tests.el
index 18e3e60a04..c99e1a4306 100644
--- a/test/lisp/progmodes/ruby-ts-mode-tests.el
+++ b/test/lisp/progmodes/ruby-ts-mode-tests.el
@@ -122,6 +122,22 @@ The whitespace before and including \"|\" on each line is
removed."
(funcall indent-line-function)
(should (= (current-indentation) ruby-indent-level))))
+(ert-deftest ruby-ts-indent-empty-if-else ()
+ (skip-unless (treesit-ready-p 'ruby t))
+ (let* ((str "c = if foo
+ zz
+ else
+ zz
+ end
+"))
+ (ruby-ts-with-temp-buffer str
+ (goto-char (point-min))
+ (dotimes (_ 2)
+ (re-search-forward "^ *zz")
+ (replace-match "")
+ (funcall indent-line-function)
+ (should (= (current-indentation) 6))))))
+
(ert-deftest ruby-ts-add-log-current-method-examples ()
(skip-unless (treesit-ready-p 'ruby t))
(let ((pairs '(("foo" . "#foo")