unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
To: Chong Yidong <cyd@stupidchicken.com>
Cc: Glenn Morris <rgm@gnu.org>, Nick Roberts <nickrob@snap.net.nz>,
	rms@gnu.org, emacs-devel@gnu.org
Subject: Re: display-completion-list should not strip text properties
Date: Fri, 06 Apr 2007 18:26:07 +0200	[thread overview]
Message-ID: <m3tzvta2qo.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <87d52ifekm.fsf@stupidchicken.com> (Chong Yidong's message of "Thu\, 05 Apr 2007 21\:59\:21 -0400")

Chong Yidong <cyd@stupidchicken.com> writes:

> The two changes that we have to reimplement are the following:
>
> 1997-03-24  Kevin Rodgers  <kevinr@ihs.com>
>
> 	* compile.el (grep-program): New variable.
> 	(grep-command): Use it, and test whether it supports the -e
> 	option; fix doc string (last command is stored in history variable).
> 	(grep-null-device): Declare before grep-program and grep-command.
> 	(grep-find-use-xargs, grep-find-command, grep-find-history):
> 	New variables.
> 	(grep-find): New command.
> 	(grep): Only concatenate grep-null-device to COMMAND when it's
> 	not nil (to support grep-find).


EXECUTIVE SUMMARY:
------------------

  We don't have to do anything about this.


ANALYSIS:
---------

I (and others) have already modified the code introduced by those
changes several times, so parts of it is no longer present -- or very
different from the original code.  However, there are still parts which
are quite close to Kevin's original code.


Let's go over those changes:

Index: compile.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/compile.el,v
retrieving revision 1.158
retrieving revision 1.159
diff -c -r1.158 -r1.159
*** compile.el	21 Feb 1997 09:46:03 -0000	1.158
--- compile.el	24 Mar 1997 23:59:44 -0000	1.159
***************
*** 256,263 ****
  
! (defvar grep-command "grep -n "
!   "Last grep command used in \\[grep]; default for next grep.")
  
--- 256,307 ----
  
! ;; Use zgrep if available, to work nicely with compressed files.
! ;; Otherwise, use ordinary grep.
! (defvar grep-program
!   (if (equal (condition-case nil	; in case "zgrep" isn't in exec-path
! 		 (call-process "zgrep" nil nil nil
! 			       "foo" grep-null-device)
! 	       (error nil))
! 	     1)
!       "zgrep"
!     "grep")
!   "The default grep program for `grep-command' and `grep-find-command'.")


This change has been reverted - but Kevin's code is still included as a comment.
We could just remove the comment.


! ;; Use -e if grep supports it,
! ;; because that avoids lossage if the pattern starts with `-'.
! (defvar grep-command
!   (if (equal (condition-case nil	; in case "grep" isn't in exec-path
! 		 (call-process grep-program nil nil nil
! 			       "-e" "foo" grep-null-device)
! 	       (error nil))
! 	     1)
!       (format "%s -n -e " grep-program)
!     (format "%s -n " grep-program))
!   "The default grep command for \\[grep].")

The variable still exists, but the code to initialize it has been reworked,
and is no longer Kevin's work.

! (defvar grep-find-use-xargs
!   (if (equal (call-process "find" nil nil nil
! 			   grep-null-device "-print0")
! 	     0)
!       'gnu)
!   "Whether \\[grep-find] uses the `xargs' utility by default.
! 
! If nil, it uses `grep -exec'; if `gnu', it uses `find -print0' and `xargs -0';
! if not nil and not `gnu', it uses `find -print' and `xargs'.
! 
! This variable's value takes effect when `compile.el' is loaded
! by influencing the default value for the variable `grep-find-command'.")

Ditto.  The current doc string is 50% similar to Kevin's work.

! 
! (defvar grep-find-command
!   (cond ((eq grep-find-use-xargs 'gnu)
! 	 (format "find . -type f -print0 | xargs -0 -e %s" grep-command))
! 	(grep-find-use-xargs
! 	 (format "find . -type f -print | xargs %s" grep-command))
! 	(t (cons (format "find . -type f -exec %s {} /dev/null \\;"
! 			 grep-command)
! 		 (+ 22 (length grep-command)))))
!   "The default find command for \\[grep-find].")


The variable still exists, but otherwise, this part has been
completely reworked.


***************
*** 308,313 ****
--- 352,358 ----

+ (defvar grep-find-history nil)

Still exists -- but that's a trivial change (how else would you define
the var?)


***************
*** 392,402 ****
    ;; Setting process-setup-function makes exit-message-function work
    ;; even when async processes aren't supported.
    (let* ((compilation-process-setup-function 'grep-process-setup)
! 	 (buf (compile-internal (concat command-args " " grep-null-device)
  				"No more grep hits" "grep"
  				;; Give it a simpler regexp to match.
  				nil grep-regexp-alist)))))
  
  (defun compile-internal (command error-message
  				 &optional name-of-mode parser regexp-alist
  				 name-function)
--- 437,464 ----
    ;; Setting process-setup-function makes exit-message-function work
    ;; even when async processes aren't supported.
    (let* ((compilation-process-setup-function 'grep-process-setup)
! 	 (buf (compile-internal (if grep-null-device
! 				    (concat command-args " " grep-null-device)
! 				  command-args)
  				"No more grep hits" "grep"
  				;; Give it a simpler regexp to match.
  				nil grep-regexp-alist)))))


This part is also completely reworked.
  
+ 
+ ;;;###autoload
+ (defun grep-find (command-args)
+   "Run grep via find, with user-specified args, and collect output in a buffer.
+ While find runs asynchronously, you can use the \\[next-error] command
+ to find the text that grep hits refer to.
+ 
+ This command uses a special history list for its arguments, so you can
+ easily repeat a find command."
+   (interactive
+    (list (read-from-minibuffer "Run find (like this): "
+ 			       grep-find-command nil nil 'grep-find-history)))
+   (let ((grep-null-device nil))		; see grep
+     (grep command-args)))
+ 

The grep-find command is still present with the above code and doc string
mostly intact (the code has been extended in various ways - but you can still
find those 5 lines of code in the current version of the function.

However, Kevin's code and doc string is clearly derived from the
already existing grep defun:

(defun grep (command-args)
  "Run grep, with user-specified args, and collect output in a buffer.
While grep runs asynchronously, you can use the \\[next-error] command
to find the text that grep hits refer to.

This command uses a special history list for its arguments, so you can
easily repeat a grep command."
  (interactive
   (list (read-from-minibuffer "Run grep (like this): "
			       grep-command nil nil 'grep-history)))
  ;; Setting process-setup-function makes exit-message-function work
  ;; even when async processes aren't supported.
  (let* ((compilation-process-setup-function 'grep-process-setup)
	 (buf (compile-internal (concat command-args " " grep-null-device)
				"No more grep hits" "grep"
				;; Give it a simpler regexp to match.
				nil grep-regexp-alist)))))



CONCLUSION:
-----------

Except for the commentary about zgrep [which I have just removed],
the relevant code has either been reworked already, or is trivially
derived from existing code.

To conclude, I don't think we need to do anything about the changes
related to grep-find functionality.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  parent reply	other threads:[~2007-04-06 16:26 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-22 17:23 display-completion-list should not strip text properties Drew Adams
2007-01-22 18:56 ` Stefan Monnier
2007-01-23  2:07 ` Richard Stallman
2007-01-23  5:10   ` Drew Adams
2007-01-23 21:32     ` Drew Adams
2007-01-24  8:22     ` Richard Stallman
2007-01-24 23:43       ` Johan Bockgård
2007-01-25 10:53         ` Richard Stallman
2007-01-26 13:17           ` Vinicius Jose Latorre
2007-01-27  0:46             ` Richard Stallman
2007-09-01 19:56           ` Drew Adams
2007-09-02 18:52             ` Juri Linkov
2007-09-03 18:25               ` Richard Stallman
2007-09-03 23:48                 ` Juri Linkov
2007-09-04  5:59                   ` David Kastrup
2007-09-04  9:52                     ` Juri Linkov
2007-09-04  8:49                   ` tomas
2007-09-04  9:54                     ` Juri Linkov
2007-09-04 10:56                       ` Johan Bockgård
2007-09-04 22:58                         ` Richard Stallman
2007-09-04 16:45                   ` Richard Stallman
2007-09-04 18:51                     ` Drew Adams
2007-09-04 22:46                       ` Davis Herring
2007-09-05  6:16                         ` Richard Stallman
2007-09-05 14:21                           ` Drew Adams
2007-09-06  4:59                             ` Richard Stallman
2007-09-06 16:35                               ` Drew Adams
2007-09-06 20:04                                 ` Edward O'Connor
2007-09-06 20:16                                   ` Drew Adams
2007-09-06 23:08                                     ` Robert J. Chassell
2007-09-06 23:42                                       ` Davis Herring
2007-09-07 12:30                                         ` Robert J. Chassell
2007-09-08  7:00                                           ` Richard Stallman
2007-09-07 19:53                                     ` Richard Stallman
2007-09-07 22:07                                       ` Drew Adams
2007-09-06 20:06                                 ` David Kastrup
2007-09-06 20:22                                   ` Drew Adams
2007-09-07  6:31                                 ` Richard Stallman
2007-09-05  6:16                       ` Richard Stallman
2007-03-20 22:36       ` Drew Adams
2007-04-02 16:55         ` Drew Adams
2007-04-02 18:51           ` Kim F. Storm
2007-04-03 21:40           ` Richard Stallman
2007-04-03 21:53             ` Juanma Barranquero
2007-04-04 14:03               ` Richard Stallman
2007-04-03 22:03             ` Nick Roberts
2007-04-04 14:03             ` Richard Stallman
2007-04-04 14:59               ` Chong Yidong
2007-04-05 23:11                 ` Richard Stallman
2007-04-05 23:20                   ` Chong Yidong
2007-04-06 19:47                     ` Richard Stallman
2007-04-05 23:45                   ` Nick Roberts
2007-04-06  1:15                     ` Glenn Morris
2007-04-06  1:59                       ` Chong Yidong
2007-04-06  2:22                         ` David Kastrup
2007-04-06  4:18                         ` Glenn Morris
2007-04-06  8:41                         ` Eli Zaretskii
2007-04-06 14:47                           ` Chong Yidong
2007-04-06 16:26                         ` Kim F. Storm [this message]
2007-04-06 17:34                           ` Eli Zaretskii
2007-04-07 12:40                           ` Richard Stallman
2007-04-06 17:06                         ` Kim F. Storm
2007-04-06 19:23                         ` Kevin Rodgers changes Chong Yidong
2007-04-07  7:32                           ` martin rudalics
2007-04-07 12:40                           ` Richard Stallman
2007-04-07 16:57                             ` Chong Yidong
2007-04-07 17:34                             ` Eli Zaretskii
2007-04-08 12:28                               ` Richard Stallman
2007-04-08 21:07                                 ` Eli Zaretskii
2007-04-09 14:33                                   ` Daniel Brockman
2007-04-09 15:42                                   ` Richard Stallman
2007-04-08 21:30                                 ` Chong Yidong
2007-04-09 15:42                                   ` Richard Stallman
2007-04-11 16:38                         ` display-completion-list should not strip text properties Markus Triska
2007-04-11 17:13                           ` Chong Yidong
2007-04-06 19:47                     ` Richard Stallman
2007-04-06  8:42                   ` Eli Zaretskii
2007-04-06 19:47                     ` Richard Stallman
2007-04-04 17:45               ` Edward O'Connor
2007-04-05 14:36                 ` Chong Yidong
2007-04-05 15:02                   ` Juanma Barranquero
2007-04-05 23:11                 ` Richard Stallman
2007-01-24  7:07   ` Kevin Rodgers

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3tzvta2qo.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=nickrob@snap.net.nz \
    --cc=rgm@gnu.org \
    --cc=rms@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).