poke-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] poke: copy-pasteable prompt


From: Jose E. Marchesi
Subject: Re: [PATCH] poke: copy-pasteable prompt
Date: Wed, 16 Mar 2022 23:12:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

This is OK for master.
Thanks!

>>From 01a401e5683c1ccd0a5b46344404f97d4ce4e4cf Mon Sep 17 00:00:00 2001
> From: Your Name <you@example.com>
> Date: Wed, 2 Feb 2022 11:07:10 +0100
> Subject: [PATCH 2/2] prompt: add prompt-commented setting to optionally use
>  shebang comments for prompts
>
> ---
>  poke/pk-repl.c      | 14 +++++++++++++-
>  poke/pk-repl.h      |  5 +++++
>  poke/pk-settings.pk | 33 +++++++++++++++++++++++++++++++++
>  poke/poke.pk        |  3 +++
>  4 files changed, 54 insertions(+), 1 deletion(-)
>
> diff --git a/poke/pk-repl.c b/poke/pk-repl.c
> index 4830d18b..5363c434 100644
> --- a/poke/pk-repl.c
> +++ b/poke/pk-repl.c
> @@ -279,6 +279,11 @@ pk_prompt (void)
>  {
>    char *prompt = "";
>  
> +  if (pk_var_int ("pk_prompt_commented_p"))
> +    {
> +      prompt = pk_str_concat(prompt, "#!", NULL);
> +    }
> +
>    if (pk_var_int ("pk_prompt_maps_p"))
>      {
>        pk_ios cur_ios;
> @@ -303,7 +308,14 @@ pk_prompt (void)
>          }
>      }
>  
> -  prompt = pk_str_concat (prompt, "(poke) ", NULL);
> +  if (pk_var_int ("pk_prompt_commented_p"))
> +    {
> +      prompt = pk_str_concat(prompt, "!# ", NULL);
> +    }
> +  else
> +    {
> +      prompt = pk_str_concat (prompt, "(poke) ", NULL);
> +    }
>    return prompt;
>  }
>  
> diff --git a/poke/pk-repl.h b/poke/pk-repl.h
> index 782f0abe..b0f903a4 100644
> --- a/poke/pk-repl.h
> +++ b/poke/pk-repl.h
> @@ -43,4 +43,9 @@ void pk_repl_insert (const char *str);
>  
>  char *poke_completion_function (const char *text, int state);
>  
> +/* Allocate and return an interactive prompt string, e.g.
> +   "(poke) " or "#!!# ".
> +   The caller is responsible for deallocation with free().  */
> +char *pk_prompt(void);
> +
>  #endif /* ! PK_REPL_H */
> diff --git a/poke/pk-settings.pk b/poke/pk-settings.pk
> index 4453ee42..070d98f1 100644
> --- a/poke/pk-settings.pk
> +++ b/poke/pk-settings.pk
> @@ -211,6 +211,39 @@ provided `auto-map' is set to `yes'.",
>          }
>      };
>  
> +pk_settings.add_setting
> +  :entry Poke_Setting {
> +    name = "prompt-commented",
> +    kind = POKE_SETTING_BOOL,
> +    summary = "whether the interactive prompt should be shebang-commented",
> +    usage = ".set prompt-commented {yes,no}",
> +    description = "\
> +This setting determines whether the prompt is a shebang-comment, allowing
> +for easy copy-paste of full terminal lines because the prompt will be
> +a syntactic no-op.
> +
> +Example of a prompt with prompt-commented enabled:
> +
> +  #!!# 1+2;
> +  3
> +
> +Example of a prompt with prompt-commented, map information, and 
> `prompt-maps' set to
> +`yes':
> +
> +  #!!# .file foo.o
> +  #![dwarf,elf]!# 1+2;
> +  3
> +  #![dwarf,elf]!#
> +
> +",
> +    getter = lambda any: { return pk_prompt_commented_p; },
> +    setter = lambda (any val) int:
> +      {
> +        pk_prompt_commented_p = val as int<32>;
> +        return 1;
> +      }
> +    };
> +
>  pk_settings.add_setting
>    :entry Poke_Setting {
>      name = "prompt-maps",
> diff --git a/poke/poke.pk b/poke/poke.pk
> index 287bba29..6fef9485 100644
> --- a/poke/poke.pk
> +++ b/poke/poke.pk
> @@ -39,6 +39,9 @@ var pk_auto_map_p = 0;
>  /* Whether map information shall be included in the REPL prompt.  */
>  var pk_prompt_maps_p = 1;
>  
> +/* Whether prompt should be "(poke) " or "#!!# ". */
> +var pk_prompt_commented_p = 0;
> +
>  /* The following global contains the name of the program to use to
>     display documentation.  Valid values are `info' and `less'.  */
>  var pk_doc_viewer = "info";



reply via email to

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