From ad3ec429a12fb8caa460de5911145d1d3c46d626 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Thu, 15 Jun 2023 01:22:53 -0700 Subject: [PATCH 1/3] Fix treesit-install-language-grammar (bug#63990) * lisp/treesit.el: (treesit-install-language-grammar): When called non-interactively, out-dir should default to default-out-dir. --- lisp/treesit.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index ea701ce1ff7..d79e7732387 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3070,7 +3070,9 @@ nil, the grammar is installed to the standard location, the nil 'treesit--install-language-grammar-out-dir-history default-out-dir) - out-dir))) + ;; When called non-interactively, OUT-DIR should + ;; default to DEFAULT-OUT-DIR. + (or out-dir default-out-dir)))) (condition-case err (progn (apply #'treesit--install-language-grammar-1 From 1acce3b5c7fdf0b2a7301db25dfc2a616df36744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Thu, 15 Jun 2023 17:08:07 +0200 Subject: [PATCH 2/3] ; cperl-mode.el: Fix font-lock after yanking into POD When extending the region to fontify for jit-lock-mode, make sure we start fontifying at the beginning of a POD section (Bug#64056). --- lisp/progmodes/cperl-mode.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index ed021a7ebc9..6548ba3bd36 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3394,7 +3394,9 @@ position of the end of the unsafe construct." (goto-char (nth 8 state)) ; beginning of this here-doc (cperl-backward-to-noncomment ; skip back over more (point-min)) ; here-documents (if any) - (beginning-of-line)))) ; skip back over here-doc starters + (beginning-of-line)) ; skip back over here-doc starters + ((nth 4 state) ; in a comment (or POD) + (goto-char (nth 8 state))))) ; ...so go to its beginning (while (and pos (progn (beginning-of-line) (get-text-property (setq pos (point)) 'syntax-type))) From f2aae8b879baa4986b69af7ee54fe4eb987b99d6 Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Sat, 3 Jun 2023 14:23:19 +0200 Subject: [PATCH 3/3] eshell-next-prompt: More precisely navigate to the prompt (bug#63748) * lisp/eshell/em-prompt.el (eshell-next-prompt): Navigate to the current prompt more accurately by using text properties instead of going to the beginning of the line. This is important for multiline prompts, as they don't necessarily start at the beginning of the current line. * test/lisp/eshell/em-prompt-tests.el (em-prompt-test--with-multiline): Execute a given body with a multiline prompt. (em-prompt-test/next-previous-prompt-with): (em-prompt-test/forward-backward-matching-input-with): Helper functions for code reuse. (em-prompt-test/forward-backward-matching-input): (em-prompt-test/next-previous-prompt): Rewrite in terms of the appropriate helper functions. (em-prompt-test/next-previous-prompt-multiline): (em-prompt-test/forward-backward-matching-input-multiline): Add multiline variants of existing tests. --- lisp/eshell/em-prompt.el | 3 ++- test/lisp/eshell/em-prompt-tests.el | 31 +++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el index 9f9e58e83d7..42f8f273b52 100644 --- a/lisp/eshell/em-prompt.el +++ b/lisp/eshell/em-prompt.el @@ -180,7 +180,8 @@ negative, find the Nth next match." (text-property-search-forward 'field 'prompt t)) (setq n (1- n))) (let (match this-match) - (forward-line 0) ; Don't count prompt on current line. + ;; Don't count the current prompt. + (text-property-search-backward 'field 'prompt t) (while (and (< n 0) (setq this-match (text-property-search-backward 'field 'prompt t))) diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 257549e40fb..93bf9d84ab3 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -80,8 +80,13 @@ This tests the case when `eshell-highlight-prompt' is nil." (apply #'propertize "hello\n" eshell-command-output-properties))))))) -(ert-deftest em-prompt-test/next-previous-prompt () - "Check that navigating forward/backward through old prompts works correctly." +(defmacro em-prompt-test--with-multiline (&rest body) + "Execute BODY with a multiline Eshell prompt." + `(let ((eshell-prompt-function (lambda () "multiline prompt\n$ "))) + ,@body)) + +(defun em-prompt-test/next-previous-prompt-with () + "Helper for checking forward/backward navigation of old prompts." (with-temp-eshell (eshell-insert-command "echo one") (eshell-insert-command "echo two") @@ -98,8 +103,17 @@ This tests the case when `eshell-highlight-prompt' is nil." (eshell-next-prompt 3) (should (equal (eshell-get-old-input) "echo fou")))) -(ert-deftest em-prompt-test/forward-backward-matching-input () - "Check that navigating forward/backward via regexps works correctly." +(ert-deftest em-prompt-test/next-previous-prompt () + "Check that navigating forward/backward through old prompts works correctly." + (em-prompt-test/next-previous-prompt-with)) + +(ert-deftest em-prompt-test/next-previous-prompt-multiline () + "Check old prompt forward/backward navigation for multiline prompts." + (em-prompt-test--with-multiline + (em-prompt-test/next-previous-prompt-with))) + +(defun em-prompt-test/forward-backward-matching-input-with () + "Helper for checking forward/backward navigation via regexps." (with-temp-eshell (eshell-insert-command "echo one") (eshell-insert-command "printnl something else") @@ -117,4 +131,13 @@ This tests the case when `eshell-highlight-prompt' is nil." (eshell-forward-matching-input "echo" 3) (should (equal (eshell-get-old-input) "echo fou")))) +(ert-deftest em-prompt-test/forward-backward-matching-input () + "Check that navigating forward/backward via regexps works correctly." + (em-prompt-test/forward-backward-matching-input-with)) + +(ert-deftest em-prompt-test/forward-backward-matching-input-multiline () + "Check forward/backward regexp navigation for multiline prompts." + (em-prompt-test--with-multiline + (em-prompt-test/forward-backward-matching-input-with))) + ;;; em-prompt-tests.el ends here