From: joaotavora@gmail.com (João Távora)
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Lars Magne Ingebrigtsen <larsi@gnus.org>,
Stefan Monnier <monnier@IRO.UMontreal.CA>,
emacs-devel@gnu.org
Subject: Re: electric-pair-mode as a minor mode?
Date: Sun, 12 Apr 2015 23:16:57 +0100 [thread overview]
Message-ID: <m2mw2d3sbq.fsf@gmail.com> (raw)
In-Reply-To: <552A9FD2.8040307@yandex.ru> (Dmitry Gutov's message of "Sun, 12 Apr 2015 19:39:46 +0300")
Dmitry Gutov <dgutov@yandex.ru> writes:
> On 04/12/2015 04:16 PM, joaotavora@gmail.com (João Távora) wrote:
>
>> As a side note, a spurious "Summary: " prefix slipped through in the
>> first line of the commit message, since I ammended my local commit from
>> the command line, with emacsclient as EDITOR and then used M-p
>> `log-edit-previous-comment' to pull in the last message. I saw
>> 'Summary:' fontified so assumed it would be killed by `log-edit-mode'.
>
> Thoughts:
>
> - I wonder why you didn't have the existing message already filled in
> the buffer, so you'd had to press `M-n'.
(I pressed `M-p', not `M-n'). But true, in recent tests I see always see
the last commit message when I commit --amend. Perhaps I had amended
some more times and wanted to go to some intermediate version. I dunno
anymore.
> - This kind of commit message buffers should probably use a different
> major mode: after all, the format of the contents is different.
That's right. Although I can't resist asking why these "Summary" and
"Author" hints/cookies can't be some display-only element like a
before-string in an overlay. Why are they implemented as actual buffer
text?
> - vc-git supports the "amend" feature, so you shouldn't have had to
> use the command line; although it's a bit awkward when you want just
> to edit the message, and there are no changes in any files: then
> `vc-next-action' doesn't even initiate commit. We should integrate it
> with `log-view-modify-change-comment'.
Never tried it. Didn't know they existed even. I make commits from
vc-dir and command line alternately as is more convenient, so I
`log-edit-mode' in COMMIT_EDITMSG for a consistent UI.
> Maybe somewhere in `before-save-hook' of the new major mode?
Won't kick in when the buffer doesn't need saving. This seems works
nicely though:
(defun log-edit--commit-editmsg-done ()
;; no idea why `log-edit-callback' is called with `call-interactive'
(interactive)
(save-excursion
(goto-char (point-min))
(when (and (search-forward-regexp "^Summary:[ \t]+" (line-end-position) t)
(y-or-n-p "Possibly spurious \"Summary:\" header detected. Remove?"))
(delete-region (match-beginning 0) (match-end 0))))
(save-buffer)
(server-edit))
(define-derived-mode log-edit--commit-editmsg-mode log-edit-mode "Log-Edit*"
"Special version of `log-edit-mode' for .git/COMMIT_EDITMSG."
(set (make-local-variable 'log-edit-callback)
'log-edit--commit-editmsg-done)
(setq default-directory (file-name-directory (directory-file-name default-directory))))
(add-to-list 'auto-mode-alist '("\\.git/COMMIT_EDITMSG" . log-edit--commit-editmsg-mode))
Got it in my .emacs, but perhaps this could be installed, seems generic
enough. OTOH, git log --grep '^Summary:' seems to indicate this happens
only once every 5-6 years
João
next prev parent reply other threads:[~2015-04-12 22:16 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 19:51 electric-pair-mode as a minor mode? Yuri D'Elia
2015-03-27 2:18 ` Stefan Monnier
2015-03-27 8:04 ` Yuri D'Elia
2015-03-27 13:19 ` Stefan Monnier
2015-03-27 11:18 ` João Távora
2015-03-27 13:25 ` Stefan Monnier
2015-03-27 14:09 ` João Távora
2015-03-27 18:20 ` Stefan Monnier
2015-03-28 16:11 ` João Távora
2015-03-28 20:36 ` Stefan Monnier
2015-03-28 21:47 ` João Távora
2015-03-28 23:09 ` João Távora
2015-03-29 4:01 ` Stefan Monnier
2015-03-29 20:41 ` João Távora
2015-03-30 0:54 ` Stefan Monnier
2015-03-30 10:46 ` João Távora
2015-03-30 13:53 ` Stefan Monnier
2015-03-30 15:43 ` João Távora
2015-03-30 20:33 ` Stefan Monnier
2015-03-30 20:42 ` João Távora
2015-03-30 21:47 ` João Távora
2015-03-30 22:02 ` Stefan Monnier
2015-04-11 16:06 ` João Távora
2015-04-12 11:56 ` Stefan Monnier
2015-04-12 13:16 ` João Távora
2015-04-12 16:39 ` Dmitry Gutov
2015-04-12 22:16 ` João Távora [this message]
2015-04-12 23:10 ` Dmitry Gutov
2015-04-15 21:32 ` João Távora
2015-04-15 13:59 ` Lars Magne Ingebrigtsen
2015-04-15 21:16 ` João Távora
2015-04-15 21:21 ` Lars Magne Ingebrigtsen
2015-04-15 21:39 ` João Távora
2015-04-15 21:43 ` Lars Magne Ingebrigtsen
2015-04-26 10:28 ` João Távora
2015-04-26 19:48 ` Lars Magne Ingebrigtsen
2015-04-27 2:29 ` Stefan Monnier
2015-03-27 19:38 ` Yuri D'Elia
2015-03-27 12:52 ` Tom Willemse
2015-03-27 19:01 ` Stefan Monnier
2015-03-28 15:47 ` João Távora
2015-03-28 17:37 ` bug#19528: " Glenn Morris
2015-03-28 21:01 ` João Távora
2015-04-14 6:28 ` Glenn Morris
2015-03-28 15:47 ` João Távora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2mw2d3sbq.fsf@gmail.com \
--to=joaotavora@gmail.com \
--cc=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.