emacs-diffs
[Top][All Lists]
Advanced

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

master 1ddd31bf98: Merge from origin/emacs-29


From: Stefan Kangas
Subject: master 1ddd31bf98: Merge from origin/emacs-29
Date: Wed, 4 Jan 2023 00:45:03 -0500 (EST)

branch: master
commit 1ddd31bf9843c0453af92a09f98935cfcbb4e250
Merge: 0e1b03bbb8 0d98fac6bb
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Merge from origin/emacs-29
    
    0d98fac6bbc (ruby-ts-add-log-current-function): Fix when between two ...
    da69f116bfc ; * doc/lispref/positions.texi (List Motion): Minor wordi...
    0b0eae0bf76 ; Improve documentation of 'treesit-language-source-alist'
    ae0d218d0b3 ; * etc/NEWS: Mention treesit-install-language-grammar.
    de3df3bc51e * lisp/vc/vc-git.el (vc-git-checkin): Pass vc-git-diff-sw...
    
    # Conflicts:
    #       etc/NEWS
---
 doc/lispref/positions.texi                |  2 +-
 etc/NEWS.29                               |  6 ++++++
 lisp/progmodes/ruby-ts-mode.el            |  7 ++++++-
 lisp/treesit.el                           |  7 ++++++-
 lisp/vc/vc-git.el                         | 13 ++++++++++---
 test/lisp/progmodes/ruby-mode-tests.el    |  3 +++
 test/lisp/progmodes/ruby-ts-mode-tests.el |  3 +++
 7 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index f47720184a..f382443624 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -852,7 +852,7 @@ matches either @code{"function_definition"} or 
@code{"class_definition"}.
 @end defvar
 
 @defvar treesit-defun-tactic
-This variable determines how does Emacs treat nested defuns.  If the
+This variable determines how Emacs treats nested defuns.  If the
 value is @code{top-level}, navigation functions only move across
 top-level defuns, if the value is @code{nested}, navigation functions
 recognize nested defuns.
diff --git a/etc/NEWS.29 b/etc/NEWS.29
index 355ba6ba8a..38a8798507 100644
--- a/etc/NEWS.29
+++ b/etc/NEWS.29
@@ -68,6 +68,12 @@ Emacs modes you will use, as Emacs loads these libraries 
only when the
 corresponding mode is turned on in some buffer for the first time in
 an Emacs session.
 
+Emacs provides a user command, 'treesit-install-language-grammar',
+that automates the download and build process of a grammar library.
+It prompts for the language, the URL of the language grammar's VCS
+repository, and then uses the installed C/C++ compiler to build the
+library and install it.
+
 +++
 ** Emacs can be built with built-in support for accessing SQLite databases.
 This uses the popular sqlite3 library, and can be disabled by using
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index c086214a11..5c173ad24c 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -850,7 +850,12 @@ The hash (#) is for instance methods only which are methods
 dot (.) is used.  Double colon (::) is used between classes.  The
 leading double colon is not added."
   (let* ((node (treesit-node-at (point)))
-         (method (treesit-parent-until node (ruby-ts--type-pred 
ruby-ts--method-regex)))
+         (method-pred
+          (lambda (node)
+            (and (<= (treesit-node-start node) (point))
+                 (>= (treesit-node-end node) (point))
+                 (string-match-p ruby-ts--method-regex (treesit-node-type 
node)))))
+         (method (treesit-parent-until node method-pred t))
          (class (or method node))
          (result nil)
          (sep "#")
diff --git a/lisp/treesit.el b/lisp/treesit.el
index bcdc9daeac..e141f872c7 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -2671,7 +2671,7 @@ CC and C++ are C and C++ compilers, defaulting to \"cc\" 
and
 \"c++\", respectively.")
 
 (defun treesit--install-language-grammar-build-recipe (lang)
-  "Interactively build a recipe for LANG and return it.
+  "Interactively produce a download/build recipe for LANG and return it.
 See `treesit-language-source-alist' for details."
   (when (y-or-n-p (format "There is no recipe for %s, do you want to build it 
interactively?" lang))
     (cl-labels ((empty-string-to-nil (string)
@@ -2693,9 +2693,14 @@ See `treesit-language-source-alist' for details."
         (read-string
          "Enter the C++ compiler to use (default: auto-detect): "))))))
 
