all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Fill package description in Info buffers.
@ 2015-07-13 20:08 Ludovic Courtès
  2015-07-14  8:31 ` Alex Kost
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-07-13 20:08 UTC (permalink / raw)
  To: guix-devel; +Cc: alezost

* 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)))
+                (guix-format-insert val (and (facep face) face))
+                (fill-region begin (point))
+                (insert "\n\n")))))
         guix-package-info-heading-params))
 
 (defun guix-package-info-insert-with-heading (entry)
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: Fill package description in Info buffers.
  2015-07-13 20:08 [PATCH] emacs: Fill package description in Info buffers Ludovic Courtès
@ 2015-07-14  8:31 ` Alex Kost
  2015-07-14 13:15   ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Kost @ 2015-07-14  8:31 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: Fill package description in Info buffers.
  2015-07-14  8:31 ` Alex Kost
@ 2015-07-14 13:15   ` Ludovic Courtès
  0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2015-07-14 13:15 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> 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)))

Indeed, it’s better this way.

>> +                (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)))

Agreed, I hadn’t noticed that one.

> 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 :-))

I think I would turn to the source file when I want to nitpick on
description formatting.  ;-)

> 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."

Your patch looks better indeed.  Please push, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-14 13:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-13 20:08 [PATCH] emacs: Fill package description in Info buffers Ludovic Courtès
2015-07-14  8:31 ` Alex Kost
2015-07-14 13:15   ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.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.