1

When I open commit buffer (pressing c c), the pointer is shown in random locations instead of showing point at beginning of buffer. This is quite annoying as I have to manually move point every time.

I also checked this FAQ in magit and added these to init file

(setq session-name-disable-regexp "\\(?:\\`'\\.git/[A-Z_]+\\'\\)")

(with-eval-after-load 'pointback
  (lambda ()
     (when (or git-commit-mode git-rebase-mode)
     (pointback-mode -1))))

But still point is not getting restored. I even tried this

(defun restore-point ()
   (interactive)
   (when (string-match ".git/COMMIT_EDITMSG" buffer-file-name)
      (goto-char (point-min))))
(add-hook 'git-commit-mode-hook 'restore-point)

Still its not restoring. Any idea what might be going wrong here?

Magit config is here and emacs config.

  • 1
    Seems like you should try with emacs -Q and if that works, then bisect your init file. – tarsius Jan 19 '16 at 21:31
  • Do you think it could be this package: github.com/ChillarAnand/.emacs.d/blob/master/init.el#L163 Maybe point is being saved from the last time you edited a commit message? – elethan Jan 19 '16 at 22:23
  • @elethan that fixed issue. But if i remove that, how can i save position of pointer for other files? – ChillarAnand Jan 20 '16 at 4:58
  • I haven't tested this, but it seems like you could use the function toggle-save-place in that library and maybe hook it to the git-commit-setup-hook or a similar hook, or do something of that nature to automatically toggle the mode off when you are writing commit messages, and toggle it back on when you are finished. – elethan Jan 20 '16 at 15:22
1

The snippet to turn off pointback-mode from the FAQ misses a crucial part. Here's a fixed version:

(with-eval-after-load 'pointback
  (add-hook 'git-commit-setup-hook
            (lambda ()
              (when (or git-commit-mode git-rebase-mode)
                (pointback-mode -1)))))

I'll update the FAQ later (after checking whether pointback offers an option which would make that hack unnecessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.