+;;;###autoload
 (defun treesit-install-language-grammar (lang)
   "Build and install the tree-sitter language grammar library for LANG.
 
+Interactively, if `treesit-language-source-alist' doesn't already
+have data for building the grammar for LANG, prompt for its
+repository URL and the C/C++ compiler to use.
+
 This command requires Git, a C compiler and (sometimes) a C++ compiler,
 and the linker to be installed and on PATH.  It also requires that the
 recipe for LANG exists in `treesit-language-source-alist'.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 7a34357811..7689d5f879 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1036,6 +1036,8 @@ It is based on `log-edit-mode', and has Git-specific 
extensions."
   (let ((vc-git-patch-string patch-string))
     (vc-git-checkin nil comment)))
 
+(autoload 'vc-switches "vc")
+
 (defun vc-git-checkin (files comment &optional _rev)
   (let* ((file1 (or (car files) default-directory))
          (root (vc-git-root file1))
@@ -1078,7 +1080,14 @@ It is based on `log-edit-mode', and has Git-specific 
extensions."
         ;;    want to commit any changes to that file, we need to
         ;;    stash those changes before committing.
         (with-temp-buffer
-          (vc-git-command (current-buffer) t nil "diff" "--cached")
+          ;; If the user has switches like -D, -M etc. in their
+          ;; `vc-git-diff-switches', we must pass them here too, or
+          ;; our string matches will fail.
+          (if vc-git-diff-switches
+              (apply #'vc-git-command (current-buffer) t nil
+                     "diff" "--cached" (vc-switches 'git 'diff))
+            ;; Following code doesn't understand plain diff(1) output.
+            (user-error "Cannot commit patch with nil `vc-git-diff-switches'"))
           (goto-char (point-min))
           (let ((pos (point)) file-name file-header file-diff file-beg)
             (while (not (eobp))
@@ -1410,8 +1419,6 @@ This prompts for a branch to merge from."
   :type 'boolean
   :version "26.1")
 
-(autoload 'vc-switches "vc")
-
 (defun vc-git-print-log (files buffer &optional shortlog start-revision limit)
   "Print commit log associated with FILES into specified BUFFER.
 If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'.
diff --git a/test/lisp/progmodes/ruby-mode-tests.el 
b/test/lisp/progmodes/ruby-mode-tests.el
index 9687231dbf..8a75c83d2c 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -537,9 +537,12 @@ VALUES-PLIST is a list with alternating index and value 
elements."
                           |    def foo
                           |    end
                           |    _
+                          |    def bar
+                          |    end
                           |  end
                           |end")
     (search-backward "_")
+    (delete-char 1)
     (should (string= (ruby-add-log-current-method)"M::C"))))
 
 (ert-deftest ruby-add-log-current-method-in-singleton-class ()
diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el 
b/test/lisp/progmodes/ruby-ts-mode-tests.el
index aa1ab1e260..b2c990f8e5 100644
--- a/test/lisp/progmodes/ruby-ts-mode-tests.el
+++ b/test/lisp/progmodes/ruby-ts-mode-tests.el
@@ -141,9 +141,12 @@ The whitespace before and including \"|\" on each line is 
removed."
                              |    def foo
                              |    end
                              |    _
+                             |    def bar
+                             |    end
                              |  end
                              |end")
     (search-backward "_")
+    (delete-char 1)
     (should (string= (ruby-ts-add-log-current-function) "M::C"))))
 
 (ert-deftest ruby-ts-add-log-current-method-in-singleton-class ()



reply via email to

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