Skip to content

Commit a187720

Browse files
committed
Closes #1: Add option that save some buffers before pathaction-run
1 parent 4d77074 commit a187720

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ To edit the `pathaction.yaml` file, use the following function, which will promp
5959
(pathaction-edit)
6060
```
6161

62-
## Frequently Asked Questions
62+
## Customization
6363

64-
## How to make pathaction open a window under the current one?
64+
## Making pathaction open a window under the current one?
6565

6666
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.
6767

@@ -72,6 +72,11 @@ Here's the code to do this:
7272
(window-height . 0.33)))
7373
```
7474

75+
## Hooks
76+
77+
- `pathaction-before-run-hook`: This hook is executed before the `pathaction-run` function is invoked. By default, it calls the `save-some-buffers` function to prompt saving any modified buffers.
78+
- `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.
79+
7580
## Author and License
7681

7782
The *pathaction* Emacs package has been written by [James Cherti](https://www.jamescherti.com/) and is distributed under terms of the GNU General Public License version 3, or, at your choice, any later version.

pathaction.el

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ Defaults to `ansi-term'.
5353
of the buffer as the second argument.
5454
Example: (function-name command buffername)")
5555

56-
(defvar pathaction-after-create-buffer-hook nil
56+
(defcustom pathaction-before-run-hook '(save-some-buffers)
57+
"Hook run before `pathaction-run'.
58+
By default, it calls `save-some-buffers'."
59+
:group 'pathaction
60+
:type 'hook)
61+
62+
(defcustom pathaction-after-create-buffer-hook nil
5763
"Hooks to run after the pathaction buffer is created.
5864
This hook is executed from the pathaction buffer, allowing further
59-
customization or actions once the buffer is ready.")
65+
customization or actions once the buffer is ready."
66+
:group 'pathaction
67+
:type 'hook)
6068

6169
;; Internal variables
6270
(defvar-local pathaction--enabled nil)
@@ -168,6 +176,8 @@ directory being processed."
168176
(unless (executable-find "pathaction")
169177
(user-error "'pathaction' command not found in $PATH"))
170178

179+
(run-hooks 'pathaction-before-run-hook)
180+
171181
(let* ((switch-to-buffer-obey-display-actions t)
172182
(directory (file-name-directory file-name))
173183
(base-name (file-name-nondirectory file-name))

0 commit comments

Comments
 (0)