bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43866: 26.3; italian postfix additions


From: Eli Zaretskii
Subject: bug#43866: 26.3; italian postfix additions
Date: Thu, 22 Oct 2020 15:59:52 +0300

> From: Juri Linkov <juri@linkov.net>
> Cc: rpluim@gmail.com,  43866@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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]