Hi! Sorry for the repost, but I still haven't figured this out:
Quick question (hopefully): when global-magit-file-mode is t (the default), does one still need to
(require 'magit)
in their init file in order to enable magit-file-mode bindings?
My .emacs does not(require 'magit)
ATM andC-x g
and other shortcuts do not seem to work until I manually callM-x magit-status
once. Adding(require 'magit)
in the init file fixes this. Is this expected?
The installation node in the manual explicitly says to(require 'magit)
when installing from the Git repository, but no such step is mentioned in "Installing from Melpa" nor in "Post-Installation Tasks".
(Tested with Emacs 28)
(My curiosity was renewed by Stefan's recent message on emacs-devel explaining why one shouldn't, in principle, (require 'foo)
in their init file)
@rgrinberg
For example, I'd like to add the diff stat to the current log with -s
Butting in without having read the rest; does L -s g
in a log buffer do what you want?
@tarsius I'd appreciate it if you could weigh in on my question above; tl;dr must a user add (require 'magit)
to their init file to make C-x g
work without first running magit-status
, even though global-magit-file-mode
is t
?
It's not terribly important so no rush though. I don't know if Gitter is the best place to ask; my impression is that this is too trivial to warrant a Github issue or a post on StackExchange…
transient-append-suffix
and it does what I want. But I can't figure out how to set the default value of a switch (also of existing switches). The docs I found only talk about magit-popup
. I did see there's :value
in define-transient-command
, but can I set that for an existing transient command?
@tarsius Mmm; is that something that package.el is supposed to handle automatically? I can see magit-autoloads.el under ~/.emacs.d/elpa/magit-2020...
, and I guess something is autoloaded, because magit-status
shows up right from the start when I M-x magit- TAB
, but magit-file-mode-map
bindings are not loaded until I run magit-status
or (require 'magit)
:/
If that helps, I'm running Emacs 28 (but I've observed this behaviour with previous Emacs versions too), I don't have any customization on package.el-related variables (that I know of), and I installed magit from MELPA using package.el...
Let me know if you want me to make a proper issue out of this.
C-x g
and friends without first invoking magit-status
, so I'd say it's 100% reproducible over here. I'll see if I can figure things out; in the meantime, if you have any specific ideas of stuff I could look for, feel free to ask! No rush though, since the workaround ((require 'magit)
in .emacs
) is simple enough.
(global-magit-file-mode 1)
in your .emacs
should work.
(require 'magit)
in the init file. It would be better to discuss this in an issue than here.
OK, I've stared long and hard at magit-files.el, define-(globalized-)minor-mode
, and the documentation for autoload, and I'm now convinced I'm out of my depth "^^
Should I file an issue about this then? ("This" being "enabling magit-file-mode-map without first requir
ing 'magit
")
The keybinding-only modes you mention are magit-file-mode and magit-blob-mode, right? I can't come up with a single all-encompassing name (magit-file-commands.el
?), the most obvious idea that comes to mind being two distinct files (magit-file.el
or magit-dispatch.el
, and magit-blob.el
).
Hey guys - I'm trying to link a custom command into magit that will ultimately run git reset --hard @{u}
in one go (the exact command/bindings rn don't really matter.. more the idea of adding a specific command that calls git "for effect" as it says in the user manual.
Done a decent amount of reading in the manual but I'm stuck (also an elisp/emacs newbie) my code sofar
(defun magit-reset-hard-upstream ()
(magit-run-git "reset --hard @{u}"))
(define-transient-command magit-reset-hard-upstream ())
(with-eval-after-load 'magit
(transient-append-suffix 'magit-commit "c"
'("n" "Reset hard upstream" magit-reset-hard-upstream))
)
FYI this is in my init.el
Am I on the right track? any help would be appreciated!
@tarsius - don't I need to use transient-append-suffix
to add it to an existing transient? When I just use defun I get fixup-head is not defined or autoloaded as command
Here's an example of working code that does what I was hoping (add a custom command to an already existing transient)
(define-suffix-command fixup-head ()
"Make current commit a fixup to HEAD"
(interactive)
(magit-run-git "commit" "--fixup" "HEAD")
)
(with-eval-after-load 'magit
(transient-append-suffix 'magit-commit "c"
'("h" "fixup head" fixup-head))
)
M-: (magit-rev-hash "HEAD")
machine gitlab.com/api/v4 login username^forge password TOKEN
works for forge stuff and machine gitlab.com login port 443 username password TOKEN
which I was hoping would work for git push (but doesn't appear to). I didn't have a blank line at the end of the file, but adding one makes no difference.