git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git.el: Add a git-grep command

From
XMXavier Maillard <xma@gnu.org>
Date
Feb 24, 2008, 02:00 UTC
Message-ID
<200802240200.m1O201Rh015406@localhost.localdomain>
In-Reply-To
<8763wfwjg6.dlv@maison.homelinux.org>
   Xavier Maillard <xma@gnu.org> writes:
   > Hi,
   >
   >    Here is a modification with inclusion of git-grep only when the grep
   >    library is available. 
   >
   >    +(require 'grep () t)
   >
   >    +(when (featurep 'grep)
   >    +  (defvar git-grep-history nil)
   >    +
   >    +  (defun git-grep (regexp &optional files dir)
   >
   > Why not just do something like this ?
   >
   > (when (require 'grep () t)
   >       (defvar ...)
   >       (defun git-grep ...))
   Because I wanted require to stay on top of the file, but I didn't want
   to put the rest of the git-grep stuff there.

Good point. Though, you can still "embed" the require form directly into the defun. This is thing I have already seen in the past. Dunno if it is a convention or a coding style but something like:

(defun git-grep ()
 "Docstring"
 (interactive)
 (when (require 'grep nil t)
       here the rest
  ))

is doable too. Maybe the if-else form would be better though with an else clause to (error "No grep package foud.").

Well just kidding, your patch is okay ;)
	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org
Previous: Xavier Maillard
Message 17 of 17 in “git.el: Add a git-grep command”
  1. git.el: Add a git-grep commandDavid Kågedal, Feb 19, 2008
  2. Remi VanicatFeb 21, 2008
  3. David KågedalFeb 21, 2008
  4. Xavier MaillardFeb 22, 2008
  5. Karl HasselströmFeb 22, 2008
  6. David KågedalFeb 22, 2008
  7. Karl HasselströmFeb 22, 2008
  8. Jakub NarebskiFeb 22, 2008
  9. David KågedalFeb 22, 2008
  10. Jakub NarebskiFeb 22, 2008
  11. David KågedalFeb 22, 2008
  12. Remi VanicatFeb 22, 2008
  13. David KågedalFeb 22, 2008
  14. Xavier MaillardFeb 23, 2008
  15. Remi VanicatFeb 23, 2008
  16. Xavier MaillardFeb 23, 2008
  17. Xavier MaillardFeb 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.