From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 48302@debbugs.gnu.org
Subject: bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows
Date: Sun, 9 May 2021 13:07:42 -0700 [thread overview]
Message-ID: <CANh=_JE417Ls2qQVv6w63rX94ETr0JTx7WT5HnqDx8Qf=WwFxg@mail.gmail.com> (raw)
In-Reply-To: <83r1ig8kk3.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 898 bytes --]
On Sat, May 8, 2021 at 11:53 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> Thanks, but could you also add a test for this issue to the test
> suite?
I see some grep-related tests in
`test/lisp/progmodes/compile-tests.el', but those only cover
`grep-regexp-alist', not `grep-mode-font-lock-keywords'. Testing
grep.el's font-lock didn't seem like it would belong in
`compile-tests.el', so I've added `test/lisp/progmodes/grep-tests.el'
and included a (very) simple test for find-abbreviation. It uses the
shell-quoting semantics of whatever the current system is; it would be
nice to test all shell-quoting styles in one test run, but I wasn't
sure how to do that. Still, if automated tests are run on multiple
platforms, this should (hopefully) catch any bugs.
My Elisp skills are fairly basic, so I may have made some mistakes
here. Just let me know what (if anything) needs improved for the
tests.
[-- Attachment #2: 0001-Abbreviate-rgrep-command-when-using-MS-Windows-style.patch --]
[-- Type: application/octet-stream, Size: 2808 bytes --]
From f038b2426edc7c7db7ecbdc896e11b4dc35d54e0 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sun, 9 May 2021 13:05:22 -0700
Subject: [PATCH] Abbreviate rgrep command when using MS Windows-style
shell-quoting
lisp/progmodes/grep.el (grep-mode-font-lock-keywords): Adapt regexp to match
MS Windows-style shell-quoting.
test/lisp/progmodes/grep-tests.el: New file.
---
lisp/progmodes/grep.el | 2 +-
test/lisp/progmodes/grep-tests.el | 39 +++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 test/lisp/progmodes/grep-tests.el
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index e9fbcbbfcd..80c3e7840f 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -473,7 +473,7 @@ grep-mode-font-lock-keywords
(1 (if (eq (char-after (match-beginning 1)) ?\0)
`(face nil display ,(match-string 2)))))
;; Hide excessive part of rgrep command
- ("^find \\(\\. -type d .*\\\\)\\)"
+ ("^find \\(\\. -type d .*\\(?:\\\\)\\|\")\"\\)\\)"
(1 (if grep-find-abbreviate grep-find-abbreviate-properties
'(face nil abbreviated-command t))))
;; Hide excessive part of lgrep command
diff --git a/test/lisp/progmodes/grep-tests.el b/test/lisp/progmodes/grep-tests.el
new file mode 100644
index 0000000000..211b96a765
--- /dev/null
+++ b/test/lisp/progmodes/grep-tests.el
@@ -0,0 +1,39 @@
+;;; grep-tests.el --- Test suite for grep.el -*- lexical-binding:t -*-
+
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'grep)
+
+(ert-deftest grep-tests--find-abbreviate-properties ()
+ (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]")))
+ (with-temp-buffer
+ (grep-compute-defaults)
+ (insert (rgrep-default-command "search" "*" nil))
+ (grep-mode)
+ (font-lock-mode)
+ (font-lock-ensure)
+ (goto-char (point-min))
+ (re-search-forward "find ")
+ (should (equal (get-text-property (point) 'display) ellipsis)))))
+
+;;; grep-tests.el ends here
--
2.25.1
next prev parent reply other threads:[~2021-05-09 20:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-08 22:17 bug#48302: [PATCH] Abbreviate `find' properties in M-x rgrep on MS Windows Jim Porter
2021-05-09 6:53 ` Eli Zaretskii
2021-05-09 20:07 ` Jim Porter [this message]
2021-05-10 7:42 ` Michael Albinus
2021-05-11 4:36 ` bug#48302: [PATCH v2] " Jim Porter
2021-05-11 7:11 ` Michael Albinus
2021-05-11 12:22 ` Eli Zaretskii
2021-05-12 8:48 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANh=_JE417Ls2qQVv6w63rX94ETr0JTx7WT5HnqDx8Qf=WwFxg@mail.gmail.com' \
--to=jporterbugs@gmail.com \
--cc=48302@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.