mohkale / projection

Projectile like project management library built on Emacs project.el
GNU General Public License v3.0
53 stars 2 forks source link

+TITLE: Projection

+AUTHOR: Mohsin Kaleem

LocalWords: pluggable ibuffer

+html:

+html:

+html:

+html: MELPA

+html:

Project type support for Emacs builtin ~project.el~.

+html:

This Emacs package provides a [[https://github.com/bbatsov/projectile][Projectile]] like project management library atop Emacs built-in ~project.el~. The end goal is to provide a stable and reliable out-of-the-box project management experience for as many project types as possible while supporting very targeted support for some project types like [[https://cmake.org/][CMake]].

** MELPA Projection and any extension packages are on [[https://github.com/melpa/melpa][MELPA]]. You can add this to your ~package-archives~ variable and then install through ~M-x package-install~.

+begin_src emacs-lisp

 (push '("melpa" . "https://melpa.org/packages/") package-archives)
 (package-refresh-contents)
 (package-install 'projection)
 (package-install 'projection-multi)

+end_src

** Projection Hook Provides a more general purpose parallel to ~projectile-toggle-project-read-only~. With this you can hook certain functions (Example: ~read-only-mode~) into a project and retroactively apply it to both all the open buffers from that project and any new buffers that will be opened in it.

** Projection ibuffer Offers variants of ~projectile-ibuffer~ and the [[https://github.com/purcell/ibuffer-projectile][ibuffer-projectile]] project in the form of =ibuffer-projection-current-project= and =ibuffer-projection-set-filter-groups=. The former creates and displays a dedicated ibuffer window for only buffers in the current project. The latter pre-pends filters to group by a specific project for all currently open projects.

** Projection Find Adds facilities for jumping to related files within a project. The most common use case for this would be jumping between C++ header ~.h~ and implementation ~.cpp~ files. This is already possible with Emacs's builtin =ff-find-other-file= command but projection builds on top of it by supporting jumping to related files in other directories or with alterations to the file-name beyond extensions. For example if you have header files in an include directory and implementation files in a src directory then =projection-find-other-file= can still jump between them without any extra configuration. If you're working on a python project and define test files with a ~test_BASENAME.py~ format then ~projection-find-other-file~ can also jump between ~BASENAME.py~ and ~test_BASENAME.py~. ~projection-find-other-file~ is intended to be a consistent and transitive command. You can invoke it repeatedly to cycle between related files and the order in which you cycle will be consistent independent of which file you're currently in.

General associations between the current files extension and possible related file extensions is configured in =projection-find-other-file-suffix=. Supported suffixes and prefixes for test files is configured by the project-type in [[file:src/projection-types.el]].

** Projection recentf A variant of =M-x recentf= for files exclusively in the current project.

** Projection multi-compile

+html:

+html: MELPA

+html:

+html: Demo

[[https://github.com/mohkale/compile-multi][compile-multi]] is a multi target interface to =M-x compile=. It allows you to configure and interactively select compilation targets based on arbitrary projects.

Projection has an optional extension package called =projection-multi-compile= to integrate =compile-multi= into the current project type. It can extract available compilation targets from Makefiles, CMake configuration, etc. and let you execute them easily. By default =projection-multi-compile= determines all project types matching the current project and then resolves compilation targets based on them. For example a project that would match CMake and tox would let you select both tox environments and CMake build targets.

Each target generation function in projection-multi also supports being run independently. To select a tox task you can run =M-x projection-multi-compile-tox=, and you won't be presented with CMake or any other target types. This bypasses project type matching altogether and so may present targets not normally discovered by =projection-multi-compile=.

Currently automatic target generation functions are available for the following project types:

** Projection multi-embark

+html:

+html: MELPA

+html:

Add embark integration to multi-compile using the [[https://github.com/mohkale/compile-multi#compile-multi-embark][multi-compile-embark]] extension feature. This allows you to immediately set one of the candidates show in a compile-multi session as the projects build, configure, etc. command type. Use this to interactively and incrementally update build targets.

** Projection dape

+html:

+html: MELPA

+html:

Adds support for interactively selecting debuggable artifacts of a project and starting a debugger instance with [[https://github.com/svaante/dape][dape]].

** Specialised Project Support Currently projection has very extensive support for certain project types. This tries to bind Emacs a little stronger into the framework and bring more IDE like support for extending the project builds. This section documents some of the extra support available.

*** CMake For CMake projects projection supports the following extensions:

- =projection-cmake-set-preset= - Interactively sets a preset for a given
  build-type in the current project. By default if a project has any supported
  presets for a build-type projection will automatically prompt you for which to
  use and then cache it for subsequent invocations. See =projection-cmake-preset=
  to set an alternative preset behaviour for your use case.
- =projection-cmake-set-build-type= - Alter the value of the =CMAKE_BUILD_TYPE=
  option passed through to CMake while configuring.
- Target resolution through the [[https://cmake.org/cmake/help/v3.15/manual/cmake-file-api.7.html][CMake file API]]. This is disabled by default but
  can be enabled by customizing =projection-cmake-target-backend= (for example:
  =(setq projection-cmake-target-backend 'code-model)=) and then re-configuring the
  project.