Commit Graph

63 Commits

Author SHA1 Message Date
0150f879ea feat(magit): introduce +magit-auto-revert option
Provides more control over our auto-reverting feature, and changes its
behavior to only target non-remote buffers by default, because reverting
remote buffers could be tremendously slow.

This could be later improved to treat TRAMP buffers with local
methods (like sudo) as local buffers.

Fix: #8354
2025-04-10 18:34:49 -04:00
a13fda7ec0 fix(magit): don't auto-revert non-file-visiting buffers
Fix: #8339
Amend: 17a870fef8
2025-04-05 02:02:00 -04:00
cf41865693 perf(magit): optimize +magit-mark-stale-buffers-h
For cases where the user has *many* buffers open in long-lived sessions.
2025-04-02 03:18:08 -04:00
17a870fef8 fix(magit): reload related buffers after git ops
And when refocusing a frame.
2025-03-30 16:10:22 -04:00
da071559e1 fix(magit): polish +magit-display-buffer-fn
- Ensure `magit-log-select-mode` windows use the same window as the
  magit-status buffer, and that the revision buffer is displayed below
  it (similar to commit window configs).
- Uses the same window when invoking diffs (#8083).

Fix: #8083
2025-03-25 18:11:35 -04:00
0a715cc3f2 refactor: (if|when)-let -> (if|when)-let*
With the former macros' future in the air (and likely to be targeted in
future, potentially breaking changes), I'll deal with this now than have
it bite me later.

Ref: https://lists.gnu.org/archive/html/emacs-devel/2024-10/msg00637.html
2025-01-08 19:33:37 -05:00
b405225b90 refactor!(vc-gutter): drop git-gutter for diff-hl
BREAKING CHANGE: This removes git-gutter as an implementation for the
`:ui vc-gutter` module, leaving only the diff-hl implementation. There
are no longer any +git-gutter or +diff-hl flags for this module. Users
don't have to do anything to keep the vc gutter, unless they prefer
git-gutter for any reason (in which case they'll need to install and set
it up themselves).

