From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: emacs-devel@gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: RFC: Automatic setup for bug-reference-mode
Date: Sun, 14 Jun 2020 15:56:27 +0100 [thread overview]
Message-ID: <87k109vgpw.fsf@tcd.ie> (raw)
In-Reply-To: <875zbt24br.fsf@gnu.org> (Tassilo Horn's message of "Sun, 14 Jun 2020 14:56:56 +0200")
Tassilo Horn <tsdh@gnu.org> writes:
> "Basil L. Contovounesios" <contovob@tcd.ie> writes:
>
>>> + (url (pcase backend
>>> + ('Git (string-trim
>>
>> This needs (eval-when-compile (require 'subr-x)).
>
> Or simply remove the "p" from "pcase", I guess.
I was referring to your use of string-trim.
>>> + (shell-command-to-string
>>> + "git ls-remote --get-url"))))))
>>
>> Doesn't VC provide a robust way to get output from Git?
>
> vc-git--call maybe?
Perhaps; I'm not that familiar with VC.
>>> + (cl-flet ((maybe-set (url-rx bug-rx bug-url-fmt)
>>> + (when (string-match url-rx url)
>>> + (setq bug-reference-bug-regexp bug-rx)
>>> + (setq bug-reference-url-format
>>> + (if (functionp bug-url-fmt)
>>> + (funcall bug-url-fmt)
>>> + bug-url-fmt)))))
>>> + (when (and url
>>> + ;; If there's a space in the url, it's propably an
>>> + ;; error message.
>>> + (not (string-match-p "[[:space:]]" url)))
>>> + (or
>>> + ;; GNU projects on savannah. FIXME: Only a fraction of
>>> + ;; them uses debbugs.
>>> + (maybe-set "git\\.\\(sv\\|savannah\\)\\.gnu\\.org:"
>> ^^^
>> Nit: Can this be a shy group?
>
> Yes. Is is generally better to use shy groups if we aren't going to do
> anything with the groups anyway?
Yes, for the negligible potential performance gain, so that there's one
less group number taken, and more importantly so the reader isn't left
wondering why we're capturing this.
Personally, I often just go with what rx does, either by writing rx
forms directly or by manually copying its expansion into the program, as
that way I'm less likely to make a mistake.
>>> ;;;###autoload
>>> -(defun vc-responsible-backend (file)
>>> +(defun vc-responsible-backend (file &optional no-error)
>>> "Return the name of a backend system that is responsible for FILE.
>>>
>>> If FILE is already registered, return the
>>> @@ -967,7 +967,10 @@ vc-responsible-backend
>>>
>>> Note that if FILE is a symbolic link, it will not be resolved --
>>> the responsible backend system for the symbolic link itself will
>>> -be reported."
>>> +be reported.
>>> +
>>> +If NO-ERROR is nil, signal an error that no VC backend is
>>> +responsible for the given file."
>>> (or (and (not (file-directory-p file)) (vc-backend file))
>>> (catch 'found
>>> ;; First try: find a responsible backend. If this is for registration,
>>
>> NO-ERROR seems to be a no-op in this patch.
>
> Indeed. Obviously it should have done what the docstring says.
>
>> Instead of changing the function's arglist, would it be any worse to
>> do the following?
>>
>> (ignore-errors (vc-responsible-backend ...))
>
> IMHO, that it errors if no backend is found is the actual error but we
> cannot change that anymore. And to me "what backend would this file
> use" is a very common question. Even vc.el itself encodes that (dolist
> (backend vc-handled-backends) ...) form again in
> `vc-backend-for-registration' in order not to trigger the error
> semantics of `vc-responsible-backend'.
>
> But that's not important to me. I can also leave it as it is.
FWIW I'm happy with the optional argument you suggest.
> PS: I like your style of suggesting improvements using questions which
> all have a positive answer. Did you visit a lecture of Stefan? ;-)
No, but I wish. ;)
Thanks,
--
Basil
next prev parent reply other threads:[~2020-06-14 14:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 9:37 RFC: Automatic setup for bug-reference-mode Tassilo Horn
2020-06-14 12:13 ` Basil L. Contovounesios
2020-06-14 12:56 ` Tassilo Horn
2020-06-14 14:56 ` Basil L. Contovounesios [this message]
2020-06-14 14:22 ` Stefan Monnier
2020-06-14 15:18 ` Tassilo Horn
2020-06-14 16:30 ` Tassilo Horn
2020-06-14 18:08 ` Basil L. Contovounesios
2020-06-14 18:40 ` Stefan Monnier
2020-06-14 18:57 ` Basil L. Contovounesios
2020-06-14 19:43 ` Tassilo Horn
2020-06-14 19:41 ` Dmitry Gutov
2020-06-14 20:39 ` Tassilo Horn
2020-06-14 20:51 ` Dmitry Gutov
2020-06-14 21:03 ` Basil L. Contovounesios
2020-06-15 6:23 ` VC repository-url command (was: RFC: Automatic setup for bug-reference-mode) Tassilo Horn
2020-06-15 11:33 ` VC repository-url command Basil L. Contovounesios
2020-06-15 9:56 ` RFC: Automatic setup for bug-reference-mode Stephen Leake
2020-06-15 10:21 ` Tassilo Horn
2020-06-17 21:35 ` Juri Linkov
2020-06-17 22:10 ` Dmitry Gutov
2020-06-18 6:06 ` Tassilo Horn
2020-06-18 9:46 ` Dmitry Gutov
2020-06-18 13:37 ` Tassilo Horn
2020-06-18 14:28 ` Dmitry Gutov
2020-06-15 10:57 ` Tassilo Horn
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k109vgpw.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=emacs-devel@gnu.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).