aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2020-03-21 13:26:19 +0200
committerEli Zaretskii2020-03-21 13:26:19 +0200
commit561e9fb91bba98616f6d7ea3818727c1cdd2d853 (patch)
tree63423d044102e79f59135c9354cb05fbe41576a1
parentb28a9a6cc3451ea865449cf010466cd3ac8bf9a0 (diff)
downloademacs-561e9fb91bba98616f6d7ea3818727c1cdd2d853.tar.gz
emacs-561e9fb91bba98616f6d7ea3818727c1cdd2d853.zip
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.
-rw-r--r--doc/emacs/emacs.texi1
-rw-r--r--doc/emacs/maintaining.texi75
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/progmodes/project.el11
4 files changed, 86 insertions, 4 deletions
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index c3cb37e6a6d..6ef4ca63ae7 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -785,6 +785,7 @@ GDB Graphical Interface
785Maintaining Large Programs 785Maintaining Large Programs
786 786
787* Version Control:: Using version control systems. 787* Version Control:: Using version control systems.
788* Projects:: Commands for handling source files in a project.
788* Change Log:: Maintaining a change history for your program. 789* Change Log:: Maintaining a change history for your program.
789* Xref:: Find definitions and references of any function, 790* Xref:: Find definitions and references of any function,
790 method, struct, macro, @dots{} in your program. 791 method, struct, macro, @dots{} in your program.
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index a6f66f6e7f3..ebcdddfcae3 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -14,6 +14,9 @@ Unified interface to Support for Version Control Systems
14(@acronym{VCS}) that record the history of changes to source files. 14(@acronym{VCS}) that record the history of changes to source files.
15 15
16@item 16@item
17Commands for handling programming projects.
18
19@item
17A specialized mode for maintaining @file{ChangeLog} files that provide 20A specialized mode for maintaining @file{ChangeLog} files that provide
18a chronological log of program changes. 21a chronological log of program changes.
19 22
@@ -38,6 +41,7 @@ Lisp Regression Testing}).
38 41
39@menu 42@menu
40* Version Control:: Using version control systems. 43* Version Control:: Using version control systems.
44* Projects:: Commands for handling source files in a project.
41* Change Log:: Maintaining a change history for your program. 45* Change Log:: Maintaining a change history for your program.
42* Xref:: Find definitions and references of any function, 46* Xref:: Find definitions and references of any function,
43 method, struct, macro, @dots{} in your program. 47 method, struct, macro, @dots{} in your program.
@@ -1630,6 +1634,77 @@ different revision with @kbd{C-u C-x v v}.
1630@include vc1-xtra.texi 1634@include vc1-xtra.texi
1631@end ifnottex 1635@end ifnottex
1632 1636
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
1643more programs. Files that belong to a project are typically stored in
1644a hierarchy of directories; the top-level directory of the hierarchy
1645is 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
1649the project-specific infrastructure, known as @dfn{project back-end}.
1650Emacs currently supports two such back-ends: VC (@pxref{Version
1651Control}), whereby a VCS repository is considered a project; and EDE
1652(@pxref{EDE}). This is expected to be extended in the future to
1653support additional types of projects.
1654
1655 Which files do or don't belong to a project is also determined by
1656the 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.
1660This 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
1666the current buffer when the command is invoked. If that directory
1667doesn't seem to belong to a recognizable project, these commands
1668prompt you for the project directory.
1669
1670@findex project-find-file
1671 The command @code{project-find-file} is a convenient way of visiting
1672files (@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
1674of the file to visit, you can type only the file's base name (i.e.,
1675omit the leading directories). In addition, the completion candidates
1676considered by the command include only the files belonging to the
1677current project, and nothing else. If there's a file name at point,
1678this 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
1683to the current project. The command prompts for the regular
1684expression to search, and pops up an Xref mode buffer with the search
1685results, where you can select a match using the Xref mode commands
1686(@pxref{Xref Commands}). When invoked with a prefix argument, this
1687command additionally prompts for the base directory from which to
1688start the search; this allows, for example, to limit the search only
1689to 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
1694search in the current project's files, but instead of finding all the
1695matches and displaying them, it stops when it finds a match and visits
1696the matched file at the locus of the match, allowing you to edit the
1697matched file. To find the rest of the matches, type @w{@kbd{M-x
1698fileloop-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
1703match it finds, like @code{query-replace} does (@pxref{Query
1704Replace}), and continues to the next match after you respond. If your
1705response causes Emacs to exit the query-replace loop, you can later
1706continue with @w{@kbd{M-x fileloop-continue @key{RET}}}.
1707
1633@node Change Log 1708@node Change Log
1634@section Change Logs 1709@section Change Logs
1635 1710
diff --git a/etc/NEWS b/etc/NEWS
index b41541c715f..d3f27e328e7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -978,7 +978,10 @@ The mode is automatically enabled in files that start with the
978 978
979** project.el 979** project.el
980 980
981+++
981*** New commands 'project-search' and 'project-query-replace-regexp'. 982*** New commands 'project-search' and 'project-query-replace-regexp'.
983
984---
982*** New user option 'project-read-file-name-function'. 985*** New user option 'project-read-file-name-function'.
983 986
984** Etags 987** Etags
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ccd8cc049d4..f4678681858 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -437,6 +437,7 @@ triggers completion when entering a pattern, including it
437requires quoting, e.g. `\\[quoted-insert]<space>'." 437requires quoting, e.g. `\\[quoted-insert]<space>'."
438 (interactive (list (project--read-regexp))) 438 (interactive (list (project--read-regexp)))
439 (require 'xref) 439 (require 'xref)
440 (require 'grep)
440 (let* ((pr (project-current t)) 441 (let* ((pr (project-current t))
441 (files 442 (files
442 (if (not current-prefix-arg) 443 (if (not current-prefix-arg)
@@ -606,7 +607,8 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in
606(defun project-search (regexp) 607(defun project-search (regexp)
607 "Search for REGEXP in all the files of the project. 608 "Search for REGEXP in all the files of the project.
608Stops when a match is found. 609Stops when a match is found.
609To continue searching for next match, use command \\[fileloop-continue]." 610To continue searching for the next match, use the
611command \\[fileloop-continue]."
610 (interactive "sSearch (regexp): ") 612 (interactive "sSearch (regexp): ")
611 (fileloop-initialize-search 613 (fileloop-initialize-search
612 regexp (project-files (project-current t)) 'default) 614 regexp (project-files (project-current t)) 'default)
@@ -614,9 +616,10 @@ To continue searching for next match, use command \\[fileloop-continue]."
614 616
615;;;###autoload 617;;;###autoload
616(defun project-query-replace-regexp (from to) 618(defun project-query-replace-regexp (from to)
617 "Search for REGEXP in all the files of the project. 619 "Query-replace REGEXP in all the files of the project.
618Stops when a match is found. 620Stops when a match is found and prompts for whether to replace it.
619To continue searching for next match, use command \\[fileloop-continue]." 621If you exit the query-replace, you can later continue the query-replace
622loop using the command \\[fileloop-continue]."
620 (interactive 623 (interactive
621 (pcase-let ((`(,from ,to) 624 (pcase-let ((`(,from ,to)
622 (query-replace-read-args "Query replace (regexp)" t t))) 625 (query-replace-read-args "Query replace (regexp)" t t)))