Skip to content

Commit 561e9fb

Browse files
committed
Improve documentation of project.el commands
* lisp/progmodes/project.el (project-find-regexp): Require 'grep' to be able to call 'grep-read-files'. (project-search, project-query-replace-regexp): Doc fixes. * doc/emacs/maintaining.texi (Projects): New section. * doc/emacs/emacs.texi (Top): Add "Projects" to the detailed menu.
1 parent b28a9a6 commit 561e9fb

File tree

4 files changed

+86
-4
lines changed

4 files changed

+86
-4
lines changed

doc/emacs/emacs.texi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ GDB Graphical Interface
785785
Maintaining Large Programs
786786
787787
* Version Control:: Using version control systems.
788+
* Projects:: Commands for handling source files in a project.
788789
* Change Log:: Maintaining a change history for your program.
789790
* Xref:: Find definitions and references of any function,
790791
method, struct, macro, @dots{} in your program.

doc/emacs/maintaining.texi

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ large-size programs and packages. These features include:
1313
Unified interface to Support for Version Control Systems
1414
(@acronym{VCS}) that record the history of changes to source files.
1515

16+
@item
17+
Commands for handling programming projects.
18+
1619
@item
1720
A specialized mode for maintaining @file{ChangeLog} files that provide
1821
a chronological log of program changes.
@@ -38,6 +41,7 @@ Lisp Regression Testing}).
3841

3942
@menu
4043
* Version Control:: Using version control systems.
44+
* Projects:: Commands for handling source files in a project.
4145
* Change Log:: Maintaining a change history for your program.
4246
* Xref:: Find definitions and references of any function,
4347
method, struct, macro, @dots{} in your program.
@@ -1630,6 +1634,77 @@ different revision with @kbd{C-u C-x v v}.
16301634
@include vc1-xtra.texi
16311635
@end ifnottex
16321636

1637+
@node Projects
1638+
@section Working with Projects
1639+
@cindex projects
1640+
1641+
@cindex project root
1642+
A @dfn{project} is a collection of files used for producing one or
1643+
more programs. Files that belong to a project are typically stored in
1644+
a hierarchy of directories; the top-level directory of the hierarchy
1645+
is known as the @dfn{project root}.
1646+
1647+
@cindex project back-end
1648+
Whether a given directory is a root of some project is determined by
1649+
the project-specific infrastructure, known as @dfn{project back-end}.
1650+
Emacs currently supports two such back-ends: VC (@pxref{Version
1651+
Control}), whereby a VCS repository is considered a project; and EDE
1652+
(@pxref{EDE}). This is expected to be extended in the future to
1653+
support additional types of projects.
1654+
1655+
Which files do or don't belong to a project is also determined by
1656+
the project back-end. For example, the VC back-end doesn't consider
1657+
``ignored'' files (@pxref{VC Ignore}) to be part of the project.
1658+
1659+
Emacs provides commands for handling project files conveniently.
1660+
This section describes these commands.
1661+
1662+
@cindex current project
1663+
All of the commands described here share the notion of the
1664+
@dfn{current project}. The current project is determined by the
1665+
@code{default-directory} (@pxref{File Names}) of the buffer that is
1666+
the current buffer when the command is invoked. If that directory
1667+
doesn't seem to belong to a recognizable project, these commands
1668+
prompt you for the project directory.
1669+
1670+
@findex project-find-file
1671+
The command @code{project-find-file} is a convenient way of visiting
1672+
files (@pxref{Visiting}) that belong to the current project. Unlike
1673+
@kbd{C-x C-f}, this command doesn't require to type the full file name
1674+
of the file to visit, you can type only the file's base name (i.e.,
1675+
omit the leading directories). In addition, the completion candidates
1676+
considered by the command include only the files belonging to the
1677+
current project, and nothing else. If there's a file name at point,
1678+
this command offers that file as the default to visit.
1679+
1680+
@findex project-find-regexp
1681+
The command @code{project-find-regexp} is similar to @code{rgrep}
1682+
(@pxref{Grep Searching}), but it searches only the files that belong
1683+
to the current project. The command prompts for the regular
1684+
expression to search, and pops up an Xref mode buffer with the search
1685+
results, where you can select a match using the Xref mode commands
1686+
(@pxref{Xref Commands}). When invoked with a prefix argument, this
1687+
command additionally prompts for the base directory from which to
1688+
start the search; this allows, for example, to limit the search only
1689+
to project files under a certain subdirectory of the project root.
1690+
1691+
@findex project-search
1692+
@kbd{M-x project-search} is an interactive variant of
1693+
@code{project-find-regexp}. It prompts for a regular expression to
1694+
search in the current project's files, but instead of finding all the
1695+
matches and displaying them, it stops when it finds a match and visits
1696+
the matched file at the locus of the match, allowing you to edit the
1697+
matched file. To find the rest of the matches, type @w{@kbd{M-x
1698+
fileloop-continue @key{RET}}}.
1699+
1700+
@findex project-query-replace-regexp
1701+
@kbd{M-x project-query-replace-regexp} is similar to
1702+
@code{project-search}, but it prompts you for whether to replace each
1703+
match it finds, like @code{query-replace} does (@pxref{Query
1704+
Replace}), and continues to the next match after you respond. If your
1705+
response causes Emacs to exit the query-replace loop, you can later
1706+
continue with @w{@kbd{M-x fileloop-continue @key{RET}}}.
1707+
16331708
@node Change Log
16341709
@section Change Logs
16351710

etc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,10 @@ The mode is automatically enabled in files that start with the
978978

979979
** project.el
980980

981+
+++
981982
*** New commands 'project-search' and 'project-query-replace-regexp'.
983+
984+
---
982985
*** New user option 'project-read-file-name-function'.
983986

984987
** Etags

lisp/progmodes/project.el

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ triggers completion when entering a pattern, including it
437437
requires quoting, e.g. `\\[quoted-insert]<space>'."
438438
(interactive (list (project--read-regexp)))
439439
(require 'xref)
440+
(require 'grep)
440441
(let* ((pr (project-current t))
441442
(files
442443
(if (not current-prefix-arg)
@@ -606,17 +607,19 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in
606607
(defun project-search (regexp)
607608
"Search for REGEXP in all the files of the project.
608609
Stops when a match is found.
609-
To continue searching for next match, use command \\[fileloop-continue]."
610+
To continue searching for the next match, use the
611+
command \\[fileloop-continue]."
610612
(interactive "sSearch (regexp): ")
611613
(fileloop-initialize-search
612614
regexp (project-files (project-current t)) 'default)
613615
(fileloop-continue))
614616

615617
;;;###autoload
616618
(defun project-query-replace-regexp (from to)
617-
"Search for REGEXP in all the files of the project.
618-
Stops when a match is found.
619-
To continue searching for next match, use command \\[fileloop-continue]."
619+
"Query-replace REGEXP in all the files of the project.
620+
Stops when a match is found and prompts for whether to replace it.
621+
If you exit the query-replace, you can later continue the query-replace
622+
loop using the command \\[fileloop-continue]."
620623
(interactive
621624
(pcase-let ((`(,from ,to)
622625
(query-replace-read-args "Query replace (regexp)" t t)))

0 commit comments

Comments
 (0)