all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: Yuan Fu <casouri@gmail.com>
Cc: Po Lu <luangruo@yahoo.com>,
	 Stefan Kangas <stefankangas@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: emacs-30 f0daa2f2153: Conservative heuristic for tree-sitter parser ranges (bug#73324)
Date: Sun, 22 Sep 2024 23:23:06 +0200	[thread overview]
Message-ID: <87tte7mlhh.fsf@gmail.com> (raw)
In-Reply-To: <4A9D96DA-C260-46B6-A3BC-E2F4A9E5C8E2@gmail.com> (Yuan Fu's message of "Sat, 21 Sep 2024 23:44:38 -0700")

Yuan Fu <casouri@gmail.com> writes:

>> On Sep 21, 2024, at 10:43 PM, Po Lu <luangruo@yahoo.com> wrote:
>> 
>> Stefan Kangas <stefankangas@gmail.com> writes:
>> 
>>>> Please fill ChangeLog entries in commit messages to a width of 64
>>>> columns, not 71 or 72, as here.
>>> 
>>> I don't want to get into another argument about this, but I don't see
>>> any problem with the above formatting, FWIW.
>>> 
>>> In any case, I really don't think it is a good use of our time to police
>> 
>> It is a good (and a exceedingly slight) use of my time.
>> 
>>> the recently introduced default of 64 columns here.  We never did that
>>> before, when the default in `vc-git-log-edit-mode' was 70 characters,
>>> and there is no reason to start doing it now.
>> 
>> That point is moot when most of us were self-consciously observing this
>> standard before it was formalized in .dir-locals.el.
>
> I took a look and it’s set for log-edit-mode only. It would be nice if magit can pick it up. I’m sure a lot of people (me included) use magit for developing Emacs. The only problem is magit’s commit message editing buffer doesn’t have a special major mode. It does git-commit-mode which is a minor mode, and runs git-commit-setup-hook. But I’m not sure how to edit dir-locals to set fill-column using a hook or minor mode.

Kludge from my personal config reproduced below¹, if it can help.  It
adds a function to git-commit-setup-hook that sets fill-column when it
detects that one of the remotes is Emacs's Savannah repo.

Thinking more about it, and considering the existence of the
git-commit-major-mode variable, I guess one could also

1) define a major mode derived from text-mode in their personal config;
2) add a .dir-locals-2.el file to their Emacs checkout that sets
git-commit-major-mode to that-new-mode, and fill-column to
  *checks config*
63
  *checks discussion*
^W64
  *ponders git-blaming to see what Past Self has to say for himself*
  *looks at the time*
  *you're off the hook, Past Self*
for that-new-mode.

Thinking *more* about it, setting git-commit-major-mode to log-edit-mode
in .dir-locals-2.el sounds like TRT in theory; in practice though I bet
it would lead to "interesting" fireworks².


¹

```
(defun my/git-upstreams ()
  ;; TODO: memoize, perhaps?
  (seq-uniq
   (seq-keep
    (lambda (remote-desc)
      (and (string-match "\\`.*\t\\(.*\\) (fetch)\\'" remote-desc)
           (match-string 1 remote-desc)))
    (process-lines "git" "remote" "-v"))))

(defun my/emacs-repo-p (upstreams)
  "Guess whether we are working in the Emacs repository.
UPSTREAMS is a list of fetch URLs."
  (member "https://git.savannah.gnu.org/git/emacs.git" upstreams))

(defvar my/git-commit-fill-columns
  '((my/emacs-repo-p . 63)))

(cl-defun my/git-commit-maybe-set-fill-column ()
  (let ((remotes (my/git-upstreams)))
    (pcase-dolist (`(,pred . ,column) my/git-commit-fill-columns)
      (when (funcall pred remotes)
        (cl-return-from my/git-commit-maybe-set-fill-column
          (setq fill-column column))))))

(add-hook
 'git-commit-setup-hook
 'my/git-commit-maybe-set-fill-column)
```

² Off the top of my head:

* bindings conflicting, e.g. log-edit-done vs with-editor-finish:
guessing the minor mode wins in that case… 🫣

* log-edit-generate-changelog-from-diff being ineffectual because
log-edit-diff-function is not set up: something to kludge around, though
Magit does also provide magit-commit-add-log from the diff buffer 🤷



  reply	other threads:[~2024-09-22 21:23 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <172663360099.23732.9998257239822693024@vcs2.savannah.gnu.org>
     [not found] ` <20240918042641.56C7BC410E2@vcs2.savannah.gnu.org>
2024-09-18  6:31   ` emacs-30 f0daa2f2153: Conservative heuristic for tree-sitter parser ranges (bug#73324) Po Lu
2024-09-20  4:53     ` Yuan Fu
2024-09-20  6:32       ` Eli Zaretskii
2024-09-20  6:44         ` Eli Zaretskii
2024-09-21  3:10           ` Yuan Fu
2024-09-22  0:59     ` Stefan Kangas
2024-09-22  5:18       ` Eli Zaretskii
2024-09-22  5:43       ` Po Lu
2024-09-22  6:44         ` Yuan Fu
2024-09-22 21:23           ` Kévin Le Gouguec [this message]
2024-09-23  8:27             ` Robert Pluim
2024-09-23 11:49             ` Eli Zaretskii
2024-09-23 17:24               ` Kévin Le Gouguec
2024-09-23 18:24                 ` Eli Zaretskii
2024-09-24  7:10                   ` Kévin Le Gouguec
2024-09-26  7:28                     ` Yuan Fu

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=87tte7mlhh.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=stefankangas@gmail.com \
    /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.