From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Dired: Improve symmetry in mark/unmark commands bound to keys Date: Sun, 25 Sep 2016 02:31:30 +0900 (JST) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1474738380 27939 195.159.176.226 (24 Sep 2016 17:33:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Sep 2016 17:33:00 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: tino.calancha@gmail.com To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 24 19:32:56 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bnqoh-0005pA-3n for ged-emacs-devel@m.gmane.org; Sat, 24 Sep 2016 19:32:47 +0200 Original-Received: from localhost ([::1]:34875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnqof-000222-Jh for ged-emacs-devel@m.gmane.org; Sat, 24 Sep 2016 13:32:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnqoY-00020J-NF for emacs-devel@gnu.org; Sat, 24 Sep 2016 13:32:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bnqoT-0005yW-L4 for emacs-devel@gnu.org; Sat, 24 Sep 2016 13:32:38 -0400 Original-Received: from mail-pf0-f194.google.com ([209.85.192.194]:34445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bnqoT-0005yS-Ch for emacs-devel@gnu.org; Sat, 24 Sep 2016 13:32:33 -0400 Original-Received: by mail-pf0-f194.google.com with SMTP id 21so6805456pfy.1 for ; Sat, 24 Sep 2016 10:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:user-agent:mime-version; bh=6DAzobH7pdGN/KyeofAx5Watrx6ZpMid6Vh+HwGOqc0=; b=TyloWRmfxPzLxmcZ3kxC7rnMLZrSmbxERRFmhYCi7RShoURVb5hEhXUNbXo71crvFX a1y+yOdINK5xszofNb3qtt8ySIHuJKiWf8+7g6fRjGkXJ6CcFGKVxCvdWamtzBZWvjrZ O4KEHSi+5bmwidCmk/SzdWpKhm5Zm30ADLBnMk8DcXNuYzz31bkCHhM1LraARz6tKfYo MPk+SS412aiHUxt887TD5jDGsnno9nUTnGXRSRoqqZxvziBDm2qLQlVfstG8mU8vHWqW hWKy1yMlwxBV4wGe8p/zuvkvBWnrMM9YbfHVtMifFCjnem4qihL4qN33/ybttyBy1ik8 LYLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:message-id:user-agent :mime-version; bh=6DAzobH7pdGN/KyeofAx5Watrx6ZpMid6Vh+HwGOqc0=; b=NzyJNtlguOFXgVhSjD4TQEw0LDSi7Zx+37Z3bvzCW0fFMSht2aW5mBT/tlVCMv3Pt6 IFdM3+k37GHss83+x9QsVextd1fm7IicgpCgW50MOOJqw7zu6rX42B92cLt2K1LbNDq4 Btz/cc91wTIA0Y9X5403OC1/I623fp5UhIffYOoSbCGMhEtRTAhsvC3x2Emey4ecKncB CbOBZ4DKE5kvHKI4gbhwXHXyyaQbKZYKrMO+FqfsaKn8dokdcHbHEwZ3JK5RbxM+PZum zs/bAGV3Q45BYryw8gdVtVS+jq0PZRrJU/0BhTVnz7AZsObdR47maFRaJDw64MyG3XEd oihA== X-Gm-Message-State: AE9vXwMkzqmQqp64NqnQiNktFm1EluCUTMqfe5ZgmlMXLG/Q/jdRJayxw89D2mP9iKrX6g== X-Received: by 10.98.113.135 with SMTP id m129mr22873812pfc.41.1474738292733; Sat, 24 Sep 2016 10:31:32 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id f7sm19805584pfk.79.2016.09.24.10.31.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Sep 2016 10:31:32 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.194 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207754 Archived-At: Dear all, in Dired we have several commmands for mark files bound to keys (the order is irrelevant): 1) * / 2) * @ 3) % m 4) % g 5) * * 6) * s If you load `dired-x' you get more: 7) M-( 8) * . >From that list all but 6) and 8) will _unmark_ in an interactive call with prefix argument. That is, they mark files or unmark them. I have suggested in Bug#24518 that 8) should follow the same idiom with no success :-( Let's see my new proposal: I) Add optional argument in 6) unflag-p to behave as the others. II) Add a new command `dired-mark-or-unmark-extension', as `dired-mark-extension' but, in interactive calls: * A prefix argument _unmark_ files. I propose to rebind '* .' to this command instead of the `dired-mark-extension'. After I) and II) we have an uniform behaviour for all commands marking files which are bound to keys. Powerful and easy to remember. What do you think? Regards, Tino ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 33847d0f96356c6c09a78f391e27fa6a5b4f7628 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sun, 25 Sep 2016 02:26:37 +0900 Subject: [PATCH] All Dired commands marking files, with prefix arg unmark * lisp/dired-aux.el (dired-mark-subdir-files): Add optional argument UNFLAG-P; if non-nil unmark files instead. Save the point, call dired-mark-extension' but interactively with prefix arg unmark files. Rebind '*.' to this command. (dired-mark-sexp): Say 'Unmark' in the prompt for interactive calls with prefix arg. --- lisp/dired-aux.el | 11 +++++++---- lisp/dired-x.el | 28 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 9e0943a..a817f74 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2523,13 +2523,16 @@ dired-goto-subdir (point))))) ;;;###autoload -(defun dired-mark-subdir-files () +(defun dired-mark-subdir-files (&optional unflag-p) "Mark all files except `.' and `..' in current subdirectory. +With prefix argument, unmark or unflag all those files. If the Dired buffer shows multiple directories, this command marks the files listed in the subdirectory that point is in." - (interactive) - (let ((p-min (dired-subdir-min))) - (dired-mark-files-in-region p-min (dired-subdir-max)))) + (interactive "P") + (let ((dired-marker-char (or (and unflag-p ?\s) dired-marker-char)) + (p-min (dired-subdir-min))) + (save-excursion + (dired-mark-files-in-region p-min (dired-subdir-max))))) ;;;###autoload (defun dired-kill-subdir (&optional remember-marks) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 7d73c42..0656b47 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -245,7 +245,7 @@ dired-mode-map (define-key dired-mode-map "*O" 'dired-mark-omitted) (define-key dired-mode-map "\M-(" 'dired-mark-sexp) (define-key dired-mode-map "*(" 'dired-mark-sexp) -(define-key dired-mode-map "*." 'dired-mark-extension) +(define-key dired-mode-map "*." 'dired-mark-or-unmark-extension) (define-key dired-mode-map "\M-!" 'dired-smart-shell-command) (define-key dired-mode-map "\M-G" 'dired-goto-subdir) (define-key dired-mode-map "F" 'dired-do-find-marked-files) @@ -354,6 +354,26 @@ dired-mark-extension "\\)$") marker-char)) +(defun dired-mark-or-unmark-extension (extension &optional marker-char) + "Mark all files with a certain EXTENSION for use in later commands. +With prefix argument, unmark or unflag all those files. +A `.' is *not* automatically prepended to the string entered. +EXTENSION may also be a list of extensions instead of a single one. +Interactively, ask for EXTENSION." + (interactive + (list (read-string + (format "%s extension: " + (if current-prefix-arg "Unmarking" "Marking"))) + (and current-prefix-arg ?\s))) + (or (listp extension) + (setq extension (list extension))) + (dired-mark-files-regexp + (concat ".";; don't match names with nothing but an extension + "\\(" + (mapconcat 'regexp-quote extension "\\|") + "\\)$") + marker-char)) + (defun dired-flag-extension (extension) "In Dired, flag all files with a certain EXTENSION for deletion. A `.' is *not* automatically prepended to the string entered." @@ -1470,7 +1490,11 @@ dired-mark-sexp ;; (string-match "foo" sym) into which a user would soon fall. ;; Give `equal' instead of `=' in the example, as this works on ;; integers and strings. - (interactive "xMark if (lisp expr): \nP") + (interactive + (list (read--expression + (format "%s if (lisp expr): " + (if current-prefix-arg "Unmark" "Mark"))) + current-prefix-arg)) (message "%s" predicate) (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)) inode s mode nlink uid gid size time name sym) -- 2.9.3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.2.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.0) of 2016-09-25 Repository revision: 5ee56c4613e9380dbbe4bbaa97b29dd377e2134c