GNU bug report logs - #43866
26.3; italian postfix additions

Previous Next

Package: emacs;

Reported by: Francesco Potortì <pot <at> gnu.org>

Date: Thu, 8 Oct 2020 12:07:01 UTC

Severity: wishlist

Tags: moreinfo

Found in version 26.3

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: rpluim <at> gmail.com, 43866 <at> debbugs.gnu.org
Subject: bug#43866: 26.3; italian postfix additions
Date: Thu, 22 Oct 2020 15:59:52 +0300
> From: Juri Linkov <juri <at> linkov.net>
> Cc: rpluim <at> gmail.com,  43866 <at> debbugs.gnu.org
> Date: Wed, 21 Oct 2020 22:39:08 +0300
> 
> However, do you think something like the following is a good idea?
> 
> Let-binding a new variable 'print-integers-as-chars' to t:
> 
> (let ((print-integers-as-chars t))
>   (pp '(("'A" . [?Á])
>         ("'E" . [?É])
>         ("'I" . [?Í])
>         ("'O" . [?Ó])
>         ("'U" . [?Ú])
>         ("'Y" . [?Ý]))
>       (current-buffer)))
> 
> prints integers as characters:
> 
> (("'A" .  [?Á])
>  ("'E" .  [?É])
>  ("'I" .  [?Í])
>  ("'O" .  [?Ó])
>  ("'U" .  [?Ú])
>  ("'Y" .  [?Ý]))
> 
> with this patch:

The idea is fine, but I have a few comments about implementation:

>      case_Lisp_Int:
>        {
> -	int len = sprintf (buf, "%"pI"d", XFIXNUM (obj));
> -	strout (buf, len, len, printcharfun);
> +        if (!NILP (Vprint_integers_as_chars) && CHARACTERP (obj))
                      ^^^^^^^^^^^^^^^^^^^^^^^^
If this is supposed to be a boolean variable, please use DEFVAR_BOOL,
with all the consequences.

> +            int len = sprintf (buf, "%s", SDATA (call1 (intern ("prin1-char"), obj)));

Do we really need to call Lisp?  I thought we were quite capable of
printing characters from C, aren't we?

> @@ -2247,6 +2255,10 @@ syms_of_print (void)
>  that represents the number without losing information.  */);
>    Vfloat_output_format = Qnil;
>  
> +  DEFVAR_LISP ("print-integers-as-chars", Vprint_integers_as_chars,
> +	       doc: /* Print integers as characters.  */);
> +  Vprint_integers_as_chars = Qnil;

I wonder whether it wouldn't be cleaner to add another optional
argument to prin1, and let it bind some internal variable so that
print_object does this, instead  of exposing this knob to Lisp.
Because print_object is used all over the place, and who knows what
will this do to other callers?

Thanks.




This bug report was last modified 3 years and 56 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.