Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at submit) by debbugs.gnu.org; 4 Sep 2023 16:31:42 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 04 12:31:42 2023 Received: from localhost ([127.0.0.1]:52417 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qdCUH-0007P6-E6 for submit <at> debbugs.gnu.org; Mon, 04 Sep 2023 12:31:42 -0400 Received: from lists.gnu.org ([2001:470:142::17]:44372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stephen.berman@HIDDEN>) id 1qdCUB-0007Op-CZ for submit <at> debbugs.gnu.org; Mon, 04 Sep 2023 12:31:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <stephen.berman@HIDDEN>) id 1qdCU6-0007pP-0T for bug-gnu-emacs@HIDDEN; Mon, 04 Sep 2023 12:31:30 -0400 Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <stephen.berman@HIDDEN>) id 1qdCU2-00037Z-Vv for bug-gnu-emacs@HIDDEN; Mon, 04 Sep 2023 12:31:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1693845084; x=1694449884; i=stephen.berman@HIDDEN; bh=RRfq8xAqfOJVDXDL0/eypltsZFtOho9IPmI7VDW/Akw=; h=X-UI-Sender-Class:From:To:Subject:Date; b=oh9o1Nnu7Sxuenb1jjgNYO8QsO2XFO6ONNJ1+N2zhhQQgH7XOAYSu129WFecZplBwUTPk5D 88vVjcqKQd6OAUQwXnaUg/1JzvTLsEjT/lAi1cPRXYJrhi+MmFSFiIddY3vUCRGS7x9S//ckf WWb+3KaOlgHzYIBmYH/Nd5NfFz5uTFuLZkf8GFMvHVJf7r8f8lR76qFA5Gep0hvdCKUFponMc Ixc5mF1ArmviivIxnTjke5F6sgu0aUS4SyRRXf7+ZmBJcp70Tcn7+EDUxJUXTzAw17OweZhuy NrVnFOc4Iqtv6tRd2Z6T22rif9FL5rqgIqNV9T5vLWzfoTfLyJAg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from strobelfssd ([94.134.196.62]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mn2aN-1ptzmF0SsZ-00k4Ua for <bug-gnu-emacs@HIDDEN>; Mon, 04 Sep 2023 18:31:24 +0200 From: Stephen Berman <stephen.berman@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 30.0.50; Extending the use of format-prompt Date: Mon, 04 Sep 2023 18:31:23 +0200 Message-ID: <87jzt599yc.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:up5I1hfnKR4uF2j1XayZdwvB6JhfyfRgIVuTPRJQniacMmMHyan /gz9pFfXlivQzdtXdZz199mETokNw06PARMxsOl6IqYihIhjX0YMmxm/6hL2iPCH1RdXc23 NtxFSNwxUcWKUIssO21/Uxyy/763VMM91Clx/9m6sqKS0yOe/dFEUuNavtYST3dxjrSDSRM eix/mbrxzKugU9i1F9vsg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:+T76QsfvqQQ=;bu7WDe4JITVI3Sv3S38+96Sz3vm dGinps+8VghIS6oDHU3XxTvHXaDmWSBIDsBv6kwsKMQhxEdsd6Pt1d+rabS9XWWPQi30qn9b9 4S81CcbrswwlmDzRFeWi+vrFkPdsa4nlOzt3qPdEoutQ90UwX16nND3gCi3f+P7a8dNQlmWIr VXmI+oHPEQ2I4UvunQFdLZrbjNdjq9zhZldirLXdH4+/GrRrU0h839NHU3HN1wDLB19Oo7/BB gWSy2mSmISF1QMC6v7AJ6W4jN3snEprUUb+FbOJT6nxPsmZNOSOWBdPztEx3+eOLjFXM5pnWs CeTfd2tXBGjL0c5K8BPWvLSvX1O5Sum0jHn4TNVxgeeM9TMVIN3z5qab0/7ekmBkTJT8tT9o3 xLAOOfp5ZngriBGDpcAZ2WCUEGku5uubx6FPbema72tmeUZPxexb+fqw2FUS3jIlWIyqEW4QO N9gTa9SOo9hh5dY2e+STH41dbVvwXn0AJJu9EQn7XNwFv2aK9BFN3rvgdhCF8lcdOfE07a5QH qQ/w3z1nDrD/niYJUBkZSPODZUIBCb5GO7XW6ivns7yRVDnjq1wnK5BcRwsE8/6IUmd5GmKwP iJOWFBf2ctZJPFXhFdTswiLlyUmfeJjQH21GDzQBayOhsnKYGF9l7YQuf3+9A32QHePLZgmLL CoE1gc2SRK2g/bCrxO08ljYo5GgOtpUCyLxKsZEJjESvrPracA+RZHeX03UXuuefZZ6diStfj zwYEnCIg+U5Np7HL+qnTk9QoxmshFafONEbkkEkJPZfsLvQyVsVvXi35HVhm0nn/Ec+3J9CtC rScIQmY4HElrVo8oHeyjOVt5i4oz1FzUWfsj+aGzu5fNFiDs3X52cVlWutz23YigkJi6EBEgV woweOSlXNKijmY4xGtcinuIhKzVXF7S3P0wa5IFmB51AsdnQplBbbFTTGC/RnTmkVCU0ntZsq JtKzYnfZ+OF+qQ1eldyZC8KZn7I= Received-SPF: pass client-ip=212.227.17.20; envelope-from=stephen.berman@HIDDEN; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 0. emacs -Q 1. Invoke read-buffer with a prompt containg grave-style quoting and with no default buffer argument, e.g.: M-: (read-buffer "Enter `buffer': ") =3D> This displays the prompt in the minibuffer with grave-style quoting, i.e. as it appears in the invocation. 2. Repeat step 1 but add a default buffer argument, e.g.: M-: (read-buffer "Enter `buffer': " "*scratch*") =3D> This displays the prompt in the minibuffer with curve-style quoting: Enter =E2=80=98buffer=E2=80=99 (default *scratch*):=20=20 The different appearances of the prompt with and without the presence of a default argument is due to commit 50512e36c7, which passes the prompt string to format-prompt when read-buffer has a non-nil default argument DEF, but not when DEF is nil. (The purpose of that commit was to replace occurrences of prompts containing the string "(default %s)" by invocations of the then recently introduced function format-prompt; the fact that this function also calls substitute-command-keys was not a concern for that commit and its effect was presumably for that reason overlooked.) I think the simplest fix is to pass PROMPT to format-prompt regardless of the presence of a default argument of read-buffer, as in the first attached patch. But having substitute-command-keys always apply to the prompt string of read-buffer raises the question whether it should apply more generally to prompt strings. In fact, commit 50512e36c7 did change numerous mostly mode-specific prompts in several Lisp libraries to pass the prompt to format-prompt, but in almost all cases those prompts are fixed strings where applying substitute-command-keys makes no difference. But with read-buffer the prompt string is provided by the caller, so its appearance could be affected by substitute-command-keys. By default, read-buffer calls (in C) completing-read, which by default calls read-from-minibuffer, and indeed most, if not all, other functions that prompt for minibuffer input end up calling read-from-minibuffer. So passing the prompt string to format-prompt in read-from-minibuffer, as in the second attached patch (which should be applied instead of the first patch), would achieve a higher degree of consistency and simplicity in Emacs in the handling of prompts for minibuffer input, at least by default. (With functions that accept a user-defined function, like read-buffer-function with read-buffer, it would be up to the user to decide whether or not to use format-prompt, if the function does not invoke read-from-minibuffer.) If this change (the second patch) is accepted, it will probably require adjustments in the Emacs code base, e.g. to avoid double invocations of format-prompt. This would partly undo the changes made in 50512e36c7. I'd be willing to make the needed adjustments in Emacs. Steve Berman --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: read-buffer patch Content-Transfer-Encoding: quoted-printable diff --git a/src/minibuf.c b/src/minibuf.c index 58adde1bf66..a1cbf4747f5 100644 =2D-- a/src/minibuf.c +++ b/src/minibuf.c @@ -1502,34 +1502,30 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, = 1, 4, 0, specbind (Qcompletion_ignore_case, read_buffer_completion_ignore_case ? Qt : Qnil); - if (NILP (Vread_buffer_function)) - { - if (!NILP (def)) - { - /* A default value was provided: we must change PROMPT, - editing the default value in before the colon. To achieve - this, we replace PROMPT with a substring that doesn't - contain the terminal space and colon (if present). They - are then added back using Fformat. */ + /* For backward compatibility we accept prompt strings ending with a + colon and a space, but we have to delete them, if present, before + passing PROMPT to `format-prompt', which automatically appends + these characters to PROMPT. */ - if (STRINGP (prompt)) - { - s =3D SSDATA (prompt); - len =3D SBYTES (prompt); - if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ') - len =3D len - 2; - else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D= ' ')) - len--; - - prompt =3D make_specified_string (s, -1, len, - STRING_MULTIBYTE (prompt)); - } + if (STRINGP (prompt)) + { + s =3D SSDATA (prompt); + len =3D SBYTES (prompt); + if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ') + len =3D len - 2; + else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D = ' ')) + len--; + + prompt =3D make_specified_string (s, -1, len, + STRING_MULTIBYTE (prompt)); + } - prompt =3D CALLN (Ffuncall, intern("format-prompt"), - prompt, - CONSP (def) ? XCAR (def) : def); - } + prompt =3D CALLN (Ffuncall, intern("format-prompt"), + prompt, + CONSP (def) ? XCAR (def) : def); + if (NILP (Vread_buffer_function)) + { result =3D Fcompleting_read (prompt, intern ("internal-complete-buf= fer"), predicate, require_match, Qnil, Qbuffer_name_history, def, Qnil); --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: read-from-minibuffer patch Content-Transfer-Encoding: quoted-printable diff --git a/src/minibuf.c b/src/minibuf.c index 58adde1bf66..4318cab04cb 100644 =2D-- a/src/minibuf.c +++ b/src/minibuf.c @@ -1343,10 +1343,34 @@ DEFUN ("read-from-minibuffer", Fread_from_minibuff= er, (Lisp_Object prompt, Lisp_Object initial_contents, Lisp_Object keymap, = Lisp_Object read, Lisp_Object hist, Lisp_Object default_value, Lisp_Object= inherit_input_method) { Lisp_Object histvar, histpos, val; + char *s; + ptrdiff_t len; barf_if_interaction_inhibited (); CHECK_STRING (prompt); + + /* For backward compatibility we accept prompt strings ending with a + colon and a space, but we have to delete them, if present, before + passing PROMPT to `format-prompt', which automatically appends + these characters to PROMPT. */ + + if (STRINGP (prompt)) + { + s =3D SSDATA (prompt); + len =3D SBYTES (prompt); + if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ') + len =3D len - 2; + else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D = ' ')) + len--; + + prompt =3D make_specified_string (s, -1, len, + STRING_MULTIBYTE (prompt)); + } + + prompt =3D CALLN (Ffuncall, intern("format-prompt"), prompt, + CONSP (default_value) ? XCAR (default_value) : default_value); + if (NILP (keymap)) keymap =3D Vminibuffer_local_map; else @@ -1473,8 +1497,7 @@ DEFUN ("read-variable", Fread_variable, Sread_variab= le, 1, 2, 0, DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 4, 0, doc: /* Read the name of a buffer and return it as a string. -Prompt with PROMPT, which should be a string ending with a colon and a sp= ace. -Provides completion on buffer names the user types. +Prompt with string PROMPT. Provides completion on buffer names the user = types. Optional second arg DEF is value to return if user enters an empty line, instead of that empty string. If DEF is a list of default values, return its first element. @@ -1492,8 +1515,6 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1,= 4, 0, Lisp_Object predicate) { Lisp_Object result; - char *s; - ptrdiff_t len; specpdl_ref count =3D SPECPDL_INDEX (); if (BUFFERP (def)) @@ -1503,37 +1524,9 @@ DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1= , 4, 0, read_buffer_completion_ignore_case ? Qt : Qnil); if (NILP (Vread_buffer_function)) - { - if (!NILP (def)) - { - /* A default value was provided: we must change PROMPT, - editing the default value in before the colon. To achieve - this, we replace PROMPT with a substring that doesn't - contain the terminal space and colon (if present). They - are then added back using Fformat. */ - - if (STRINGP (prompt)) - { - s =3D SSDATA (prompt); - len =3D SBYTES (prompt); - if (len >=3D 2 && s[len - 2] =3D=3D ':' && s[len - 1] =3D=3D ' ') - len =3D len - 2; - else if (len >=3D 1 && (s[len - 1] =3D=3D ':' || s[len - 1] =3D=3D= ' ')) - len--; - - prompt =3D make_specified_string (s, -1, len, - STRING_MULTIBYTE (prompt)); - } - - prompt =3D CALLN (Ffuncall, intern("format-prompt"), - prompt, - CONSP (def) ? XCAR (def) : def); - } - - result =3D Fcompleting_read (prompt, intern ("internal-complete-buf= fer"), - predicate, require_match, Qnil, - Qbuffer_name_history, def, Qnil); - } + result =3D Fcompleting_read (prompt, intern ("internal-complete-buffe= r"), + predicate, require_match, Qnil, + Qbuffer_name_history, def, Qnil); else result =3D (NILP (predicate) /* Partial backward compatibility for older read_buffer_functions @@ -1978,7 +1971,7 @@ DEFUN ("all-completions", Fall_completions, Sall_com= pletions, 2, 4, 0, =0C DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0, doc: /* Read a string in the minibuffer, with completion. -PROMPT is a string to prompt with; normally it ends in a colon and a spac= e. +PROMPT is a string to prompt with. COLLECTION can be a list of strings, an alist, an obarray or a hash table= . COLLECTION can also be a function to do the completion itself. PREDICATE limits completion to a subset of COLLECTION. --=-=-=--
Stephen Berman <stephen.berman@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#65736
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.