unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Paul van der Walt <paul@denknerd.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH 4/8] gnu: Add zathura.
Date: Mon, 02 Mar 2015 15:19:32 -0500	[thread overview]
Message-ID: <87zj7vm9t7.fsf@netris.org> (raw)
In-Reply-To: <1425290046-9612-4-git-send-email-paul@denknerd.org> (Paul van der Walt's message of "Mon, 2 Mar 2015 10:54:02 +0100")

Paul van der Walt <paul@denknerd.org> writes:

> * gnu/packages/pdf.scm (zathura): New variable.
> * gnu-system.am: Add zathura-plugindir-environment-variable.patch
> * gnu/packages/patches/zathura-plugindir-environment-variable.patch: Add patch
>   for zathura environment variable.

It's not important, but the way we usually write this is:

* gnu/packages/patches/zathura-plugindir-environment-variable.patch: New file.
* gnu-system.am: Add it.

We don't generally describe what new files are for in the commit log.
Such explanations belong in the files themselves.

> ---
>  gnu-system.am                                      |  4 +-
>  .../zathura-plugindir-environment-variable.patch   | 44 ++++++++++++++++++++
>  gnu/packages/pdf.scm                               | 47 ++++++++++++++++++++++
>  3 files changed, 93 insertions(+), 2 deletions(-)
>  create mode 100644 gnu/packages/patches/zathura-plugindir-environment-variable.patch
>
> diff --git a/gnu-system.am b/gnu-system.am
> index e42e89a..5dda73a 100644
> --- a/gnu-system.am
> +++ b/gnu-system.am
> @@ -550,8 +550,8 @@ dist_patch_DATA =						\
>    gnu/packages/patches/xf86-video-trident-remove-mibstore.patch	\
>    gnu/packages/patches/xf86-video-vmware-glibc-2.20.patch	\
>    gnu/packages/patches/xfce4-panel-plugins.patch		\
> -  gnu/packages/patches/xmodmap-asprintf.patch
> -
> +  gnu/packages/patches/xmodmap-asprintf.patch                   \
> +  gnu/packages/patches/zathura-plugindir-environment-variable.patch
>  MISC_DISTRO_FILES = gnu/packages/javac.in

For consistency, please use tabs before the "\", and keep the blank line
above the MISC_DISTRO_FILES definition.

> +diff --git a/zathura/zathura.c b/zathura/zathura.c
> +index 589dd28..d3c9887 100644
> +--- a/zathura/zathura.c
> ++++ b/zathura/zathura.c
> +@@ -413,12 +413,24 @@ zathura_set_plugin_dir(zathura_t* zathura, const char* dir)
> +   g_return_if_fail(zathura != NULL);
> +   g_return_if_fail(zathura->plugins.manager != NULL);
> + 
> ++  // Get the new environment variable, if any.
> ++  const gchar* envvar_plugin_dir = g_getenv("ZATHURA_PLUGIN_DIR");
> ++
> +   if (dir != NULL) {
> ++    // This bit sets the plugin dir from command-line.
> +     girara_list_t* paths = girara_split_path_array(dir);
> +     GIRARA_LIST_FOREACH(paths, char*, iter, path)
> +     zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
> +     GIRARA_LIST_FOREACH_END(paths, char*, iter, path);
> +     girara_list_free(paths);
> ++  } else if (envvar_plugin_dir != NULL) {
> ++    // Set plugins dir to the contents of environment variable
> ++    // ZATHURA_PLUGIN_DIR.
> ++    girara_list_t* paths = girara_split_path_array(envvar_plugin_dir);
> ++    GIRARA_LIST_FOREACH(paths, char*, iter, path)
> ++    zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
> ++    GIRARA_LIST_FOREACH_END(paths, char*, iter, path);
> ++    girara_list_free(paths);
> +   } else {

Since the environment variable can hold a path with more than one
directory, it is misnamed.  How about ZATHURA_PLUGIN_PATH instead?

Also the code above could be simplified.
How about something like this: (untested)

--8<---------------cut here---------------start------------->8---
  g_return_if_fail(zathura != NULL);
  g_return_if_fail(zathura->plugins.manager != NULL);

  if (dir == NULL)
    dir = g_getenv("ZATHURA_PLUGIN_PATH");

  if (dir != NULL) {
    girara_list_t* paths = girara_split_path_array(dir);
    GIRARA_LIST_FOREACH(paths, char*, iter, path)
    zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
    GIRARA_LIST_FOREACH_END(paths, char*, iter, path);
    girara_list_free(paths);
  } else {
--8<---------------cut here---------------end--------------->8---

This would be just three new lines, but it depends on 'dir' not being
used for anything else further down in the function, and it not being
freed.  If it is freed later, you could just wrap the 'g_getenv' with
'g_strdup'.

What do you think?

> diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
> index 5e24a43..1c5c193 100644
> --- a/gnu/packages/pdf.scm
> +++ b/gnu/packages/pdf.scm
> @@ -29,6 +29,9 @@
>    #:use-module (gnu packages compression)
>    #:use-module (gnu packages fontutils)
>    #:use-module (gnu packages ghostscript)
> +  #:use-module (gnu packages databases)
> +  #:use-module (gnu packages gettext)
> +  #:use-module (gnu packages backup)
>    #:use-module (gnu packages lesstif)
>    #:use-module (gnu packages image)
>    #:use-module (gnu packages pkg-config)
> @@ -146,6 +149,50 @@
>  
>  
>  
> +
> +(define-public zathura

Too many blank lines.

> +  (package
> +    (name "zathura")
> +    (version "0.3.2")
> +    (source (origin
> +              (method url-fetch)
> +              (uri
> +               (string-append "https://pwmt.org/projects/zathura/download/zathura-"
> +                              version ".tar.gz"))
> +              (sha256
> +               (base32
> +                "1qk5s7cyqp4l673yhma5igk9g24p5jyqyy81fdk7q7xjqlym19px"))
> +              (patches
> +               (list
> +                (search-patch "zathura-plugindir-environment-variable.patch")))))
> +    (native-inputs
> +     `(("pkg-config" ,pkg-config)
> +       ("gettext" ,gnu-gettext)))
> +    (native-search-paths
> +     (list (search-path-specification
> +            (variable "ZATHURA_PLUGIN_DIR")
> +            (files '("lib/zathura")))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:make-flags
> +       `(,(string-append "PREFIX=" (assoc-ref %outputs "out"))
> +         "CC=gcc" "COLOR=0")
> +       #:tests? #f ; Tests fail: "Gtk cannot open display".
> +       #:test-target "test"
> +       #:phases
> +       (alist-delete
> +        'configure
> +        %standard-phases)))

This fits easily on one line:

 #:phases (alist-delete 'configure %standard-phases)

> +    (home-page "https://pwmt.org/projects/zathura/")
> +    (synopsis "Lightweight keyboard-driven PDF viewer")
> +    (description "zathura is a highly customizable and functional document
> +viewer.  It provides a minimalistic and space saving interface as well as an
> +easy usage that mainly focuses on keyboard interaction.")

Probably the description should start with a capital letter, and I would
remove "and functional" and "as well as an easy usage" which sound like
marketing-speak.

> +    (inputs `(("girara" ,girara)
> +              ("sqlite" ,sqlite)
> +              ("gtk+" ,gtk+)))

Please move this next to 'native-inputs'.

Can you send an updated patch?

     Thanks!
       Mark

  reply	other threads:[~2015-03-02 20:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02  9:53 [PATCH 1/8] gnu: check: Update version to 0.9.14 Paul van der Walt
2015-03-02  9:54 ` [PATCH 2/8] gnu: Add girara Paul van der Walt
2015-03-02  9:54 ` [PATCH 3/8] gnu: Add djvulibre Paul van der Walt
2015-03-02  9:54 ` [PATCH 4/8] gnu: Add zathura Paul van der Walt
2015-03-02 20:19   ` Mark H Weaver [this message]
2015-03-02 21:20     ` Paul van der Walt
2015-03-02  9:54 ` [PATCH 5/8] gnu: Add zathura PDF plugin Paul van der Walt
2015-03-02  9:54 ` [PATCH 6/8] gnu: Add zathura DjVu plugin Paul van der Walt
2015-03-02  9:54 ` [PATCH 7/8] gnu: Add zathura postscript plugin Paul van der Walt
2015-03-02  9:54 ` [PATCH 8/8] gnu: Add zathura comicbook plugin Paul van der Walt
  -- strict thread matches above, loose matches on Subject: below --
2015-03-02 21:26 [PATCH 1/8] gnu: check: Update version to 0.9.14 Paul van der Walt
2015-03-02 21:26 ` [PATCH 4/8] gnu: Add zathura Paul van der Walt

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://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zj7vm9t7.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guix-devel@gnu.org \
    --cc=paul@denknerd.org \
    /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/guix.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).