Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

New commit mode buffer selection after committing #1014

Closed
marcbowes opened this Issue Oct 28, 2013 · 18 comments

Comments

Projects
None yet
4 participants
  • Make some changes to some file (F)
  • magit-status
  • Stage and commit
  • Type into the new buffer, save it and quit the buffer with C-x # as per the prompt
  • The selected buffer is now the one for F

I think this is almost always the wrong behavior. I would expect it to select the status buffer so I can push my commit, amend the message and so forth. Am I doing something wrong?

Owner

tarsius commented Oct 29, 2013

The selected buffer is now the one for F

That was a problem until more than a month ago. I pretty sure I have fixed that and have not seen it again.

I have just made some more adjustment related to this, like:

Type into the new buffer, save it and quit the buffer with C-x # as per the prompt

You should use C-c C-c instead. We have been displaying a message to that effect for a while now. Unfortunately server displays its usage information later, so nobody ever got to see ours :-| We now use a timer so that our usage information gets displayed last.

@tarsius tarsius closed this Oct 29, 2013

This doesn't work for me. I'm using C-c C-c and getting:

diff-beginning-of-file-and-jump: Can't find the beginning of the file

I am using the most recent version of magit from ELPA - 20131026.

@tarsius tarsius reopened this Oct 29, 2013

Owner

tarsius commented Oct 29, 2013

I am using the most recent version of magit from ELPA - 20131026.

Well, I just pushed that change a few seconds before posting the above. So it's not in melpa yet.

When did you last update git-commit-mode?

diff-beginning-of-file-and-jump: Can't find the beginning of the file

Could I have a backtrace with that :-)

Debugger entered--Lisp error: (error "Can't find the beginning of the file")
  signal(error ("Can't find the beginning of the file"))
  diff-beginning-of-file-and-junk()
  #[257 "\300\204��\301\302!\210\303 \210\304 \210`\207" [t error "Can't find the beginning of the hunk" diff-beginning-of-file-and-junk diff-hunk-next] 3 "\n\n(fn IGNORED)"]((search-failed "^\\(?:^@@ -\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\+\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? @@.*\\|\\*\\{15\\}.*\n\\*\\*\\* .+ \\*\\*\\*\\*\\|[0-9]+\\(,[0-9]+\\)?[acd][0-9]+\\(,[0-9]+\\)?\\)$"))
  funcall(#[257 "\300\204��\301\302!\210\303 \210\304 \210`\207" [t error "Can't find the beginning of the hunk" diff-beginning-of-file-and-junk diff-hunk-next] 3 "\n\n(fn IGNORED)"] (search-failed "^\\(?:^@@ -\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\+\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? @@.*\\|\\*\\{15\\}.*\n\\*\\*\\* .+ \\*\\*\\*\\*\\|[0-9]+\\(,[0-9]+\\)?[acd][0-9]+\\(,[0-9]+\\)?\\)$"))
  diff-beginning-of-hunk(t)
  diff-find-source-location(nil t)
  diff-goto-source(nil 3)
  call-interactively(diff-goto-source nil nil)

When did you last update git-commit-mode?

The editor buffer isn't even using git-commit-mode. If I enable it with M-x git-commit-mode, then C-c C-c works correctly. Am I missing some config?

Here is a ps while the buffer is open:

20135 pts/4    S+     0:00 /usr/bin/emacsclient /my/repo/MyProject.git/COMMIT_EDITMSG
Owner

tarsius commented Oct 29, 2013

Do you still have magit-log-edit.elc laying around somewhere? Try (featurep 'magit-log-edit), (locate-library "magit-log-edit").

Both of those eval to nil.

Is there an easy way to print the auto-mode alist so I can see if something is overwriting these entries:

(dolist (pattern '("/COMMIT_EDITMSG\\'" "/NOTES_EDITMSG\\'"
                   "/MERGE_MSG\\'" "/TAG_EDITMSG\\'"
                   "/PULLREQ_EDITMSG\\'"))
  (add-to-list 'auto-mode-alist (cons pattern 'git-commit-mode)))
Owner

tarsius commented Oct 30, 2013

Could you please try updating both packages again, unfortunately the newest versions I mentioned above weren't available from melpa yet at the time I mentioned them, but now they are.

Contributor

PureAbstract commented Oct 30, 2013

@marcbowes You could try something like:

(loop for (expr . mode) in auto-mode-alist
      when (string-match "MSG" expr)
      collect (cons expr mode))

That will give you all the auto-mode-alist pairs whose regexp contain "MSG". And, of course, it's the first one that takes precedence.

Similarly, you can try something like:

(let ((filename "/COMMIT_EDITMSG"))
  (loop for (expr . mode) in auto-mode-alist
        when (string-match expr filename)
        collect (cons expr mode)))

to get all the pairs that match the filename - although in this case you have to be careful about how you compose filename, since it's been my experience that different packages use different regexp recipes to try and catch the "right" set of filenames.

Owner

tarsius commented Oct 30, 2013

What is the value of variable major-mode in the buffer that is supposed to be in git-commit-mode but isn't? If it is nil then the problem most likely isn't due to some conflicting package.

Sorry for the late responses, I was traveling.

value of variable major-mode

It is set to diff-mode.

COMMIT_EDITMSG loop

Ahah!

(("COMMIT_EDITMSG$" . diff-mode) ("/COMMIT_EDITMSG\\'" . git-commit-mode))
starter-kit-misc-recommended.org:(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG$" . diff-mode))

I picked that up from emacs24-starter-kit (@eschulte, eschulte/emacs24-starter-kit).

Adding this fixes it for me:

(delq (assoc "COMMIT_EDITMSG$" auto-mode-alist) auto-mode-alist)

Not sure if there is a neater way.

Not sure how easy this is to add, but maybe when the autoloads are setup we can emit a warning to the user if there is a conflict, perhaps with the loop that @PureAbstract provided?

Either way, I'm happy now. Thanks so much!

@marcbowes marcbowes closed this Nov 6, 2013

Owner

tarsius commented Nov 6, 2013

@eschulte Could you please remove the above auto-mode-alist entry from your starter-kit.

Contributor

eschulte commented Nov 6, 2013

Done, thanks for the suggestion.

Owner

tarsius commented Nov 6, 2013

Thanks to you too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment