From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#35564: [PATCH v2] Tweak dired warning about "wildcard" characters Date: Wed, 12 Jun 2019 08:23:10 -0400 Message-ID: <87muinyoup.fsf@gmail.com> References: <87zho2cd4f.fsf@gmail.com> <87wohvf22u.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="56320"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 35564@debbugs.gnu.org, Stefan Monnier To: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 12 14:43:24 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hb2b5-000EYe-IJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Jun 2019 14:43:23 +0200 Original-Received: from localhost ([::1]:59978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb2b4-0007sG-JV for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Jun 2019 08:43:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49978) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hb2IW-00040Z-KU for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 08:24:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hb2IU-00054s-E5 for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 08:24:12 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47299) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hb2IL-0004HZ-UB for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 08:24:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hb2IL-0003is-Pd for bug-gnu-emacs@gnu.org; Wed, 12 Jun 2019 08:24:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 12 Jun 2019 12:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35564 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35564-submit@debbugs.gnu.org id=B35564.156034220214261 (code B ref 35564); Wed, 12 Jun 2019 12:24:01 +0000 Original-Received: (at 35564) by debbugs.gnu.org; 12 Jun 2019 12:23:22 +0000 Original-Received: from localhost ([127.0.0.1]:60843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hb2Hf-0003hu-W7 for submit@debbugs.gnu.org; Wed, 12 Jun 2019 08:23:22 -0400 Original-Received: from mail-it1-f181.google.com ([209.85.166.181]:54368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hb2Hd-0003hh-Mw for 35564@debbugs.gnu.org; Wed, 12 Jun 2019 08:23:18 -0400 Original-Received: by mail-it1-f181.google.com with SMTP id m138so10382941ita.4 for <35564@debbugs.gnu.org>; Wed, 12 Jun 2019 05:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=pRdyNG5JpuS2Ub9Xw/ejRJDDHRRwMk8QlCSMmqmC66M=; b=FIj0a4RAsR8TouSYPeJEp/CS6U4Ty7QGtGLmn4ocP33Xd05nprPzBpFixKih+ujKVl M8a9X9+FDnqyBOoZxgN1g13Fojw/ZrrX19Ac9vJmLwrdnu5yHLvFXX6PEEmSCCot2dqr Z77A0IJzY430FR9Gt+kUyq4qhU4r4QvGv/Nrx+Rpj6mMtVKg0o9yOW2AuLggf3JGPLJK pCV1W1jgUwpcychmKoafm6QrypxSDjgJb2CjJECYXUJoiRyGwUXzBNkBNDV12kK7mfD8 N4BfkhBFotIcKvgyUsVq5nvfZBKGr+JkMoMuy/w56nFwRhL3PyCbKCW0e42nFjEr7Reo C6dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=pRdyNG5JpuS2Ub9Xw/ejRJDDHRRwMk8QlCSMmqmC66M=; b=XTOGGjVYQr6GwY3oP/LRKrhtN0ZoQBc9137A2htiRSDlMXl6W8KwMyHDUYjcAnpIYf 7+p+IJT1sxxFWjltYCRQuNT8s5PerccIe/PbmXYr6vnAGSGJWJsYZ+oIPPCqqKbQgJYD KKKNFJJFBLvVq1RCYjmvzSuSemCMh7Zs8ssHPn0rdjYYa7tmLvAFzFO7DnoTeYD4i6KR zG1Laco2ljdG7jfX4b3RJtHdelzjVjFk1aEWyjieQkAieyH0/24UWwNcJia5YW6u+2GD uEtmxBG62wFeqN/HUL7szHwQ6hmzYub9el07DiMJUT3qWO966DYTygMipZuoYFNHMpcd Ctww== X-Gm-Message-State: APjAAAXZMRf5BiQrjaz2RSepiZrZFpl56Efyrk7oxDus4dCzmz/66pTm Fh44iKAAv4oHUL8Sf2F2cd4= X-Google-Smtp-Source: APXvYqzNb+9aueFgDbeGe7xT8ntBS+W9fCen9Vir+da1jDp9VjUlcDAP6oklr74eYZymKVmaX2xCow== X-Received: by 2002:a24:9f04:: with SMTP id c4mr21339250ite.176.1560342192044; Wed, 12 Jun 2019 05:23:12 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id y136sm2399696itc.37.2019.06.12.05.23.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Jun 2019 05:23:11 -0700 (PDT) In-Reply-To: <87wohvf22u.fsf@gmail.com> ("=?UTF-8?Q?K=C3=A9vin?= Le Gouguec"'s message of "Sun, 09 Jun 2019 13:08:41 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160431 Archived-At: K=C3=A9vin Le Gouguec writes: > +(defun dired--isolated-char-p (command pos) > + "Assert whether the character at POS is isolated within COMMAND. > +A character is isolated if: > +- it is surrounded by whitespace, the start of the command, or > + the end of the command, > +- it is surrounded by `\\=3D`' characters." > + (let ((n (length command)) > + (whitespace '(?\s ?\t))) > + (or (=3D n 1) > + (and (=3D pos 0) > + (memq (elt command 1) whitespace)) > + (and (=3D pos (1- n)) > + (memq (elt command (1- pos)) whitespace)) > + (and > + (> pos 0) > + (< pos (1- n)) > + (let ((prev (elt command (1- pos))) > + (next (elt command (1+ pos)))) > + (or (and (memq prev whitespace) > + (memq next whitespace)) > + (and (=3D prev ?`) > + (=3D next ?`)))))))) I think this might be better expressed in regexp: (and (string-match (rx-to-string '(seq (or bos (in blank ?`)) (group (eval (string (aref command pos)))) (or eos (in blank ?`)))) command (max 0 (1- pos))) (=3D pos (match-beginning 1))) Although this gives different results for things like: (dired--isolated-char-p "?`foo`" 0) Do we care about that? (if yes, then that's a missing test case) > +(defun dired--highlight-nosubst-char (command char) > + "Highlight occurences of CHAR that are not isolated in COMMAND. > +These occurences will not be substituted; they will be sent as-is > +to the shell, which may interpret them as wildcards." > + (save-match-data > + (let ((highlighted (substring-no-properties command)) > + (pos 0)) > + (while (string-match (regexp-quote char) command pos) > + (let ((start (match-beginning 0)) > + (end (match-end 0))) > + (unless (dired--isolated-char-p command start) > + (add-face-text-property start end 'warning nil highlighted)) > + (setq pos end))) > + highlighted))) And perhaps the regexp above (if it's correct) can be integrated into this search? (maybe not though, since negation isn't straightforward in regexps)