From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: Re: [PATCH] emacs: Fill package description in Info buffers. Date: Tue, 14 Jul 2015 11:31:16 +0300 Message-ID: <87y4ijxhrf.fsf@gmail.com> References: <1436818091-6524-1-git-send-email-ludo@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEvcZ-0007vX-5f for guix-devel@gnu.org; Tue, 14 Jul 2015 04:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEvcV-0002l4-Vo for guix-devel@gnu.org; Tue, 14 Jul 2015 04:31:23 -0400 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") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s (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-h= eading-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)) >=20=20 > (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." --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-emacs-Fill-package-heading-in-Info-buffers.patch Content-Transfer-Encoding: quoted-printable >From 45d7206e66ac53de4fdec698f27ed428f3d43569 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Ludovic=3D20Court=3DC3=3DA8s?=3D 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 --- 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-bin= ding: t -*- =20 -;; Copyright =C2=A9 2014 Alex Kost +;; Copyright =C2=A9 2014, 2015 Alex Kost +;; Copyright =C2=A9 2015 Ludovic Court=C3=A8s =20 ;; This file is part of GNU Guix. =20 @@ -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.") =20 +(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-hea= ding-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)) =20 (defun guix-package-info-insert-with-heading (entry) --=20 2.4.5 --=-=-=--