Execute pathaction.yaml rules using the pathaction command-line tool.
(The pathaction command-line tool enables the execution of specific commands on targeted files or directories. Its key advantage lies in its flexibility, allowing users to handle various types of files simply by passing the file or directory as an argument to the pathaction
tool. The tool uses a .pathaction.yaml
rule-set file to determine which command to execute. Additionally, Jinja2 templating can be employed in the rule-set file to further customize the commands.)
To install pathaction
with straight.el
:
(use-package pathaction :ensure t :straight (pathaction :type git :host github :repo "jamescherti/pathaction.el") :config (add-to-list 'display-buffer-alist '("\\*pathaction:" (display-buffer-at-bottom) (window-height . 0.33))))Installing with use-package and :vc (Built-in feature in Emacs version >= 30)
To install pathaction
with use-package
and :vc
(Emacs >= 30):
(use-package pathaction :ensure t :vc (:url "https://github.com/jamescherti/pathaction.el" :rev :newest) :config (add-to-list 'display-buffer-alist '("\\*pathaction:" (display-buffer-at-bottom) (window-height . 0.33))))
To execute the pathaction
action that is tagged with main
, you can call the following Emacs function:
pathaction-run
: This is the main function for triggering pathaction
actions."main"
: This is the tag used to identify a specific action. The tag you provide to the function determines which set of actions will be executed. In this case, "main"
refers to the actions that are specifically tagged with this name.To edit the pathaction.yaml
file, use the following function, which will prompt you to select one of the pathaction.yaml
files in the parent directories:
To configure pathaction
to open its window under the current one, you can use the display-buffer-alist
variable to customize how the pathaction
buffer is displayed. Specifically, you can use the display-buffer-at-bottom
action, which will display the buffer in a new window at the bottom of the current frame.
Here's the code to do this:
(add-to-list 'display-buffer-alist '("\\*pathaction:" (display-buffer-at-bottom) (window-height . 0.33)))
pathaction-before-run-hook
: This hook is executed by pathaction-run
before the pathaction
command is executed. By default, it calls the save-some-buffers
function to prompt saving any modified buffers:
(setq pathaction-before-run-hook '(save-some-buffers))
pathaction-after-create-buffer-hook
: This hook is executed after the pathaction buffer is created. It runs from within the pathaction buffer, enabling further customization or actions once the buffer is available.By default, pathaction-before-run-hook
only calls a function to save the current buffer before executing actions or commands that affect the current or any other edited buffer.
To make pathaction
save all buffers, use the following configuration:
(defun my-save-some-buffers () "Prevent `save-some-buffers' from prompting by passing 1 to it." (save-some-buffers)) (add-hook 'pathaction-before-run-hook #'my-save-some-buffers)
(If you want to prevent save-some-buffers
from prompting the user before saving, replace (save-some-buffers)
with (save-some-buffers t)
.)
The pathaction Emacs package has been written by James Cherti and is distributed under terms of the GNU General Public License version 3, or, at your choice, any later version.
Copyright (C) 2025 James Cherti
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.
pathaction
command-line tool (requirement): pathactionpathaction
command-line tool directly from Vim.Other Emacs packages by the same author:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4