From de3df3bc51e056d179e572fc0fc3bed89b372662 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 2 Jan 2023 23:08:39 -0700 Subject: [PATCH 1/5] * lisp/vc/vc-git.el (vc-git-checkin): Pass vc-git-diff-switches. --- lisp/vc/vc-git.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 7413ecb79b1..06bf927831d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -992,6 +992,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)) @@ -1021,7 +1023,14 @@ It is based on `log-edit-mode', and has Git-specific extensions." ;; currently staged to the index. So remove the whole file diff ;; from the patch because commit will take it from the index. (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-diff file-beg) (while (not (eobp)) @@ -1291,8 +1300,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'. From ae0d218d0b38ae94db44006fc9930ab1d14b345d Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Mon, 2 Jan 2023 22:52:42 -0800 Subject: [PATCH 2/5] ; * etc/NEWS: Mention treesit-install-language-grammar. --- etc/NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 355ba6ba8aa..e679b904a65 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -63,6 +63,13 @@ the other shared libraries used by Emacs, or in the "tree-sitter" subdirectory of your 'user-emacs-directory', or in a directory mentioned in the variable 'treesit-extra-load-path'. +Emacs provides a user command, 'treesit-install-language-grammar', +that automates the building process. A third-party major mode package +could instruct its users to set 'treesit-language-source-alist' +accordingly and use that command to download and compile the language +grammar. A user could also use that command directly and manually +guide it through the process. + You only need to install language grammar libraries required by the 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 From 0b0eae0bf76c4d791cc47dad82306e33d54290c0 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 3 Jan 2023 15:12:48 +0200 Subject: [PATCH 3/5] ; Improve documentation of 'treesit-language-source-alist' * lisp/treesit.el (treesit--install-language-grammar-build-recipe) (treesit-install-language-grammar): Doc fixes. (treesit-install-language-grammar): Autoload it. * etc/NEWS: Improve wording of the 'treesit-install-language-grammar' documentation. --- etc/NEWS | 13 ++++++------- lisp/treesit.el | 7 ++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index e679b904a65..38a8798507a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -63,18 +63,17 @@ the other shared libraries used by Emacs, or in the "tree-sitter" subdirectory of your 'user-emacs-directory', or in a directory mentioned in the variable 'treesit-extra-load-path'. -Emacs provides a user command, 'treesit-install-language-grammar', -that automates the building process. A third-party major mode package -could instruct its users to set 'treesit-language-source-alist' -accordingly and use that command to download and compile the language -grammar. A user could also use that command directly and manually -guide it through the process. - You only need to install language grammar libraries required by the 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/treesit.el b/lisp/treesit.el index 1ca72af5c2d..933d53082f9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2633,7 +2633,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) @@ -2655,9 +2655,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'. From da69f116bfc37d28942ca6d35eaff978e6805bac Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 3 Jan 2023 15:16:42 +0200 Subject: [PATCH 4/5] ; * doc/lispref/positions.texi (List Motion): Minor wording fix. --- doc/lispref/positions.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index f47720184a3..f3824436246 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. From 0d98fac6bbc19c7728d42d6196adf4d392ba3132 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 4 Jan 2023 00:37:43 +0200 Subject: [PATCH 5/5] (ruby-ts-add-log-current-function): Fix when between two methods * lisp/progmodes/ruby-ts-mode.el (ruby-ts-add-log-current-function): Fix the case when point is between two methods. 'treesit-node-at' returs the 'def' node of the method after point in such case, so it behaved like point was inside the method below. * test/lisp/progmodes/ruby-ts-mode-tests.el (ruby-ts-add-log-current-method-outside-of-method): Update the test case. * test/lisp/progmodes/ruby-mode-tests.el (ruby-add-log-current-method-outside-of-method): Mirror that change. --- lisp/progmodes/ruby-ts-mode.el | 7 ++++++- test/lisp/progmodes/ruby-mode-tests.el | 3 +++ test/lisp/progmodes/ruby-ts-mode-tests.el | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index c086214a11d..5c173ad24c7 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/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el index 9687231dbfa..8a75c83d2c3 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 aa1ab1e2605..b2c990f8e56 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 ()