From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#17251: 24.4.50; `dired-guess-default': wrong logic Date: Sat, 12 Apr 2014 09:05:42 -0700 (PDT) Message-ID: <97d70b54-93f6-4247-9a29-68145f9d8965@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1397318855 8730 80.91.229.3 (12 Apr 2014 16:07:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Apr 2014 16:07:35 +0000 (UTC) To: 17251@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 12 18:07:28 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WZ0Sl-000232-1h for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Apr 2014 18:07:27 +0200 Original-Received: from localhost ([::1]:34980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ0Sk-0006uk-3z for geb-bug-gnu-emacs@m.gmane.org; Sat, 12 Apr 2014 12:07:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ0SW-0006uS-Vr for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:07:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZ0SM-0002hd-Kb for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:07:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ0SM-0002hZ-GT for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WZ0SM-0001Vg-0l for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Apr 2014 16:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17251 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13973187825736 (code B ref -1); Sat, 12 Apr 2014 16:07:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Apr 2014 16:06:22 +0000 Original-Received: from localhost ([127.0.0.1]:46359 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WZ0Rh-0001US-LK for submit@debbugs.gnu.org; Sat, 12 Apr 2014 12:06:22 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49715) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WZ0Rf-0001UA-4I for submit@debbugs.gnu.org; Sat, 12 Apr 2014 12:06:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZ0RP-0002Hk-Gs for submit@debbugs.gnu.org; Sat, 12 Apr 2014 12:06:13 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:46347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ0RP-0002Hg-EI for submit@debbugs.gnu.org; Sat, 12 Apr 2014 12:06:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ0RG-0006Dj-L3 for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:06:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WZ0R7-0002C8-UW for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:05:54 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:24749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WZ0R7-0002AG-Ms for bug-gnu-emacs@gnu.org; Sat, 12 Apr 2014 12:05:45 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s3CG5guw029446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 12 Apr 2014 16:05:43 GMT Original-Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s3CG5fBS023313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 12 Apr 2014 16:05:42 GMT Original-Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s3CG5fEA003098 for ; Sat, 12 Apr 2014 16:05:41 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:87976 Archived-At: The logic in the implementation of `dired-guess-default' is wrong, or at least not optimal. And it is not what users are entitled to expect, based on the doc of `dired-guess-shell-alist-user'. If this logic is kept as is (which would be unfortunate), then at least there is a doc bug here, because the doc of user option `dired-guess-shell-alist-user' does not reflect this logic. Users will thus get behavior that does not correspond to what they expect based on the doc. The doc gives the impression that if you have multiple entries in the option value that use different regexps with the same command, these will be used together, IOW, any and all of them will be associated with the same command. That is the whole point of this user option (and also of variable `dired-guess-shell-alist-default'): to associate file names with one or more commands. The regexps are only a handy means to that end. For example, from the doc, one can reasonably expect that if the option value is this: (("\\.png\\'" "foo.exe") ("\\.jpg\\'" "foo.exe")) then command "foo.exe" can be used for a list of files such as: ("toto.png" "tata.jpg") But this is not in fact what the behavior is. To get that expected behavior, the user would have to combine those entries into a single entry such as this: (("\\.\\(png\\|jpg\\)\\'" "foo.exe")) This is not at all clear from the doc. And it means extra work and better knowledge of regexps on the part of users. The culprit code is this part of `dired-guess-default': ;; If more than one file, see if all of FILES match regular expression. (while (and flist (string-match-p regexp (car flist))) (setq flist (cdr flist))) IOW, the code expects each of the files in the list of candidates to match the given regexp. In the case above, this means that the regexp "\\.png\\'" would be tested against each of the files ("toto.png" "tata.jpg"), it would fail, and so the command "foo.exe", which the user has explicitly configured as appropriate for both PNG files and JPG files, would not be available. IOW, instead of working off of the regexp only, the code should work off of the associated COMMANDS. What is important here is the COMMAND, "foo.exe", and it is clearly (according to the user) appropriate for all files whose names match either regexp (i.e., all PNG and JPG files). IOW, the implementation is overly restrictive. The true requirement is that each of the file names in the list of candidates must be mapped to the SAME COMMAND via *some* regexp. The requirement is not (should not be) that each of the file names must match the SAME REGEXP. It is the COMMAND that is important. The regexps are just a means of associating file names with commands. If you do not fix the implementation logic of `dired-guess-default' (which would be unfortunate), then please at least fix the doc string of option `dired-guess-shell-alist-user' so that it tells users that they MUST COMBINE regexps that are mapped to the same command, i.e., they must come up with a single regexp for the given command. A list of files whose names are associated with the same command via different regexps will not be handled by that command. In GNU Emacs 24.4.50.1 (i686-pc-mingw32) of 2014-04-08 on ODIEONE Bzr revision: 116956 dancol@dancol.org-20140408123940-knoyutxt4l8ws7qm Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --prefix=3D/c/Devel/emacs/snapshot/trunk --enable-checking=3Dyes,glyphs 'CFLAGS=3D-O0 -g3' LDFLAGS=3D-Lc:/Devel/emacs/lib 'CPPFLAGS=3D-DGC_MCHECK=3D1 -Ic:/Devel/emacs/include''