Commit b82228bc authored by Jonas Bernoulli's avatar Jonas Bernoulli

magit-revision-show-gravatar: Make more easily customizable

Actually it was already easily customizable using the
Custom interface, but when using `setq' it was painful.
parent f4b8fee6
......@@ -8,7 +8,7 @@
#+TEXINFO_DIR_CATEGORY: Emacs
#+TEXINFO_DIR_TITLE: Magit: (magit).
#+TEXINFO_DIR_DESC: Using Git from Emacs with Magit.
#+SUBTITLE: for version 2.13.0 (2.13.0-333-ge9104e3f8+1)
#+SUBTITLE: for version 2.13.0 (2.13.0-338-gf4b8fee66+1)
#+BIND: ox-texinfo+-before-export-hook ox-texinfo+-update-version-strings
#+TEXINFO_DEFFN: t
......@@ -23,7 +23,7 @@ directly from within Emacs. While many fine Git clients exist, only
Magit and Git itself deserve to be called porcelains.
#+TEXINFO: @noindent
This manual is for Magit version 2.13.0 (2.13.0-333-ge9104e3f8+1).
This manual is for Magit version 2.13.0 (2.13.0-338-gf4b8fee66+1).
#+BEGIN_QUOTE
Copyright (C) 2015-2018 Jonas Bernoulli <jonas@bernoul.li>
......@@ -3003,17 +3003,18 @@ These commands are available in diff buffers.
Whether to show gravatar images in revision buffers.
If non-nil, then the value has to be a cons-cell which specifies
where the gravatar images for the author and/or the committer are
inserted inside the text that was previously inserted according
to ~magit-revision-header-format~.
Both cells are regular expressions. The car specifies where to
insert the author gravatar image. The top half of the image is
inserted right after the matched text, the bottom half on the
next line at the same offset. The cdr specifies where to insert
the committer image, accordingly. Either the car or the cdr may
be nil.
If ~nil~, then don't insert any gravatar images. If ~t~, then insert
both images. If ~author~ or ~committer~, then insert only the
respective image.
If you have customized the option ~magit-revision-header-format~
and want to insert the images then you might also have to specify
where to do so. In that case the value has to be a cons-cell of
two regular expressions. The car specifies where to insert the
author's image. The top half of the image is inserted right
after the matched text, the bottom half on the next line in the
same column. The cdr specifies where to insert the committer's
image, accordingly. Either the car or the cdr may be nil."
- User Option: magit-revision-use-hash-sections
......
......@@ -31,7 +31,7 @@ General Public License for more details.
@finalout
@titlepage
@title Magit User Manual
@subtitle for version 2.13.0 (2.13.0-333-ge9104e3f8+1)
@subtitle for version 2.13.0 (2.13.0-338-gf4b8fee66+1)
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
......@@ -53,7 +53,7 @@ directly from within Emacs. While many fine Git clients exist, only
Magit and Git itself deserve to be called porcelains.
@noindent
This manual is for Magit version 2.13.0 (2.13.0-333-ge9104e3f8+1).
This manual is for Magit version 2.13.0 (2.13.0-338-gf4b8fee66+1).
@quotation
Copyright (C) 2015-2018 Jonas Bernoulli <jonas@@bernoul.li>
......@@ -4079,17 +4079,18 @@ Whether to show related branches in revision buffers.
Whether to show gravatar images in revision buffers.
If non-nil, then the value has to be a cons-cell which specifies
where the gravatar images for the author and/or the committer are
inserted inside the text that was previously inserted according
to @code{magit-revision-header-format}.
Both cells are regular expressions. The car specifies where to
insert the author gravatar image. The top half of the image is
inserted right after the matched text, the bottom half on the
next line at the same offset. The cdr specifies where to insert
the committer image, accordingly. Either the car or the cdr may
be nil.
If @code{nil}, then don't insert any gravatar images. If @code{t}, then insert
both images. If @code{author} or @code{committer}, then insert only the
respective image.
If you have customized the option @code{magit-revision-header-format}
and want to insert the images then you might also have to specify
where to do so. In that case the value has to be a cons-cell of
two regular expressions. The car specifies where to insert the
author's image. The top half of the image is inserted right
after the matched text, the bottom half on the next line in the
same column. The cdr specifies where to insert the committer's
image, accordingly. Either the car or the cdr may be nil."
@end defopt
@defopt magit-revision-use-hash-sections
......
......@@ -351,21 +351,25 @@ still visit the commit at point using \"RET\"."
(defcustom magit-revision-show-gravatars nil
"Whether to show gravatar images in revision buffers.
If non-nil, then the value has to be a cons-cell which specifies
where the gravatar images for the author and/or the committer are
inserted inside the text that was previously inserted according
to `magit-revision-header-format'.
Both cells are regular expressions. The car specifies where to
insert the author gravatar image. The top half of the image is
inserted right after the matched text, the bottom half on the
next line at the same offset. The cdr specifies where to insert
the committer image, accordingly. Either the car or the cdr may
be nil."
If nil, then don't insert any gravatar images. If t, then insert
both images. If `author' or `committer', then insert only the
respective image.
If you have customized the option `magit-revision-header-format'
and want to insert the images then you might also have to specify
where to do so. In that case the value has to be a cons-cell of
two regular expressions. The car specifies where to insert the
author's image. The top half of the image is inserted right
after the matched text, the bottom half on the next line in the
same column. The cdr specifies where to insert the committer's
image, accordingly. Either the car or the cdr may be nil."
:package-version '(magit . "2.3.0")
:group 'magit-revision
:type '(choice (const :tag "Don't show gravatars" nil)
(cons :tag "Show gravatars"
(const :tag "Show gravatars" t)
(const :tag "Show author gravatar" author)
(const :tag "Show committer gravatar" committer)
(cons :tag "Show gravatars using custom pattern."
(regexp :tag "Author regexp" "^Author: ")
(regexp :tag "Committer regexp" "^Commit: "))))
......@@ -2188,7 +2192,12 @@ or a ref which is not a branch, then it inserts nothing."
(when (and magit-revision-show-gravatars
(window-system))
(require 'gravatar)
(pcase-let ((`(,author . ,committer) magit-revision-show-gravatars))
(pcase-let ((`(,author . ,committer)
(pcase magit-revision-show-gravatars
(`t '("^Author: " . "^Commit: "))
(`author '("^Author: " . nil))
(`committer '(nil . "^Commit: "))
(_ magit-revision-show-gravatars))))
(--when-let (and author (magit-rev-format "%aE" rev))
(magit-insert-revision-gravatar beg rev it author))
(--when-let (and committer (magit-rev-format "%cE" rev))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment