Skip to main content
added 76 characters in body
Source Link

The first answer is beautiful, but it leaves out some critical details about modern versions of Emacs. I am knew to Emacs myself, so other newcomers might not be aware of this. Given your goal is to search for text WITHIN a file in a PROJECT, then you would first install Projectile using the MELPA repository.

This installs the package in .emacs.d and adds some basic configuration to .emacs in your $USER directory (assuming you had created the .emacs file), such as requiring Projectile in your Emacs install.

However, you still need to enable it and associate keymap prefixes, so you can invoke it in the mini buffer.

The accepted answer mentions the following command:

C-c p s g

This will not work, unless you configure Projectile with this keymap prefix. But I configured it to use C-c C-p as the command for Project in .emacs:

(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)

Now given this, I am able to perform text searches in files in a project using grep:

C-c C-p f # switch to a project first
C-c C-p s g # perform grep search in project

To break it down, C-c C-p will invoke Projectile, and s g will perform the grep search. You will get a beautiful output like this, assuming your search is visit_contact and you are searching Ruby's rspec in a project:

./spec/support/capybara_classification_code_helper.rb:21:  def visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:8:    visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:33:    visit_contact
./spec/features/user_views_global_filters_from_line_item_spec.rb:9:      visit_contact

The first answer is beautiful, but it leaves out some critical details about modern versions of Emacs. I am knew to Emacs myself, so other newcomers might not be aware of this. Given your goal is to search for text WITHIN a file in a PROJECT, then you would first install Projectile using the MELPA repository.

This installs the package in .emacs.d and adds some basic configuration to .emacs in your $USER directory (assuming you had created the .emacs file), such as requiring Projectile in your Emacs install.

However, you still need to enable it and associate keymap prefixes, so you can invoke it in the mini buffer.

The accepted answer mentions the following command:

C-c p s g

This will not work, unless you configure Projectile with this keymap prefix. But I configured it to use C-c C-p as the command for Project in .emacs:

(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)

Now given this, I am able to perform text searches in files in a project using grep:

C-c C-p s g

To break it down, C-c C-p will invoke Projectile, and s g will perform the grep search. You will get a beautiful output like this, assuming your search is visit_contact and you are searching Ruby's rspec in a project:

./spec/support/capybara_classification_code_helper.rb:21:  def visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:8:    visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:33:    visit_contact
./spec/features/user_views_global_filters_from_line_item_spec.rb:9:      visit_contact

The first answer is beautiful, but it leaves out some critical details about modern versions of Emacs. I am knew to Emacs myself, so other newcomers might not be aware of this. Given your goal is to search for text WITHIN a file in a PROJECT, then you would first install Projectile using the MELPA repository.

This installs the package in .emacs.d and adds some basic configuration to .emacs in your $USER directory (assuming you had created the .emacs file), such as requiring Projectile in your Emacs install.

However, you still need to enable it and associate keymap prefixes, so you can invoke it in the mini buffer.

The accepted answer mentions the following command:

C-c p s g

This will not work, unless you configure Projectile with this keymap prefix. But I configured it to use C-c C-p as the command for Project in .emacs:

(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)

Now given this, I am able to perform text searches in files in a project using grep:

C-c C-p f # switch to a project first
C-c C-p s g # perform grep search in project

To break it down, C-c C-p will invoke Projectile, and s g will perform the grep search. You will get a beautiful output like this, assuming your search is visit_contact and you are searching Ruby's rspec in a project:

./spec/support/capybara_classification_code_helper.rb:21:  def visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:8:    visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:33:    visit_contact
./spec/features/user_views_global_filters_from_line_item_spec.rb:9:      visit_contact
Source Link

The first answer is beautiful, but it leaves out some critical details about modern versions of Emacs. I am knew to Emacs myself, so other newcomers might not be aware of this. Given your goal is to search for text WITHIN a file in a PROJECT, then you would first install Projectile using the MELPA repository.

This installs the package in .emacs.d and adds some basic configuration to .emacs in your $USER directory (assuming you had created the .emacs file), such as requiring Projectile in your Emacs install.

However, you still need to enable it and associate keymap prefixes, so you can invoke it in the mini buffer.

The accepted answer mentions the following command:

C-c p s g

This will not work, unless you configure Projectile with this keymap prefix. But I configured it to use C-c C-p as the command for Project in .emacs:

(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c C-p") 'projectile-command-map)

Now given this, I am able to perform text searches in files in a project using grep:

C-c C-p s g

To break it down, C-c C-p will invoke Projectile, and s g will perform the grep search. You will get a beautiful output like this, assuming your search is visit_contact and you are searching Ruby's rspec in a project:

./spec/support/capybara_classification_code_helper.rb:21:  def visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:8:    visit_contact
./spec/features/admin_edits_classification_code_role_dynamic_field_spec.rb:33:    visit_contact
./spec/features/user_views_global_filters_from_line_item_spec.rb:9:      visit_contact