From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: trentbuck@gmail.com (Trent W. Buck) Newsgroups: gmane.emacs.bugs Subject: bug#15504: 24.3; find-dired's numerous prompts are inflexible and annoying Date: Wed, 02 Oct 2013 11:45:16 +1000 Message-ID: <8761tg1m4z.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1380678375 14141 80.91.229.3 (2 Oct 2013 01:46:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Oct 2013 01:46:15 +0000 (UTC) To: 15504@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 02 03:46:18 2013 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 1VRBW6-0001sP-7x for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Oct 2013 03:46:18 +0200 Original-Received: from localhost ([::1]:33530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRBW5-0004bf-U4 for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Oct 2013 21:46:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRBVx-0004U9-7T for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:46:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRBVr-0005Or-2w for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:46:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRBVq-0005Oh-Va for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:46:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VRBVq-0003Q7-FI for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: trentbuck@gmail.com (Trent W. Buck) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Oct 2013 01:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 15504 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.138067834713117 (code B ref -1); Wed, 02 Oct 2013 01:46:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Oct 2013 01:45:47 +0000 Original-Received: from localhost ([127.0.0.1]:48300 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VRBVa-0003PU-E9 for submit@debbugs.gnu.org; Tue, 01 Oct 2013 21:45:46 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:59400) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VRBVY-0003PL-T4 for submit@debbugs.gnu.org; Tue, 01 Oct 2013 21:45:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRBVS-0005Ev-IO for submit@debbugs.gnu.org; Tue, 01 Oct 2013 21:45:44 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:56242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRBVS-0005Er-DE for submit@debbugs.gnu.org; Tue, 01 Oct 2013 21:45:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRBVM-00041e-5t for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:45:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRBVG-00054G-11 for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:45:32 -0400 Original-Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]:44448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRBVF-00053s-Kn for bug-gnu-emacs@gnu.org; Tue, 01 Oct 2013 21:45:25 -0400 Original-Received: by mail-pa0-f48.google.com with SMTP id bj1so328542pad.7 for ; Tue, 01 Oct 2013 18:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=EAZ4vgEHUZUOKQohbZXoMKRaJQpivLD5hHXWWhWdfOo=; b=Cy8CYN/z9rWwBlV358X5aIQZb7qGovSMYE088xT4x3pSVR2VeoblpzBsODKGqF0U9c 96Z0T5c2MbBR3OY7GEsQNCFQjknJhkT7yKjhX9WC5zARvSq4J29LSdezjVqc/pEiT6uD 1kNPo3tq5CHqgyi8GI5n9uOgdvrTCH3KmUZYrPp6DRA+UP9MDgVToYR3NEdV5IMyHMb0 w/jwehJU0sUCBw++dEnPIn4vXRAEikJo+lqgYnlFgRlBsmsRL2eaGsyH2Sm+XA9vXZq9 g4Klk/0uM8eXKP5N/Hfi1HXsDmuuCcb5lqinI8A+qza7Jwrb+S8vdxtjuutdUf6kS0pZ OW7A== X-Received: by 10.66.192.8 with SMTP id hc8mr463144pac.66.1380678324227; Tue, 01 Oct 2013 18:45:24 -0700 (PDT) Original-Received: from localhost ([203.7.155.76]) by mx.google.com with ESMTPSA id xs1sm11489544pac.7.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 01 Oct 2013 18:45:23 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:78849 Archived-At: I prefer to do M-x grep RET and then type something complicated like grep -r --include '*.c' --exclude-dir .git . -e foo -e bar ...rather than M-x rgrep which has lots of stupid prompts that then get stuck together in a fixed kind of way. In the same vein, I hate M-x find dired RET multiple prompts. For a few years I've been using a munged up replacement that just asks for a single command, and runs it (below). The history handling is a bit buggered, and it breaks the existing multi-prompt style (presumably some people prefer it). Daniel Colascione liked my approach and asked me to publish it, (presumably) so it can be cleaned up and pushed into Emacs proper. I don't care enough to do that work myself, but I'm happy to talk to anyone who does. I've already done the copyright assignment dance. PS: find -ls's output is actually crap, because the entries don't line up properly and files with spaces become "foo\ bar" which dired mode doesn't like, so I generally end up doing "find -exec ls -lidsh {} +". (setq find-ls-option ; http://emacsbugs.donarmstrong.com/4403 (let ((help (shell-command-to-string (format "%s --help" find-program)))) (if (string-match " -ls\\>" help) '("-ls" . "-lids") (if (string-match "{} \\+" help) '("-exec ls -ldh {} +" . "-ldh") '("-exec ls -ldh {} \\;" . "-ldh"))))) ;;; Guerilla patch -- redefine FIND-DIRED to act less like RGREP and more like ;;; GREP. That is, prompt for an arbitrary command instead of "helpfully" ;;; constructing a command from an inflexible series of prompts. Defaults to ;;; "find -ls"; "find -exec ls {} +" is also possible to e.g. sort by file size. (eval-after-load "dired" '(eval-after-load "find-dired" '(progn (defvar find-command/twb (concat find-program " " (car find-ls-option))) (defvar find-command-history/twb nil) (defun find-dired (command) "Like find-dired, but let me just WRITE the command instead of trying to construct it for me. Cf. `grep' vs. `rgrep'." (interactive (list (read-string "Run find: " find-command/twb '(find-command-history/twb . 1)))) (let ((dired-buffers dired-buffers) (dir default-directory)) (switch-to-buffer (get-buffer-create "*Find*")) (setq default-directory dir) ;; See if there's still a `find' running, and offer to kill ;; it first, if it is. (let ((find (get-buffer-process (current-buffer)))) (when find (if (or (not (eq (process-status find) 'run)) (yes-or-no-p "A `find' process is running; kill it? ")) (condition-case nil (progn (interrupt-process find) (sit-for 1) (delete-process find)) (error nil)) (error "Cannot have two processes in `%s' at once" (buffer-name))))) (widen) (kill-all-local-variables) (setq buffer-read-only nil) (erase-buffer) (setq find-command command) ; save for next interactive call ;; Start the find process. (shell-command (concat command "&") (current-buffer)) ;; The next statement will bomb in classic dired (no optional arg allowed) (dired-mode default-directory (cdr find-ls-option)) (let ((map (make-sparse-keymap))) (set-keymap-parent map (current-local-map)) (define-key map "\C-c\C-k" 'kill-find) (use-local-map map)) (make-local-variable 'dired-sort-inhibit) (setq dired-sort-inhibit t) (set (make-local-variable 'revert-buffer-function) `(lambda (ignore-auto noconfirm) (find-dired ,find-command))) ;; Set subdir-alist so that Tree Dired will work: (if (fboundp 'dired-simple-subdir-alist) ;; will work even with nested dired format (dired-nstd.el,v 1.15 ;; and later) (dired-simple-subdir-alist) ;; else we have an ancient tree dired (or classic dired, where ;; this does no harm) (set (make-local-variable 'dired-subdir-alist) (list (cons default-directory (point-min-marker))))) (set (make-local-variable 'dired-subdir-switches) find-ls-subdir-switches) (setq buffer-read-only nil) ;; Subdir headlerline must come first because the first marker in ;; subdir-alist points there. (insert " " default-directory ":\n") ;; Make second line a ``find'' line in analogy to the ``total'' or ;; ``wildcard'' line. (insert " " command "\n") (setq buffer-read-only t) (let ((proc (get-buffer-process (current-buffer)))) (set-process-filter proc (function find-dired-filter)) (set-process-sentinel proc (function find-dired-sentinel)) ;; Initialize the process marker; it is used by the filter. (move-marker (process-mark proc) 1 (current-buffer))) (setq mode-line-process '(":%s"))))))) In GNU Emacs 24.3.1 (armv7l-unknown-linux-gnueabi) of 2013-03-15 on elba System Description: Ubuntu 11.10 Configured using: `configure '--without-x' '--without-sound' '--without-all' '--with-x-toolkit=no' '--with-xpm=no' '--with-gif=no' '--with-jpeg=no' '--with-tiff=no' '--with-png=no' '--with-dbus=no' '--with-gsettings=no' '--with-gnutls=no' '--prefix=/home/twb/opt/emacs-24.3''