This has been planned for some time, because of a roadmap goal for Doom
to lean into native/built-in functionality where it's equal or better
than the third party alternatives. diff-hl relies on the built-in vc.el
library instead of talking to git directly (thus expanding support to
whatever VCS's vc.el supports, and not git alone), which also means it
can take advantage of its caching and other user configuration for
vc.el. Overall, it is faster and lighter.

What I've also been waiting for was a stage-hunk command, similar to
git-gutter:stage-hunk, which arrived in dgutov/diff-hl@a0560551cd and
dgutov/diff-hl@133538973b, and have evolved since.

Ref: dgutov/diff-hl@a0560551cd
Ref: dgutov/diff-hl@133538973b
Ref: https://github.com/orgs/doomemacs/projects/5/views/1?pane=issue&itemId=58747789
2024-06-22 18:14:04 -04:00
6ceb1e0bbe fix(magit): only revert if buffer file exists 2022-06-18 17:19:23 +02:00
2d3a68df49 feat(magit): replace github-review for code-review 2021-12-15 07:06:49 +00:00
e0bac80447 fix(magit): shut up magit-version
To prevent Magit's harmless, but annoying, "Cannot determine Magit's
version" errors.
2021-09-14 18:41:18 +02:00
195ad0fec6 Fix #5003: rethink +magit/quit
Changes +magit/quit to behave more like canonical
magit-mode-bury-buffer, but after burying/killing the last magit buffer
for the current repo, kill all the other buried ones too.

Also binds Q in magit to kill all magit buffers for the current repo.
2021-05-07 14:17:04 -04:00
768160b001 Don't reload repo buffer modes after closing magit
Mentioned in #4640
2021-02-11 17:46:22 -05:00
8a90862777 Remove +magit/clone
Upstream magit-clone has superseded +magit/clone.

Closes #4292
2020-11-21 01:39:25 -05:00
3a1fd7b282 Respect magit-display-buffer-noselect
This fixes the behavior of e.g. magit-diff-show-or-scroll-down.
When in magit-log-mode, said action should not move focus to the diff
window because it would otherwise behave identical to pressing
magit-show-commit.
2020-10-10 19:50:10 +02:00
518c97a2ac Rename {if,when}! -> eval-{if,when}!
To better represent its purpose, as extensions to Emacs' eval-when*
API (for control flow at compile time).
2020-08-27 01:10:08 -04:00
95c5ebc01a Fix #3726: respect +magit-open-windows-in-direction
Also fixes an issue where `q` would not delete a magit-dedicated split
window (leaving duplicate magit-status windows about).
2020-08-11 13:48:12 -04:00
a16c40d493 tools/magit: split sub-windows to the side
When a log or diff buffer is opened from the magit status buffer, it
would display them in a random window (or split, if none were
available). This changes forces it to predictably open to the right of
the magit status window (using the next window over, if available).
2020-08-06 00:22:39 -04:00
885197bd06 Fix "Cannot determine magit's version" logs on Windows
Magit complains loudly (but harmlessly) when it can't determine its own
version in a sparse clone. This was fixed upstream in
magit/magit@b1b2683 for unix OSes, but not for Windows where symlinks
aren't supported, and so `magit-version` can't resolve its own repo's
root (see raxod502/straight.el#520).
2020-05-20 16:08:52 -04:00
94fc6f714f Bump :tools magit
magit/magit@d27d6e4 -> magit/magit@b1b2683
magit/forge@e2da806 -> magit/forge@09bf8ad

We no longer need the magit version hack, thanks to magit/magit@b1b2683
2020-05-20 01:10:15 -04:00
ea18c83c0a General refactors & reformatting across the board 2020-05-15 01:44:53 -04:00
3622e36c75 Fix 'buffer does not seem to be associated with any file' error
Fixes #2869
Closes #2870
2020-04-10 13:47:41 -04:00
93521ba5be Prevent "version control data is outdated" prompt
The prompt was too intrusive, so update vc state if buffer is modified
instead.
2020-03-14 22:04:49 -04:00
0a9b06ac16 Prevent magit trying to revert non-existent file buffers 2020-02-25 20:23:04 -05:00
24282a454e Fix revert-buffer--default error after using magit
It too aggressively tries to revert all buffers, even ones that can't be
reverted.
2020-02-24 19:30:35 -05:00
731e1c503d Lazily revert affected buffers after magit 2020-02-21 13:40:52 -05:00
48cd3e0ad0 tools/magit: prevent 'cannot determine magit's version' warnings
By ensuring the advice runs twice.
2019-12-15 23:43:33 -05:00
89f4f9d88f fix(magit): add bindings for github-review 2019-12-08 13:35:18 -06:00
44e22b7f80 tools/magit: replace +magit/clone w/ magit-clone
The former no longer works, since ghub's API has changed. Meanwhile, the
magit-clone command has grown in features to match (and surpass)
+magit/clone, so we'll just use that instead.
2019-11-23 01:21:25 -05:00
19bfb1285d Fix #1852: magit not restoring wconf when quitting 2019-10-03 16:43:49 -04:00
bad0dba1fc tools/magit: refactor magit-version advice
Not strictly necessary, but more correct.
2019-09-20 17:18:16 -04:00
2d365619cd General refactor & cleanup, across the board 2019-09-13 22:00:34 -04:00
ccaf92b0d3 tools/magit: don't kill all magit buffers when quitting one
And mark all outdated buffers, rather than just the ones in the current
workgroup.
2019-08-28 15:22:14 -04:00
9ab49be564 Fix "fatal: no names found" errors on 'doom rebuild'
Some packages that depend on org (like elfeed) will load the built-in
org early in the rebuild/package install process, which causes org to
define org-release and org-git-version, sometimes overwriting our stubs
for it. Without our hack, org call 'git describe' in the org repo in an
attempt to determine the installed version, which won't work in a sparse
clone. To ensure future definitions never overwrite ours, we advise them
as well.

Also moves magit-version hack to its autoload file, for consistency with
org's hacks.
2019-08-07 16:31:45 -04:00
6b5d65b55b tools/magit: reuse magit-status window
Instead of opening the same buffer in a new window.
2019-07-22 04:01:18 +02:00
ce4b8940ca tools/magit: revise default window management for magit
The former default display function would strive to open windows below
the current magit window (splitting it), but this would stack and
quickly become cramped. The behavior is now to reuse the same
window *unless* you're opening the process buffer or from the commit
window.
2019-07-22 02:30:41 +02:00
149b2617b0 💥 revise hook/var fns naming convention (2/2)
This is second of three big naming convention changes. In this commit,
we change the naming conventions for hook functions and variable
functions:

1. Replace the bar | to indicate a hook function with a -h suffix, e.g.

     doom|init-ui -> doom-init-ui-h
     doom|run-local-var-hooks -> doom-run-local-var-hooks-h

2. And add a -fn suffix for functions meant to be set on variables,
   e.g.

     (setq magit-display-buffer-function #'+magit-display-buffer-fn)

See ccf327f8 for the reasoning behind these changes.
2019-07-22 02:30:38 +02:00
51d3b1b424 💥 revise advice naming convention (1/2)
This is first of three big naming convention updates that have been a
long time coming. With 2.1 on the horizon, all the breaking updates will
batched together in preparation for the long haul.

In this commit, we do away with the asterix to communicate that a
function is an advice function, and we replace it with the '-a' suffix.
e.g.

  doom*shut-up -> doom-shut-up-a
  doom*recenter -> doom-recenter-a
  +evil*static-reindent -> +evil--static-reindent-a

The rationale behind this change is:

1. Elisp's own formatting/indenting tools would occasionally struggle
   with | and * (particularly pp and cl-prettyprint). They have no
   problem with / and :, fortunately.
2. External syntax highlighters (like pygmentize, discord markdown or
   github markdown) struggle with it, sometimes refusing to highlight
   code beyond these symbols.
3. * and | are less expressive than - and -- in communicating the
   intended visibility, versatility and stability of a function.
4. It complicated the regexps we must use to search for them.
5. They were arbitrary and over-complicated to begin with, decided
   on haphazardly way back when Doom was simply "my private config".

Anyhow, like how predicate functions have the -p suffix, we'll adopt the
-a suffix for advice functions, -h for hook functions and -fn for
variable functions.

Other noteable changes:
- Replaces advice-{add,remove}! macro with new def-advice!
  macro. The old pair weren't as useful. The new def-advice! saves on a
  lot of space.
- Removed "stage" assertions to make sure you were using the right
  macros in the right place. Turned out to not be necessary, we'll
  employ better checks later.
2019-07-22 02:27:45 +02:00
108c7ba5ad Fix 'selected killed buffer' error on +magit/quit 2019-06-30 13:20:07 +02:00
c4b325fa4b Fix magit-clone error
magit-clone function has changed signature to work with transient.
So using the new magit-clone-regular instead.

Signed-off-by: Huy Duong <huy.duong@employmenthero.com>
2019-06-03 16:59:03 +07:00
051f792205 tools/magit: remove +magit-display-popup-buffer
Because magit uses transient now, and other plugins that use magit-popup
don't seem to need it anymore.

And update docstring+comments.
2019-05-04 19:13:26 -04:00
5bcab488a7 Add {vc,git-gutter}-mode checks to vc refresher 2019-04-01 13:21:25 -04:00
bdd410cb9c Refresh vc on-demand after quitting magit #1298
To avoid the long delay when you have many buffers open while quitting
magit.
2019-04-01 13:12:00 -04:00
7f1c275d62 +magit/clone: fix void-function ghub--username 2019-02-18 20:13:37 -05:00
ecfe52f71c Fix +magit/clone to no longer use magithub 2019-02-18 18:26:19 -05:00
ba0ccc1d34 tools/magit: cleanup magit concurrently
A quick attempt to make +magit/quit faster.
2019-02-14 00:40:19 -05:00
f0465f22cc tools/magit: fix +magit/quit & default display fn
When used with magit-display-buffer-traditional, q wouldn't close the
window, just kill the buffer inside.
2018-10-07 11:12:51 -04:00
b573fcce20 quit-window on multiple magit-status windows
If you accidentally open multiple magit status windows, you'll be stuck
in a deadlock, where `q` will do nothing. Now, +magit/quit will use
`quit-window` on excess magit-status windows instead.
2018-10-03 00:04:08 -04:00
fcd1e913c5 tools/magit: update vc on +magit/quit
Instead of magit-post-refresh-hook, which fires much more frequently.
Updating vc across all buffers is expensive, so let's only do it when we
quit magit.

Warning: this may make quitting magit expensive when you have many
buffers open. Still searching for a better solution.
2018-09-26 12:10:00 -04:00
7d3ffdff06 Remove third line in section headers
This is truly important stuff. We've saved many lives with this update.
2018-09-09 09:58:19 -04:00
17abb990e4 tools/magit: don't make new windows too tall
Some popups (like logs or revisions) completely consume the current
window.
2018-08-21 22:45:42 +02:00