unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] emacs: Fill package description in Info buffers.
Date: Tue, 14 Jul 2015 11:31:16 +0300	[thread overview]
Message-ID: <87y4ijxhrf.fsf@gmail.com> (raw)
In-Reply-To: <1436818091-6524-1-git-send-email-ludo@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22's\?\= message of "Mon, 13 Jul 2015 22:08:11 +0200")

[-- Attachment #1: Type: text/plain, Size: 2249 bytes --]

Ludovic Courtès (2015-07-13 23:08 +0300) wrote:

> * emacs/guix-info.el (guix-package-info-insert-heading): Add call to
>   'fill-region'.
> ---
>  emacs/guix-info.el | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/guix-info.el b/emacs/guix-info.el
> index bb21024..1e03d65 100644
> --- a/emacs/guix-info.el
> +++ b/emacs/guix-info.el
> @@ -494,8 +494,11 @@ Show package name, version, and `guix-package-info-heading-params'."
>                  (face (guix-get-symbol (symbol-name param)
>                                         'info 'package)))
>              (when val
> -              (guix-format-insert val (and (facep face) face))
> -              (insert "\n\n"))))
> +              (let ((begin       (point))
> +                    (fill-column (min (window-width) 72)))

Since there is a buffer-local 'fill-column' variable, I think we may use
it instead of hard-coding '72', so that a user could change it, for
example like this:

(add-hook 'guix-package-info-mode-hook
          (lambda () (setq fill-column 60)))

> +                (guix-format-insert val (and (facep face) face))
> +                (fill-region begin (point))

I think it's better to use 'guix-get-filled-string' instead of
(let ((begin (point))) ... (fill-region begin (point)))

> +                (insert "\n\n")))))
>          guix-package-info-heading-params))
>  
>  (defun guix-package-info-insert-with-heading (entry)

Actually, I think that preserving the original formatting used in
"description" fields is a feature, not a bug, as it allows to find too
long lines or other related things and then to fix those.

(For example, I've just accidentally found that the first line of
"pulseaudio" description is too long, and when I looked at the source, I
also noticed that the description ends with a space.  With your change
it wouldn't be possible to notice :-))

But as we can always add another option for a user to choose the variant
he wants, I agree.  What about the attached modified patch?

Also as it may concern synopsis (when a current window is too small to
fit the synopsis), I renamed the patch into "emacs: Fill package heading
in Info buffers."


[-- Attachment #2: 0001-emacs-Fill-package-heading-in-Info-buffers.patch --]
[-- Type: text/x-diff, Size: 2328 bytes --]

From 45d7206e66ac53de4fdec698f27ed428f3d43569 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Mon, 13 Jul 2015 22:08:11 +0200
Subject: [PATCH] emacs: Fill package heading in Info buffers.

* emacs/guix-info.el (guix-package-info-fill-heading): New variable.
  (guix-package-info-insert-heading): Fill heading if needed.

Co-authored-by: Alex Kost <alezost@gmail.com>
---
 emacs/guix-info.el | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index bb21024..f17ce01 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -1,6 +1,7 @@
 ;;; guix-info.el --- Info buffers for displaying entries   -*- lexical-binding: t -*-
 
-;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
 
 ;; This file is part of GNU Guix.
 
@@ -482,6 +483,12 @@ If nil, insert package in a default way.")
 (defvar guix-package-info-heading-params '(synopsis description)
   "List of parameters displayed in a heading along with name and version.")
 
+(defcustom guix-package-info-fill-heading t
+  "If nil, insert heading parameters in a raw form, without
+filling them to fit the window."
+  :type 'boolean
+  :group 'guix-package-info)
+
 (defun guix-package-info-insert-heading (entry)
   "Insert the heading for package ENTRY.
 Show package name, version, and `guix-package-info-heading-params'."
@@ -494,8 +501,12 @@ Show package name, version, and `guix-package-info-heading-params'."
                 (face (guix-get-symbol (symbol-name param)
                                        'info 'package)))
             (when val
-              (guix-format-insert val (and (facep face) face))
-              (insert "\n\n"))))
+              (let* ((col (min (window-width) fill-column))
+                     (val (if guix-package-info-fill-heading
+                              (guix-get-filled-string val col)
+                            val)))
+                (guix-format-insert val (and (facep face) face))
+                (insert "\n\n")))))
         guix-package-info-heading-params))
 
 (defun guix-package-info-insert-with-heading (entry)
-- 
2.4.5


  reply	other threads:[~2015-07-14  8:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13 20:08 [PATCH] emacs: Fill package description in Info buffers Ludovic Courtès
2015-07-14  8:31 ` Alex Kost [this message]
2015-07-14 13:15   ` Ludovic Courtès

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=87y4ijxhrf.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.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).